8295871: G1: Use different explicit claim marks for CLDs

Reviewed-by: sjohanss, ayang
This commit is contained in:
Thomas Schatzl 2022-11-10 19:36:11 +00:00
parent 9ef7852be3
commit e1badb77fb
7 changed files with 21 additions and 17 deletions

@ -972,6 +972,8 @@ void ClassLoaderData::print_on(outputStream* out) const {
case _claim_none: out->print_cr("none"); break;
case _claim_finalizable: out->print_cr("finalizable"); break;
case _claim_strong: out->print_cr("strong"); break;
case _claim_stw_fullgc_mark: out->print_cr("stw full gc mark"); break;
case _claim_stw_fullgc_adjust: out->print_cr("stw full gc adjust"); break;
case _claim_other: out->print_cr("other"); break;
case _claim_other | _claim_finalizable: out->print_cr("other and finalizable"); break;
case _claim_other | _claim_strong: out->print_cr("other and strong"); break;

@ -202,10 +202,12 @@ class ClassLoaderData : public CHeapObj<mtClass> {
// The "claim" is typically used to check if oops_do needs to be applied on
// the CLD or not. Most GCs only perform strong marking during the marking phase.
enum Claim {
_claim_none = 0,
_claim_finalizable = 2,
_claim_strong = 3,
_claim_other = 4
_claim_none = 0,
_claim_finalizable = 2,
_claim_strong = 3,
_claim_stw_fullgc_mark = 4,
_claim_stw_fullgc_adjust = 8,
_claim_other = 16
};
void clear_claim() { _claim = 0; }
void clear_claim(int claim);

@ -23,6 +23,7 @@
*/
#include "precompiled.hpp"
#include "classfile/classLoaderData.hpp"
#include "classfile/classLoaderDataGraph.hpp"
#include "classfile/systemDictionary.hpp"
#include "code/codeCache.hpp"
@ -2108,7 +2109,7 @@ static ReferenceProcessor* get_cm_oop_closure_ref_processor(G1CollectedHeap* g1h
G1CMOopClosure::G1CMOopClosure(G1CollectedHeap* g1h,
G1CMTask* task)
: MetadataVisitingOopIterateClosure(get_cm_oop_closure_ref_processor(g1h)),
: ClaimMetadataVisitingOopIterateClosure(ClassLoaderData::_claim_strong, get_cm_oop_closure_ref_processor(g1h)),
_g1h(g1h), _task(task)
{ }

@ -181,10 +181,6 @@ void G1FullCollector::prepare_collection() {
if (in_concurrent_cycle) {
GCTraceTime(Debug, gc) debug("Clear Bitmap");
_heap->concurrent_mark()->clear_bitmap(_heap->workers());
// Need cleared claim bits for the mark phase.
ClassLoaderDataGraph::clear_claimed_marks();
} else {
ClassLoaderDataGraph::verify_claimed_marks_cleared(ClassLoaderData::_claim_strong);
}
_heap->gc_prologue(true);
@ -227,7 +223,7 @@ void G1FullCollector::complete_collection() {
// update the derived pointer table.
update_derived_pointers();
// Need cleared claim bits for the next concurrent marking.
// Need completely cleared claim bits for the next concurrent marking or full gc.
ClassLoaderDataGraph::clear_claimed_marks();
// Prepare the bitmap for the next (potentially concurrent) marking.

@ -23,6 +23,7 @@
*/
#include "precompiled.hpp"
#include "classfile/classLoaderData.hpp"
#include "classfile/classLoaderDataGraph.hpp"
#include "gc/g1/g1CollectedHeap.hpp"
#include "gc/g1/g1ConcurrentMarkBitMap.inline.hpp"
@ -84,8 +85,7 @@ G1FullGCAdjustTask::G1FullGCAdjustTask(G1FullCollector* collector) :
_weak_proc_task(collector->workers()),
_hrclaimer(collector->workers()),
_adjust(collector) {
// Need cleared claim bits for the roots processing
ClassLoaderDataGraph::clear_claimed_marks();
ClassLoaderDataGraph::verify_claimed_marks_cleared(ClassLoaderData::_claim_stw_fullgc_adjust);
}
void G1FullGCAdjustTask::work(uint worker_id) {
@ -102,7 +102,7 @@ void G1FullGCAdjustTask::work(uint worker_id) {
_weak_proc_task.work(worker_id, &always_alive, &_adjust);
}
CLDToOopClosure adjust_cld(&_adjust, ClassLoaderData::_claim_strong);
CLDToOopClosure adjust_cld(&_adjust, ClassLoaderData::_claim_stw_fullgc_adjust);
CodeBlobToOopClosure adjust_code(&_adjust, CodeBlobToOopClosure::FixRelocations);
_root_processor.process_all_roots(&_adjust, &adjust_cld, &adjust_code);

@ -24,6 +24,7 @@
#include "precompiled.hpp"
#include "classfile/classLoaderData.hpp"
#include "classfile/classLoaderDataGraph.hpp"
#include "gc/g1/g1FullGCMarker.inline.hpp"
#include "gc/shared/referenceProcessor.hpp"
#include "gc/shared/taskTerminator.hpp"
@ -43,8 +44,9 @@ G1FullGCMarker::G1FullGCMarker(G1FullCollector* collector,
_mark_closure(worker_id, this, G1CollectedHeap::heap()->ref_processor_stw()),
_verify_closure(VerifyOption::G1UseFullMarking),
_stack_closure(this),
_cld_closure(mark_closure(), ClassLoaderData::_claim_strong),
_cld_closure(mark_closure(), ClassLoaderData::_claim_stw_fullgc_mark),
_mark_stats_cache(mark_stats, G1RegionMarkStatsCache::RegionMarkStatsCacheSize) {
ClassLoaderDataGraph::verify_claimed_marks_cleared(ClassLoaderData::_claim_stw_fullgc_mark);
}
G1FullGCMarker::~G1FullGCMarker() {

@ -25,6 +25,7 @@
#ifndef SHARE_GC_G1_G1OOPCLOSURES_HPP
#define SHARE_GC_G1_G1OOPCLOSURES_HPP
#include "classfile/classLoaderData.hpp"
#include "gc/g1/g1HeapRegionAttr.hpp"
#include "memory/iterator.hpp"
#include "oops/markWord.hpp"
@ -179,7 +180,7 @@ public:
};
// Closure for iterating over object fields during concurrent marking
class G1CMOopClosure : public MetadataVisitingOopIterateClosure {
class G1CMOopClosure : public ClaimMetadataVisitingOopIterateClosure {
G1CollectedHeap* _g1h;
G1CMTask* _task;
public:
@ -190,13 +191,13 @@ public:
};
// Closure to scan the root regions during concurrent marking
class G1RootRegionScanClosure : public MetadataVisitingOopIterateClosure {
private:
class G1RootRegionScanClosure : public ClaimMetadataVisitingOopIterateClosure {
G1CollectedHeap* _g1h;
G1ConcurrentMark* _cm;
uint _worker_id;
public:
G1RootRegionScanClosure(G1CollectedHeap* g1h, G1ConcurrentMark* cm, uint worker_id) :
ClaimMetadataVisitingOopIterateClosure(ClassLoaderData::_claim_strong, nullptr),
_g1h(g1h), _cm(cm), _worker_id(worker_id) { }
template <class T> void do_oop_work(T* p);
virtual void do_oop( oop* p) { do_oop_work(p); }