--- old/src/hotspot/share/gc/g1/heapRegionRemSet.cpp 2018-10-02 14:13:11.846849058 +0200 +++ new/src/hotspot/share/gc/g1/heapRegionRemSet.cpp 2018-10-02 14:13:11.429836440 +0200 @@ -239,10 +239,9 @@ size_t OtherRegionsTable::_fine_eviction_stride = 0; size_t OtherRegionsTable::_fine_eviction_sample_size = 0; -OtherRegionsTable::OtherRegionsTable(HeapRegion* hr, Mutex* m) : +OtherRegionsTable::OtherRegionsTable(Mutex* m) : _g1h(G1CollectedHeap::heap()), _m(m), - _hr(hr), _coarse_map(G1CollectedHeap::heap()->max_regions(), mtGC), _n_coarse_entries(0), _fine_grain_regions(NULL), @@ -250,7 +249,7 @@ _first_all_fine_prts(NULL), _last_all_fine_prts(NULL), _fine_eviction_start(0), - _sparse_table(hr) + _sparse_table() { typedef PerRegionTable* PerRegionTablePtr; @@ -348,15 +347,6 @@ } void OtherRegionsTable::add_reference(OopOrNarrowOopStar from, uint tid) { - uint cur_hrm_ind = _hr->hrm_index(); - - uintptr_t from_card = uintptr_t(from) >> CardTable::card_shift; - - if (G1FromCardCache::contains_or_replace(tid, cur_hrm_ind, from_card)) { - assert(contains_reference(from), "We just found " PTR_FORMAT " in the FromCardCache", p2i(from)); - return; - } - // Note that this may be a continued H region. HeapRegion* from_hr = _g1h->heap_region_containing(from); RegionIdx_t from_hrm_ind = (RegionIdx_t) from_hr->hrm_index(); @@ -569,10 +559,6 @@ return PerRegionTable::fl_mem_size(); } -void OtherRegionsTable::clear_fcc() { - G1FromCardCache::clear(_hr->hrm_index()); -} - void OtherRegionsTable::clear() { // if there are no entries, skip this step if (_first_all_fine_prts != NULL) { @@ -590,8 +576,6 @@ } _n_fine_entries = 0; _n_coarse_entries = 0; - - clear_fcc(); } bool OtherRegionsTable::contains_reference(OopOrNarrowOopStar from) const { @@ -627,11 +611,16 @@ : _bot(bot), _code_roots(), _m(Mutex::leaf, FormatBuffer<128>("HeapRegionRemSet lock #%u", hr->hrm_index()), true, Monitor::_safepoint_check_never), - _other_regions(hr, &_m), + _other_regions(&_m), + _hr(hr), _state(Untracked) { } +void HeapRegionRemSet::clear_fcc() { + G1FromCardCache::clear(_hr->hrm_index()); +} + void HeapRegionRemSet::setup_remset_size() { // Setup sparse and fine-grain tables sizes. // table_size = base * (log(region_size / 1M) + 1) @@ -659,6 +648,7 @@ if (!only_cardset) { _code_roots.clear(); } + clear_fcc(); _other_regions.clear(); set_state_empty(); assert(occupied_locked() == 0, "Should be clear."); --- old/src/hotspot/share/gc/g1/heapRegionRemSet.hpp 2018-10-02 14:13:13.449897564 +0200 +++ new/src/hotspot/share/gc/g1/heapRegionRemSet.hpp 2018-10-02 14:13:13.031884915 +0200 @@ -76,7 +76,6 @@ G1CollectedHeap* _g1h; Mutex* _m; - HeapRegion* _hr; // These are protected by "_m". CHeapBitMap _coarse_map; @@ -124,11 +123,9 @@ bool contains_reference_locked(OopOrNarrowOopStar from) const; public: - // Clear the from_card_cache entries for this region. - void clear_fcc(); // Create a new remembered set for the given heap region. The given mutex should // be used to ensure consistency. - OtherRegionsTable(HeapRegion* hr, Mutex* m); + OtherRegionsTable(Mutex* m); // Returns the card index of the given within_region pointer relative to the bottom // of the given heap region. @@ -182,6 +179,10 @@ OtherRegionsTable _other_regions; + HeapRegion* _hr; + + void clear_fcc(); + public: HeapRegionRemSet(G1BlockOffsetTable* bot, HeapRegion* hr); @@ -243,18 +244,18 @@ if (_state == Untracked) { return; } - _other_regions.clear_fcc(); + clear_fcc(); _state = Untracked; } void set_state_updating() { guarantee(SafepointSynchronize::is_at_safepoint() && !is_tracked(), "Should only set to Updating from Untracked during safepoint but is %s", get_state_str()); - _other_regions.clear_fcc(); + clear_fcc(); _state = Updating; } void set_state_complete() { - _other_regions.clear_fcc(); + clear_fcc(); _state = Complete; } @@ -269,6 +270,15 @@ if (state == Untracked) { return; } + + uint cur_idx = _hr->hrm_index(); + uintptr_t from_card = uintptr_t(from) >> CardTable::card_shift; + + if (G1FromCardCache::contains_or_replace(tid, cur_idx, from_card)) { + assert(contains_reference(from), "We just found " PTR_FORMAT " in the FromCardCache", p2i(from)); + return; + } + _other_regions.add_reference(from, tid); } --- old/src/hotspot/share/gc/g1/sparsePRT.cpp 2018-10-02 14:13:15.044945827 +0200 +++ new/src/hotspot/share/gc/g1/sparsePRT.cpp 2018-10-02 14:13:14.620932997 +0200 @@ -361,8 +361,8 @@ } -SparsePRT::SparsePRT(HeapRegion* hr) : - _hr(hr), _expanded(false), _next_expanded(NULL) +SparsePRT::SparsePRT() : + _expanded(false), _next_expanded(NULL) { _cur = new RSHashTable(InitialCapacity); _next = _cur; --- old/src/hotspot/share/gc/g1/sparsePRT.hpp 2018-10-02 14:13:16.638994061 +0200 +++ new/src/hotspot/share/gc/g1/sparsePRT.hpp 2018-10-02 14:13:16.220981412 +0200 @@ -231,8 +231,6 @@ RSHashTable* _cur; RSHashTable* _next; - HeapRegion* _hr; - enum SomeAdditionalPrivateConstants { InitialCapacity = 16 }; @@ -254,7 +252,7 @@ static SparsePRT* volatile _head_expanded_list; public: - SparsePRT(HeapRegion* hr); + SparsePRT(); ~SparsePRT();