236 // Do we have any marking information for this region?
237 if (r->is_marked()) {
238 // We will skip any region that's currently used as an old GC
239 // alloc region (we should not consider those for collection
240 // before we fill them up).
241 if (_cset_updater.should_add(r) && !_g1h->is_old_gc_alloc_region(r)) {
242 _cset_updater.add_region(r);
243 } else if (r->is_old()) {
244 // Can clean out the remembered sets of all regions that we did not choose but
245 // we created the remembered set for.
246 r->rem_set()->clear(true);
247 }
248 }
249 return false;
250 }
251 };
252
253 class ParKnownGarbageTask: public AbstractGangTask {
254 CollectionSetChooser* _hrSorted;
255 uint _chunk_size;
256 G1CollectedHeap* _g1;
257 HeapRegionClaimer _hrclaimer;
258
259 public:
260 ParKnownGarbageTask(CollectionSetChooser* hrSorted, uint chunk_size, uint n_workers) :
261 AbstractGangTask("ParKnownGarbageTask"),
262 _hrSorted(hrSorted), _chunk_size(chunk_size),
263 _g1(G1CollectedHeap::heap()), _hrclaimer(n_workers) {}
264
265 void work(uint worker_id) {
266 ParKnownGarbageHRClosure par_known_garbage_cl(_hrSorted, _chunk_size);
267 _g1->heap_region_par_iterate_from_worker_offset(&par_known_garbage_cl, &_hrclaimer, worker_id);
268 }
269 };
270
271 uint CollectionSetChooser::calculate_parallel_work_chunk_size(uint n_workers, uint n_regions) const {
272 assert(n_workers > 0, "Active gc workers should be greater than 0");
273 const uint overpartition_factor = 4;
274 const uint min_chunk_size = MAX2(n_regions / n_workers, 1U);
275 return MAX2(n_regions / (n_workers * overpartition_factor), min_chunk_size);
276 }
277
278 bool CollectionSetChooser::region_occupancy_low_enough_for_evac(size_t live_bytes) {
279 return live_bytes < mixed_gc_live_threshold_bytes();
280 }
281
282 bool CollectionSetChooser::should_add(HeapRegion* hr) const {
283 assert(hr->is_marked(), "pre-condition");
284 assert(!hr->is_young(), "should never consider young regions");
285 return !hr->is_pinned() &&
286 region_occupancy_low_enough_for_evac(hr->live_bytes()) &&
287 hr->rem_set()->is_complete();
|
236 // Do we have any marking information for this region?
237 if (r->is_marked()) {
238 // We will skip any region that's currently used as an old GC
239 // alloc region (we should not consider those for collection
240 // before we fill them up).
241 if (_cset_updater.should_add(r) && !_g1h->is_old_gc_alloc_region(r)) {
242 _cset_updater.add_region(r);
243 } else if (r->is_old()) {
244 // Can clean out the remembered sets of all regions that we did not choose but
245 // we created the remembered set for.
246 r->rem_set()->clear(true);
247 }
248 }
249 return false;
250 }
251 };
252
253 class ParKnownGarbageTask: public AbstractGangTask {
254 CollectionSetChooser* _hrSorted;
255 uint _chunk_size;
256 G1CollectedHeap* _g1h;
257 HeapRegionClaimer _hrclaimer;
258
259 public:
260 ParKnownGarbageTask(CollectionSetChooser* hrSorted, uint chunk_size, uint n_workers) :
261 AbstractGangTask("ParKnownGarbageTask"),
262 _hrSorted(hrSorted), _chunk_size(chunk_size),
263 _g1h(G1CollectedHeap::heap()), _hrclaimer(n_workers) {}
264
265 void work(uint worker_id) {
266 ParKnownGarbageHRClosure par_known_garbage_cl(_hrSorted, _chunk_size);
267 _g1h->heap_region_par_iterate_from_worker_offset(&par_known_garbage_cl, &_hrclaimer, worker_id);
268 }
269 };
270
271 uint CollectionSetChooser::calculate_parallel_work_chunk_size(uint n_workers, uint n_regions) const {
272 assert(n_workers > 0, "Active gc workers should be greater than 0");
273 const uint overpartition_factor = 4;
274 const uint min_chunk_size = MAX2(n_regions / n_workers, 1U);
275 return MAX2(n_regions / (n_workers * overpartition_factor), min_chunk_size);
276 }
277
278 bool CollectionSetChooser::region_occupancy_low_enough_for_evac(size_t live_bytes) {
279 return live_bytes < mixed_gc_live_threshold_bytes();
280 }
281
282 bool CollectionSetChooser::should_add(HeapRegion* hr) const {
283 assert(hr->is_marked(), "pre-condition");
284 assert(!hr->is_young(), "should never consider young regions");
285 return !hr->is_pinned() &&
286 region_occupancy_low_enough_for_evac(hr->live_bytes()) &&
287 hr->rem_set()->is_complete();
|