diff --git a/src/hotspot/share/gc/g1/g1CollectedHeap.cpp b/src/hotspot/share/gc/g1/g1CollectedHeap.cpp index 4f7eaa36c2d..4a257265931 100644 --- a/src/hotspot/share/gc/g1/g1CollectedHeap.cpp +++ b/src/hotspot/share/gc/g1/g1CollectedHeap.cpp @@ -1200,7 +1200,7 @@ G1CollectedHeap::G1CollectedHeap() : _rem_set(nullptr), _card_set_config(), _card_set_freelist_pool(G1CardSetConfiguration::num_mem_object_types()), - _young_regions_cset_group(card_set_config(), &_card_set_freelist_pool, 1u /* group_id */), + _young_regions_cset_group(card_set_config(), &_card_set_freelist_pool, G1CSetCandidateGroup::YoungRegionId), _cm(nullptr), _cm_thread(nullptr), _cr(nullptr), diff --git a/src/hotspot/share/gc/g1/g1CollectionSetCandidates.cpp b/src/hotspot/share/gc/g1/g1CollectionSetCandidates.cpp index ccb52922c09..47340fad768 100644 --- a/src/hotspot/share/gc/g1/g1CollectionSetCandidates.cpp +++ b/src/hotspot/share/gc/g1/g1CollectionSetCandidates.cpp @@ -27,7 +27,7 @@ #include "gc/g1/g1HeapRegion.inline.hpp" #include "utilities/growableArray.hpp" -uint G1CSetCandidateGroup::_next_group_id = 2; +uint G1CSetCandidateGroup::_next_group_id = G1CSetCandidateGroup::InitialId; G1CSetCandidateGroup::G1CSetCandidateGroup(G1CardSetConfiguration* config, G1MonotonicArenaFreePool* card_set_freelist_pool, uint group_id) : _candidates(4, mtGCCardSet), diff --git a/src/hotspot/share/gc/g1/g1CollectionSetCandidates.hpp b/src/hotspot/share/gc/g1/g1CollectionSetCandidates.hpp index 02a4d5f6d76..0f4e92968fa 100644 --- a/src/hotspot/share/gc/g1/g1CollectionSetCandidates.hpp +++ b/src/hotspot/share/gc/g1/g1CollectionSetCandidates.hpp @@ -73,14 +73,21 @@ class G1CSetCandidateGroup : public CHeapObj{ size_t _reclaimable_bytes; double _gc_efficiency; - // The _group_id is primarily used when printing out per-region liveness information, - // making it easier to associate regions with their assigned G1CSetCandidateGroup, if any. - // Note: - // * _group_id 0 is reserved for special G1CSetCandidateGroups that hold only a single region, - // such as G1CSetCandidateGroups for retained regions. - // * _group_id 1 is reserved for the G1CSetCandidateGroup that contains all young regions. +public: + // The _group_id uniquely identifies a candidate group when printing, making it + // easier to associate regions with their assigned G1CSetCandidateGroup, if any. + // Special values for the id: + // * id 0 is reserved for regions that do not have a remembered set. + // * id 1 is reserved for the G1CollectionSetCandidate that contains all young regions. + // * other ids are handed out incrementally, starting from InitialId. + static const uint NoRemSetId = 0; + static const uint YoungRegionId = 1; + static const uint InitialId = 2; + +private: const uint _group_id; static uint _next_group_id; + public: G1CSetCandidateGroup(); G1CSetCandidateGroup(G1CardSetConfiguration* config, G1MonotonicArenaFreePool* card_set_freelist_pool, uint group_id); @@ -95,8 +102,6 @@ public: G1CardSet* card_set() { return &_card_set; } const G1CardSet* card_set() const { return &_card_set; } - uint group_id() const { return _group_id; } - void calculate_efficiency(); double liveness_percent() const; @@ -127,8 +132,10 @@ public: return _candidates.end(); } + uint group_id() const { return _group_id; } + static void reset_next_group_id() { - _next_group_id = 2; + _next_group_id = InitialId; } }; diff --git a/src/hotspot/share/gc/g1/g1ConcurrentMark.cpp b/src/hotspot/share/gc/g1/g1ConcurrentMark.cpp index 6d30a93dafb..3d95541ae3c 100644 --- a/src/hotspot/share/gc/g1/g1ConcurrentMark.cpp +++ b/src/hotspot/share/gc/g1/g1ConcurrentMark.cpp @@ -3052,11 +3052,9 @@ bool G1PrintRegionLivenessInfoClosure::do_heap_region(G1HeapRegion* r) { size_t remset_bytes = r->rem_set()->mem_size(); size_t code_roots_bytes = r->rem_set()->code_roots_mem_size(); const char* remset_type = r->rem_set()->get_short_state_str(); - uint cset_group_id = 0; - - if (r->rem_set()->has_cset_group()) { - cset_group_id = r->rem_set()->cset_group_id(); - } + uint cset_group_id = r->rem_set()->has_cset_group() + ? r->rem_set()->cset_group_id() + : G1CSetCandidateGroup::NoRemSetId; _total_used_bytes += used_bytes; _total_capacity_bytes += capacity_bytes;