void scanCard(size_t index, HeapRegion *r) { _cards_done++; DirtyCardToOopClosure* cl = r->new_dcto_closure(_oc, CardTableModRefBS::Precise, HeapRegionDCTOC::IntoCSFilterKind); // Set the "from" region in the closure. _oc->set_region(r); HeapWord* card_start = _bot_shared->address_for_index(index); HeapWord* card_end = card_start + G1BlockOffsetSharedArray::N_words; Space *sp = SharedHeap::heap()->space_containing(card_start); MemRegion sm_region; if (ParallelGCThreads > 0) { // first find the used area sm_region = sp->used_region_at_save_marks(); } else { // The closure is not idempotent. We shouldn't look at objects // allocated during the GC. sm_region = sp->used_region_at_save_marks(); } MemRegion mr = sm_region.intersection(MemRegion(card_start,card_end)); if (!mr.is_empty()) { cl->do_MemRegion(mr); } }
void scanCard(size_t index, HeapRegion *r) { // Stack allocate the DirtyCardToOopClosure instance HeapRegionDCTOC cl(_g1h, r, _oc, CardTableModRefBS::Precise); // Set the "from" region in the closure. _oc->set_region(r); MemRegion card_region(_bot_shared->address_for_index(index), G1BlockOffsetSharedArray::N_words); MemRegion pre_gc_allocated(r->bottom(), r->scan_top()); MemRegion mr = pre_gc_allocated.intersection(card_region); if (!mr.is_empty() && !_ct_bs->is_card_claimed(index)) { // We make the card as "claimed" lazily (so races are possible // but they're benign), which reduces the number of duplicate // scans (the rsets of the regions in the cset can intersect). _ct_bs->set_card_claimed(index); _cards_done++; cl.do_MemRegion(mr); } }