8296768: Use different explicit claim marks for CLDs in Parallel and Serial GC

Reviewed-by: ayang, sjohanss, kbarrett
This commit is contained in:
Thomas Schatzl 2022-11-24 08:58:13 +00:00
parent 9c77e41b81
commit 5e5b774bfb
5 changed files with 20 additions and 15 deletions

View File

@ -52,11 +52,13 @@ public:
virtual void do_oop(narrowOop* p) { do_oop_nv(p); }
};
class PCIterateMarkAndPushClosure: public MetadataVisitingOopIterateClosure {
class PCIterateMarkAndPushClosure: public ClaimMetadataVisitingOopIterateClosure {
private:
ParCompactionManager* _compaction_manager;
public:
PCIterateMarkAndPushClosure(ParCompactionManager* cm, ReferenceProcessor* rp) : MetadataVisitingOopIterateClosure(rp), _compaction_manager(cm) { }
PCIterateMarkAndPushClosure(ParCompactionManager* cm, ReferenceProcessor* rp) :
ClaimMetadataVisitingOopIterateClosure(ClassLoaderData::_claim_stw_fullgc_mark, rp),
_compaction_manager(cm) { }
template <typename T> void do_oop_nv(T* p) { _compaction_manager->mark_and_push(p); }
virtual void do_oop(oop* p) { do_oop_nv(p); }

View File

@ -1033,6 +1033,9 @@ void PSParallelCompact::post_compact()
ClassLoaderDataGraph::purge(/*at_safepoint*/true);
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
@ -1965,7 +1968,7 @@ public:
PCMarkAndPushClosure mark_and_push_closure(cm);
{
CLDToOopClosure cld_closure(&mark_and_push_closure, ClassLoaderData::_claim_strong);
CLDToOopClosure cld_closure(&mark_and_push_closure, ClassLoaderData::_claim_stw_fullgc_mark);
ClassLoaderDataGraph::always_strong_cld_do(&cld_closure);
// Do the real work
@ -2016,9 +2019,7 @@ void PSParallelCompact::marking_phase(ParallelOldTracer *gc_tracer) {
uint active_gc_threads = ParallelScavengeHeap::heap()->workers().active_workers();
// Need new claim bits before marking starts.
ClassLoaderDataGraph::clear_claimed_marks();
ClassLoaderDataGraph::verify_claimed_marks_cleared(ClassLoaderData::_claim_stw_fullgc_mark);
{
GCTraceTime(Debug, gc, phases) tm("Par Mark", &_gc_timer);
@ -2094,8 +2095,8 @@ public:
_sub_tasks(PSAdjustSubTask_num_elements),
_weak_proc_task(nworkers),
_nworkers(nworkers) {
// Need new claim bits when tracing through and adjusting pointers.
ClassLoaderDataGraph::clear_claimed_marks();
ClassLoaderDataGraph::verify_claimed_marks_cleared(ClassLoaderData::_claim_stw_fullgc_adjust);
if (nworkers > 1) {
Threads::change_thread_claim_token();
}
@ -2114,7 +2115,7 @@ public:
}
_oop_storage_iter.oops_do(&adjust);
{
CLDToOopClosure cld_closure(&adjust, ClassLoaderData::_claim_strong);
CLDToOopClosure cld_closure(&adjust, ClassLoaderData::_claim_stw_fullgc_adjust);
ClassLoaderDataGraph::cld_do(&cld_closure);
}
{

View File

@ -180,8 +180,7 @@ void GenMarkSweep::mark_sweep_phase1(bool clear_all_softrefs) {
GenCollectedHeap* gch = GenCollectedHeap::heap();
// Need new claim bits before marking starts.
ClassLoaderDataGraph::clear_claimed_marks();
ClassLoaderDataGraph::verify_claimed_marks_cleared(ClassLoaderData::_claim_stw_fullgc_mark);
{
StrongRootsScope srs(0);
@ -261,8 +260,7 @@ void GenMarkSweep::mark_sweep_phase3() {
// Adjust the pointers to reflect the new locations
GCTraceTime(Info, gc, phases) tm("Phase 3: Adjust pointers", gc_timer());
// Need new claim bits for the pointer adjustment tracing.
ClassLoaderDataGraph::clear_claimed_marks();
ClassLoaderDataGraph::verify_claimed_marks_cleared(ClassLoaderData::_claim_stw_fullgc_adjust);
{
StrongRootsScope srs(0);

View File

@ -62,8 +62,8 @@ StringDedup::Requests* MarkSweep::_string_dedup_requests = NULL;
MarkSweep::FollowRootClosure MarkSweep::follow_root_closure;
MarkAndPushClosure MarkSweep::mark_and_push_closure;
CLDToOopClosure MarkSweep::follow_cld_closure(&mark_and_push_closure, ClassLoaderData::_claim_strong);
CLDToOopClosure MarkSweep::adjust_cld_closure(&adjust_pointer_closure, ClassLoaderData::_claim_strong);
CLDToOopClosure MarkSweep::follow_cld_closure(&mark_and_push_closure, ClassLoaderData::_claim_stw_fullgc_mark);
CLDToOopClosure MarkSweep::adjust_cld_closure(&adjust_pointer_closure, ClassLoaderData::_claim_stw_fullgc_adjust);
template <class T> inline void MarkSweep::KeepAliveClosure::do_oop_work(T* p) {
mark_and_push(p);

View File

@ -628,6 +628,10 @@ void GenCollectedHeap::do_collection(bool full,
// 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();
// Resize the metaspace capacity after full collections
MetaspaceGC::compute_new_size();
update_full_collections_completed();