| 1 | /* |
| 2 | * Copyright (c) 2011, 2019, Oracle and/or its affiliates. All rights reserved. |
| 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
| 4 | * |
| 5 | * This code is free software; you can redistribute it and/or modify it |
| 6 | * under the terms of the GNU General Public License version 2 only, as |
| 7 | * published by the Free Software Foundation. |
| 8 | * |
| 9 | * This code is distributed in the hope that it will be useful, but WITHOUT |
| 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
| 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
| 12 | * version 2 for more details (a copy is included in the LICENSE file that |
| 13 | * accompanied this code). |
| 14 | * |
| 15 | * You should have received a copy of the GNU General Public License version |
| 16 | * 2 along with this work; if not, write to the Free Software Foundation, |
| 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
| 18 | * |
| 19 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
| 20 | * or visit www.oracle.com if you need additional information or have any |
| 21 | * questions. |
| 22 | */ |
| 23 | |
| 24 | #ifndef SHARE_JVMCI_JVMCICOMPILERTOVM_HPP |
| 25 | #define SHARE_JVMCI_JVMCICOMPILERTOVM_HPP |
| 26 | |
| 27 | #include "gc/shared/cardTable.hpp" |
| 28 | #include "jvmci/jvmciExceptions.hpp" |
| 29 | #include "runtime/javaCalls.hpp" |
| 30 | #include "runtime/signature.hpp" |
| 31 | |
| 32 | class JVMCIObjectArray; |
| 33 | |
| 34 | class CompilerToVM { |
| 35 | public: |
| 36 | class Data { |
| 37 | friend class JVMCIVMStructs; |
| 38 | |
| 39 | private: |
| 40 | static int Klass_vtable_start_offset; |
| 41 | static int Klass_vtable_length_offset; |
| 42 | |
| 43 | static int ; |
| 44 | |
| 45 | static address SharedRuntime_ic_miss_stub; |
| 46 | static address SharedRuntime_handle_wrong_method_stub; |
| 47 | static address SharedRuntime_deopt_blob_unpack; |
| 48 | static address SharedRuntime_deopt_blob_uncommon_trap; |
| 49 | |
| 50 | static size_t ThreadLocalAllocBuffer_alignment_reserve; |
| 51 | |
| 52 | static CollectedHeap* Universe_collectedHeap; |
| 53 | static int Universe_base_vtable_size; |
| 54 | static address Universe_narrow_oop_base; |
| 55 | static int Universe_narrow_oop_shift; |
| 56 | static address Universe_narrow_klass_base; |
| 57 | static int Universe_narrow_klass_shift; |
| 58 | static uintptr_t Universe_verify_oop_mask; |
| 59 | static uintptr_t Universe_verify_oop_bits; |
| 60 | static void* Universe_non_oop_bits; |
| 61 | |
| 62 | static bool _supports_inline_contig_alloc; |
| 63 | static HeapWord** _heap_end_addr; |
| 64 | static HeapWord* volatile* _heap_top_addr; |
| 65 | static int _max_oop_map_stack_offset; |
| 66 | static int _fields_annotations_base_offset; |
| 67 | |
| 68 | static CardTable::CardValue* cardtable_start_address; |
| 69 | static int cardtable_shift; |
| 70 | |
| 71 | static int vm_page_size; |
| 72 | |
| 73 | static int sizeof_vtableEntry; |
| 74 | static int sizeof_ExceptionTableElement; |
| 75 | static int sizeof_LocalVariableTableElement; |
| 76 | static int sizeof_ConstantPool; |
| 77 | static int sizeof_narrowKlass; |
| 78 | static int sizeof_arrayOopDesc; |
| 79 | static int sizeof_BasicLock; |
| 80 | |
| 81 | static address dsin; |
| 82 | static address dcos; |
| 83 | static address dtan; |
| 84 | static address dexp; |
| 85 | static address dlog; |
| 86 | static address dlog10; |
| 87 | static address dpow; |
| 88 | |
| 89 | static address symbol_init; |
| 90 | static address symbol_clinit; |
| 91 | |
| 92 | public: |
| 93 | static void initialize(JVMCI_TRAPS); |
| 94 | |
| 95 | static int max_oop_map_stack_offset() { |
| 96 | assert(_max_oop_map_stack_offset > 0, "must be initialized" ); |
| 97 | return Data::_max_oop_map_stack_offset; |
| 98 | } |
| 99 | }; |
| 100 | |
| 101 | static bool cstring_equals(const char* const& s0, const char* const& s1) { |
| 102 | return strcmp(s0, s1) == 0; |
| 103 | } |
| 104 | |
| 105 | static unsigned cstring_hash(const char* const& s) { |
| 106 | int h = 0; |
| 107 | const char* p = s; |
| 108 | while (*p != '\0') { |
| 109 | h = 31 * h + *p; |
| 110 | p++; |
| 111 | } |
| 112 | return h; |
| 113 | } |
| 114 | |
| 115 | static JNINativeMethod methods[]; |
| 116 | static JNINativeMethod jni_methods[]; |
| 117 | |
| 118 | static JVMCIObjectArray initialize_intrinsics(JVMCI_TRAPS); |
| 119 | public: |
| 120 | static int methods_count(); |
| 121 | |
| 122 | }; |
| 123 | |
| 124 | |
| 125 | class JavaArgumentUnboxer : public SignatureIterator { |
| 126 | protected: |
| 127 | JavaCallArguments* _jca; |
| 128 | arrayOop _args; |
| 129 | int _index; |
| 130 | |
| 131 | Handle next_arg(BasicType expectedType); |
| 132 | |
| 133 | public: |
| 134 | JavaArgumentUnboxer(Symbol* signature, JavaCallArguments* jca, arrayOop args, bool is_static) : SignatureIterator(signature) { |
| 135 | this->_return_type = T_ILLEGAL; |
| 136 | _jca = jca; |
| 137 | _index = 0; |
| 138 | _args = args; |
| 139 | if (!is_static) { |
| 140 | _jca->push_oop(next_arg(T_OBJECT)); |
| 141 | } |
| 142 | iterate(); |
| 143 | assert(_index == args->length(), "arg count mismatch with signature" ); |
| 144 | } |
| 145 | |
| 146 | inline void do_bool() { if (!is_return_type()) _jca->push_int(next_arg(T_BOOLEAN)->bool_field(java_lang_boxing_object::value_offset_in_bytes(T_BOOLEAN))); } |
| 147 | inline void do_char() { if (!is_return_type()) _jca->push_int(next_arg(T_CHAR)->char_field(java_lang_boxing_object::value_offset_in_bytes(T_CHAR))); } |
| 148 | inline void do_short() { if (!is_return_type()) _jca->push_int(next_arg(T_SHORT)->short_field(java_lang_boxing_object::value_offset_in_bytes(T_SHORT))); } |
| 149 | inline void do_byte() { if (!is_return_type()) _jca->push_int(next_arg(T_BYTE)->byte_field(java_lang_boxing_object::value_offset_in_bytes(T_BYTE))); } |
| 150 | inline void do_int() { if (!is_return_type()) _jca->push_int(next_arg(T_INT)->int_field(java_lang_boxing_object::value_offset_in_bytes(T_INT))); } |
| 151 | |
| 152 | inline void do_long() { if (!is_return_type()) _jca->push_long(next_arg(T_LONG)->long_field(java_lang_boxing_object::value_offset_in_bytes(T_LONG))); } |
| 153 | inline void do_float() { if (!is_return_type()) _jca->push_float(next_arg(T_FLOAT)->float_field(java_lang_boxing_object::value_offset_in_bytes(T_FLOAT))); } |
| 154 | inline void do_double() { if (!is_return_type()) _jca->push_double(next_arg(T_DOUBLE)->double_field(java_lang_boxing_object::value_offset_in_bytes(T_DOUBLE))); } |
| 155 | |
| 156 | inline void do_object() { _jca->push_oop(next_arg(T_OBJECT)); } |
| 157 | inline void do_object(int begin, int end) { if (!is_return_type()) _jca->push_oop(next_arg(T_OBJECT)); } |
| 158 | inline void do_array(int begin, int end) { if (!is_return_type()) _jca->push_oop(next_arg(T_OBJECT)); } |
| 159 | inline void do_void() { } |
| 160 | }; |
| 161 | |
| 162 | class JNIHandleMark : public StackObj { |
| 163 | JavaThread* _thread; |
| 164 | public: |
| 165 | JNIHandleMark(JavaThread* thread) : _thread(thread) { push_jni_handle_block(thread); } |
| 166 | ~JNIHandleMark() { pop_jni_handle_block(_thread); } |
| 167 | |
| 168 | private: |
| 169 | static void push_jni_handle_block(JavaThread* thread); |
| 170 | static void pop_jni_handle_block(JavaThread* thread); |
| 171 | }; |
| 172 | |
| 173 | #endif // SHARE_JVMCI_JVMCICOMPILERTOVM_HPP |
| 174 | |