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 | // no precompiled headers |
25 | #include "ci/ciUtilities.hpp" |
26 | #include "gc/shared/barrierSet.hpp" |
27 | #include "gc/shared/cardTable.hpp" |
28 | #include "gc/shared/collectedHeap.hpp" |
29 | #include "jvmci/jvmciEnv.hpp" |
30 | #include "jvmci/jvmciCompilerToVM.hpp" |
31 | #include "jvmci/vmStructs_jvmci.hpp" |
32 | #include "memory/universe.hpp" |
33 | #include "oops/compressedOops.hpp" |
34 | #include "runtime/sharedRuntime.hpp" |
35 | #include "utilities/resourceHash.hpp" |
36 | |
37 | |
38 | int CompilerToVM::Data::Klass_vtable_start_offset; |
39 | int CompilerToVM::Data::Klass_vtable_length_offset; |
40 | |
41 | int CompilerToVM::Data::; |
42 | |
43 | address CompilerToVM::Data::SharedRuntime_ic_miss_stub; |
44 | address CompilerToVM::Data::SharedRuntime_handle_wrong_method_stub; |
45 | address CompilerToVM::Data::SharedRuntime_deopt_blob_unpack; |
46 | address CompilerToVM::Data::SharedRuntime_deopt_blob_uncommon_trap; |
47 | |
48 | size_t CompilerToVM::Data::ThreadLocalAllocBuffer_alignment_reserve; |
49 | |
50 | CollectedHeap* CompilerToVM::Data::Universe_collectedHeap; |
51 | int CompilerToVM::Data::Universe_base_vtable_size; |
52 | address CompilerToVM::Data::Universe_narrow_oop_base; |
53 | int CompilerToVM::Data::Universe_narrow_oop_shift; |
54 | address CompilerToVM::Data::Universe_narrow_klass_base; |
55 | int CompilerToVM::Data::Universe_narrow_klass_shift; |
56 | void* CompilerToVM::Data::Universe_non_oop_bits; |
57 | uintptr_t CompilerToVM::Data::Universe_verify_oop_mask; |
58 | uintptr_t CompilerToVM::Data::Universe_verify_oop_bits; |
59 | |
60 | bool CompilerToVM::Data::_supports_inline_contig_alloc; |
61 | HeapWord** CompilerToVM::Data::_heap_end_addr; |
62 | HeapWord* volatile* CompilerToVM::Data::_heap_top_addr; |
63 | int CompilerToVM::Data::_max_oop_map_stack_offset; |
64 | int CompilerToVM::Data::_fields_annotations_base_offset; |
65 | |
66 | CardTable::CardValue* CompilerToVM::Data::cardtable_start_address; |
67 | int CompilerToVM::Data::cardtable_shift; |
68 | |
69 | int CompilerToVM::Data::vm_page_size; |
70 | |
71 | int CompilerToVM::Data::sizeof_vtableEntry = sizeof(vtableEntry); |
72 | int CompilerToVM::Data::sizeof_ExceptionTableElement = sizeof(ExceptionTableElement); |
73 | int CompilerToVM::Data::sizeof_LocalVariableTableElement = sizeof(LocalVariableTableElement); |
74 | int CompilerToVM::Data::sizeof_ConstantPool = sizeof(ConstantPool); |
75 | int CompilerToVM::Data::sizeof_narrowKlass = sizeof(narrowKlass); |
76 | int CompilerToVM::Data::sizeof_arrayOopDesc = sizeof(arrayOopDesc); |
77 | int CompilerToVM::Data::sizeof_BasicLock = sizeof(BasicLock); |
78 | |
79 | address CompilerToVM::Data::dsin; |
80 | address CompilerToVM::Data::dcos; |
81 | address CompilerToVM::Data::dtan; |
82 | address CompilerToVM::Data::dexp; |
83 | address CompilerToVM::Data::dlog; |
84 | address CompilerToVM::Data::dlog10; |
85 | address CompilerToVM::Data::dpow; |
86 | |
87 | address CompilerToVM::Data::symbol_init; |
88 | address CompilerToVM::Data::symbol_clinit; |
89 | |
90 | void CompilerToVM::Data::initialize(JVMCI_TRAPS) { |
91 | Klass_vtable_start_offset = in_bytes(Klass::vtable_start_offset()); |
92 | Klass_vtable_length_offset = in_bytes(Klass::vtable_length_offset()); |
93 | |
94 | Method_extra_stack_entries = Method::extra_stack_entries(); |
95 | |
96 | SharedRuntime_ic_miss_stub = SharedRuntime::get_ic_miss_stub(); |
97 | SharedRuntime_handle_wrong_method_stub = SharedRuntime::get_handle_wrong_method_stub(); |
98 | SharedRuntime_deopt_blob_unpack = SharedRuntime::deopt_blob()->unpack(); |
99 | SharedRuntime_deopt_blob_uncommon_trap = SharedRuntime::deopt_blob()->uncommon_trap(); |
100 | |
101 | ThreadLocalAllocBuffer_alignment_reserve = ThreadLocalAllocBuffer::alignment_reserve(); |
102 | |
103 | Universe_collectedHeap = Universe::heap(); |
104 | Universe_base_vtable_size = Universe::base_vtable_size(); |
105 | Universe_narrow_oop_base = CompressedOops::base(); |
106 | Universe_narrow_oop_shift = CompressedOops::shift(); |
107 | Universe_narrow_klass_base = CompressedKlassPointers::base(); |
108 | Universe_narrow_klass_shift = CompressedKlassPointers::shift(); |
109 | Universe_non_oop_bits = Universe::non_oop_word(); |
110 | Universe_verify_oop_mask = Universe::verify_oop_mask(); |
111 | Universe_verify_oop_bits = Universe::verify_oop_bits(); |
112 | |
113 | _supports_inline_contig_alloc = Universe::heap()->supports_inline_contig_alloc(); |
114 | _heap_end_addr = _supports_inline_contig_alloc ? Universe::heap()->end_addr() : (HeapWord**) -1; |
115 | _heap_top_addr = _supports_inline_contig_alloc ? Universe::heap()->top_addr() : (HeapWord* volatile*) -1; |
116 | |
117 | _max_oop_map_stack_offset = (OopMapValue::register_mask - VMRegImpl::stack2reg(0)->value()) * VMRegImpl::stack_slot_size; |
118 | int max_oop_map_stack_index = _max_oop_map_stack_offset / VMRegImpl::stack_slot_size; |
119 | assert(OopMapValue::legal_vm_reg_name(VMRegImpl::stack2reg(max_oop_map_stack_index)), "should be valid" ); |
120 | assert(!OopMapValue::legal_vm_reg_name(VMRegImpl::stack2reg(max_oop_map_stack_index + 1)), "should be invalid" ); |
121 | |
122 | symbol_init = (address) vmSymbols::object_initializer_name(); |
123 | symbol_clinit = (address) vmSymbols::class_initializer_name(); |
124 | |
125 | _fields_annotations_base_offset = Array<AnnotationArray*>::base_offset_in_bytes(); |
126 | |
127 | BarrierSet* bs = BarrierSet::barrier_set(); |
128 | if (bs->is_a(BarrierSet::CardTableBarrierSet)) { |
129 | CardTable::CardValue* base = ci_card_table_address(); |
130 | assert(base != NULL, "unexpected byte_map_base" ); |
131 | cardtable_start_address = base; |
132 | cardtable_shift = CardTable::card_shift; |
133 | } else { |
134 | // No card mark barriers |
135 | cardtable_start_address = 0; |
136 | cardtable_shift = 0; |
137 | } |
138 | |
139 | vm_page_size = os::vm_page_size(); |
140 | |
141 | #define SET_TRIGFUNC(name) \ |
142 | if (StubRoutines::name() != NULL) { \ |
143 | name = StubRoutines::name(); \ |
144 | } else { \ |
145 | name = CAST_FROM_FN_PTR(address, SharedRuntime::name); \ |
146 | } |
147 | |
148 | SET_TRIGFUNC(dsin); |
149 | SET_TRIGFUNC(dcos); |
150 | SET_TRIGFUNC(dtan); |
151 | SET_TRIGFUNC(dexp); |
152 | SET_TRIGFUNC(dlog10); |
153 | SET_TRIGFUNC(dlog); |
154 | SET_TRIGFUNC(dpow); |
155 | |
156 | #undef SET_TRIGFUNC |
157 | } |
158 | |
159 | JVMCIObjectArray CompilerToVM::initialize_intrinsics(JVMCI_TRAPS) { |
160 | JVMCIObjectArray vmIntrinsics = JVMCIENV->new_VMIntrinsicMethod_array(vmIntrinsics::ID_LIMIT - 1, JVMCI_CHECK_NULL); |
161 | int index = 0; |
162 | vmSymbols::SID kls_sid = vmSymbols::NO_SID; |
163 | JVMCIObject kls_str; |
164 | #define VM_SYMBOL_TO_STRING(s) \ |
165 | JVMCIENV->create_string(vmSymbols::symbol_at(vmSymbols::VM_SYMBOL_ENUM_NAME(s)), JVMCI_CHECK_NULL) |
166 | #define VM_INTRINSIC_INFO(id, kls, name, sig, ignore_fcode) { \ |
167 | vmSymbols::SID |
---|