--- old/src/hotspot/share/gc/g1/g1CollectionSet.cpp 2019-11-26 16:18:12.202852028 +0100 +++ new/src/hotspot/share/gc/g1/g1CollectionSet.cpp 2019-11-26 16:18:11.778849925 +0100 @@ -205,6 +205,13 @@ } } +void G1CollectionSet::par_iterate(HeapRegionClosure* cl, + HeapRegionClaimer* hr_claimer, + uint worker_id, + uint total_workers) const { + iterate_part_from(cl, hr_claimer, 0, cur_length(), worker_id, total_workers); +} + void G1CollectionSet::iterate_optional(HeapRegionClosure* cl) const { assert_at_safepoint(); @@ -219,18 +226,25 @@ HeapRegionClaimer* hr_claimer, uint worker_id, uint total_workers) const { - assert_at_safepoint(); + iterate_part_from(cl, hr_claimer, _inc_part_start, increment_length(), worker_id, total_workers); +} - size_t len = increment_length(); - if (len == 0) { +void G1CollectionSet::iterate_part_from(HeapRegionClosure* cl, + HeapRegionClaimer* hr_claimer, + size_t offset, + size_t lenght, + uint worker_id, + uint total_workers) const { + assert_at_safepoint(); + if (lenght == 0) { return; } - size_t start_pos = (worker_id * len) / total_workers; + size_t start_pos = (worker_id * lenght) / total_workers; size_t cur_pos = start_pos; do { - uint region_idx = _collection_set_regions[cur_pos + _inc_part_start]; + uint region_idx = _collection_set_regions[cur_pos + offset]; if (hr_claimer == NULL || hr_claimer->claim_region(region_idx)) { HeapRegion* r = _g1h->region_at(region_idx); bool result = cl->do_heap_region(r); @@ -238,7 +252,7 @@ } cur_pos++; - if (cur_pos == len) { + if (cur_pos == lenght) { cur_pos = 0; } } while (cur_pos != start_pos);