Skip to content

Commit e90970b

Browse files
committed
8230674: Heap dumps should exclude dormant CDS archived objects of unloaded classes
Reviewed-by: dholmes, jiangli
1 parent 4285853 commit e90970b

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
@@ -686,6 +686,16 @@ class DumperSupport : AllStatic {
686686

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

691701
// write a header of the given type
@@ -761,6 +771,13 @@ void DumperSupport::dump_field_value(DumpWriter* writer, char type, oop obj, int
761771
case JVM_SIGNATURE_CLASS :
762772
case JVM_SIGNATURE_ARRAY : {
763773
oop o = obj->obj_field_access<ON_UNKNOWN_OOP_REF | AS_NO_KEEPALIVE>(offset);
774+
if (o != NULL && log_is_enabled(Debug, cds, heap) && mask_dormant_archived_object(o) == NULL) {
775+
ResourceMark rm;
776+
log_debug(cds, heap)("skipped dormant archived object " INTPTR_FORMAT " (%s) referenced by " INTPTR_FORMAT " (%s)",
777+
p2i(o), o->klass()->external_name(),
778+
p2i(obj), obj->klass()->external_name());
779+
}
780+
o = mask_dormant_archived_object(o);
764781
assert(oopDesc::is_oop_or_null(o), "Expected an oop or NULL at " PTR_FORMAT, p2i(o));
765782
writer->write_objectID(o);
766783
break;
@@ -958,11 +975,6 @@ void DumperSupport::dump_instance_field_descriptors(DumpWriter* writer, Klass* k
958975
// creates HPROF_GC_INSTANCE_DUMP record for the given object
959976
void DumperSupport::dump_instance(DumpWriter* writer, oop o) {
960977
Klass* k = o->klass();
961-
if (k->java_mirror() == NULL) {
962-
// Ignoring this object since the corresponding java mirror is not loaded.
963-
// Might be a dormant archive object.
964-
return;
965-
}
966978

967979
writer->write_u1(HPROF_GC_INSTANCE_DUMP);
968980
writer->write_objectID(o);
@@ -1148,6 +1160,13 @@ void DumperSupport::dump_object_array(DumpWriter* writer, objArrayOop array) {
11481160
// [id]* elements
11491161
for (int index = 0; index < length; index++) {
11501162
oop o = array->obj_at(index);
1163+
if (o != NULL && log_is_enabled(Debug, cds, heap) && mask_dormant_archived_object(o) == NULL) {
1164+
ResourceMark rm;
1165+
log_debug(cds, heap)("skipped dormant archived object " INTPTR_FORMAT " (%s) referenced by " INTPTR_FORMAT " (%s)",
1166+
p2i(o), o->klass()->external_name(),
1167+
p2i(array), array->klass()->external_name());
1168+
}
1169+
o = mask_dormant_archived_object(o);
11511170
writer->write_objectID(o);
11521171
}
11531172
}
@@ -1427,6 +1446,11 @@ void HeapObjectDumper::do_object(oop o) {
14271446
}
14281447
}
14291448

1449+
if (DumperSupport::mask_dormant_archived_object(o) == NULL) {
1450+
log_debug(cds, heap)("skipped dormant archived object " INTPTR_FORMAT " (%s)", p2i(o), o->klass()->external_name());
1451+
return;
1452+
}
1453+
14301454
if (o->is_instance()) {
14311455
// create a HPROF_GC_INSTANCE record for each object
14321456
DumperSupport::dump_instance(writer(), o);

0 commit comments

Comments
 (0)