File: | jdk/src/hotspot/share/jvmci/jvmciCodeInstaller.cpp |
Warning: | line 790, column 5 Value stored to 'last_pc_offset' is never read |
Press '?' to see keyboard shortcuts
Keyboard shortcuts:
1 | /* |
2 | * Copyright (c) 2011, 2021, 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 | #include "precompiled.hpp" |
25 | #include "classfile/javaClasses.inline.hpp" |
26 | #include "code/compiledIC.hpp" |
27 | #include "compiler/compileBroker.hpp" |
28 | #include "compiler/compilerThread.hpp" |
29 | #include "compiler/oopMap.hpp" |
30 | #include "jvmci/jvmciCodeInstaller.hpp" |
31 | #include "jvmci/jvmciCompilerToVM.hpp" |
32 | #include "jvmci/jvmciRuntime.hpp" |
33 | #include "memory/universe.hpp" |
34 | #include "oops/compressedOops.inline.hpp" |
35 | #include "oops/klass.inline.hpp" |
36 | #include "prims/jvmtiExport.hpp" |
37 | #include "prims/methodHandles.hpp" |
38 | #include "runtime/interfaceSupport.inline.hpp" |
39 | #include "runtime/jniHandles.inline.hpp" |
40 | #include "runtime/sharedRuntime.hpp" |
41 | #include "utilities/align.hpp" |
42 | |
43 | // frequently used constants |
44 | // Allocate them with new so they are never destroyed (otherwise, a |
45 | // forced exit could destroy these objects while they are still in |
46 | // use). |
47 | ConstantOopWriteValue* CodeInstaller::_oop_null_scope_value = new (ResourceObj::C_HEAP, mtJVMCI) ConstantOopWriteValue(NULL__null); |
48 | ConstantIntValue* CodeInstaller::_int_m1_scope_value = new (ResourceObj::C_HEAP, mtJVMCI) ConstantIntValue(-1); |
49 | ConstantIntValue* CodeInstaller::_int_0_scope_value = new (ResourceObj::C_HEAP, mtJVMCI) ConstantIntValue((jint)0); |
50 | ConstantIntValue* CodeInstaller::_int_1_scope_value = new (ResourceObj::C_HEAP, mtJVMCI) ConstantIntValue(1); |
51 | ConstantIntValue* CodeInstaller::_int_2_scope_value = new (ResourceObj::C_HEAP, mtJVMCI) ConstantIntValue(2); |
52 | LocationValue* CodeInstaller::_illegal_value = new (ResourceObj::C_HEAP, mtJVMCI) LocationValue(Location()); |
53 | MarkerValue* CodeInstaller::_virtual_byte_array_marker = new (ResourceObj::C_HEAP, mtJVMCI) MarkerValue(); |
54 | |
55 | VMReg CodeInstaller::getVMRegFromLocation(JVMCIObject location, int total_frame_size, JVMCI_TRAPSJVMCIEnv* __jvmci_env__) { |
56 | if (location.is_null()) { |
57 | JVMCI_THROW_NULL(NullPointerException){ __jvmci_env__->throw_NullPointerException(); return __null ; }; |
58 | } |
59 | |
60 | JVMCIObject reg = jvmci_env()->get_code_Location_reg(location); |
61 | jint offset = jvmci_env()->get_code_Location_offset(location); |
62 | |
63 | if (reg.is_non_null()) { |
64 | // register |
65 | jint number = jvmci_env()->get_code_Register_number(reg); |
66 | VMReg vmReg = CodeInstaller::get_hotspot_reg(number, JVMCI_CHECK_NULL__jvmci_env__); if ((__jvmci_env__->has_pending_exception( ))) return __null; (void)(0); |
67 | if (offset % 4 == 0) { |
68 | return vmReg->next(offset / 4); |
69 | } else { |
70 | JVMCI_ERROR_NULL("unaligned subregister offset %d in oop map", offset){ __jvmci_env__->fthrow_error( "/home/daniel/Projects/java/jdk/src/hotspot/share/jvmci/jvmciCodeInstaller.cpp" , 70, "unaligned subregister offset %d in oop map", offset); return __null; }; |
71 | } |
72 | } else { |
73 | // stack slot |
74 | if (offset % 4 == 0) { |
75 | VMReg vmReg = VMRegImpl::stack2reg(offset / 4); |
76 | if (!OopMapValue::legal_vm_reg_name(vmReg)) { |
77 | // This restriction only applies to VMRegs that are used in OopMap but |
78 | // since that's the only use of VMRegs it's simplest to put this test |
79 | // here. This test should also be equivalent legal_vm_reg_name but JVMCI |
80 | // clients can use max_oop_map_stack_stack_offset to detect this problem |
81 | // directly. The asserts just ensure that the tests are in agreement. |
82 | assert(offset > CompilerToVM::Data::max_oop_map_stack_offset(), "illegal VMReg")do { if (!(offset > CompilerToVM::Data::max_oop_map_stack_offset ())) { (*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/jvmci/jvmciCodeInstaller.cpp" , 82, "assert(" "offset > CompilerToVM::Data::max_oop_map_stack_offset()" ") failed", "illegal VMReg"); ::breakpoint(); } } while (0); |
83 | JVMCI_ERROR_NULL("stack offset %d is too large to be encoded in OopMap (max %d)",{ __jvmci_env__->fthrow_error( "/home/daniel/Projects/java/jdk/src/hotspot/share/jvmci/jvmciCodeInstaller.cpp" , 84, "stack offset %d is too large to be encoded in OopMap (max %d)" , offset, CompilerToVM::Data::max_oop_map_stack_offset()); return __null; } |
84 | offset, CompilerToVM::Data::max_oop_map_stack_offset()){ __jvmci_env__->fthrow_error( "/home/daniel/Projects/java/jdk/src/hotspot/share/jvmci/jvmciCodeInstaller.cpp" , 84, "stack offset %d is too large to be encoded in OopMap (max %d)" , offset, CompilerToVM::Data::max_oop_map_stack_offset()); return __null; }; |
85 | } |
86 | assert(OopMapValue::legal_vm_reg_name(vmReg), "illegal VMReg")do { if (!(OopMapValue::legal_vm_reg_name(vmReg))) { (*g_assert_poison ) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/jvmci/jvmciCodeInstaller.cpp" , 86, "assert(" "OopMapValue::legal_vm_reg_name(vmReg)" ") failed" , "illegal VMReg"); ::breakpoint(); } } while (0); |
87 | return vmReg; |
88 | } else { |
89 | JVMCI_ERROR_NULL("unaligned stack offset %d in oop map", offset){ __jvmci_env__->fthrow_error( "/home/daniel/Projects/java/jdk/src/hotspot/share/jvmci/jvmciCodeInstaller.cpp" , 89, "unaligned stack offset %d in oop map", offset); return __null; }; |
90 | } |
91 | } |
92 | } |
93 | |
94 | // creates a HotSpot oop map out of the byte arrays provided by DebugInfo |
95 | OopMap* CodeInstaller::create_oop_map(JVMCIObject debug_info, JVMCI_TRAPSJVMCIEnv* __jvmci_env__) { |
96 | JVMCIObject reference_map = jvmci_env()->get_DebugInfo_referenceMap(debug_info); |
97 | if (reference_map.is_null()) { |
98 | JVMCI_THROW_NULL(NullPointerException){ __jvmci_env__->throw_NullPointerException(); return __null ; }; |
99 | } |
100 | if (!jvmci_env()->isa_HotSpotReferenceMap(reference_map)) { |
101 | JVMCI_ERROR_NULL("unknown reference map: %s", jvmci_env()->klass_name(reference_map)){ __jvmci_env__->fthrow_error( "/home/daniel/Projects/java/jdk/src/hotspot/share/jvmci/jvmciCodeInstaller.cpp" , 101, "unknown reference map: %s", jvmci_env()->klass_name (reference_map)); return __null; }; |
102 | } |
103 | if (!_has_wide_vector && SharedRuntime::is_wide_vector(jvmci_env()->get_HotSpotReferenceMap_maxRegisterSize(reference_map))) { |
104 | if (SharedRuntime::polling_page_vectors_safepoint_handler_blob() == NULL__null) { |
105 | JVMCI_ERROR_NULL("JVMCI is producing code using vectors larger than the runtime supports"){ __jvmci_env__->fthrow_error( "/home/daniel/Projects/java/jdk/src/hotspot/share/jvmci/jvmciCodeInstaller.cpp" , 105, "JVMCI is producing code using vectors larger than the runtime supports" ); return __null; }; |
106 | } |
107 | _has_wide_vector = true; |
108 | } |
109 | OopMap* map = new OopMap(_total_frame_size, _parameter_count); |
110 | JVMCIObjectArray objects = jvmci_env()->get_HotSpotReferenceMap_objects(reference_map); |
111 | JVMCIObjectArray derivedBase = jvmci_env()->get_HotSpotReferenceMap_derivedBase(reference_map); |
112 | JVMCIPrimitiveArray sizeInBytes = jvmci_env()->get_HotSpotReferenceMap_sizeInBytes(reference_map); |
113 | if (objects.is_null() || derivedBase.is_null() || sizeInBytes.is_null()) { |
114 | JVMCI_THROW_NULL(NullPointerException){ __jvmci_env__->throw_NullPointerException(); return __null ; }; |
115 | } |
116 | if (JVMCIENV__jvmci_env__->get_length(objects) != JVMCIENV__jvmci_env__->get_length(derivedBase) || JVMCIENV__jvmci_env__->get_length(objects) != JVMCIENV__jvmci_env__->get_length(sizeInBytes)) { |
117 | JVMCI_ERROR_NULL("arrays in reference map have different sizes: %d %d %d", JVMCIENV->get_length(objects), JVMCIENV->get_length(derivedBase), JVMCIENV->get_length(sizeInBytes)){ __jvmci_env__->fthrow_error( "/home/daniel/Projects/java/jdk/src/hotspot/share/jvmci/jvmciCodeInstaller.cpp" , 117, "arrays in reference map have different sizes: %d %d %d" , __jvmci_env__->get_length(objects), __jvmci_env__->get_length (derivedBase), __jvmci_env__->get_length(sizeInBytes)); return __null; }; |
118 | } |
119 | for (int i = 0; i < JVMCIENV__jvmci_env__->get_length(objects); i++) { |
120 | JVMCIObject location = JVMCIENV__jvmci_env__->get_object_at(objects, i); |
121 | JVMCIObject baseLocation = JVMCIENV__jvmci_env__->get_object_at(derivedBase, i); |
122 | jint bytes = JVMCIENV__jvmci_env__->get_int_at(sizeInBytes, i); |
123 | |
124 | VMReg vmReg = getVMRegFromLocation(location, _total_frame_size, JVMCI_CHECK_NULL__jvmci_env__); if ((__jvmci_env__->has_pending_exception( ))) return __null; (void)(0); |
125 | if (baseLocation.is_non_null()) { |
126 | // derived oop |
127 | #ifdef _LP641 |
128 | if (bytes == 8) { |
129 | #else |
130 | if (bytes == 4) { |
131 | #endif |
132 | VMReg baseReg = getVMRegFromLocation(baseLocation, _total_frame_size, JVMCI_CHECK_NULL__jvmci_env__); if ((__jvmci_env__->has_pending_exception( ))) return __null; (void)(0); |
133 | map->set_derived_oop(vmReg, baseReg); |
134 | } else { |
135 | JVMCI_ERROR_NULL("invalid derived oop size in ReferenceMap: %d", bytes){ __jvmci_env__->fthrow_error( "/home/daniel/Projects/java/jdk/src/hotspot/share/jvmci/jvmciCodeInstaller.cpp" , 135, "invalid derived oop size in ReferenceMap: %d", bytes) ; return __null; }; |
136 | } |
137 | #ifdef _LP641 |
138 | } else if (bytes == 8) { |
139 | // wide oop |
140 | map->set_oop(vmReg); |
141 | } else if (bytes == 4) { |
142 | // narrow oop |
143 | map->set_narrowoop(vmReg); |
144 | #else |
145 | } else if (bytes == 4) { |
146 | map->set_oop(vmReg); |
147 | #endif |
148 | } else { |
149 | JVMCI_ERROR_NULL("invalid oop size in ReferenceMap: %d", bytes){ __jvmci_env__->fthrow_error( "/home/daniel/Projects/java/jdk/src/hotspot/share/jvmci/jvmciCodeInstaller.cpp" , 149, "invalid oop size in ReferenceMap: %d", bytes); return __null; }; |
150 | } |
151 | } |
152 | |
153 | JVMCIObject callee_save_info = jvmci_env()->get_DebugInfo_calleeSaveInfo(debug_info); |
154 | if (callee_save_info.is_non_null()) { |
155 | JVMCIObjectArray registers = jvmci_env()->get_RegisterSaveLayout_registers(callee_save_info); |
156 | JVMCIPrimitiveArray slots = jvmci_env()->get_RegisterSaveLayout_slots(callee_save_info); |
157 | for (jint i = 0; i < JVMCIENV__jvmci_env__->get_length(slots); i++) { |
158 | JVMCIObject jvmci_reg = JVMCIENV__jvmci_env__->get_object_at(registers, i); |
159 | jint jvmci_reg_number = jvmci_env()->get_code_Register_number(jvmci_reg); |
160 | VMReg hotspot_reg = CodeInstaller::get_hotspot_reg(jvmci_reg_number, JVMCI_CHECK_NULL__jvmci_env__); if ((__jvmci_env__->has_pending_exception( ))) return __null; (void)(0); |
161 | // HotSpot stack slots are 4 bytes |
162 | jint jvmci_slot = JVMCIENV__jvmci_env__->get_int_at(slots, i); |
163 | jint hotspot_slot = jvmci_slot * VMRegImpl::slots_per_word; |
164 | VMReg hotspot_slot_as_reg = VMRegImpl::stack2reg(hotspot_slot); |
165 | map->set_callee_saved(hotspot_slot_as_reg, hotspot_reg); |
166 | #ifdef _LP641 |
167 | // (copied from generate_oop_map() in c1_Runtime1_x86.cpp) |
168 | VMReg hotspot_slot_hi_as_reg = VMRegImpl::stack2reg(hotspot_slot + 1); |
169 | map->set_callee_saved(hotspot_slot_hi_as_reg, hotspot_reg->next()); |
170 | #endif |
171 | } |
172 | } |
173 | return map; |
174 | } |
175 | |
176 | void* CodeInstaller::record_metadata_reference(CodeSection* section, address dest, JVMCIObject constant, JVMCI_TRAPSJVMCIEnv* __jvmci_env__) { |
177 | /* |
178 | * This method needs to return a raw (untyped) pointer, since the value of a pointer to the base |
179 | * class is in general not equal to the pointer of the subclass. When patching metaspace pointers, |
180 | * the compiler expects a direct pointer to the subclass (Klass* or Method*), not a pointer to the |
181 | * base class (Metadata* or MetaspaceObj*). |
182 | */ |
183 | JVMCIObject obj = jvmci_env()->get_HotSpotMetaspaceConstantImpl_metaspaceObject(constant); |
184 | if (jvmci_env()->isa_HotSpotResolvedObjectTypeImpl(obj)) { |
185 | Klass* klass = JVMCIENV__jvmci_env__->asKlass(obj); |
186 | assert(!jvmci_env()->get_HotSpotMetaspaceConstantImpl_compressed(constant), "unexpected compressed klass pointer %s @ " INTPTR_FORMAT, klass->name()->as_C_string(), p2i(klass))do { if (!(!jvmci_env()->get_HotSpotMetaspaceConstantImpl_compressed (constant))) { (*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/jvmci/jvmciCodeInstaller.cpp" , 186, "assert(" "!jvmci_env()->get_HotSpotMetaspaceConstantImpl_compressed(constant)" ") failed", "unexpected compressed klass pointer %s @ " "0x%016" "l" "x", klass->name()->as_C_string(), p2i(klass)); :: breakpoint(); } } while (0); |
187 | int index = _oop_recorder->find_index(klass); |
188 | section->relocate(dest, metadata_Relocation::spec(index)); |
189 | JVMCI_event_3if (JVMCITraceLevel < 3 && JVMCIEventLogLevel < 3) ; else ::JVMCI::event3("metadata[%d of %d] = %s", index, _oop_recorder->metadata_count(), klass->name()->as_C_string()); |
190 | return klass; |
191 | } else if (jvmci_env()->isa_HotSpotResolvedJavaMethodImpl(obj)) { |
192 | Method* method = jvmci_env()->asMethod(obj); |
193 | assert(!jvmci_env()->get_HotSpotMetaspaceConstantImpl_compressed(constant), "unexpected compressed method pointer %s @ " INTPTR_FORMAT, method->name()->as_C_string(), p2i(method))do { if (!(!jvmci_env()->get_HotSpotMetaspaceConstantImpl_compressed (constant))) { (*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/jvmci/jvmciCodeInstaller.cpp" , 193, "assert(" "!jvmci_env()->get_HotSpotMetaspaceConstantImpl_compressed(constant)" ") failed", "unexpected compressed method pointer %s @ " "0x%016" "l" "x", method->name()->as_C_string(), p2i(method)); :: breakpoint(); } } while (0); |
194 | int index = _oop_recorder->find_index(method); |
195 | section->relocate(dest, metadata_Relocation::spec(index)); |
196 | JVMCI_event_3if (JVMCITraceLevel < 3 && JVMCIEventLogLevel < 3) ; else ::JVMCI::event3("metadata[%d of %d] = %s", index, _oop_recorder->metadata_count(), method->name()->as_C_string()); |
197 | return method; |
198 | } else { |
199 | JVMCI_ERROR_NULL("unexpected metadata reference for constant of type %s", jvmci_env()->klass_name(obj)){ __jvmci_env__->fthrow_error( "/home/daniel/Projects/java/jdk/src/hotspot/share/jvmci/jvmciCodeInstaller.cpp" , 199, "unexpected metadata reference for constant of type %s" , jvmci_env()->klass_name(obj)); return __null; }; |
200 | } |
201 | } |
202 | |
203 | #ifdef _LP641 |
204 | narrowKlass CodeInstaller::record_narrow_metadata_reference(CodeSection* section, address dest, JVMCIObject constant, JVMCI_TRAPSJVMCIEnv* __jvmci_env__) { |
205 | JVMCIObject obj = jvmci_env()->get_HotSpotMetaspaceConstantImpl_metaspaceObject(constant); |
206 | assert(jvmci_env()->get_HotSpotMetaspaceConstantImpl_compressed(constant), "unexpected uncompressed pointer")do { if (!(jvmci_env()->get_HotSpotMetaspaceConstantImpl_compressed (constant))) { (*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/jvmci/jvmciCodeInstaller.cpp" , 206, "assert(" "jvmci_env()->get_HotSpotMetaspaceConstantImpl_compressed(constant)" ") failed", "unexpected uncompressed pointer"); ::breakpoint (); } } while (0); |
207 | |
208 | if (!jvmci_env()->isa_HotSpotResolvedObjectTypeImpl(obj)) { |
209 | JVMCI_ERROR_0("unexpected compressed pointer of type %s", jvmci_env()->klass_name(obj)){ __jvmci_env__->fthrow_error( "/home/daniel/Projects/java/jdk/src/hotspot/share/jvmci/jvmciCodeInstaller.cpp" , 209, "unexpected compressed pointer of type %s", jvmci_env( )->klass_name(obj)); return 0; }; |
210 | } |
211 | |
212 | Klass* klass = JVMCIENV__jvmci_env__->asKlass(obj); |
213 | int index = _oop_recorder->find_index(klass); |
214 | section->relocate(dest, metadata_Relocation::spec(index)); |
215 | JVMCI_event_3if (JVMCITraceLevel < 3 && JVMCIEventLogLevel < 3) ; else ::JVMCI::event3("narrowKlass[%d of %d] = %s", index, _oop_recorder->metadata_count(), klass->name()->as_C_string()); |
216 | return CompressedKlassPointers::encode(klass); |
217 | } |
218 | #endif |
219 | |
220 | Location::Type CodeInstaller::get_oop_type(JVMCIObject value) { |
221 | JVMCIObject valueKind = jvmci_env()->get_Value_valueKind(value); |
222 | JVMCIObject platformKind = jvmci_env()->get_ValueKind_platformKind(valueKind); |
223 | |
224 | if (jvmci_env()->equals(platformKind, word_kind())) { |
225 | return Location::oop; |
226 | } else { |
227 | return Location::narrowoop; |
228 | } |
229 | } |
230 | |
231 | ScopeValue* CodeInstaller::get_scope_value(JVMCIObject value, BasicType type, GrowableArray<ScopeValue*>* objects, ScopeValue* &second, JVMCI_TRAPSJVMCIEnv* __jvmci_env__) { |
232 | second = NULL__null; |
233 | if (value.is_null()) { |
234 | JVMCI_THROW_NULL(NullPointerException){ __jvmci_env__->throw_NullPointerException(); return __null ; }; |
235 | } else if (JVMCIENV__jvmci_env__->equals(value, jvmci_env()->get_Value_ILLEGAL())) { |
236 | if (type != T_ILLEGAL) { |
237 | JVMCI_ERROR_NULL("unexpected illegal value, expected %s", basictype_to_str(type)){ __jvmci_env__->fthrow_error( "/home/daniel/Projects/java/jdk/src/hotspot/share/jvmci/jvmciCodeInstaller.cpp" , 237, "unexpected illegal value, expected %s", basictype_to_str (type)); return __null; }; |
238 | } |
239 | return _illegal_value; |
240 | } else if (jvmci_env()->isa_RegisterValue(value)) { |
241 | JVMCIObject reg = jvmci_env()->get_RegisterValue_reg(value); |
242 | jint number = jvmci_env()->get_code_Register_number(reg); |
243 | VMReg hotspotRegister = get_hotspot_reg(number, JVMCI_CHECK_NULL__jvmci_env__); if ((__jvmci_env__->has_pending_exception( ))) return __null; (void)(0); |
244 | if (is_general_purpose_reg(hotspotRegister)) { |
245 | Location::Type locationType; |
246 | if (type == T_OBJECT) { |
247 | locationType = get_oop_type(value); |
248 | } else if (type == T_LONG) { |
249 | locationType = Location::lng; |
250 | } else if (type == T_INT || type == T_FLOAT || type == T_SHORT || type == T_CHAR || type == T_BYTE || type == T_BOOLEAN) { |
251 | locationType = Location::int_in_long; |
252 | } else { |
253 | JVMCI_ERROR_NULL("unexpected type %s in cpu register", basictype_to_str(type)){ __jvmci_env__->fthrow_error( "/home/daniel/Projects/java/jdk/src/hotspot/share/jvmci/jvmciCodeInstaller.cpp" , 253, "unexpected type %s in cpu register", basictype_to_str (type)); return __null; }; |
254 | } |
255 | ScopeValue* value = new LocationValue(Location::new_reg_loc(locationType, hotspotRegister)); |
256 | if (type == T_LONG) { |
257 | second = value; |
258 | } |
259 | return value; |
260 | } else { |
261 | Location::Type locationType; |
262 | if (type == T_FLOAT) { |
263 | // this seems weird, but the same value is used in c1_LinearScan |
264 | locationType = Location::normal; |
265 | } else if (type == T_DOUBLE) { |
266 | locationType = Location::dbl; |
267 | } else { |
268 | JVMCI_ERROR_NULL("unexpected type %s in floating point register", basictype_to_str(type)){ __jvmci_env__->fthrow_error( "/home/daniel/Projects/java/jdk/src/hotspot/share/jvmci/jvmciCodeInstaller.cpp" , 268, "unexpected type %s in floating point register", basictype_to_str (type)); return __null; }; |
269 | } |
270 | ScopeValue* value = new LocationValue(Location::new_reg_loc(locationType, hotspotRegister)); |
271 | if (type == T_DOUBLE) { |
272 | second = value; |
273 | } |
274 | return value; |
275 | } |
276 | } else if (jvmci_env()->isa_StackSlot(value)) { |
277 | jint offset = jvmci_env()->get_StackSlot_offset(value); |
278 | if (jvmci_env()->get_StackSlot_addFrameSize(value)) { |
279 | offset += _total_frame_size; |
280 | } |
281 | |
282 | Location::Type locationType; |
283 | if (type == T_OBJECT) { |
284 | locationType = get_oop_type(value); |
285 | } else if (type == T_LONG) { |
286 | locationType = Location::lng; |
287 | } else if (type == T_DOUBLE) { |
288 | locationType = Location::dbl; |
289 | } else if (type == T_INT || type == T_FLOAT || type == T_SHORT || type == T_CHAR || type == T_BYTE || type == T_BOOLEAN) { |
290 | locationType = Location::normal; |
291 | } else { |
292 | JVMCI_ERROR_NULL("unexpected type %s in stack slot", basictype_to_str(type)){ __jvmci_env__->fthrow_error( "/home/daniel/Projects/java/jdk/src/hotspot/share/jvmci/jvmciCodeInstaller.cpp" , 292, "unexpected type %s in stack slot", basictype_to_str(type )); return __null; }; |
293 | } |
294 | ScopeValue* value = new LocationValue(Location::new_stk_loc(locationType, offset)); |
295 | if (type == T_DOUBLE || type == T_LONG) { |
296 | second = value; |
297 | } |
298 | return value; |
299 | } else if (jvmci_env()->isa_JavaConstant(value)) { |
300 | if (jvmci_env()->isa_PrimitiveConstant(value)) { |
301 | if (jvmci_env()->isa_RawConstant(value)) { |
302 | jlong prim = jvmci_env()->get_PrimitiveConstant_primitive(value); |
303 | return new ConstantLongValue(prim); |
304 | } else { |
305 | BasicType constantType = jvmci_env()->kindToBasicType(jvmci_env()->get_PrimitiveConstant_kind(value), JVMCI_CHECK_NULL__jvmci_env__); if ((__jvmci_env__->has_pending_exception( ))) return __null; (void)(0); |
306 | if (type != constantType) { |
307 | JVMCI_ERROR_NULL("primitive constant type doesn't match, expected %s but got %s", basictype_to_str(type), basictype_to_str(constantType)){ __jvmci_env__->fthrow_error( "/home/daniel/Projects/java/jdk/src/hotspot/share/jvmci/jvmciCodeInstaller.cpp" , 307, "primitive constant type doesn't match, expected %s but got %s" , basictype_to_str(type), basictype_to_str(constantType)); return __null; }; |
308 | } |
309 | if (type == T_INT || type == T_FLOAT) { |
310 | jint prim = (jint)jvmci_env()->get_PrimitiveConstant_primitive(value); |
311 | switch (prim) { |
312 | case -1: return _int_m1_scope_value; |
313 | case 0: return _int_0_scope_value; |
314 | case 1: return _int_1_scope_value; |
315 | case 2: return _int_2_scope_value; |
316 | default: return new ConstantIntValue(prim); |
317 | } |
318 | } else if (type == T_LONG || type == T_DOUBLE) { |
319 | jlong prim = jvmci_env()->get_PrimitiveConstant_primitive(value); |
320 | second = _int_1_scope_value; |
321 | return new ConstantLongValue(prim); |
322 | } else { |
323 | JVMCI_ERROR_NULL("unexpected primitive constant type %s", basictype_to_str(type)){ __jvmci_env__->fthrow_error( "/home/daniel/Projects/java/jdk/src/hotspot/share/jvmci/jvmciCodeInstaller.cpp" , 323, "unexpected primitive constant type %s", basictype_to_str (type)); return __null; }; |
324 | } |
325 | } |
326 | } else if (jvmci_env()->isa_NullConstant(value) || jvmci_env()->isa_HotSpotCompressedNullConstant(value)) { |
327 | if (type == T_OBJECT) { |
328 | return _oop_null_scope_value; |
329 | } else { |
330 | JVMCI_ERROR_NULL("unexpected null constant, expected %s", basictype_to_str(type)){ __jvmci_env__->fthrow_error( "/home/daniel/Projects/java/jdk/src/hotspot/share/jvmci/jvmciCodeInstaller.cpp" , 330, "unexpected null constant, expected %s", basictype_to_str (type)); return __null; }; |
331 | } |
332 | } else if (jvmci_env()->isa_HotSpotObjectConstantImpl(value)) { |
333 | if (type == T_OBJECT) { |
334 | Handle obj = jvmci_env()->asConstant(value, JVMCI_CHECK_NULL__jvmci_env__); if ((__jvmci_env__->has_pending_exception( ))) return __null; (void)(0); |
335 | if (obj == NULL__null) { |
336 | JVMCI_ERROR_NULL("null value must be in NullConstant"){ __jvmci_env__->fthrow_error( "/home/daniel/Projects/java/jdk/src/hotspot/share/jvmci/jvmciCodeInstaller.cpp" , 336, "null value must be in NullConstant"); return __null; }; |
337 | } |
338 | return new ConstantOopWriteValue(JNIHandles::make_local(obj())); |
339 | } else { |
340 | JVMCI_ERROR_NULL("unexpected object constant, expected %s", basictype_to_str(type)){ __jvmci_env__->fthrow_error( "/home/daniel/Projects/java/jdk/src/hotspot/share/jvmci/jvmciCodeInstaller.cpp" , 340, "unexpected object constant, expected %s", basictype_to_str (type)); return __null; }; |
341 | } |
342 | } |
343 | } else if (jvmci_env()->isa_VirtualObject(value)) { |
344 | if (type == T_OBJECT) { |
345 | int id = jvmci_env()->get_VirtualObject_id(value); |
346 | if (0 <= id && id < objects->length()) { |
347 | ScopeValue* object = objects->at(id); |
348 | if (object != NULL__null) { |
349 | return object; |
350 | } |
351 | } |
352 | JVMCI_ERROR_NULL("unknown virtual object id %d", id){ __jvmci_env__->fthrow_error( "/home/daniel/Projects/java/jdk/src/hotspot/share/jvmci/jvmciCodeInstaller.cpp" , 352, "unknown virtual object id %d", id); return __null; }; |
353 | } else { |
354 | JVMCI_ERROR_NULL("unexpected virtual object, expected %s", basictype_to_str(type)){ __jvmci_env__->fthrow_error( "/home/daniel/Projects/java/jdk/src/hotspot/share/jvmci/jvmciCodeInstaller.cpp" , 354, "unexpected virtual object, expected %s", basictype_to_str (type)); return __null; }; |
355 | } |
356 | } |
357 | |
358 | JVMCI_ERROR_NULL("unexpected value in scope: %s", jvmci_env()->klass_name(value)){ __jvmci_env__->fthrow_error( "/home/daniel/Projects/java/jdk/src/hotspot/share/jvmci/jvmciCodeInstaller.cpp" , 358, "unexpected value in scope: %s", jvmci_env()->klass_name (value)); return __null; } |
359 | } |
360 | |
361 | void CodeInstaller::record_object_value(ObjectValue* sv, JVMCIObject value, GrowableArray<ScopeValue*>* objects, JVMCI_TRAPSJVMCIEnv* __jvmci_env__) { |
362 | JVMCIObject type = jvmci_env()->get_VirtualObject_type(value); |
363 | int id = jvmci_env()->get_VirtualObject_id(value); |
364 | Klass* klass = JVMCIENV__jvmci_env__->asKlass(type); |
365 | bool isLongArray = klass == Universe::longArrayKlassObj(); |
366 | bool isByteArray = klass == Universe::byteArrayKlassObj(); |
367 | |
368 | JVMCIObjectArray values = jvmci_env()->get_VirtualObject_values(value); |
369 | JVMCIObjectArray slotKinds = jvmci_env()->get_VirtualObject_slotKinds(value); |
370 | for (jint i = 0; i < JVMCIENV__jvmci_env__->get_length(values); i++) { |
371 | ScopeValue* cur_second = NULL__null; |
372 | JVMCIObject object = JVMCIENV__jvmci_env__->get_object_at(values, i); |
373 | BasicType type = jvmci_env()->kindToBasicType(JVMCIENV__jvmci_env__->get_object_at(slotKinds, i), JVMCI_CHECK__jvmci_env__); if ((__jvmci_env__->has_pending_exception( ))) return ; (void)(0); |
374 | ScopeValue* value; |
375 | if (JVMCIENV__jvmci_env__->equals(object, jvmci_env()->get_Value_ILLEGAL())) { |
376 | if (isByteArray && type == T_ILLEGAL) { |
377 | /* |
378 | * The difference between a virtualized large access and a deferred write is the kind stored in the slotKinds |
379 | * of the virtual object: in the virtualization case, the kind is illegal, in the deferred write case, the kind |
380 | * is access stack kind (an int). |
381 | */ |
382 | value = _virtual_byte_array_marker; |
383 | } else { |
384 | value = _illegal_value; |
385 | if (type == T_DOUBLE || type == T_LONG) { |
386 | cur_second = _illegal_value; |
387 | } |
388 | } |
389 | } else { |
390 | value = get_scope_value(object, type, objects, cur_second, JVMCI_CHECK__jvmci_env__); if ((__jvmci_env__->has_pending_exception( ))) return ; (void)(0); |
391 | } |
392 | |
393 | if (isLongArray && cur_second == NULL__null) { |
394 | // we're trying to put ints into a long array... this isn't really valid, but it's used for some optimizations. |
395 | // add an int 0 constant |
396 | cur_second = _int_0_scope_value; |
397 | } |
398 | |
399 | if (isByteArray && cur_second != NULL__null && (type == T_DOUBLE || type == T_LONG)) { |
400 | // we are trying to write a long in a byte Array. We will need to count the illegals to restore the type of |
401 | // the thing we put inside. |
402 | cur_second = NULL__null; |
403 | } |
404 | |
405 | if (cur_second != NULL__null) { |
406 | sv->field_values()->append(cur_second); |
407 | } |
408 | assert(value != NULL, "missing value")do { if (!(value != __null)) { (*g_assert_poison) = 'X';; report_vm_error ("/home/daniel/Projects/java/jdk/src/hotspot/share/jvmci/jvmciCodeInstaller.cpp" , 408, "assert(" "value != __null" ") failed", "missing value" ); ::breakpoint(); } } while (0); |
409 | sv->field_values()->append(value); |
410 | } |
411 | } |
412 | |
413 | MonitorValue* CodeInstaller::get_monitor_value(JVMCIObject value, GrowableArray<ScopeValue*>* objects, JVMCI_TRAPSJVMCIEnv* __jvmci_env__) { |
414 | if (value.is_null()) { |
415 | JVMCI_THROW_NULL(NullPointerException){ __jvmci_env__->throw_NullPointerException(); return __null ; }; |
416 | } |
417 | if (!jvmci_env()->isa_StackLockValue(value)) { |
418 | JVMCI_ERROR_NULL("Monitors must be of type StackLockValue, got %s", jvmci_env()->klass_name(value)){ __jvmci_env__->fthrow_error( "/home/daniel/Projects/java/jdk/src/hotspot/share/jvmci/jvmciCodeInstaller.cpp" , 418, "Monitors must be of type StackLockValue, got %s", jvmci_env ()->klass_name(value)); return __null; }; |
419 | } |
420 | |
421 | ScopeValue* second = NULL__null; |
422 | ScopeValue* owner_value = get_scope_value(jvmci_env()->get_StackLockValue_owner(value), T_OBJECT, objects, second, JVMCI_CHECK_NULL__jvmci_env__); if ((__jvmci_env__->has_pending_exception( ))) return __null; (void)(0); |
423 | assert(second == NULL, "monitor cannot occupy two stack slots")do { if (!(second == __null)) { (*g_assert_poison) = 'X';; report_vm_error ("/home/daniel/Projects/java/jdk/src/hotspot/share/jvmci/jvmciCodeInstaller.cpp" , 423, "assert(" "second == __null" ") failed", "monitor cannot occupy two stack slots" ); ::breakpoint(); } } while (0); |
424 | |
425 | ScopeValue* lock_data_value = get_scope_value(jvmci_env()->get_StackLockValue_slot(value), T_LONG, objects, second, JVMCI_CHECK_NULL__jvmci_env__); if ((__jvmci_env__->has_pending_exception( ))) return __null; (void)(0); |
426 | assert(second == lock_data_value, "monitor is LONG value that occupies two stack slots")do { if (!(second == lock_data_value)) { (*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/jvmci/jvmciCodeInstaller.cpp" , 426, "assert(" "second == lock_data_value" ") failed", "monitor is LONG value that occupies two stack slots" ); ::breakpoint(); } } while (0); |
427 | assert(lock_data_value->is_location(), "invalid monitor location")do { if (!(lock_data_value->is_location())) { (*g_assert_poison ) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/jvmci/jvmciCodeInstaller.cpp" , 427, "assert(" "lock_data_value->is_location()" ") failed" , "invalid monitor location"); ::breakpoint(); } } while (0); |
428 | Location lock_data_loc = ((LocationValue*)lock_data_value)->location(); |
429 | |
430 | bool eliminated = false; |
431 | if (jvmci_env()->get_StackLockValue_eliminated(value)) { |
432 | eliminated = true; |
433 | } |
434 | |
435 | return new MonitorValue(owner_value, lock_data_loc, eliminated); |
436 | } |
437 | |
438 | void CodeInstaller::initialize_dependencies(JVMCIObject compiled_code, OopRecorder* oop_recorder, JVMCI_TRAPSJVMCIEnv* __jvmci_env__) { |
439 | JavaThread* thread = JavaThread::current(); |
440 | CompilerThread* compilerThread = thread->is_Compiler_thread() ? CompilerThread::cast(thread) : NULL__null; |
441 | _oop_recorder = oop_recorder; |
442 | _dependencies = new Dependencies(&_arena, _oop_recorder, compilerThread != NULL__null ? compilerThread->log() : NULL__null); |
443 | JVMCIObjectArray assumptions = jvmci_env()->get_HotSpotCompiledCode_assumptions(compiled_code); |
444 | if (assumptions.is_non_null()) { |
445 | int length = JVMCIENV__jvmci_env__->get_length(assumptions); |
446 | for (int i = 0; i < length; ++i) { |
447 | JVMCIObject assumption = JVMCIENV__jvmci_env__->get_object_at(assumptions, i); |
448 | if (assumption.is_non_null()) { |
449 | if (jvmci_env()->isa_Assumptions_NoFinalizableSubclass(assumption)) { |
450 | assumption_NoFinalizableSubclass(assumption); |
451 | } else if (jvmci_env()->isa_Assumptions_ConcreteSubtype(assumption)) { |
452 | assumption_ConcreteSubtype(assumption); |
453 | } else if (jvmci_env()->isa_Assumptions_LeafType(assumption)) { |
454 | assumption_LeafType(assumption); |
455 | } else if (jvmci_env()->isa_Assumptions_ConcreteMethod(assumption)) { |
456 | assumption_ConcreteMethod(assumption); |
457 | } else if (jvmci_env()->isa_Assumptions_CallSiteTargetValue(assumption)) { |
458 | assumption_CallSiteTargetValue(assumption, JVMCI_CHECK__jvmci_env__); if ((__jvmci_env__->has_pending_exception( ))) return ; (void)(0); |
459 | } else { |
460 | JVMCI_ERROR("unexpected Assumption subclass %s", jvmci_env()->klass_name(assumption)){ __jvmci_env__->fthrow_error("/home/daniel/Projects/java/jdk/src/hotspot/share/jvmci/jvmciCodeInstaller.cpp" , 460, "unexpected Assumption subclass %s", jvmci_env()->klass_name (assumption)); return; }; |
461 | } |
462 | } |
463 | } |
464 | } |
465 | if (JvmtiExport::can_hotswap_or_post_breakpoint()) { |
466 | JVMCIObjectArray methods = jvmci_env()->get_HotSpotCompiledCode_methods(compiled_code); |
467 | if (methods.is_non_null()) { |
468 | int length = JVMCIENV__jvmci_env__->get_length(methods); |
469 | for (int i = 0; i < length; ++i) { |
470 | JVMCIObject method_handle = JVMCIENV__jvmci_env__->get_object_at(methods, i); |
471 | Method* method = jvmci_env()->asMethod(method_handle); |
472 | _dependencies->assert_evol_method(method); |
473 | } |
474 | } |
475 | } |
476 | } |
477 | |
478 | // constructor used to create a method |
479 | JVMCI::CodeInstallResult CodeInstaller::install(JVMCICompiler* compiler, |
480 | JVMCIObject target, |
481 | JVMCIObject compiled_code, |
482 | CodeBlob*& cb, |
483 | nmethodLocker& nmethod_handle, |
484 | JVMCIObject installed_code, |
485 | FailedSpeculation** failed_speculations, |
486 | char* speculations, |
487 | int speculations_len, |
488 | JVMCI_TRAPSJVMCIEnv* __jvmci_env__) { |
489 | |
490 | CodeBuffer buffer("JVMCI Compiler CodeBuffer"); |
491 | OopRecorder* recorder = new OopRecorder(&_arena, true); |
492 | initialize_dependencies(compiled_code, recorder, JVMCI_CHECK_OK__jvmci_env__); if ((__jvmci_env__->has_pending_exception( ))) return JVMCI::ok; (void)(0); |
493 | |
494 | // Get instructions and constants CodeSections early because we need it. |
495 | _instructions = buffer.insts(); |
496 | _constants = buffer.consts(); |
497 | |
498 | initialize_fields(target, compiled_code, JVMCI_CHECK_OK__jvmci_env__); if ((__jvmci_env__->has_pending_exception( ))) return JVMCI::ok; (void)(0); |
499 | JVMCI::CodeInstallResult result = initialize_buffer(buffer, true, JVMCI_CHECK_OK__jvmci_env__); if ((__jvmci_env__->has_pending_exception( ))) return JVMCI::ok; (void)(0); |
500 | if (result != JVMCI::ok) { |
501 | return result; |
502 | } |
503 | |
504 | int stack_slots = _total_frame_size / HeapWordSize; // conversion to words |
505 | |
506 | if (!jvmci_env()->isa_HotSpotCompiledNmethod(compiled_code)) { |
507 | JVMCIObject stubName = jvmci_env()->get_HotSpotCompiledCode_name(compiled_code); |
508 | if (stubName.is_null()) { |
509 | JVMCI_ERROR_OK("stub should have a name"){ __jvmci_env__->fthrow_error( "/home/daniel/Projects/java/jdk/src/hotspot/share/jvmci/jvmciCodeInstaller.cpp" , 509, "stub should have a name"); return JVMCI::ok; }; |
510 | } |
511 | char* name = strdup(jvmci_env()->as_utf8_string(stubName)); |
512 | cb = RuntimeStub::new_runtime_stub(name, |
513 | &buffer, |
514 | _offsets.value(CodeOffsets::Frame_Complete), |
515 | stack_slots, |
516 | _debug_recorder->_oopmaps, |
517 | false); |
518 | result = JVMCI::ok; |
519 | } else { |
520 | JVMCICompileState* compile_state = (JVMCICompileState*) (address) jvmci_env()->get_HotSpotCompiledNmethod_compileState(compiled_code); |
521 | if (compile_state != NULL__null) { |
522 | jvmci_env()->set_compile_state(compile_state); |
523 | } |
524 | |
525 | Thread* thread = Thread::current(); |
526 | |
527 | methodHandle method(thread, jvmci_env()->asMethod(jvmci_env()->get_HotSpotCompiledNmethod_method(compiled_code))); |
528 | jint entry_bci = jvmci_env()->get_HotSpotCompiledNmethod_entryBCI(compiled_code); |
529 | bool has_unsafe_access = jvmci_env()->get_HotSpotCompiledNmethod_hasUnsafeAccess(compiled_code) == JNI_TRUE1; |
530 | jint id = jvmci_env()->get_HotSpotCompiledNmethod_id(compiled_code); |
531 | if (id == -1) { |
532 | // Make sure a valid compile_id is associated with every compile |
533 | id = CompileBroker::assign_compile_id_unlocked(thread, method, entry_bci); |
534 | jvmci_env()->set_HotSpotCompiledNmethod_id(compiled_code, id); |
535 | } |
536 | if (!jvmci_env()->isa_HotSpotNmethod(installed_code)) { |
537 | JVMCI_THROW_MSG_(IllegalArgumentException, "InstalledCode object must be a HotSpotNmethod when installing a HotSpotCompiledNmethod", JVMCI::ok){ __jvmci_env__->throw_IllegalArgumentException("InstalledCode object must be a HotSpotNmethod when installing a HotSpotCompiledNmethod" ); return (JVMCI::ok); }; |
538 | } |
539 | |
540 | JVMCIObject mirror = installed_code; |
541 | result = runtime()->register_method(jvmci_env(), method, nmethod_handle, entry_bci, &_offsets, _orig_pc_offset, &buffer, |
542 | stack_slots, _debug_recorder->_oopmaps, &_exception_handler_table, &_implicit_exception_table, |
543 | compiler, _debug_recorder, _dependencies, id, |
544 | has_unsafe_access, _has_wide_vector, compiled_code, mirror, |
545 | failed_speculations, speculations, speculations_len); |
546 | if (result == JVMCI::ok) { |
547 | nmethod* nm = nmethod_handle.code()->as_nmethod_or_null(); |
548 | cb = nm; |
549 | if (compile_state == NULL__null) { |
550 | // This compile didn't come through the CompileBroker so perform the printing here |
551 | DirectiveSet* directive = DirectivesStack::getMatchingDirective(method, compiler); |
552 | nm->maybe_print_nmethod(directive); |
553 | DirectivesStack::release(directive); |
554 | } |
555 | } |
556 | } |
557 | |
558 | if (cb != NULL__null) { |
559 | // Make sure the pre-calculated constants section size was correct. |
560 | guarantee((cb->code_begin() - cb->content_begin()) >= _constants_size, "%d < %d", (int)(cb->code_begin() - cb->content_begin()), _constants_size)do { if (!((cb->code_begin() - cb->content_begin()) >= _constants_size)) { (*g_assert_poison) = 'X';; report_vm_error ("/home/daniel/Projects/java/jdk/src/hotspot/share/jvmci/jvmciCodeInstaller.cpp" , 560, "guarantee(" "(cb->code_begin() - cb->content_begin()) >= _constants_size" ") failed", "%d < %d", (int)(cb->code_begin() - cb-> content_begin()), _constants_size); ::breakpoint(); } } while (0); |
561 | } |
562 | return result; |
563 | } |
564 | |
565 | void CodeInstaller::initialize_fields(JVMCIObject target, JVMCIObject compiled_code, JVMCI_TRAPSJVMCIEnv* __jvmci_env__) { |
566 | if (jvmci_env()->isa_HotSpotCompiledNmethod(compiled_code)) { |
567 | JVMCIObject hotspotJavaMethod = jvmci_env()->get_HotSpotCompiledNmethod_method(compiled_code); |
568 | Thread* thread = Thread::current(); |
569 | methodHandle method(thread, jvmci_env()->asMethod(hotspotJavaMethod)); |
570 | _parameter_count = method->size_of_parameters(); |
571 | JVMCI_event_2if (JVMCITraceLevel < 2 && JVMCIEventLogLevel < 2) ; else ::JVMCI::event2("installing code for %s", method->name_and_sig_as_C_string()); |
572 | } else { |
573 | // Must be a HotSpotCompiledRuntimeStub. |
574 | // Only used in OopMap constructor for non-product builds |
575 | _parameter_count = 0; |
576 | } |
577 | _sites_handle = jvmci_env()->get_HotSpotCompiledCode_sites(compiled_code); |
578 | |
579 | _code_handle = jvmci_env()->get_HotSpotCompiledCode_targetCode(compiled_code); |
580 | _code_size = jvmci_env()->get_HotSpotCompiledCode_targetCodeSize(compiled_code); |
581 | _total_frame_size = jvmci_env()->get_HotSpotCompiledCode_totalFrameSize(compiled_code); |
582 | |
583 | JVMCIObject deoptRescueSlot = jvmci_env()->get_HotSpotCompiledCode_deoptRescueSlot(compiled_code); |
584 | if (deoptRescueSlot.is_null()) { |
585 | _orig_pc_offset = -1; |
586 | } else { |
587 | _orig_pc_offset = jvmci_env()->get_StackSlot_offset(deoptRescueSlot); |
588 | if (jvmci_env()->get_StackSlot_addFrameSize(deoptRescueSlot)) { |
589 | _orig_pc_offset += _total_frame_size; |
590 | } |
591 | if (_orig_pc_offset < 0) { |
592 | JVMCI_ERROR("invalid deopt rescue slot: %d", _orig_pc_offset){ __jvmci_env__->fthrow_error("/home/daniel/Projects/java/jdk/src/hotspot/share/jvmci/jvmciCodeInstaller.cpp" , 592, "invalid deopt rescue slot: %d", _orig_pc_offset); return ; }; |
593 | } |
594 | } |
595 | |
596 | // Pre-calculate the constants section size. This is required for PC-relative addressing. |
597 | _data_section_handle = jvmci_env()->get_HotSpotCompiledCode_dataSection(compiled_code); |
598 | if ((_constants->alignment() % jvmci_env()->get_HotSpotCompiledCode_dataSectionAlignment(compiled_code)) != 0) { |
599 | JVMCI_ERROR("invalid data section alignment: %d", jvmci_env()->get_HotSpotCompiledCode_dataSectionAlignment(compiled_code)){ __jvmci_env__->fthrow_error("/home/daniel/Projects/java/jdk/src/hotspot/share/jvmci/jvmciCodeInstaller.cpp" , 599, "invalid data section alignment: %d", jvmci_env()-> get_HotSpotCompiledCode_dataSectionAlignment(compiled_code)); return; }; |
600 | } |
601 | _constants_size = JVMCIENV__jvmci_env__->get_length(data_section()); |
602 | |
603 | _data_section_patches_handle = jvmci_env()->get_HotSpotCompiledCode_dataSectionPatches(compiled_code); |
604 | |
605 | #ifndef PRODUCT |
606 | _comments_handle = jvmci_env()->get_HotSpotCompiledCode_comments(compiled_code); |
607 | #endif |
608 | |
609 | _next_call_type = INVOKE_INVALID; |
610 | |
611 | _has_wide_vector = false; |
612 | |
613 | JVMCIObject arch = jvmci_env()->get_TargetDescription_arch(target); |
614 | _word_kind_handle = jvmci_env()->get_Architecture_wordKind(arch); |
615 | } |
616 | |
617 | int CodeInstaller::estimate_stubs_size(JVMCI_TRAPSJVMCIEnv* __jvmci_env__) { |
618 | // Estimate the number of static call stubs that might be emitted. |
619 | int static_call_stubs = 0; |
620 | int trampoline_stubs = 0; |
621 | JVMCIObjectArray sites = this->sites(); |
622 | for (int i = 0; i < JVMCIENV__jvmci_env__->get_length(sites); i++) { |
623 | JVMCIObject site = JVMCIENV__jvmci_env__->get_object_at(sites, i); |
624 | if (!site.is_null()) { |
625 | if (jvmci_env()->isa_site_Mark(site)) { |
626 | JVMCIObject id_obj = jvmci_env()->get_site_Mark_id(site); |
627 | if (id_obj.is_non_null()) { |
628 | if (!jvmci_env()->is_boxing_object(T_INT, id_obj)) { |
629 | JVMCI_ERROR_0("expected Integer id, got %s", jvmci_env()->klass_name(id_obj)){ __jvmci_env__->fthrow_error( "/home/daniel/Projects/java/jdk/src/hotspot/share/jvmci/jvmciCodeInstaller.cpp" , 629, "expected Integer id, got %s", jvmci_env()->klass_name (id_obj)); return 0; }; |
630 | } |
631 | jint id = jvmci_env()->get_boxed_value(T_INT, id_obj).i; |
632 | switch (id) { |
633 | case INVOKEINTERFACE: |
634 | case INVOKEVIRTUAL: |
635 | trampoline_stubs++; |
636 | break; |
637 | case INVOKESTATIC: |
638 | case INVOKESPECIAL: |
639 | static_call_stubs++; |
640 | trampoline_stubs++; |
641 | break; |
642 | default: |
643 | break; |
644 | } |
645 | } |
646 | } |
647 | } |
648 | } |
649 | int size = static_call_stubs * CompiledStaticCall::to_interp_stub_size(); |
650 | size += trampoline_stubs * CompiledStaticCall::to_trampoline_stub_size(); |
651 | return size; |
652 | } |
653 | |
654 | // perform data and call relocation on the CodeBuffer |
655 | JVMCI::CodeInstallResult CodeInstaller::initialize_buffer(CodeBuffer& buffer, bool check_size, JVMCI_TRAPSJVMCIEnv* __jvmci_env__) { |
656 | HandleMark hm(Thread::current()); |
657 | JVMCIObjectArray sites = this->sites(); |
658 | int locs_buffer_size = JVMCIENV__jvmci_env__->get_length(sites) * (relocInfo::length_limit + sizeof(relocInfo)); |
659 | |
660 | // Allocate enough space in the stub section for the static call |
661 | // stubs. Stubs have extra relocs but they are managed by the stub |
662 | // section itself so they don't need to be accounted for in the |
663 | // locs_buffer above. |
664 | int stubs_size = estimate_stubs_size(JVMCI_CHECK_OK__jvmci_env__); if ((__jvmci_env__->has_pending_exception( ))) return JVMCI::ok; (void)(0); |
665 | int total_size = align_up(_code_size, buffer.insts()->alignment()) + align_up(_constants_size, buffer.consts()->alignment()) + align_up(stubs_size, buffer.stubs()->alignment()); |
666 | |
667 | if (check_size && total_size > JVMCINMethodSizeLimit) { |
668 | return JVMCI::code_too_large; |
669 | } |
670 | |
671 | buffer.initialize(total_size, locs_buffer_size); |
672 | if (buffer.blob() == NULL__null) { |
673 | return JVMCI::cache_full; |
674 | } |
675 | buffer.initialize_stubs_size(stubs_size); |
676 | buffer.initialize_consts_size(_constants_size); |
677 | |
678 | _debug_recorder = new DebugInformationRecorder(_oop_recorder); |
679 | _debug_recorder->set_oopmaps(new OopMapSet()); |
680 | |
681 | buffer.initialize_oop_recorder(_oop_recorder); |
682 | |
683 | // copy the constant data into the newly created CodeBuffer |
684 | address end_data = _constants->start() + _constants_size; |
685 | JVMCIENV__jvmci_env__->copy_bytes_to(data_section(), (jbyte*) _constants->start(), 0, _constants_size); |
686 | _constants->set_end(end_data); |
687 | |
688 | // copy the code into the newly created CodeBuffer |
689 | address end_pc = _instructions->start() + _code_size; |
690 | guarantee(_instructions->allocates2(end_pc), "initialize should have reserved enough space for all the code")do { if (!(_instructions->allocates2(end_pc))) { (*g_assert_poison ) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/jvmci/jvmciCodeInstaller.cpp" , 690, "guarantee(" "_instructions->allocates2(end_pc)" ") failed" , "initialize should have reserved enough space for all the code" ); ::breakpoint(); } } while (0); |
691 | JVMCIENV__jvmci_env__->copy_bytes_to(code(), (jbyte*) _instructions->start(), 0, _code_size); |
692 | _instructions->set_end(end_pc); |
693 | |
694 | for (int i = 0; i < JVMCIENV__jvmci_env__->get_length(data_section_patches()); i++) { |
695 | // HandleMark hm(THREAD); |
696 | JVMCIObject patch = JVMCIENV__jvmci_env__->get_object_at(data_section_patches(), i); |
697 | if (patch.is_null()) { |
698 | JVMCI_THROW_(NullPointerException, JVMCI::ok){ __jvmci_env__->throw_NullPointerException(); return (JVMCI ::ok); }; |
699 | } |
700 | JVMCIObject reference = jvmci_env()->get_site_DataPatch_reference(patch); |
701 | if (reference.is_null()) { |
702 | JVMCI_THROW_(NullPointerException, JVMCI::ok){ __jvmci_env__->throw_NullPointerException(); return (JVMCI ::ok); }; |
703 | } |
704 | if (!jvmci_env()->isa_site_ConstantReference(reference)) { |
705 | JVMCI_ERROR_OK("invalid patch in data section: %s", jvmci_env()->klass_name(reference)){ __jvmci_env__->fthrow_error( "/home/daniel/Projects/java/jdk/src/hotspot/share/jvmci/jvmciCodeInstaller.cpp" , 705, "invalid patch in data section: %s", jvmci_env()->klass_name (reference)); return JVMCI::ok; }; |
706 | } |
707 | JVMCIObject constant = jvmci_env()->get_site_ConstantReference_constant(reference); |
708 | if (constant.is_null()) { |
709 | JVMCI_THROW_(NullPointerException, JVMCI::ok){ __jvmci_env__->throw_NullPointerException(); return (JVMCI ::ok); }; |
710 | } |
711 | address dest = _constants->start() + jvmci_env()->get_site_Site_pcOffset(patch); |
712 | if (jvmci_env()->isa_HotSpotMetaspaceConstantImpl(constant)) { |
713 | if (jvmci_env()->get_HotSpotMetaspaceConstantImpl_compressed(constant)) { |
714 | #ifdef _LP641 |
715 | *((narrowKlass*) dest) = record_narrow_metadata_reference(_constants, dest, constant, JVMCI_CHECK_OK__jvmci_env__); if ((__jvmci_env__->has_pending_exception( ))) return JVMCI::ok; (void)(0); |
716 | #else |
717 | JVMCI_ERROR_OK("unexpected compressed Klass* in 32-bit mode"){ __jvmci_env__->fthrow_error( "/home/daniel/Projects/java/jdk/src/hotspot/share/jvmci/jvmciCodeInstaller.cpp" , 717, "unexpected compressed Klass* in 32-bit mode"); return JVMCI::ok; }; |
718 | #endif |
719 | } else { |
720 | *((void**) dest) = record_metadata_reference(_constants, dest, constant, JVMCI_CHECK_OK__jvmci_env__); if ((__jvmci_env__->has_pending_exception( ))) return JVMCI::ok; (void)(0); |
721 | } |
722 | } else if (jvmci_env()->isa_HotSpotObjectConstantImpl(constant)) { |
723 | Handle obj = jvmci_env()->asConstant(constant, JVMCI_CHECK_OK__jvmci_env__); if ((__jvmci_env__->has_pending_exception( ))) return JVMCI::ok; (void)(0); |
724 | jobject value = JNIHandles::make_local(obj()); |
725 | int oop_index = _oop_recorder->find_index(value); |
726 | |
727 | if (jvmci_env()->get_HotSpotObjectConstantImpl_compressed(constant)) { |
728 | #ifdef _LP641 |
729 | _constants->relocate(dest, oop_Relocation::spec(oop_index), relocInfo::narrow_oop_in_const); |
730 | #else |
731 | JVMCI_ERROR_OK("unexpected compressed oop in 32-bit mode"){ __jvmci_env__->fthrow_error( "/home/daniel/Projects/java/jdk/src/hotspot/share/jvmci/jvmciCodeInstaller.cpp" , 731, "unexpected compressed oop in 32-bit mode"); return JVMCI ::ok; }; |
732 | #endif |
733 | } else { |
734 | _constants->relocate(dest, oop_Relocation::spec(oop_index)); |
735 | } |
736 | } else { |
737 | JVMCI_ERROR_OK("invalid constant in data section: %s", jvmci_env()->klass_name(constant)){ __jvmci_env__->fthrow_error( "/home/daniel/Projects/java/jdk/src/hotspot/share/jvmci/jvmciCodeInstaller.cpp" , 737, "invalid constant in data section: %s", jvmci_env()-> klass_name(constant)); return JVMCI::ok; }; |
738 | } |
739 | } |
740 | jint last_pc_offset = -1; |
741 | for (int i = 0; i < JVMCIENV__jvmci_env__->get_length(sites); i++) { |
742 | // HandleMark hm(THREAD); |
743 | JVMCIObject site = JVMCIENV__jvmci_env__->get_object_at(sites, i); |
744 | if (site.is_null()) { |
745 | JVMCI_THROW_(NullPointerException, JVMCI::ok){ __jvmci_env__->throw_NullPointerException(); return (JVMCI ::ok); }; |
746 | } |
747 | |
748 | jint pc_offset = jvmci_env()->get_site_Site_pcOffset(site); |
749 | |
750 | if (jvmci_env()->isa_site_Call(site)) { |
751 | JVMCI_event_4if (JVMCITraceLevel < 4 && JVMCIEventLogLevel < 4) ; else ::JVMCI::event4("call at %i", pc_offset); |
752 | site_Call(buffer, pc_offset, site, JVMCI_CHECK_OK__jvmci_env__); if ((__jvmci_env__->has_pending_exception( ))) return JVMCI::ok; (void)(0); |
753 | } else if (jvmci_env()->isa_site_Infopoint(site)) { |
754 | // three reasons for infopoints denote actual safepoints |
755 | JVMCIObject reason = jvmci_env()->get_site_Infopoint_reason(site); |
756 | if (JVMCIENV__jvmci_env__->equals(reason, jvmci_env()->get_site_InfopointReason_SAFEPOINT()) || |
757 | JVMCIENV__jvmci_env__->equals(reason, jvmci_env()->get_site_InfopointReason_CALL()) || |
758 | JVMCIENV__jvmci_env__->equals(reason, jvmci_env()->get_site_InfopointReason_IMPLICIT_EXCEPTION())) { |
759 | JVMCI_event_4if (JVMCITraceLevel < 4 && JVMCIEventLogLevel < 4) ; else ::JVMCI::event4("safepoint at %i", pc_offset); |
760 | site_Safepoint(buffer, pc_offset, site, JVMCI_CHECK_OK__jvmci_env__); if ((__jvmci_env__->has_pending_exception( ))) return JVMCI::ok; (void)(0); |
761 | if (_orig_pc_offset < 0) { |
762 | JVMCI_ERROR_OK("method contains safepoint, but has no deopt rescue slot"){ __jvmci_env__->fthrow_error( "/home/daniel/Projects/java/jdk/src/hotspot/share/jvmci/jvmciCodeInstaller.cpp" , 762, "method contains safepoint, but has no deopt rescue slot" ); return JVMCI::ok; }; |
763 | } |
764 | if (JVMCIENV__jvmci_env__->equals(reason, jvmci_env()->get_site_InfopointReason_IMPLICIT_EXCEPTION())) { |
765 | if (jvmci_env()->isa_site_ImplicitExceptionDispatch(site)) { |
766 | jint dispatch_offset = jvmci_env()->get_site_ImplicitExceptionDispatch_dispatchOffset(site); |
767 | JVMCI_event_4if (JVMCITraceLevel < 4 && JVMCIEventLogLevel < 4) ; else ::JVMCI::event4("implicit exception at %i, dispatch to %i", pc_offset, dispatch_offset); |
768 | _implicit_exception_table.append(pc_offset, dispatch_offset); |
769 | } else { |
770 | JVMCI_event_4if (JVMCITraceLevel < 4 && JVMCIEventLogLevel < 4) ; else ::JVMCI::event4("implicit exception at %i", pc_offset); |
771 | _implicit_exception_table.add_deoptimize(pc_offset); |
772 | } |
773 | } |
774 | } else { |
775 | JVMCI_event_4if (JVMCITraceLevel < 4 && JVMCIEventLogLevel < 4) ; else ::JVMCI::event4("infopoint at %i", pc_offset); |
776 | site_Infopoint(buffer, pc_offset, site, JVMCI_CHECK_OK__jvmci_env__); if ((__jvmci_env__->has_pending_exception( ))) return JVMCI::ok; (void)(0); |
777 | } |
778 | } else if (jvmci_env()->isa_site_DataPatch(site)) { |
779 | JVMCI_event_4if (JVMCITraceLevel < 4 && JVMCIEventLogLevel < 4) ; else ::JVMCI::event4("datapatch at %i", pc_offset); |
780 | site_DataPatch(buffer, pc_offset, site, JVMCI_CHECK_OK__jvmci_env__); if ((__jvmci_env__->has_pending_exception( ))) return JVMCI::ok; (void)(0); |
781 | } else if (jvmci_env()->isa_site_Mark(site)) { |
782 | JVMCI_event_4if (JVMCITraceLevel < 4 && JVMCIEventLogLevel < 4) ; else ::JVMCI::event4("mark at %i", pc_offset); |
783 | site_Mark(buffer, pc_offset, site, JVMCI_CHECK_OK__jvmci_env__); if ((__jvmci_env__->has_pending_exception( ))) return JVMCI::ok; (void)(0); |
784 | } else if (jvmci_env()->isa_site_ExceptionHandler(site)) { |
785 | JVMCI_event_4if (JVMCITraceLevel < 4 && JVMCIEventLogLevel < 4) ; else ::JVMCI::event4("exceptionhandler at %i", pc_offset); |
786 | site_ExceptionHandler(pc_offset, site); |
787 | } else { |
788 | JVMCI_ERROR_OK("unexpected site subclass: %s", jvmci_env()->klass_name(site)){ __jvmci_env__->fthrow_error( "/home/daniel/Projects/java/jdk/src/hotspot/share/jvmci/jvmciCodeInstaller.cpp" , 788, "unexpected site subclass: %s", jvmci_env()->klass_name (site)); return JVMCI::ok; }; |
789 | } |
790 | last_pc_offset = pc_offset; |
Value stored to 'last_pc_offset' is never read | |
791 | |
792 | JavaThread* thread = JavaThread::current(); |
793 | if (SafepointMechanism::should_process(thread)) { |
794 | // this is a hacky way to force a safepoint check but nothing else was jumping out at me. |
795 | ThreadToNativeFromVM ttnfv(thread); |
796 | } |
797 | } |
798 | |
799 | #ifndef PRODUCT |
800 | if (comments().is_non_null()) { |
801 | for (int i = 0; i < JVMCIENV__jvmci_env__->get_length(comments()); i++) { |
802 | JVMCIObject comment = JVMCIENV__jvmci_env__->get_object_at(comments(), i); |
803 | assert(jvmci_env()->isa_HotSpotCompiledCode_Comment(comment), "cce")do { if (!(jvmci_env()->isa_HotSpotCompiledCode_Comment(comment ))) { (*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/jvmci/jvmciCodeInstaller.cpp" , 803, "assert(" "jvmci_env()->isa_HotSpotCompiledCode_Comment(comment)" ") failed", "cce"); ::breakpoint(); } } while (0); |
804 | jint offset = jvmci_env()->get_HotSpotCompiledCode_Comment_pcOffset(comment); |
805 | const char* text = jvmci_env()->as_utf8_string(jvmci_env()->get_HotSpotCompiledCode_Comment_text(comment)); |
806 | buffer.block_comment(offset, text); |
807 | } |
808 | } |
809 | #endif |
810 | if (_has_auto_box) { |
811 | JavaThread* THREAD__the_thread__ = JavaThread::current(); // For exception macros. |
812 | JVMCI::ensure_box_caches_initialized(CHECK_(JVMCI::ok)__the_thread__); if ((((ThreadShadow*)__the_thread__)->has_pending_exception ())) return JVMCI::ok; (void)(0); |
813 | } |
814 | return JVMCI::ok; |
815 | } |
816 | |
817 | void CodeInstaller::assumption_NoFinalizableSubclass(JVMCIObject assumption) { |
818 | JVMCIObject receiverType_handle = jvmci_env()->get_Assumptions_NoFinalizableSubclass_receiverType(assumption); |
819 | Klass* receiverType = jvmci_env()->asKlass(receiverType_handle); |
820 | _dependencies->assert_has_no_finalizable_subclasses(receiverType); |
821 | } |
822 | |
823 | void CodeInstaller::assumption_ConcreteSubtype(JVMCIObject assumption) { |
824 | JVMCIObject context_handle = jvmci_env()->get_Assumptions_ConcreteSubtype_context(assumption); |
825 | JVMCIObject subtype_handle = jvmci_env()->get_Assumptions_ConcreteSubtype_subtype(assumption); |
826 | Klass* context = jvmci_env()->asKlass(context_handle); |
827 | Klass* subtype = jvmci_env()->asKlass(subtype_handle); |
828 | |
829 | assert(context->is_abstract(), "")do { if (!(context->is_abstract())) { (*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/jvmci/jvmciCodeInstaller.cpp" , 829, "assert(" "context->is_abstract()" ") failed", ""); ::breakpoint(); } } while (0); |
830 | _dependencies->assert_abstract_with_unique_concrete_subtype(context, subtype); |
831 | } |
832 | |
833 | void CodeInstaller::assumption_LeafType(JVMCIObject assumption) { |
834 | JVMCIObject context_handle = jvmci_env()->get_Assumptions_LeafType_context(assumption); |
835 | Klass* context = jvmci_env()->asKlass(context_handle); |
836 | |
837 | _dependencies->assert_leaf_type(context); |
838 | } |
839 | |
840 | void CodeInstaller::assumption_ConcreteMethod(JVMCIObject assumption) { |
841 | JVMCIObject impl_handle = jvmci_env()->get_Assumptions_ConcreteMethod_impl(assumption); |
842 | JVMCIObject context_handle = jvmci_env()->get_Assumptions_ConcreteMethod_context(assumption); |
843 | |
844 | Method* impl = jvmci_env()->asMethod(impl_handle); |
845 | Klass* context = jvmci_env()->asKlass(context_handle); |
846 | |
847 | _dependencies->assert_unique_concrete_method(context, impl); |
848 | } |
849 | |
850 | void CodeInstaller::assumption_CallSiteTargetValue(JVMCIObject assumption, JVMCI_TRAPSJVMCIEnv* __jvmci_env__) { |
851 | JVMCIObject callSiteConstant = jvmci_env()->get_Assumptions_CallSiteTargetValue_callSite(assumption); |
852 | Handle callSite = jvmci_env()->asConstant(callSiteConstant, JVMCI_CHECK__jvmci_env__); if ((__jvmci_env__->has_pending_exception( ))) return ; (void)(0); |
853 | JVMCIObject methodConstant = jvmci_env()->get_Assumptions_CallSiteTargetValue_methodHandle(assumption); |
854 | Handle methodHandle = jvmci_env()->asConstant(methodConstant, JVMCI_CHECK__jvmci_env__); if ((__jvmci_env__->has_pending_exception( ))) return ; (void)(0); |
855 | _dependencies->assert_call_site_target_value(callSite(), methodHandle()); |
856 | } |
857 | |
858 | void CodeInstaller::site_ExceptionHandler(jint pc_offset, JVMCIObject exc) { |
859 | jint handler_offset = jvmci_env()->get_site_ExceptionHandler_handlerPos(exc); |
860 | |
861 | // Subtable header |
862 | _exception_handler_table.add_entry(HandlerTableEntry(1, pc_offset, 0)); |
863 | |
864 | // Subtable entry |
865 | _exception_handler_table.add_entry(HandlerTableEntry(-1, handler_offset, 0)); |
866 | } |
867 | |
868 | // If deoptimization happens, the interpreter should reexecute these bytecodes. |
869 | // This function mainly helps the compilers to set up the reexecute bit. |
870 | static bool bytecode_should_reexecute(Bytecodes::Code code) { |
871 | switch (code) { |
872 | case Bytecodes::_invokedynamic: |
873 | case Bytecodes::_invokevirtual: |
874 | case Bytecodes::_invokeinterface: |
875 | case Bytecodes::_invokespecial: |
876 | case Bytecodes::_invokestatic: |
877 | return false; |
878 | default: |
879 | return true; |
880 | } |
881 | return true; |
882 | } |
883 | |
884 | GrowableArray<ScopeValue*>* CodeInstaller::record_virtual_objects(JVMCIObject debug_info, JVMCI_TRAPSJVMCIEnv* __jvmci_env__) { |
885 | JVMCIObjectArray virtualObjects = jvmci_env()->get_DebugInfo_virtualObjectMapping(debug_info); |
886 | if (virtualObjects.is_null()) { |
887 | return NULL__null; |
888 | } |
889 | GrowableArray<ScopeValue*>* objects = new GrowableArray<ScopeValue*>(JVMCIENV__jvmci_env__->get_length(virtualObjects), JVMCIENV__jvmci_env__->get_length(virtualObjects), NULL__null); |
890 | // Create the unique ObjectValues |
891 | for (int i = 0; i < JVMCIENV__jvmci_env__->get_length(virtualObjects); i++) { |
892 | // HandleMark hm(THREAD); |
893 | JVMCIObject value = JVMCIENV__jvmci_env__->get_object_at(virtualObjects, i); |
894 | int id = jvmci_env()->get_VirtualObject_id(value); |
895 | JVMCIObject type = jvmci_env()->get_VirtualObject_type(value); |
896 | bool is_auto_box = jvmci_env()->get_VirtualObject_isAutoBox(value); |
897 | if (is_auto_box) { |
898 | _has_auto_box = true; |
899 | } |
900 | Klass* klass = jvmci_env()->asKlass(type); |
901 | oop javaMirror = klass->java_mirror(); |
902 | ScopeValue *klass_sv = new ConstantOopWriteValue(JNIHandles::make_local(javaMirror)); |
903 | ObjectValue* sv = is_auto_box ? new AutoBoxObjectValue(id, klass_sv) : new ObjectValue(id, klass_sv); |
904 | if (id < 0 || id >= objects->length()) { |
905 | JVMCI_ERROR_NULL("virtual object id %d out of bounds", id){ __jvmci_env__->fthrow_error( "/home/daniel/Projects/java/jdk/src/hotspot/share/jvmci/jvmciCodeInstaller.cpp" , 905, "virtual object id %d out of bounds", id); return __null ; }; |
906 | } |
907 | if (objects->at(id) != NULL__null) { |
908 | JVMCI_ERROR_NULL("duplicate virtual object id %d", id){ __jvmci_env__->fthrow_error( "/home/daniel/Projects/java/jdk/src/hotspot/share/jvmci/jvmciCodeInstaller.cpp" , 908, "duplicate virtual object id %d", id); return __null; }; |
909 | } |
910 | objects->at_put(id, sv); |
911 | } |
912 | // All the values which could be referenced by the VirtualObjects |
913 | // exist, so now describe all the VirtualObjects themselves. |
914 | for (int i = 0; i < JVMCIENV__jvmci_env__->get_length(virtualObjects); i++) { |
915 | // HandleMark hm(THREAD); |
916 | JVMCIObject value = JVMCIENV__jvmci_env__->get_object_at(virtualObjects, i); |
917 | int id = jvmci_env()->get_VirtualObject_id(value); |
918 | record_object_value(objects->at(id)->as_ObjectValue(), value, objects, JVMCI_CHECK_NULL__jvmci_env__); if ((__jvmci_env__->has_pending_exception( ))) return __null; (void)(0); |
919 | } |
920 | _debug_recorder->dump_object_pool(objects); |
921 | |
922 | return objects; |
923 | } |
924 | |
925 | void CodeInstaller::record_scope(jint pc_offset, JVMCIObject debug_info, ScopeMode scope_mode, bool is_mh_invoke, bool return_oop, JVMCI_TRAPSJVMCIEnv* __jvmci_env__) { |
926 | JVMCIObject position = jvmci_env()->get_DebugInfo_bytecodePosition(debug_info); |
927 | if (position.is_null()) { |
928 | // Stubs do not record scope info, just oop maps |
929 | return; |
930 | } |
931 | |
932 | GrowableArray<ScopeValue*>* objectMapping; |
933 | if (scope_mode == CodeInstaller::FullFrame) { |
934 | objectMapping = record_virtual_objects(debug_info, JVMCI_CHECK__jvmci_env__); if ((__jvmci_env__->has_pending_exception( ))) return ; (void)(0); |
935 | } else { |
936 | objectMapping = NULL__null; |
937 | } |
938 | record_scope(pc_offset, position, scope_mode, objectMapping, is_mh_invoke, return_oop, JVMCI_CHECK__jvmci_env__); if ((__jvmci_env__->has_pending_exception( ))) return ; (void)(0); |
939 | } |
940 | |
941 | int CodeInstaller::map_jvmci_bci(int bci) { |
942 | if (bci < 0) { |
943 | if (bci == jvmci_env()->get_BytecodeFrame_BEFORE_BCI()) { |
944 | return BeforeBci; |
945 | } else if (bci == jvmci_env()->get_BytecodeFrame_AFTER_BCI()) { |
946 | return AfterBci; |
947 | } else if (bci == jvmci_env()->get_BytecodeFrame_UNWIND_BCI()) { |
948 | return UnwindBci; |
949 | } else if (bci == jvmci_env()->get_BytecodeFrame_AFTER_EXCEPTION_BCI()) { |
950 | return AfterExceptionBci; |
951 | } else if (bci == jvmci_env()->get_BytecodeFrame_UNKNOWN_BCI()) { |
952 | return UnknownBci; |
953 | } else if (bci == jvmci_env()->get_BytecodeFrame_INVALID_FRAMESTATE_BCI()) { |
954 | return InvalidFrameStateBci; |
955 | } |
956 | ShouldNotReachHere()do { (*g_assert_poison) = 'X';; report_should_not_reach_here( "/home/daniel/Projects/java/jdk/src/hotspot/share/jvmci/jvmciCodeInstaller.cpp" , 956); ::breakpoint(); } while (0); |
957 | } |
958 | return bci; |
959 | } |
960 | |
961 | void CodeInstaller::record_scope(jint pc_offset, JVMCIObject position, ScopeMode scope_mode, GrowableArray<ScopeValue*>* objects, bool is_mh_invoke, bool return_oop, JVMCI_TRAPSJVMCIEnv* __jvmci_env__) { |
962 | JVMCIObject frame; |
963 | if (scope_mode == CodeInstaller::FullFrame) { |
964 | if (!jvmci_env()->isa_BytecodeFrame(position)) { |
965 | JVMCI_ERROR("Full frame expected for debug info at %i", pc_offset){ __jvmci_env__->fthrow_error("/home/daniel/Projects/java/jdk/src/hotspot/share/jvmci/jvmciCodeInstaller.cpp" , 965, "Full frame expected for debug info at %i", pc_offset) ; return; }; |
966 | } |
967 | frame = position; |
968 | } |
969 | JVMCIObject caller_frame = jvmci_env()->get_BytecodePosition_caller(position); |
970 | if (caller_frame.is_non_null()) { |
971 | record_scope(pc_offset, caller_frame, scope_mode, objects, is_mh_invoke, return_oop, JVMCI_CHECK__jvmci_env__); if ((__jvmci_env__->has_pending_exception( ))) return ; (void)(0); |
972 | } |
973 | |
974 | JVMCIObject hotspot_method = jvmci_env()->get_BytecodePosition_method(position); |
975 | Thread* thread = Thread::current(); |
976 | methodHandle method(thread, jvmci_env()->asMethod(hotspot_method)); |
977 | jint bci = map_jvmci_bci(jvmci_env()->get_BytecodePosition_bci(position)); |
978 | if (bci == jvmci_env()->get_BytecodeFrame_BEFORE_BCI()) { |
979 | bci = SynchronizationEntryBCI; |
980 | } |
981 | |
982 | JVMCI_event_2if (JVMCITraceLevel < 2 && JVMCIEventLogLevel < 2) ; else ::JVMCI::event2("Recording scope pc_offset=%d bci=%d method=%s", pc_offset, bci, method->name_and_sig_as_C_string()); |
983 | |
984 | bool reexecute = false; |
985 | if (frame.is_non_null()) { |
986 | if (bci < 0){ |
987 | reexecute = false; |
988 | } else { |
989 | Bytecodes::Code code = Bytecodes::java_code_at(method(), method->bcp_from(bci)); |
990 | reexecute = bytecode_should_reexecute(code); |
991 | if (frame.is_non_null()) { |
992 | reexecute = (jvmci_env()->get_BytecodeFrame_duringCall(frame) == JNI_FALSE0); |
993 | } |
994 | } |
995 | } |
996 | |
997 | DebugToken* locals_token = NULL__null; |
998 | DebugToken* expressions_token = NULL__null; |
999 | DebugToken* monitors_token = NULL__null; |
1000 | bool throw_exception = false; |
1001 | |
1002 | if (frame.is_non_null()) { |
1003 | jint local_count = jvmci_env()->get_BytecodeFrame_numLocals(frame); |
1004 | jint expression_count = jvmci_env()->get_BytecodeFrame_numStack(frame); |
1005 | jint monitor_count = jvmci_env()->get_BytecodeFrame_numLocks(frame); |
1006 | JVMCIObjectArray values = jvmci_env()->get_BytecodeFrame_values(frame); |
1007 | JVMCIObjectArray slotKinds = jvmci_env()->get_BytecodeFrame_slotKinds(frame); |
1008 | |
1009 | if (values.is_null() || slotKinds.is_null()) { |
1010 | JVMCI_THROW(NullPointerException){ __jvmci_env__->throw_NullPointerException(); return; }; |
1011 | } |
1012 | if (local_count + expression_count + monitor_count != JVMCIENV__jvmci_env__->get_length(values)) { |
1013 | JVMCI_ERROR("unexpected values length %d in scope (%d locals, %d expressions, %d monitors)", JVMCIENV->get_length(values), local_count, expression_count, monitor_count){ __jvmci_env__->fthrow_error("/home/daniel/Projects/java/jdk/src/hotspot/share/jvmci/jvmciCodeInstaller.cpp" , 1013, "unexpected values length %d in scope (%d locals, %d expressions, %d monitors)" , __jvmci_env__->get_length(values), local_count, expression_count , monitor_count); return; }; |
1014 | } |
1015 | if (local_count + expression_count != JVMCIENV__jvmci_env__->get_length(slotKinds)) { |
1016 | JVMCI_ERROR("unexpected slotKinds length %d in scope (%d locals, %d expressions)", JVMCIENV->get_length(slotKinds), local_count, expression_count){ __jvmci_env__->fthrow_error("/home/daniel/Projects/java/jdk/src/hotspot/share/jvmci/jvmciCodeInstaller.cpp" , 1016, "unexpected slotKinds length %d in scope (%d locals, %d expressions)" , __jvmci_env__->get_length(slotKinds), local_count, expression_count ); return; }; |
1017 | } |
1018 | |
1019 | GrowableArray<ScopeValue*>* locals = local_count > 0 ? new GrowableArray<ScopeValue*> (local_count) : NULL__null; |
1020 | GrowableArray<ScopeValue*>* expressions = expression_count > 0 ? new GrowableArray<ScopeValue*> (expression_count) : NULL__null; |
1021 | GrowableArray<MonitorValue*>* monitors = monitor_count > 0 ? new GrowableArray<MonitorValue*> (monitor_count) : NULL__null; |
1022 | |
1023 | JVMCI_event_2if (JVMCITraceLevel < 2 && JVMCIEventLogLevel < 2) ; else ::JVMCI::event2("Scope at bci %d with %d values", bci, JVMCIENV__jvmci_env__->get_length(values)); |
1024 | JVMCI_event_2if (JVMCITraceLevel < 2 && JVMCIEventLogLevel < 2) ; else ::JVMCI::event2("%d locals %d expressions, %d monitors", local_count, expression_count, monitor_count); |
1025 | |
1026 | for (jint i = 0; i < JVMCIENV__jvmci_env__->get_length(values); i++) { |
1027 | // HandleMark hm(THREAD); |
1028 | ScopeValue* second = NULL__null; |
1029 | JVMCIObject value = JVMCIENV__jvmci_env__->get_object_at(values, i); |
1030 | if (i < local_count) { |
1031 | BasicType type = jvmci_env()->kindToBasicType(JVMCIENV__jvmci_env__->get_object_at(slotKinds, i), JVMCI_CHECK__jvmci_env__); if ((__jvmci_env__->has_pending_exception( ))) return ; (void)(0); |
1032 | ScopeValue* first = get_scope_value(value, type, objects, second, JVMCI_CHECK__jvmci_env__); if ((__jvmci_env__->has_pending_exception( ))) return ; (void)(0); |
1033 | if (second != NULL__null) { |
1034 | locals->append(second); |
1035 | } |
1036 | locals->append(first); |
1037 | } else if (i < local_count + expression_count) { |
1038 | BasicType type = jvmci_env()->kindToBasicType(JVMCIENV__jvmci_env__->get_object_at(slotKinds, i), JVMCI_CHECK__jvmci_env__); if ((__jvmci_env__->has_pending_exception( ))) return ; (void)(0); |
1039 | ScopeValue* first = get_scope_value(value, type, objects, second, JVMCI_CHECK__jvmci_env__); if ((__jvmci_env__->has_pending_exception( ))) return ; (void)(0); |
1040 | if (second != NULL__null) { |
1041 | expressions->append(second); |
1042 | } |
1043 | expressions->append(first); |
1044 | } else { |
1045 | MonitorValue *monitor = get_monitor_value(value, objects, JVMCI_CHECK__jvmci_env__); if ((__jvmci_env__->has_pending_exception( ))) return ; (void)(0); |
1046 | monitors->append(monitor); |
1047 | } |
1048 | if (second != NULL__null) { |
1049 | i++; |
1050 | if (i >= JVMCIENV__jvmci_env__->get_length(values) || !JVMCIENV__jvmci_env__->equals(JVMCIENV__jvmci_env__->get_object_at(values, i), jvmci_env()->get_Value_ILLEGAL())) { |
1051 | JVMCI_ERROR("double-slot value not followed by Value.ILLEGAL"){ __jvmci_env__->fthrow_error("/home/daniel/Projects/java/jdk/src/hotspot/share/jvmci/jvmciCodeInstaller.cpp" , 1051, "double-slot value not followed by Value.ILLEGAL"); return ; }; |
1052 | } |
1053 | } |
1054 | } |
1055 | |
1056 | locals_token = _debug_recorder->create_scope_values(locals); |
1057 | expressions_token = _debug_recorder->create_scope_values(expressions); |
1058 | monitors_token = _debug_recorder->create_monitor_values(monitors); |
1059 | |
1060 | throw_exception = jvmci_env()->get_BytecodeFrame_rethrowException(frame) == JNI_TRUE1; |
1061 | } |
1062 | |
1063 | // has_ea_local_in_scope and arg_escape should be added to JVMCI |
1064 | const bool is_opt_native = false; |
1065 | const bool has_ea_local_in_scope = false; |
1066 | const bool arg_escape = false; |
1067 | _debug_recorder->describe_scope(pc_offset, method, NULL__null, bci, reexecute, throw_exception, is_mh_invoke, is_opt_native, return_oop, |
1068 | has_ea_local_in_scope, arg_escape, |
1069 | locals_token, expressions_token, monitors_token); |
1070 | } |
1071 | |
1072 | void CodeInstaller::site_Safepoint(CodeBuffer& buffer, jint pc_offset, JVMCIObject site, JVMCI_TRAPSJVMCIEnv* __jvmci_env__) { |
1073 | JVMCIObject debug_info = jvmci_env()->get_site_Infopoint_debugInfo(site); |
1074 | if (debug_info.is_null()) { |
1075 | JVMCI_ERROR("debug info expected at safepoint at %i", pc_offset){ __jvmci_env__->fthrow_error("/home/daniel/Projects/java/jdk/src/hotspot/share/jvmci/jvmciCodeInstaller.cpp" , 1075, "debug info expected at safepoint at %i", pc_offset); return; }; |
1076 | } |
1077 | |
1078 | // address instruction = _instructions->start() + pc_offset; |
1079 | // jint next_pc_offset = Assembler::locate_next_instruction(instruction) - _instructions->start(); |
1080 | OopMap *map = create_oop_map(debug_info, JVMCI_CHECK__jvmci_env__); if ((__jvmci_env__->has_pending_exception( ))) return ; (void)(0); |
1081 | _debug_recorder->add_safepoint(pc_offset, map); |
1082 | record_scope(pc_offset, debug_info, CodeInstaller::FullFrame, JVMCI_CHECK__jvmci_env__); if ((__jvmci_env__->has_pending_exception( ))) return ; (void)(0); |
1083 | _debug_recorder->end_safepoint(pc_offset); |
1084 | } |
1085 | |
1086 | void CodeInstaller::site_Infopoint(CodeBuffer& buffer, jint pc_offset, JVMCIObject site, JVMCI_TRAPSJVMCIEnv* __jvmci_env__) { |
1087 | JVMCIObject debug_info = jvmci_env()->get_site_Infopoint_debugInfo(site); |
1088 | if (debug_info.is_null()) { |
1089 | JVMCI_ERROR("debug info expected at infopoint at %i", pc_offset){ __jvmci_env__->fthrow_error("/home/daniel/Projects/java/jdk/src/hotspot/share/jvmci/jvmciCodeInstaller.cpp" , 1089, "debug info expected at infopoint at %i", pc_offset); return; }; |
1090 | } |
1091 | |
1092 | // We'd like to check that pc_offset is greater than the |
1093 | // last pc recorded with _debug_recorder (raising an exception if not) |
1094 | // but DebugInformationRecorder doesn't have sufficient public API. |
1095 | |
1096 | _debug_recorder->add_non_safepoint(pc_offset); |
1097 | record_scope(pc_offset, debug_info, CodeInstaller::BytecodePosition, JVMCI_CHECK__jvmci_env__); if ((__jvmci_env__->has_pending_exception( ))) return ; (void)(0); |
1098 | _debug_recorder->end_non_safepoint(pc_offset); |
1099 | } |
1100 | |
1101 | void CodeInstaller::site_Call(CodeBuffer& buffer, jint pc_offset, JVMCIObject site, JVMCI_TRAPSJVMCIEnv* __jvmci_env__) { |
1102 | JVMCIObject target = jvmci_env()->get_site_Call_target(site); |
1103 | JVMCIObject hotspot_method; // JavaMethod |
1104 | JVMCIObject foreign_call; |
1105 | |
1106 | if (jvmci_env()->isa_HotSpotForeignCallTarget(target)) { |
1107 | foreign_call = target; |
1108 | } else { |
1109 | hotspot_method = target; |
1110 | } |
1111 | |
1112 | JVMCIObject debug_info = jvmci_env()->get_site_Infopoint_debugInfo(site); |
1113 | |
1114 | assert(hotspot_method.is_non_null() ^ foreign_call.is_non_null(), "Call site needs exactly one type")do { if (!(hotspot_method.is_non_null() ^ foreign_call.is_non_null ())) { (*g_assert_poison) = 'X';; report_vm_error("/home/daniel/Projects/java/jdk/src/hotspot/share/jvmci/jvmciCodeInstaller.cpp" , 1114, "assert(" "hotspot_method.is_non_null() ^ foreign_call.is_non_null()" ") failed", "Call site needs exactly one type"); ::breakpoint (); } } while (0); |
1115 | |
1116 | NativeInstruction* inst = nativeInstruction_at(_instructions->start() + pc_offset); |
1117 | jint next_pc_offset = CodeInstaller::pd_next_offset(inst, pc_offset, hotspot_method, JVMCI_CHECK__jvmci_env__); if ((__jvmci_env__->has_pending_exception( ))) return ; (void)(0); |
1118 | |
1119 | if (debug_info.is_non_null()) { |
1120 | OopMap *map = create_oop_map(debug_info, JVMCI_CHECK__jvmci_env__); if ((__jvmci_env__->has_pending_exception( ))) return ; (void)(0); |
1121 | _debug_recorder->add_safepoint(next_pc_offset, map); |
1122 | |
1123 | if (hotspot_method.is_non_null()) { |
1124 | Method *method = jvmci_env()->asMethod(hotspot_method); |
1125 | vmIntrinsics::ID iid = method->intrinsic_id(); |
1126 | bool is_mh_invoke = false; |
1127 | if (jvmci_env()->get_site_Call_direct(site)) { |
1128 | is_mh_invoke = !method->is_static() && (iid == vmIntrinsics::_compiledLambdaForm || |
1129 | (MethodHandles::is_signature_polymorphic(iid) && MethodHandles::is_signature_polymorphic_intrinsic(iid))); |
1130 | } |
1131 | bool return_oop = method->is_returning_oop(); |
1132 | record_scope(next_pc_offset, debug_info, CodeInstaller::FullFrame, is_mh_invoke, return_oop, JVMCI_CHECK__jvmci_env__); if ((__jvmci_env__->has_pending_exception( ))) return ; (void)(0); |
1133 | } else { |
1134 | record_scope(next_pc_offset, debug_info, CodeInstaller::FullFrame, JVMCI_CHECK__jvmci_env__); if ((__jvmci_env__->has_pending_exception( ))) return ; (void)(0); |
1135 | } |
1136 | } |
1137 | |
1138 | if (foreign_call.is_non_null()) { |
1139 | jlong foreign_call_destination = jvmci_env()->get_HotSpotForeignCallTarget_address(foreign_call); |
1140 | CodeInstaller::pd_relocate_ForeignCall(inst, foreign_call_destination, JVMCI_CHECK__jvmci_env__); if ((__jvmci_env__->has_pending_exception( ))) return ; (void)(0); |
1141 | } else { // method != NULL |
1142 | if (debug_info.is_null()) { |
1143 | JVMCI_ERROR("debug info expected at call at %i", pc_offset){ __jvmci_env__->fthrow_error("/home/daniel/Projects/java/jdk/src/hotspot/share/jvmci/jvmciCodeInstaller.cpp" , 1143, "debug info expected at call at %i", pc_offset); return ; }; |
1144 | } |
1145 | |
1146 | JVMCI_event_3if (JVMCITraceLevel < 3 && JVMCIEventLogLevel < 3) ; else ::JVMCI::event3("method call"); |
1147 | CodeInstaller::pd_relocate_JavaMethod(buffer, hotspot_method, pc_offset, JVMCI_CHECK__jvmci_env__); if ((__jvmci_env__->has_pending_exception( ))) return ; (void)(0); |
1148 | if (_next_call_type == INVOKESTATIC || _next_call_type == INVOKESPECIAL) { |
1149 | // Need a static call stub for transitions from compiled to interpreted. |
1150 | CompiledStaticCall::emit_to_interp_stub(buffer, _instructions->start() + pc_offset); |
1151 | } |
1152 | } |
1153 | |
1154 | _next_call_type = INVOKE_INVALID; |
1155 | |
1156 | if (debug_info.is_non_null()) { |
1157 | _debug_recorder->end_safepoint(next_pc_offset); |
1158 | } |
1159 | } |
1160 | |
1161 | void CodeInstaller::site_DataPatch(CodeBuffer& buffer, jint pc_offset, JVMCIObject site, JVMCI_TRAPSJVMCIEnv* __jvmci_env__) { |
1162 | JVMCIObject reference = jvmci_env()->get_site_DataPatch_reference(site); |
1163 | if (reference.is_null()) { |
1164 | JVMCI_THROW(NullPointerException){ __jvmci_env__->throw_NullPointerException(); return; }; |
1165 | } else if (jvmci_env()->isa_site_ConstantReference(reference)) { |
1166 | JVMCIObject constant = jvmci_env()->get_site_ConstantReference_constant(reference); |
1167 | if (constant.is_null()) { |
1168 | JVMCI_THROW(NullPointerException){ __jvmci_env__->throw_NullPointerException(); return; }; |
1169 | } else if (jvmci_env()->isa_DirectHotSpotObjectConstantImpl(constant)) { |
1170 | if (!JVMCIENV__jvmci_env__->is_hotspot()) { |
1171 | JVMCIObject string = JVMCIENV__jvmci_env__->call_HotSpotJVMCIRuntime_callToString(constant, JVMCI_CHECK__jvmci_env__); if ((__jvmci_env__->has_pending_exception( ))) return ; (void)(0); |
1172 | const char* to_string = JVMCIENV__jvmci_env__->as_utf8_string(string); |
1173 | JVMCI_THROW_MSG(IllegalArgumentException, err_msg("Direct object constant reached the backend: %s", to_string)){ __jvmci_env__->throw_IllegalArgumentException(err_msg("Direct object constant reached the backend: %s" , to_string)); return; }; |
1174 | } |
1175 | pd_patch_OopConstant(pc_offset, constant, JVMCI_CHECK__jvmci_env__); if ((__jvmci_env__->has_pending_exception( ))) return ; (void)(0); |
1176 | } else if (jvmci_env()->isa_IndirectHotSpotObjectConstantImpl(constant)) { |
1177 | pd_patch_OopConstant(pc_offset, constant, JVMCI_CHECK__jvmci_env__); if ((__jvmci_env__->has_pending_exception( ))) return ; (void)(0); |
1178 | } else if (jvmci_env()->isa_HotSpotMetaspaceConstantImpl(constant)) { |
1179 | pd_patch_MetaspaceConstant(pc_offset, constant, JVMCI_CHECK__jvmci_env__); if ((__jvmci_env__->has_pending_exception( ))) return ; (void)(0); |
1180 | } else { |
1181 | JVMCI_ERROR("unknown constant type in data patch: %s", jvmci_env()->klass_name(constant)){ __jvmci_env__->fthrow_error("/home/daniel/Projects/java/jdk/src/hotspot/share/jvmci/jvmciCodeInstaller.cpp" , 1181, "unknown constant type in data patch: %s", jvmci_env( )->klass_name(constant)); return; }; |
1182 | } |
1183 | } else if (jvmci_env()->isa_site_DataSectionReference(reference)) { |
1184 | int data_offset = jvmci_env()->get_site_DataSectionReference_offset(reference); |
1185 | if (0 <= data_offset && data_offset < _constants_size) { |
1186 | pd_patch_DataSectionReference(pc_offset, data_offset, JVMCI_CHECK__jvmci_env__); if ((__jvmci_env__->has_pending_exception( ))) return ; (void)(0); |
1187 | } else { |
1188 | JVMCI_ERROR("data offset 0x%X points outside data section (size 0x%X)", data_offset, _constants_size){ __jvmci_env__->fthrow_error("/home/daniel/Projects/java/jdk/src/hotspot/share/jvmci/jvmciCodeInstaller.cpp" , 1188, "data offset 0x%X points outside data section (size 0x%X)" , data_offset, _constants_size); return; }; |
1189 | } |
1190 | } else { |
1191 | JVMCI_ERROR("unknown data patch type: %s", jvmci_env()->klass_name(reference)){ __jvmci_env__->fthrow_error("/home/daniel/Projects/java/jdk/src/hotspot/share/jvmci/jvmciCodeInstaller.cpp" , 1191, "unknown data patch type: %s", jvmci_env()->klass_name (reference)); return; }; |
1192 | } |
1193 | } |
1194 | |
1195 | void CodeInstaller::site_Mark(CodeBuffer& buffer, jint pc_offset, JVMCIObject site, JVMCI_TRAPSJVMCIEnv* __jvmci_env__) { |
1196 | JVMCIObject id_obj = jvmci_env()->get_site_Mark_id(site); |
1197 | |
1198 | if (id_obj.is_non_null()) { |
1199 | if (!jvmci_env()->is_boxing_object(T_INT, id_obj)) { |
1200 | JVMCI_ERROR("expected Integer id, got %s", jvmci_env()->klass_name(id_obj)){ __jvmci_env__->fthrow_error("/home/daniel/Projects/java/jdk/src/hotspot/share/jvmci/jvmciCodeInstaller.cpp" , 1200, "expected Integer id, got %s", jvmci_env()->klass_name (id_obj)); return; }; |
1201 | } |
1202 | jint id = jvmci_env()->get_boxed_value(T_INT, id_obj).i; |
1203 | |
1204 | address pc = _instructions->start() + pc_offset; |
1205 | |
1206 | switch (id) { |
1207 | case UNVERIFIED_ENTRY: |
1208 | _offsets.set_value(CodeOffsets::Entry, pc_offset); |
1209 | break; |
1210 | case VERIFIED_ENTRY: |
1211 | _offsets.set_value(CodeOffsets::Verified_Entry, pc_offset); |
1212 | break; |
1213 | case OSR_ENTRY: |
1214 | _offsets.set_value(CodeOffsets::OSR_Entry, pc_offset); |
1215 | break; |
1216 | case EXCEPTION_HANDLER_ENTRY: |
1217 | _offsets.set_value(CodeOffsets::Exceptions, pc_offset); |
1218 | break; |
1219 | case DEOPT_HANDLER_ENTRY: |
1220 | _offsets.set_value(CodeOffsets::Deopt, pc_offset); |
1221 | break; |
1222 | case DEOPT_MH_HANDLER_ENTRY: |
1223 | _offsets.set_value(CodeOffsets::DeoptMH, pc_offset); |
1224 | break; |
1225 | case FRAME_COMPLETE: |
1226 | _offsets.set_value(CodeOffsets::Frame_Complete, pc_offset); |
1227 | break; |
1228 | case INVOKEVIRTUAL: |
1229 | case INVOKEINTERFACE: |
1230 | case INLINE_INVOKE: |
1231 | case INVOKESTATIC: |
1232 | case INVOKESPECIAL: |
1233 | _next_call_type = (MarkId) id; |
1234 | _invoke_mark_pc = pc; |
1235 | break; |
1236 | case POLL_NEAR: |
1237 | case POLL_FAR: |
1238 | case POLL_RETURN_NEAR: |
1239 | case POLL_RETURN_FAR: |
1240 | pd_relocate_poll(pc, id, JVMCI_CHECK__jvmci_env__); if ((__jvmci_env__->has_pending_exception( ))) return ; (void)(0); |
1241 | break; |
1242 | case CARD_TABLE_SHIFT: |
1243 | case CARD_TABLE_ADDRESS: |
1244 | case HEAP_TOP_ADDRESS: |
1245 | case HEAP_END_ADDRESS: |
1246 | case NARROW_KLASS_BASE_ADDRESS: |
1247 | case NARROW_OOP_BASE_ADDRESS: |
1248 | case CRC_TABLE_ADDRESS: |
1249 | case LOG_OF_HEAP_REGION_GRAIN_BYTES: |
1250 | case INLINE_CONTIGUOUS_ALLOCATION_SUPPORTED: |
1251 | case VERIFY_OOPS: |
1252 | case VERIFY_OOP_BITS: |
1253 | case VERIFY_OOP_MASK: |
1254 | case VERIFY_OOP_COUNT_ADDRESS: |
1255 | break; |
1256 | default: |
1257 | JVMCI_ERROR("invalid mark id: %d", id){ __jvmci_env__->fthrow_error("/home/daniel/Projects/java/jdk/src/hotspot/share/jvmci/jvmciCodeInstaller.cpp" , 1257, "invalid mark id: %d", id); return; }; |
1258 | break; |
1259 | } |
1260 | } |
1261 | } |