377
378 assert(_g1h->region_at(region_idx_for_card)->is_in_reserved(card_start),
379 "Card start " PTR_FORMAT " to scan outside of region %u", p2i(card_start), _g1h->region_at(region_idx_for_card)->hrm_index());
380 HeapWord* const top = _scan_state->scan_top(region_idx_for_card);
381 if (card_start >= top) {
382 continue;
383 }
384
385 // We claim lazily (so races are possible but they're benign), which reduces the
386 // number of duplicate scans (the rsets of the regions in the cset can intersect).
387 // Claim the card after checking bounds above: the remembered set may contain
388 // random cards into current survivor, and we would then have an incorrectly
389 // claimed card in survivor space. Card table clear does not reset the card table
390 // of survivor space regions.
391 claim_card(card_index, region_idx_for_card);
392
393 MemRegion const mr(card_start, MIN2(card_start + BOTConstants::N_words, top));
394
395 scan_card(mr, region_idx_for_card);
396 }
397 event.commit(GCId::current(), _worker_i, G1GCPhaseTimes::phase_name(G1GCPhaseTimes::ScanRS));
398 }
399
400 void G1ScanRSForRegionClosure::scan_strong_code_roots(HeapRegion* r) {
401 EventGCPhaseParallel event;
402 r->strong_code_roots_do(_pss->closures()->weak_codeblobs());
403 event.commit(GCId::current(), _worker_i, G1GCPhaseTimes::phase_name(G1GCPhaseTimes::CodeRoots));
404 }
405
406 bool G1ScanRSForRegionClosure::do_heap_region(HeapRegion* r) {
407 assert(r->in_collection_set(),
408 "Should only be called on elements of the collection set but region %u is not.",
409 r->hrm_index());
410 uint const region_idx = r->hrm_index();
411
412 // Do an early out if we know we are complete.
413 if (_scan_state->iter_is_complete(region_idx)) {
414 return false;
415 }
416
417 {
418 G1EvacPhaseWithTrimTimeTracker timer(_pss, _rem_set_root_scan_time, _rem_set_trim_partially_time);
419 scan_rem_set_roots(r);
420 }
421
422 if (_scan_state->set_iter_complete(region_idx)) {
423 G1EvacPhaseWithTrimTimeTracker timer(_pss, _strong_code_root_scan_time, _strong_code_trim_partially_time);
|
377
378 assert(_g1h->region_at(region_idx_for_card)->is_in_reserved(card_start),
379 "Card start " PTR_FORMAT " to scan outside of region %u", p2i(card_start), _g1h->region_at(region_idx_for_card)->hrm_index());
380 HeapWord* const top = _scan_state->scan_top(region_idx_for_card);
381 if (card_start >= top) {
382 continue;
383 }
384
385 // We claim lazily (so races are possible but they're benign), which reduces the
386 // number of duplicate scans (the rsets of the regions in the cset can intersect).
387 // Claim the card after checking bounds above: the remembered set may contain
388 // random cards into current survivor, and we would then have an incorrectly
389 // claimed card in survivor space. Card table clear does not reset the card table
390 // of survivor space regions.
391 claim_card(card_index, region_idx_for_card);
392
393 MemRegion const mr(card_start, MIN2(card_start + BOTConstants::N_words, top));
394
395 scan_card(mr, region_idx_for_card);
396 }
397 JFR_ONLY(event.commit(GCId::current(), _worker_i, G1GCPhaseTimes::phase_name(G1GCPhaseTimes::ScanRS));)
398 }
399
400 void G1ScanRSForRegionClosure::scan_strong_code_roots(HeapRegion* r) {
401 JFR_ONLY(EventGCPhaseParallel event;)
402 r->strong_code_roots_do(_pss->closures()->weak_codeblobs());
403 JFR_ONLY(event.commit(GCId::current(), _worker_i, G1GCPhaseTimes::phase_name(G1GCPhaseTimes::CodeRoots));)
404 }
405
406 bool G1ScanRSForRegionClosure::do_heap_region(HeapRegion* r) {
407 assert(r->in_collection_set(),
408 "Should only be called on elements of the collection set but region %u is not.",
409 r->hrm_index());
410 uint const region_idx = r->hrm_index();
411
412 // Do an early out if we know we are complete.
413 if (_scan_state->iter_is_complete(region_idx)) {
414 return false;
415 }
416
417 {
418 G1EvacPhaseWithTrimTimeTracker timer(_pss, _rem_set_root_scan_time, _rem_set_trim_partially_time);
419 scan_rem_set_roots(r);
420 }
421
422 if (_scan_state->set_iter_complete(region_idx)) {
423 G1EvacPhaseWithTrimTimeTracker timer(_pss, _strong_code_root_scan_time, _strong_code_trim_partially_time);
|