Skip to content

Commit d3ec227

Browse files
committed
8367304: [lworld] Printing of rematerialized objects is broken
1 parent a80315a commit d3ec227

File tree

1 file changed

+24
-29
lines changed

1 file changed

+24
-29
lines changed

src/hotspot/share/runtime/deoptimization.cpp

Lines changed: 24 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -303,9 +303,27 @@ JRT_BLOCK_ENTRY(Deoptimization::UnrollBlock*, Deoptimization::fetch_unroll_info(
303303
JRT_END
304304

305305
#if COMPILER2_OR_JVMCI
306+
307+
static Klass* get_refined_array_klass(Klass* k, frame* fr, RegisterMap* map, ObjectValue* sv, TRAPS) {
308+
// If it's an array, get the properties
309+
if (k->is_array_klass() && !k->is_typeArray_klass()) {
310+
assert(!k->is_refArray_klass() && !k->is_flatArray_klass(), "Unexpected refined klass");
311+
nmethod* nm = fr->cb()->as_nmethod_or_null();
312+
if (nm->is_compiled_by_c2()) {
313+
assert(sv->has_properties(), "Property information is missing");
314+
ArrayKlass::ArrayProperties props = static_cast<ArrayKlass::ArrayProperties>(StackValue::create_stack_value(fr, map, sv->properties())->get_jint());
315+
k = ObjArrayKlass::cast(k)->klass_with_properties(props, THREAD);
316+
} else {
317+
// TODO Graal needs to be fixed. Just go with the default properties for now
318+
k = ObjArrayKlass::cast(k)->klass_with_properties(ArrayKlass::ArrayProperties::DEFAULT, THREAD);
319+
}
320+
}
321+
return k;
322+
}
323+
306324
// print information about reallocated objects
307-
static void print_objects(JavaThread* deoptee_thread,
308-
GrowableArray<ScopeValue*>* objects, bool realloc_failures) {
325+
static void print_objects(JavaThread* deoptee_thread, frame* deoptee, RegisterMap* map,
326+
GrowableArray<ScopeValue*>* objects, bool realloc_failures, TRAPS) {
309327
ResourceMark rm;
310328
stringStream st; // change to logStream with logging
311329
st.print_cr("REALLOC OBJECTS in thread " INTPTR_FORMAT, p2i(deoptee_thread));
@@ -321,6 +339,7 @@ static void print_objects(JavaThread* deoptee_thread,
321339
}
322340

323341
Klass* k = java_lang_Class::as_Klass(sv->klass()->as_ConstantOopReadValue()->value()());
342+
k = get_refined_array_klass(k, deoptee, map, sv, THREAD);
324343

325344
st.print(" object <" INTPTR_FORMAT "> of type ", p2i(sv->value()()));
326345
k->print_value_on(&st);
@@ -409,7 +428,7 @@ static bool rematerialize_objects(JavaThread* thread, int exec_mode, nmethod* co
409428
JRT_END
410429
}
411430
if (TraceDeoptimization && objects != nullptr) {
412-
print_objects(deoptee_thread, objects, realloc_failures);
431+
print_objects(deoptee_thread, &deoptee, &map, objects, realloc_failures, thread);
413432
}
414433
}
415434
if (save_oop_result || vk != nullptr) {
@@ -1267,19 +1286,7 @@ bool Deoptimization::realloc_objects(JavaThread* thread, frame* fr, RegisterMap*
12671286
assert(objects->at(i)->is_object(), "invalid debug information");
12681287
ObjectValue* sv = (ObjectValue*) objects->at(i);
12691288
Klass* k = java_lang_Class::as_Klass(sv->klass()->as_ConstantOopReadValue()->value()());
1270-
// If it's an array, get the properties
1271-
if (k->is_array_klass() && !k->is_typeArray_klass()) {
1272-
assert(!k->is_refArray_klass() && !k->is_flatArray_klass(), "Unexpected refined klass");
1273-
nmethod* nm = fr->cb()->as_nmethod_or_null();
1274-
if (nm->is_compiled_by_c2()) {
1275-
assert(sv->has_properties(), "Property information is missing");
1276-
ArrayKlass::ArrayProperties props = static_cast<ArrayKlass::ArrayProperties>(StackValue::create_stack_value(fr, reg_map, sv->properties())->get_jint());
1277-
k = ObjArrayKlass::cast(k)->klass_with_properties(props, THREAD);
1278-
} else {
1279-
// TODO Graal needs to be fixed. Just go with the default properties for now
1280-
k = ObjArrayKlass::cast(k)->klass_with_properties(ArrayKlass::ArrayProperties::DEFAULT, THREAD);
1281-
}
1282-
}
1289+
k = get_refined_array_klass(k, fr, reg_map, sv, THREAD);
12831290

12841291
// Check if the object may be null and has an additional null_marker input that needs
12851292
// to be checked before using the field values. Skip re-allocation if it is null.
@@ -1686,19 +1693,7 @@ void Deoptimization::reassign_fields(frame* fr, RegisterMap* reg_map, GrowableAr
16861693
assert(objects->at(i)->is_object(), "invalid debug information");
16871694
ObjectValue* sv = (ObjectValue*) objects->at(i);
16881695
Klass* k = java_lang_Class::as_Klass(sv->klass()->as_ConstantOopReadValue()->value()());
1689-
// If it's an array, get the properties
1690-
if (k->is_array_klass() && !k->is_typeArray_klass()) {
1691-
assert(!k->is_refArray_klass() && !k->is_flatArray_klass(), "Unexpected refined klass");
1692-
nmethod* nm = fr->cb()->as_nmethod_or_null();
1693-
if (nm->is_compiled_by_c2()) {
1694-
assert(sv->has_properties(), "Property information is missing");
1695-
ArrayKlass::ArrayProperties props = static_cast<ArrayKlass::ArrayProperties>(StackValue::create_stack_value(fr, reg_map, sv->properties())->get_jint());
1696-
k = ObjArrayKlass::cast(k)->klass_with_properties(props, THREAD);
1697-
} else {
1698-
// TODO Graal needs to be fixed. Just go with the default properties for now
1699-
k = ObjArrayKlass::cast(k)->klass_with_properties(ArrayKlass::ArrayProperties::DEFAULT, THREAD);
1700-
}
1701-
}
1696+
k = get_refined_array_klass(k, fr, reg_map, sv, THREAD);
17021697

17031698
Handle obj = sv->value();
17041699
assert(obj.not_null() || realloc_failures || sv->has_properties(), "reallocation was missed");

0 commit comments

Comments
 (0)