Skip to content

Commit 476c484

Browse files
committed
8292656: G1: Remove G1HotCardCache::_use_cache
Reviewed-by: tschatzl, iwalulya
1 parent a17fce7 commit 476c484

7 files changed

+12
-26
lines changed

src/hotspot/share/gc/g1/g1CollectedHeap.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -1048,7 +1048,7 @@ void G1CollectedHeap::prepare_heap_for_mutators() {
10481048
}
10491049

10501050
void G1CollectedHeap::abort_refinement() {
1051-
if (_hot_card_cache->use_cache()) {
1051+
if (G1HotCardCache::use_cache()) {
10521052
_hot_card_cache->reset_hot_cache();
10531053
}
10541054

@@ -3377,7 +3377,6 @@ void G1CollectedHeap::update_used_after_gc(bool evacuation_failed) {
33773377

33783378
void G1CollectedHeap::reset_hot_card_cache() {
33793379
_hot_card_cache->reset_hot_cache();
3380-
_hot_card_cache->set_use_cache(true);
33813380
}
33823381

33833382
void G1CollectedHeap::purge_code_root_memory() {

src/hotspot/share/gc/g1/g1FullGCPrepareTask.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ void G1FullGCPrepareTask::G1ResetMetadataClosure::reset_region_metadata(HeapRegi
121121
hr->clear_cardtable();
122122

123123
G1HotCardCache* hcc = _g1h->hot_card_cache();
124-
if (hcc->use_cache()) {
124+
if (G1HotCardCache::use_cache()) {
125125
hcc->reset_card_counts(hr);
126126
}
127127
}

src/hotspot/share/gc/g1/g1GCPhaseTimes.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ G1GCPhaseTimes::G1GCPhaseTimes(STWGCTimer* gc_timer, uint max_gc_threads) :
8383
}
8484

8585
_gc_par_phases[MergeLB] = new WorkerDataArray<double>("MergeLB", "Log Buffers (ms):", max_gc_threads);
86-
if (G1HotCardCache::default_use_cache()) {
86+
if (G1HotCardCache::use_cache()) {
8787
_gc_par_phases[MergeHCC] = new WorkerDataArray<double>("MergeHCC", "Hot Card Cache (ms):", max_gc_threads);
8888
_gc_par_phases[MergeHCC]->create_thread_work_items("Dirty Cards:", MergeHCCDirtyCards);
8989
_gc_par_phases[MergeHCC]->create_thread_work_items("Skipped Cards:", MergeHCCSkippedCards);
@@ -434,7 +434,7 @@ double G1GCPhaseTimes::print_evacuate_initial_collection_set() const {
434434
debug_time("Prepare Merge Heap Roots", _cur_prepare_merge_heap_roots_time_ms);
435435
debug_phase(_gc_par_phases[MergeER]);
436436
debug_phase(_gc_par_phases[MergeRS]);
437-
if (G1HotCardCache::default_use_cache()) {
437+
if (G1HotCardCache::use_cache()) {
438438
debug_phase(_gc_par_phases[MergeHCC]);
439439
}
440440
debug_phase(_gc_par_phases[MergeLB]);

src/hotspot/share/gc/g1/g1HotCardCache.cpp

+4-7
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,13 @@
3030
#include "runtime/atomic.hpp"
3131

3232
G1HotCardCache::G1HotCardCache(G1CollectedHeap *g1h):
33-
_g1h(g1h), _use_cache(false), _card_counts(g1h),
33+
_g1h(g1h), _card_counts(g1h),
3434
_hot_cache(NULL), _hot_cache_size(0), _hot_cache_par_chunk_size(0),
3535
_hot_cache_idx(0), _hot_cache_par_claimed_idx(0), _cache_wrapped_around(false)
3636
{}
3737

3838
void G1HotCardCache::initialize(G1RegionToSpaceMapper* card_counts_storage) {
39-
if (default_use_cache()) {
40-
_use_cache = true;
41-
39+
if (use_cache()) {
4240
_hot_cache_size = (size_t)1 << G1ConcRSLogCacheSize;
4341
_hot_cache = ArrayAllocator<CardValue*>::allocate(_hot_cache_size, mtGC);
4442

@@ -55,7 +53,7 @@ void G1HotCardCache::initialize(G1RegionToSpaceMapper* card_counts_storage) {
5553
}
5654

5755
G1HotCardCache::~G1HotCardCache() {
58-
if (default_use_cache()) {
56+
if (use_cache()) {
5957
assert(_hot_cache != NULL, "Logic");
6058
ArrayAllocator<CardValue*>::free(_hot_cache, _hot_cache_size);
6159
_hot_cache = NULL;
@@ -92,10 +90,9 @@ CardTable::CardValue* G1HotCardCache::insert(CardValue* card_ptr) {
9290
}
9391

9492
void G1HotCardCache::drain(G1CardTableEntryClosure* cl, uint worker_id) {
95-
assert(default_use_cache(), "Drain only necessary if we use the hot card cache.");
93+
assert(use_cache(), "Drain only necessary if we use the hot card cache.");
9694

9795
assert(_hot_cache != NULL, "Logic");
98-
assert(!use_cache(), "cache should be disabled");
9996

10097
while (_hot_cache_par_claimed_idx < _hot_cache_size) {
10198
size_t end_idx = Atomic::add(&_hot_cache_par_claimed_idx,

src/hotspot/share/gc/g1/g1HotCardCache.hpp

+2-10
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,6 @@ class G1HotCardCache: public CHeapObj<mtGC> {
5858
private:
5959
G1CollectedHeap* _g1h;
6060

61-
bool _use_cache;
62-
6361
G1CardCounts _card_counts;
6462

6563

@@ -90,7 +88,7 @@ class G1HotCardCache: public CHeapObj<mtGC> {
9088
static const int ClaimChunkSize = 32;
9189

9290
public:
93-
static bool default_use_cache() {
91+
static bool use_cache() {
9492
return (G1ConcRSLogCacheSize > 0);
9593
}
9694

@@ -99,12 +97,6 @@ class G1HotCardCache: public CHeapObj<mtGC> {
9997

10098
void initialize(G1RegionToSpaceMapper* card_counts_storage);
10199

102-
bool use_cache() { return _use_cache; }
103-
104-
void set_use_cache(bool b) {
105-
_use_cache = (b ? default_use_cache() : false);
106-
}
107-
108100
// Returns the card to be refined or NULL.
109101
//
110102
// Increments the count for given the card. if the card is not 'hot',
@@ -128,7 +120,7 @@ class G1HotCardCache: public CHeapObj<mtGC> {
128120
// Resets the hot card cache and discards the entries.
129121
void reset_hot_cache() {
130122
assert(SafepointSynchronize::is_at_safepoint(), "Should be at a safepoint");
131-
if (default_use_cache()) {
123+
if (use_cache()) {
132124
reset_hot_cache_internal();
133125
}
134126
}

src/hotspot/share/gc/g1/g1RemSet.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -1491,7 +1491,7 @@ class G1MergeHeapRootsTask : public WorkerTask {
14911491
}
14921492

14931493
// Apply closure to log entries in the HCC.
1494-
if (_initial_evacuation && G1HotCardCache::default_use_cache()) {
1494+
if (_initial_evacuation && G1HotCardCache::use_cache()) {
14951495
assert(merge_remset_phase == G1GCPhaseTimes::MergeRS, "Wrong merge phase");
14961496
G1GCParPhaseTimesTracker x(p, G1GCPhaseTimes::MergeHCC, worker_id);
14971497
G1MergeLogBufferCardsClosure cl(g1h, _scan_state);
@@ -1657,7 +1657,7 @@ bool G1RemSet::clean_card_before_refine(CardValue** const card_ptr_addr) {
16571657
// * a pointer to a "hot" card that was evicted from the "hot" cache.
16581658
//
16591659

1660-
if (_hot_card_cache->use_cache()) {
1660+
if (G1HotCardCache::use_cache()) {
16611661
assert(!SafepointSynchronize::is_at_safepoint(), "sanity");
16621662

16631663
const CardValue* orig_card_ptr = card_ptr;

src/hotspot/share/gc/g1/g1YoungCollector.cpp

-2
Original file line numberDiff line numberDiff line change
@@ -492,9 +492,7 @@ void G1YoungCollector::pre_evacuate_collection_set(G1EvacInfo* evacuation_info,
492492
phase_times()->record_concatenate_dirty_card_logs_time_ms(dt.seconds() * MILLIUNITS);
493493
}
494494

495-
// Disable the hot card cache.
496495
hot_card_cache()->reset_hot_cache_claimed_index();
497-
hot_card_cache()->set_use_cache(false);
498496

499497
// Initialize the GC alloc regions.
500498
allocator()->init_gc_alloc_regions(evacuation_info);

0 commit comments

Comments
 (0)