--- old/src/hotspot/share/gc/g1/g1RemSet.cpp 2019-11-18 17:32:49.497578021 +0100 +++ new/src/hotspot/share/gc/g1/g1RemSet.cpp 2019-11-18 17:32:49.065575879 +0100 @@ -304,11 +304,6 @@ } void prepare() { - for (size_t i = 0; i < _max_regions; i++) { - _collection_set_iter_state[i] = false; - clear_scan_top((uint)i); - } - _all_dirty_regions = new G1DirtyRegions(_max_regions); _next_dirty_regions = new G1DirtyRegions(_max_regions); } @@ -403,6 +398,10 @@ } while (cur != start_pos); } + void reset_region_claim(uint region_idx) { + _collection_set_iter_state[region_idx] = false; + } + // Attempt to claim the given region in the collection set for iteration. Returns true // if this call caused the transition from Unclaimed to Claimed. inline bool claim_collection_set_region(uint region) { @@ -882,10 +881,10 @@ } } -// Creates a snapshot of the current _top values at the start of collection to -// filter out card marks that we do not want to scan. -void G1RemSet::prepare_region_for_scanning(HeapRegion* region) { +void G1RemSet::prepare_region_for_scan(HeapRegion* region) { uint hrm_index = region->hrm_index(); + + _scan_state->reset_region_claim(hrm_index); if (region->in_collection_set()) { // Young regions had their card table marked as young at their allocation; // we need to make sure that these marks are cleared at the end of GC, *but* @@ -893,8 +892,10 @@ // So directly add them to the "all_dirty_regions". // Same for regions in the (initial) collection set: they may contain cards from // the log buffers, make sure they are cleaned. + _scan_state->clear_scan_top(hrm_index); _scan_state->add_all_dirty_region(hrm_index); - } else if (region->is_old_or_humongous_or_archive()) { + } else { + assert(region->is_old_or_humongous_or_archive(), "All other regions should be in the collection set"); _scan_state->set_scan_top(hrm_index, region->top()); } }