Skip to content

8364516: Serial: Move class unloading logic inside SerialFullGC::invoke_at_safepoint #26588

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

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
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
17 changes: 17 additions & 0 deletions src/hotspot/share/gc/serial/serialFullGC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -705,6 +705,16 @@ void SerialFullGC::invoke_at_safepoint(bool clear_all_softrefs) {

allocate_stacks();

// Usually, all class unloading work occurs at the end of phase 1, but Serial
// full-gc accesses dead-objs' klass to find out the start of next live-obj
// during phase 2. This requires klasses of dead-objs to be kept loaded.
// Therefore, we declare ClassUnloadingContext at the same level as
// full-gc phases, and purge dead classes (invoking
// ClassLoaderDataGraph::purge) after all phases of full-gc.
ClassUnloadingContext ctx(1 /* num_nmethod_unlink_workers */,
false /* unregister_nmethods_during_purge */,
false /* lock_nmethod_free_separately */);

phase1_mark(clear_all_softrefs);

Compacter compacter{gch};
Expand Down Expand Up @@ -755,6 +765,13 @@ void SerialFullGC::invoke_at_safepoint(bool clear_all_softrefs) {
compacter.phase4_compact();
}

// Delete metaspaces for unloaded class loaders and clean up CLDG.
ClassLoaderDataGraph::purge(true /* at_safepoint */);
DEBUG_ONLY(MetaspaceUtils::verify();)

// Need to clear claim bits for the next full-gc (specifically phase 1 and 3).
ClassLoaderDataGraph::clear_claimed_marks();

restore_marks();

deallocate_stacks();
Expand Down
10 changes: 0 additions & 10 deletions src/hotspot/share/gc/serial/serialHeap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -603,9 +603,6 @@ void SerialHeap::do_full_collection(bool clear_all_soft_refs) {
gc_prologue();
COMPILER2_OR_JVMCI_PRESENT(DerivedPointerTable::clear());
CodeCache::on_gc_marking_cycle_start();
ClassUnloadingContext ctx(1 /* num_nmethod_unlink_workers */,
false /* unregister_nmethods_during_purge */,
false /* lock_nmethod_free_separately */);

STWGCTimer* gc_timer = SerialFullGC::gc_timer();
gc_timer->register_gc_start();
Expand All @@ -630,13 +627,6 @@ void SerialHeap::do_full_collection(bool clear_all_soft_refs) {
_old_gen->compute_new_size();
_young_gen->compute_new_size();

// Delete metaspaces for unloaded class loaders and clean up loader_data graph
ClassLoaderDataGraph::purge(/*at_safepoint*/true);
DEBUG_ONLY(MetaspaceUtils::verify();)

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

_old_gen->update_promote_stats();

// Resize the metaspace capacity after full collections
Expand Down