Skip to content

Commit

Permalink
8320924: Improve heap dump performance by optimizing archived object …
Browse files Browse the repository at this point in the history
…checks

Backport-of: f32ab8cc47c8a1b4887e9c7c86b145ce4b85c546
  • Loading branch information
shipilev committed Apr 25, 2024
1 parent 41237fc commit 9c0e18c
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 22 deletions.
4 changes: 0 additions & 4 deletions src/hotspot/share/oops/klass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,6 @@ void Klass::set_java_mirror(Handle m) {
_java_mirror = class_loader_data()->add_handle(m);
}

oop Klass::java_mirror_no_keepalive() const {
return _java_mirror.peek();
}

bool Klass::is_cloneable() const {
return _access_flags.is_cloneable_fast() ||
is_subtype_of(vmClasses::Cloneable_klass());
Expand Down
4 changes: 4 additions & 0 deletions src/hotspot/share/oops/klass.inline.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ inline oop Klass::java_mirror() const {
return _java_mirror.resolve();
}

inline oop Klass::java_mirror_no_keepalive() const {
return _java_mirror.peek();
}

inline klassVtable Klass::vtable() const {
return klassVtable(const_cast<Klass*>(this), start_of_vtable(), vtable_length() / vtableEntry::size());
}
Expand Down
38 changes: 20 additions & 18 deletions src/hotspot/share/services/heapDumper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -939,15 +939,30 @@ class DumperSupport : AllStatic {
// fixes up the current dump record and writes HPROF_HEAP_DUMP_END record
static void end_of_dump(AbstractDumpWriter* writer);

static oop mask_dormant_archived_object(oop o) {
if (o != nullptr && o->klass()->java_mirror() == nullptr) {
static oop mask_dormant_archived_object(oop o, oop ref_obj) {
if (o != nullptr && o->klass()->java_mirror_no_keepalive() == nullptr) {
// Ignore this object since the corresponding java mirror is not loaded.
// Might be a dormant archive object.
report_dormant_archived_object(o, ref_obj);
return nullptr;
} else {
return o;
}
}

static void report_dormant_archived_object(oop o, oop ref_obj) {
if (log_is_enabled(Trace, cds, heap)) {
ResourceMark rm;
if (ref_obj != nullptr) {
log_trace(cds, heap)("skipped dormant archived object " INTPTR_FORMAT " (%s) referenced by " INTPTR_FORMAT " (%s)",
p2i(o), o->klass()->external_name(),
p2i(ref_obj), ref_obj->klass()->external_name());
} else {
log_trace(cds, heap)("skipped dormant archived object " INTPTR_FORMAT " (%s)",
p2i(o), o->klass()->external_name());
}
}
}
};

// Hash table of klasses to the klass metadata. This should greatly improve the
Expand Down Expand Up @@ -1135,13 +1150,7 @@ void DumperSupport::dump_field_value(AbstractDumpWriter* writer, char type, oop
case JVM_SIGNATURE_CLASS :
case JVM_SIGNATURE_ARRAY : {
oop o = obj->obj_field_access<ON_UNKNOWN_OOP_REF | AS_NO_KEEPALIVE>(offset);
if (o != nullptr && log_is_enabled(Debug, cds, heap) && mask_dormant_archived_object(o) == nullptr) {
ResourceMark rm;
log_debug(cds, heap)("skipped dormant archived object " INTPTR_FORMAT " (%s) referenced by " INTPTR_FORMAT " (%s)",
p2i(o), o->klass()->external_name(),
p2i(obj), obj->klass()->external_name());
}
o = mask_dormant_archived_object(o);
o = mask_dormant_archived_object(o, obj);
assert(oopDesc::is_oop_or_null(o), "Expected an oop or nullptr at " PTR_FORMAT, p2i(o));
writer->write_objectID(o);
break;
Expand Down Expand Up @@ -1473,13 +1482,7 @@ void DumperSupport::dump_object_array(AbstractDumpWriter* writer, objArrayOop ar
// [id]* elements
for (int index = 0; index < length; index++) {
oop o = array->obj_at(index);
if (o != nullptr && log_is_enabled(Debug, cds, heap) && mask_dormant_archived_object(o) == nullptr) {
ResourceMark rm;
log_debug(cds, heap)("skipped dormant archived object " INTPTR_FORMAT " (%s) referenced by " INTPTR_FORMAT " (%s)",
p2i(o), o->klass()->external_name(),
p2i(array), array->klass()->external_name());
}
o = mask_dormant_archived_object(o);
o = mask_dormant_archived_object(o, array);
writer->write_objectID(o);
}

Expand Down Expand Up @@ -1814,8 +1817,7 @@ void HeapObjectDumper::do_object(oop o) {
}
}

if (DumperSupport::mask_dormant_archived_object(o) == nullptr) {
log_debug(cds, heap)("skipped dormant archived object " INTPTR_FORMAT " (%s)", p2i(o), o->klass()->external_name());
if (DumperSupport::mask_dormant_archived_object(o, nullptr) == nullptr) {
return;
}

Expand Down

1 comment on commit 9c0e18c

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.