226
227 // The current position within the remembered set of the given region.
228 inline size_t iter_claimed(uint region) const {
229 assert(region < _max_regions, "Tried to access invalid region %u", region);
230 return _iter_claims[region];
231 }
232
233 // Claim the next block of cards within the remembered set of the region with
234 // step size.
235 inline size_t iter_claimed_next(uint region, size_t step) {
236 return Atomic::add(step, &_iter_claims[region]) - step;
237 }
238
239 void add_dirty_region(uint region) {
240 if (_in_dirty_region_buffer[region] == Dirty) {
241 return;
242 }
243
244 bool marked_as_dirty = Atomic::cmpxchg(Dirty, &_in_dirty_region_buffer[region], Clean) == Clean;
245 if (marked_as_dirty) {
246 size_t allocated = Atomic::add(1, &_cur_dirty_region) - 1;
247 _dirty_region_buffer[allocated] = region;
248 }
249 }
250
251 HeapWord* scan_top(uint region_idx) const {
252 return _scan_top[region_idx];
253 }
254
255 // Clear the card table of "dirty" regions.
256 void clear_card_table(WorkGang* workers) {
257 if (_cur_dirty_region == 0) {
258 return;
259 }
260
261 size_t const num_chunks = align_up(_cur_dirty_region * HeapRegion::CardsPerRegion, G1ClearCardTableTask::chunk_size()) / G1ClearCardTableTask::chunk_size();
262 uint const num_workers = (uint)MIN2(num_chunks, (size_t)workers->active_workers());
263 size_t const chunk_length = G1ClearCardTableTask::chunk_size() / HeapRegion::CardsPerRegion;
264
265 // Iterate over the dirty cards region list.
266 G1ClearCardTableTask cl(G1CollectedHeap::heap(), _dirty_region_buffer, _cur_dirty_region, chunk_length);
|
226
227 // The current position within the remembered set of the given region.
228 inline size_t iter_claimed(uint region) const {
229 assert(region < _max_regions, "Tried to access invalid region %u", region);
230 return _iter_claims[region];
231 }
232
233 // Claim the next block of cards within the remembered set of the region with
234 // step size.
235 inline size_t iter_claimed_next(uint region, size_t step) {
236 return Atomic::add(step, &_iter_claims[region]) - step;
237 }
238
239 void add_dirty_region(uint region) {
240 if (_in_dirty_region_buffer[region] == Dirty) {
241 return;
242 }
243
244 bool marked_as_dirty = Atomic::cmpxchg(Dirty, &_in_dirty_region_buffer[region], Clean) == Clean;
245 if (marked_as_dirty) {
246 size_t allocated = Atomic::add(1u, &_cur_dirty_region) - 1;
247 _dirty_region_buffer[allocated] = region;
248 }
249 }
250
251 HeapWord* scan_top(uint region_idx) const {
252 return _scan_top[region_idx];
253 }
254
255 // Clear the card table of "dirty" regions.
256 void clear_card_table(WorkGang* workers) {
257 if (_cur_dirty_region == 0) {
258 return;
259 }
260
261 size_t const num_chunks = align_up(_cur_dirty_region * HeapRegion::CardsPerRegion, G1ClearCardTableTask::chunk_size()) / G1ClearCardTableTask::chunk_size();
262 uint const num_workers = (uint)MIN2(num_chunks, (size_t)workers->active_workers());
263 size_t const chunk_length = G1ClearCardTableTask::chunk_size() / HeapRegion::CardsPerRegion;
264
265 // Iterate over the dirty cards region list.
266 G1ClearCardTableTask cl(G1CollectedHeap::heap(), _dirty_region_buffer, _cur_dirty_region, chunk_length);
|