@@ -1294,10 +1294,15 @@ class ArchiveBuilder::CDSMapLogger : AllStatic {
1294
1294
1295
1295
if (source_oop != nullptr ) {
1296
1296
// This is a regular oop that got archived.
1297
- print_oop_with_requested_addr_cr (&st, source_oop, false );
1297
+ // Don't print the requested addr again as we have just printed it at the beginning of the line.
1298
+ // Example:
1299
+ // 0x00000007ffd27938: @@ Object (0xfffa4f27) java.util.HashMap
1300
+ print_oop_info_cr (&st, source_oop, /* print_requested_addr=*/ false );
1298
1301
byte_size = source_oop->size () * BytesPerWord;
1299
1302
} else if ((byte_size = ArchiveHeapWriter::get_filler_size_at (start)) > 0 ) {
1300
1303
// We have a filler oop, which also does not exist in BufferOffsetToSourceObjectTable.
1304
+ // Example:
1305
+ // 0x00000007ffc3ffd8: @@ Object filler 40 bytes
1301
1306
st.print_cr (" filler " SIZE_FORMAT " bytes" , byte_size);
1302
1307
} else {
1303
1308
ShouldNotReachHere ();
@@ -1315,7 +1320,7 @@ class ArchiveBuilder::CDSMapLogger : AllStatic {
1315
1320
1316
1321
// ArchivedFieldPrinter is used to print the fields of archived objects. We can't
1317
1322
// use _source_obj->print_on(), because we want to print the oop fields
1318
- // in _source_obj with their requested addresses using print_oop_with_requested_addr_cr ().
1323
+ // in _source_obj with their requested addresses using print_oop_info_cr ().
1319
1324
class ArchivedFieldPrinter : public FieldClosure {
1320
1325
ArchiveHeapInfo* _heap_info;
1321
1326
outputStream* _st;
@@ -1331,8 +1336,14 @@ class ArchiveBuilder::CDSMapLogger : AllStatic {
1331
1336
switch (ft) {
1332
1337
case T_ARRAY:
1333
1338
case T_OBJECT:
1334
- fd->print_on (_st); // print just the name and offset
1335
- print_oop_with_requested_addr_cr (_st, _source_obj->obj_field (fd->offset ()));
1339
+ {
1340
+ fd->print_on (_st); // print just the name and offset
1341
+ oop obj = _source_obj->obj_field (fd->offset ());
1342
+ if (java_lang_Class::is_instance (obj)) {
1343
+ obj = HeapShared::scratch_java_mirror (obj);
1344
+ }
1345
+ print_oop_info_cr (_st, obj);
1346
+ }
1336
1347
break ;
1337
1348
default :
1338
1349
if (ArchiveHeapWriter::is_marked_as_native_pointer (_heap_info, _source_obj, fd->offset ())) {
@@ -1388,37 +1399,78 @@ class ArchiveBuilder::CDSMapLogger : AllStatic {
1388
1399
objArrayOop source_obj_array = objArrayOop (source_oop);
1389
1400
for (int i = 0 ; i < source_obj_array->length (); i++) {
1390
1401
st.print (" -%4d: " , i);
1391
- print_oop_with_requested_addr_cr (&st, source_obj_array->obj_at (i));
1402
+ oop obj = source_obj_array->obj_at (i);
1403
+ if (java_lang_Class::is_instance (obj)) {
1404
+ obj = HeapShared::scratch_java_mirror (obj);
1405
+ }
1406
+ print_oop_info_cr (&st, obj);
1392
1407
}
1393
1408
} else {
1394
1409
st.print_cr (" - fields (" SIZE_FORMAT " words):" , source_oop->size ());
1395
1410
ArchivedFieldPrinter print_field (heap_info, &st, source_oop, buffered_addr);
1396
1411
InstanceKlass::cast (source_klass)->print_nonstatic_fields (&print_field);
1412
+
1413
+ if (java_lang_Class::is_instance (source_oop)) {
1414
+ oop scratch_mirror = source_oop;
1415
+ st.print (" - signature: " );
1416
+ print_class_signature_for_mirror (&st, scratch_mirror);
1417
+ st.cr ();
1418
+
1419
+ Klass* src_klass = java_lang_Class::as_Klass (scratch_mirror);
1420
+ if (src_klass != nullptr && src_klass->is_instance_klass ()) {
1421
+ oop rr = HeapShared::scratch_resolved_references (InstanceKlass::cast (src_klass)->constants ());
1422
+ st.print (" - archived_resolved_references: " );
1423
+ print_oop_info_cr (&st, rr);
1424
+
1425
+ // We need to print the fields in the scratch_mirror, not the original mirror.
1426
+ // (if a class is not aot-initialized, static fields in its scratch mirror will be cleared).
1427
+ assert (scratch_mirror == HeapShared::scratch_java_mirror (src_klass->java_mirror ()), " sanity" );
1428
+ st.print_cr (" - ---- static fields (%d):" , java_lang_Class::static_oop_field_count (scratch_mirror));
1429
+ InstanceKlass::cast (src_klass)->do_local_static_fields (&print_field);
1430
+ }
1431
+ }
1432
+ }
1433
+ }
1434
+ }
1435
+
1436
+ static void print_class_signature_for_mirror (outputStream* st, oop scratch_mirror) {
1437
+ assert (java_lang_Class::is_instance (scratch_mirror), " sanity" );
1438
+ if (java_lang_Class::is_primitive (scratch_mirror)) {
1439
+ for (int i = T_BOOLEAN; i < T_VOID+1 ; i++) {
1440
+ BasicType bt = (BasicType)i;
1441
+ if (!is_reference_type (bt) && scratch_mirror == HeapShared::scratch_java_mirror (bt)) {
1442
+ oop orig_mirror = Universe::java_mirror (bt);
1443
+ java_lang_Class::print_signature (orig_mirror, st);
1444
+ return ;
1445
+ }
1397
1446
}
1447
+ ShouldNotReachHere ();
1398
1448
}
1449
+ java_lang_Class::print_signature (scratch_mirror, st);
1399
1450
}
1400
1451
1401
1452
static void log_heap_roots () {
1402
1453
LogStreamHandle (Trace, cds, map, oops) st;
1403
1454
if (st.is_enabled ()) {
1404
1455
for (int i = 0 ; i < HeapShared::pending_roots ()->length (); i++) {
1405
1456
st.print (" roots[%4d]: " , i);
1406
- print_oop_with_requested_addr_cr (&st, HeapShared::pending_roots ()->at (i));
1457
+ print_oop_info_cr (&st, HeapShared::pending_roots ()->at (i));
1407
1458
}
1408
1459
}
1409
1460
}
1410
1461
1411
- // The output looks like this. The first number is the requested address. The second number is
1412
- // the narrowOop version of the requested address.
1413
- // 0x00000007ffc7e840 (0xfff8fd08) java.lang.Class
1462
+ // Example output:
1463
+ // - The first number is the requested address (if print_requested_addr == true)
1464
+ // - The second number is the narrowOop version of the requested address (if UseCompressedOops == true)
1465
+ // 0x00000007ffc7e840 (0xfff8fd08) java.lang.Class Ljava/util/Array;
1414
1466
// 0x00000007ffc000f8 (0xfff8001f) [B length: 11
1415
- static void print_oop_with_requested_addr_cr (outputStream* st, oop source_oop, bool print_addr = true ) {
1467
+ static void print_oop_info_cr (outputStream* st, oop source_oop, bool print_requested_addr = true ) {
1416
1468
if (source_oop == nullptr ) {
1417
1469
st->print_cr (" null" );
1418
1470
} else {
1419
1471
ResourceMark rm;
1420
1472
oop requested_obj = ArchiveHeapWriter::source_obj_to_requested_obj (source_oop);
1421
- if (print_addr ) {
1473
+ if (print_requested_addr ) {
1422
1474
st->print (PTR_FORMAT " " , p2i (requested_obj));
1423
1475
}
1424
1476
if (UseCompressedOops) {
@@ -1428,7 +1480,27 @@ class ArchiveBuilder::CDSMapLogger : AllStatic {
1428
1480
int array_len = arrayOop (source_oop)->length ();
1429
1481
st->print_cr (" %s length: %d" , source_oop->klass ()->external_name (), array_len);
1430
1482
} else {
1431
- st->print_cr (" %s" , source_oop->klass ()->external_name ());
1483
+ st->print (" %s" , source_oop->klass ()->external_name ());
1484
+
1485
+ if (java_lang_String::is_instance (source_oop)) {
1486
+ st->print (" " );
1487
+ java_lang_String::print (source_oop, st);
1488
+ } else if (java_lang_Class::is_instance (source_oop)) {
1489
+ oop scratch_mirror = source_oop;
1490
+
1491
+ st->print (" " );
1492
+ print_class_signature_for_mirror (st, scratch_mirror);
1493
+
1494
+ Klass* src_klass = java_lang_Class::as_Klass (scratch_mirror);
1495
+ if (src_klass != nullptr && src_klass->is_instance_klass ()) {
1496
+ InstanceKlass* buffered_klass =
1497
+ ArchiveBuilder::current ()->get_buffered_addr (InstanceKlass::cast (src_klass));
1498
+ if (buffered_klass->has_aot_initialized_mirror ()) {
1499
+ st->print (" (aot-inited)" );
1500
+ }
1501
+ }
1502
+ }
1503
+ st->cr ();
1432
1504
}
1433
1505
}
1434
1506
}
1 commit comments
openjdk-notifier[bot] commentedon Nov 28, 2024
Review
Issues