1 /*
  2  * Copyright (c) 2003, 2025, Oracle and/or its affiliates. All rights reserved.
  3  * Copyright (c) 2014, Red Hat Inc. All rights reserved.
  4  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  5  *
  6  * This code is free software; you can redistribute it and/or modify it
  7  * under the terms of the GNU General Public License version 2 only, as
  8  * published by the Free Software Foundation.
  9  *
 10  * This code is distributed in the hope that it will be useful, but WITHOUT
 11  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 12  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 13  * version 2 for more details (a copy is included in the LICENSE file that
 14  * accompanied this code).
 15  *
 16  * You should have received a copy of the GNU General Public License version
 17  * 2 along with this work; if not, write to the Free Software Foundation,
 18  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 19  *
 20  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
 21  * or visit www.oracle.com if you need additional information or have any
 22  * questions.
 23  *
 24  */
 25 
 26 #ifndef CPU_AARCH64_STUBROUTINES_AARCH64_HPP
 27 #define CPU_AARCH64_STUBROUTINES_AARCH64_HPP
 28 
 29 // This file holds the platform specific parts of the StubRoutines
 30 // definition. See stubRoutines.hpp for a description on how to
 31 // extend it.
 32 
 33 static bool    returns_to_call_stub(address return_pc)   {
 34   return return_pc == _call_stub_return_address;
 35 }
 36 
 37 // emit enum used to size per-blob code buffers
 38 
 39 #define DEFINE_BLOB_SIZE(blob_name, size) \
 40   _ ## blob_name ## _code_size = size,
 41 
 42 enum platform_dependent_constants {
 43   STUBGEN_ARCH_BLOBS_DO(DEFINE_BLOB_SIZE)
 44 };
 45 
 46 #undef DEFINE_BLOB_SIZE
 47 
 48 class aarch64 {
 49  friend class StubGenerator;
 50 #if INCLUDE_JVMCI
 51   friend class JVMCIVMStructs;
 52 #endif
 53 
 54   // declare fields for arch-specific entries
 55 
 56 #define DECLARE_ARCH_ENTRY(arch, blob_name, stub_name, field_name, getter_name) \
 57   static address STUB_FIELD_NAME(field_name) ;
 58 
 59 #define DECLARE_ARCH_ENTRY_INIT(arch, blob_name, stub_name, field_name, getter_name, init_function) \
 60   DECLARE_ARCH_ENTRY(arch, blob_name, stub_name, field_name, getter_name)
 61 
 62 private:
 63   STUBGEN_ARCH_ENTRIES_DO(DECLARE_ARCH_ENTRY, DECLARE_ARCH_ENTRY_INIT)
 64 
 65 #undef DECLARE_ARCH_ENTRY_INIT
 66 #undef DECLARE_ARCH_ENTRY
 67 
 68   static bool _completed;
 69 
 70  public:
 71 
 72   // declare getters for arch-specific entries
 73 
 74 #define DEFINE_ARCH_ENTRY_GETTER(arch, blob_name, stub_name, field_name, getter_name) \
 75   static address getter_name() { return STUB_FIELD_NAME(field_name) ; }
 76 
 77 #define DEFINE_ARCH_ENTRY_GETTER_INIT(arch, blob_name, stub_name, field_name, getter_name, init_function) \
 78   DEFINE_ARCH_ENTRY_GETTER(arch, blob_name, stub_name, field_name, getter_name)
 79 
 80   STUBGEN_ARCH_ENTRIES_DO(DEFINE_ARCH_ENTRY_GETTER, DEFINE_ARCH_ENTRY_GETTER_INIT)
 81 
 82 #undef DEFINE_ARCH_ENTRY_GETTER_INIT
 83 #undef DEFINE_ARCH_ENTRY_GETTER
 84 
 85   static address large_arrays_hashcode(BasicType eltype) {
 86     switch (eltype) {
 87     case T_BOOLEAN:
 88       return large_arrays_hashcode_boolean();
 89     case T_BYTE:
 90       return large_arrays_hashcode_byte();
 91     case T_CHAR:
 92       return large_arrays_hashcode_char();
 93     case T_SHORT:
 94       return large_arrays_hashcode_short();
 95     case T_INT:
 96       return large_arrays_hashcode_int();
 97     default:
 98       ShouldNotReachHere();
 99     }
100 
101     return nullptr;
102   }
103 
104   static bool complete() {
105     return _completed;
106   }
107 
108   static void set_completed() {
109     _completed = true;
110   }
111 
112 private:
113   static uint16_t  _kyberConsts[];
114   static uint32_t _dilithiumConsts[];
115   static juint    _crc_table[];
116   static jubyte   _adler_table[];
117   // begin trigonometric tables block. See comments in .cpp file
118   static juint    _npio2_hw[];
119   static jdouble   _two_over_pi[];
120   static jdouble   _pio2[];
121   static jdouble   _dsin_coef[];
122   static jdouble  _dcos_coef[];
123   // end trigonometric tables block
124 };
125 
126 #endif // CPU_AARCH64_STUBROUTINES_AARCH64_HPP