92 _oc(oc),
93 _code_root_cl(code_root_cl),
94 _strong_code_root_scan_time_sec(0.0),
95 _cards(0),
96 _cards_done(0),
97 _worker_i(worker_i),
98 _try_claimed(false) {
99 _g1h = G1CollectedHeap::heap();
100 _bot = _g1h->bot();
101 _ct_bs = _g1h->g1_barrier_set();
102 _block_size = MAX2<size_t>(G1RSetScanBlockSize, 1);
103 }
104
105 void ScanRSClosure::scanCard(size_t index, HeapRegion *r) {
106 // Stack allocate the DirtyCardToOopClosure instance
107 HeapRegionDCTOC cl(_g1h, r, _oc,
108 CardTableModRefBS::Precise);
109
110 // Set the "from" region in the closure.
111 _oc->set_region(r);
112 MemRegion card_region(_bot->address_for_index(index), G1BlockOffsetTable::N_words);
113 MemRegion pre_gc_allocated(r->bottom(), r->scan_top());
114 MemRegion mr = pre_gc_allocated.intersection(card_region);
115 if (!mr.is_empty() && !_ct_bs->is_card_claimed(index)) {
116 // We make the card as "claimed" lazily (so races are possible
117 // but they're benign), which reduces the number of duplicate
118 // scans (the rsets of the regions in the cset can intersect).
119 _ct_bs->set_card_claimed(index);
120 _cards_done++;
121 cl.do_MemRegion(mr);
122 }
123 }
124
125 void ScanRSClosure::scan_strong_code_roots(HeapRegion* r) {
126 double scan_start = os::elapsedTime();
127 r->strong_code_roots_do(_code_root_cl);
128 _strong_code_root_scan_time_sec += (os::elapsedTime() - scan_start);
129 }
130
131 bool ScanRSClosure::doHeapRegion(HeapRegion* r) {
132 assert(r->in_collection_set(), "should only be called on elements of CS.");
|
92 _oc(oc),
93 _code_root_cl(code_root_cl),
94 _strong_code_root_scan_time_sec(0.0),
95 _cards(0),
96 _cards_done(0),
97 _worker_i(worker_i),
98 _try_claimed(false) {
99 _g1h = G1CollectedHeap::heap();
100 _bot = _g1h->bot();
101 _ct_bs = _g1h->g1_barrier_set();
102 _block_size = MAX2<size_t>(G1RSetScanBlockSize, 1);
103 }
104
105 void ScanRSClosure::scanCard(size_t index, HeapRegion *r) {
106 // Stack allocate the DirtyCardToOopClosure instance
107 HeapRegionDCTOC cl(_g1h, r, _oc,
108 CardTableModRefBS::Precise);
109
110 // Set the "from" region in the closure.
111 _oc->set_region(r);
112 MemRegion card_region(_bot->address_for_index(index), BOTConstants::N_words);
113 MemRegion pre_gc_allocated(r->bottom(), r->scan_top());
114 MemRegion mr = pre_gc_allocated.intersection(card_region);
115 if (!mr.is_empty() && !_ct_bs->is_card_claimed(index)) {
116 // We make the card as "claimed" lazily (so races are possible
117 // but they're benign), which reduces the number of duplicate
118 // scans (the rsets of the regions in the cset can intersect).
119 _ct_bs->set_card_claimed(index);
120 _cards_done++;
121 cl.do_MemRegion(mr);
122 }
123 }
124
125 void ScanRSClosure::scan_strong_code_roots(HeapRegion* r) {
126 double scan_start = os::elapsedTime();
127 r->strong_code_roots_do(_code_root_cl);
128 _strong_code_root_scan_time_sec += (os::elapsedTime() - scan_start);
129 }
130
131 bool ScanRSClosure::doHeapRegion(HeapRegion* r) {
132 assert(r->in_collection_set(), "should only be called on elements of CS.");
|