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