Skip to content

8361404: Parallel: Group all class unloading logc at the end of marking phase #26130

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 14 additions & 17 deletions src/hotspot/share/gc/parallel/psParallelCompact.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -732,16 +732,6 @@ void PSParallelCompact::post_compact()
ct->dirty_MemRegion(old_mr);
}

{
// Delete metaspaces for unloaded class loaders and clean up loader_data graph
GCTraceTime(Debug, gc, phases) t("Purge Class Loader Data", gc_timer());
ClassLoaderDataGraph::purge(true /* at_safepoint */);
DEBUG_ONLY(MetaspaceUtils::verify();)
}

// Need to clear claim bits for the next mark.
ClassLoaderDataGraph::clear_claimed_marks();

heap->prune_scavengable_nmethods();

#if COMPILER2_OR_JVMCI
Expand Down Expand Up @@ -1044,10 +1034,6 @@ bool PSParallelCompact::invoke_no_policy(bool clear_all_soft_refs) {

ref_processor()->start_discovery(clear_all_soft_refs);

ClassUnloadingContext ctx(1 /* num_nmethod_unlink_workers */,
false /* unregister_nmethods_during_purge */,
false /* lock_nmethod_free_separately */);

marking_phase(&_gc_tracer);

summary_phase();
Expand Down Expand Up @@ -1337,7 +1323,9 @@ void PSParallelCompact::marking_phase(ParallelOldTracer *gc_tracer) {
{
GCTraceTime(Debug, gc, phases) tm_m("Class Unloading", &_gc_timer);

ClassUnloadingContext* ctx = ClassUnloadingContext::context();
ClassUnloadingContext ctx(1 /* num_nmethod_unlink_workers */,
false /* unregister_nmethods_during_purge */,
false /* lock_nmethod_free_separately */);

bool unloading_occurred;
{
Expand All @@ -1353,22 +1341,31 @@ void PSParallelCompact::marking_phase(ParallelOldTracer *gc_tracer) {
{
GCTraceTime(Debug, gc, phases) t("Purge Unlinked NMethods", gc_timer());
// Release unloaded nmethod's memory.
ctx->purge_nmethods();
ctx.purge_nmethods();
}
{
GCTraceTime(Debug, gc, phases) ur("Unregister NMethods", &_gc_timer);
ParallelScavengeHeap::heap()->prune_unlinked_nmethods();
}
{
GCTraceTime(Debug, gc, phases) t("Free Code Blobs", gc_timer());
ctx->free_nmethods();
ctx.free_nmethods();
}

// Prune dead klasses from subklass/sibling/implementor lists.
Klass::clean_weak_klass_links(unloading_occurred);

// Clean JVMCI metadata handles.
JVMCI_ONLY(JVMCI::do_unloading(unloading_occurred));
{
// Delete metaspaces for unloaded class loaders and clean up loader_data graph
GCTraceTime(Debug, gc, phases) t("Purge Class Loader Data", gc_timer());
ClassLoaderDataGraph::purge(true /* at_safepoint */);
DEBUG_ONLY(MetaspaceUtils::verify();)
}

// Need to clear claim bits for the next mark.
ClassLoaderDataGraph::clear_claimed_marks();
}

{
Expand Down