Skip to content

Commit aebdee3

Browse files
committed
8230674: Heap dumps should exclude dormant CDS archived objects of unloaded classes
Reviewed-by: phh Backport-of: e90970b
1 parent 815d3e1 commit aebdee3

File tree

1 file changed

+30
-6
lines changed

1 file changed

+30
-6
lines changed

src/hotspot/share/services/heapDumper.cpp

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2005, 2018, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2005, 2019, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -683,6 +683,16 @@ class DumperSupport : AllStatic {
683683

684684
// fixes up the current dump record and writes HPROF_HEAP_DUMP_END record
685685
static void end_of_dump(DumpWriter* writer);
686+
687+
static oop mask_dormant_archived_object(oop o) {
688+
if (o != NULL && o->klass()->java_mirror() == NULL) {
689+
// Ignore this object since the corresponding java mirror is not loaded.
690+
// Might be a dormant archive object.
691+
return NULL;
692+
} else {
693+
return o;
694+
}
695+
}
686696
};
687697

688698
// write a header of the given type
@@ -758,6 +768,13 @@ void DumperSupport::dump_field_value(DumpWriter* writer, char type, oop obj, int
758768
case JVM_SIGNATURE_CLASS :
759769
case JVM_SIGNATURE_ARRAY : {
760770
oop o = obj->obj_field_access<ON_UNKNOWN_OOP_REF | AS_NO_KEEPALIVE>(offset);
771+
if (o != NULL && log_is_enabled(Debug, cds, heap) && mask_dormant_archived_object(o) == NULL) {
772+
ResourceMark rm;
773+
log_debug(cds, heap)("skipped dormant archived object " INTPTR_FORMAT " (%s) referenced by " INTPTR_FORMAT " (%s)",
774+
p2i(o), o->klass()->external_name(),
775+
p2i(obj), obj->klass()->external_name());
776+
}
777+
o = mask_dormant_archived_object(o);
761778
assert(oopDesc::is_oop_or_null(o), "Expected an oop or NULL at " PTR_FORMAT, p2i(o));
762779
writer->write_objectID(o);
763780
break;
@@ -955,11 +972,6 @@ void DumperSupport::dump_instance_field_descriptors(DumpWriter* writer, Klass* k
955972
// creates HPROF_GC_INSTANCE_DUMP record for the given object
956973
void DumperSupport::dump_instance(DumpWriter* writer, oop o) {
957974
Klass* k = o->klass();
958-
if (k->java_mirror() == NULL) {
959-
// Ignoring this object since the corresponding java mirror is not loaded.
960-
// Might be a dormant archive object.
961-
return;
962-
}
963975

964976
writer->write_u1(HPROF_GC_INSTANCE_DUMP);
965977
writer->write_objectID(o);
@@ -1145,6 +1157,13 @@ void DumperSupport::dump_object_array(DumpWriter* writer, objArrayOop array) {
11451157
// [id]* elements
11461158
for (int index = 0; index < length; index++) {
11471159
oop o = array->obj_at(index);
1160+
if (o != NULL && log_is_enabled(Debug, cds, heap) && mask_dormant_archived_object(o) == NULL) {
1161+
ResourceMark rm;
1162+
log_debug(cds, heap)("skipped dormant archived object " INTPTR_FORMAT " (%s) referenced by " INTPTR_FORMAT " (%s)",
1163+
p2i(o), o->klass()->external_name(),
1164+
p2i(array), array->klass()->external_name());
1165+
}
1166+
o = mask_dormant_archived_object(o);
11481167
writer->write_objectID(o);
11491168
}
11501169
}
@@ -1424,6 +1443,11 @@ void HeapObjectDumper::do_object(oop o) {
14241443
}
14251444
}
14261445

1446+
if (DumperSupport::mask_dormant_archived_object(o) == NULL) {
1447+
log_debug(cds, heap)("skipped dormant archived object " INTPTR_FORMAT " (%s)", p2i(o), o->klass()->external_name());
1448+
return;
1449+
}
1450+
14271451
if (o->is_instance()) {
14281452
// create a HPROF_GC_INSTANCE record for each object
14291453
DumperSupport::dump_instance(writer(), o);

0 commit comments

Comments
 (0)