Skip to content

Commit

Permalink
8295871: G1: Use different explicit claim marks for CLDs
Browse files Browse the repository at this point in the history
Reviewed-by: sjohanss, ayang
  • Loading branch information
Thomas Schatzl committed Nov 10, 2022
1 parent 9ef7852 commit e1badb7
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 17 deletions.
2 changes: 2 additions & 0 deletions src/hotspot/share/classfile/classLoaderData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
10 changes: 6 additions & 4 deletions src/hotspot/share/classfile/classLoaderData.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
3 changes: 2 additions & 1 deletion src/hotspot/share/gc/g1/g1ConcurrentMark.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
*/

#include "precompiled.hpp"
#include "classfile/classLoaderData.hpp"
#include "classfile/classLoaderDataGraph.hpp"
#include "classfile/systemDictionary.hpp"
#include "code/codeCache.hpp"
Expand Down Expand Up @@ -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)
{ }

Expand Down
6 changes: 1 addition & 5 deletions src/hotspot/share/gc/g1/g1FullCollector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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.
Expand Down
6 changes: 3 additions & 3 deletions src/hotspot/share/gc/g1/g1FullGCAdjustTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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) {
Expand All @@ -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);

Expand Down
4 changes: 3 additions & 1 deletion src/hotspot/share/gc/g1/g1FullGCMarker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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() {
Expand Down
7 changes: 4 additions & 3 deletions src/hotspot/share/gc/g1/g1OopClosures.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -179,7 +180,7 @@ class G1CLDScanClosure : public CLDClosure {
};

// Closure for iterating over object fields during concurrent marking
class G1CMOopClosure : public MetadataVisitingOopIterateClosure {
class G1CMOopClosure : public ClaimMetadataVisitingOopIterateClosure {
G1CollectedHeap* _g1h;
G1CMTask* _task;
public:
Expand All @@ -190,13 +191,13 @@ class G1CMOopClosure : public MetadataVisitingOopIterateClosure {
};

// 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); }
Expand Down

1 comment on commit e1badb7

@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.