268
269 class G1CreateCardLiveDataTask: public AbstractGangTask {
270 // Aggregate the counting data that was constructed concurrently
271 // with marking.
272 class G1CreateLiveDataClosure : public HeapRegionClosure {
273 G1CardLiveDataHelper _helper;
274
275 G1CMBitMap* _mark_bitmap;
276
277 G1ConcurrentMark* _cm;
278 public:
279 G1CreateLiveDataClosure(G1CollectedHeap* g1h,
280 G1ConcurrentMark* cm,
281 G1CMBitMap* mark_bitmap,
282 G1CardLiveData* live_data) :
283 HeapRegionClosure(),
284 _helper(live_data, g1h->reserved_region().start()),
285 _mark_bitmap(mark_bitmap),
286 _cm(cm) { }
287
288 bool doHeapRegion(HeapRegion* hr) {
289 size_t marked_bytes = _helper.mark_marked_during_marking(_mark_bitmap, hr);
290 if (marked_bytes > 0) {
291 hr->add_to_marked_bytes(marked_bytes);
292 }
293
294 return (_cm->do_yield_check() && _cm->has_aborted());
295 }
296 };
297
298 G1ConcurrentMark* _cm;
299 G1CardLiveData* _live_data;
300 HeapRegionClaimer _hr_claimer;
301
302 public:
303 G1CreateCardLiveDataTask(G1CMBitMap* bitmap,
304 G1CardLiveData* live_data,
305 uint n_workers) :
306 AbstractGangTask("G1 Create Live Data"),
307 _live_data(live_data),
308 _hr_claimer(n_workers) {
335 // (which contains the implicitly live objects) in the
336 // card liveness bitmap. Also sets the bit for each region
337 // containing live data, in the region liveness bitmap.
338 class G1FinalizeCardLiveDataClosure: public HeapRegionClosure {
339 private:
340 G1CardLiveDataHelper _helper;
341
342 uint _gc_timestamp_at_create;
343
344 bool has_been_reclaimed(HeapRegion* hr) const {
345 return hr->get_gc_time_stamp() > _gc_timestamp_at_create;
346 }
347 public:
348 G1FinalizeCardLiveDataClosure(G1CollectedHeap* g1h,
349 G1CMBitMap* bitmap,
350 G1CardLiveData* live_data) :
351 HeapRegionClosure(),
352 _helper(live_data, g1h->reserved_region().start()),
353 _gc_timestamp_at_create(live_data->gc_timestamp_at_create()) { }
354
355 bool doHeapRegion(HeapRegion* hr) {
356 if (has_been_reclaimed(hr)) {
357 _helper.reset_live_data(hr);
358 }
359 bool allocated_since_marking = _helper.mark_allocated_since_marking(hr);
360 if (allocated_since_marking || hr->next_marked_bytes() > 0) {
361 _helper.set_bit_for_region(hr);
362 }
363 return false;
364 }
365 };
366
367 G1CMBitMap* _bitmap;
368
369 G1CardLiveData* _live_data;
370
371 HeapRegionClaimer _hr_claimer;
372
373 public:
374 G1FinalizeCardLiveDataTask(G1CMBitMap* bitmap, G1CardLiveData* live_data, uint n_workers) :
375 AbstractGangTask("G1 Finalize Card Live Data"),
461 bool allocated_since_marking = _helper.mark_allocated_since_marking(hr);
462 if (allocated_since_marking || bytes_marked > 0) {
463 _helper.set_bit_for_region(hr);
464 }
465 return bytes_marked;
466 }
467 public:
468 G1VerifyCardLiveDataClosure(G1CollectedHeap* g1h,
469 G1CMBitMap* mark_bitmap,
470 G1CardLiveData* act_live_data,
471 G1CardLiveData* exp_live_data) :
472 _g1h(g1h),
473 _mark_bitmap(mark_bitmap),
474 _helper(exp_live_data, g1h->reserved_region().start()),
475 _act_live_data(act_live_data),
476 _exp_live_data(exp_live_data),
477 _failures(0) { }
478
479 int failures() const { return _failures; }
480
481 bool doHeapRegion(HeapRegion* hr) {
482 int failures = 0;
483
484 // Walk the marking bitmap for this region and set the corresponding bits
485 // in the expected region and card bitmaps.
486 size_t exp_marked_bytes = create_live_data_count(hr);
487 size_t act_marked_bytes = hr->next_marked_bytes();
488 // Verify the marked bytes for this region.
489
490 if (exp_marked_bytes != act_marked_bytes) {
491 log_error(gc)("Expected marked bytes " SIZE_FORMAT " != actual marked bytes " SIZE_FORMAT " in region %u", exp_marked_bytes, act_marked_bytes, hr->hrm_index());
492 failures += 1;
493 } else if (exp_marked_bytes > HeapRegion::GrainBytes) {
494 log_error(gc)("Expected marked bytes " SIZE_FORMAT " larger than possible " SIZE_FORMAT " in region %u", exp_marked_bytes, HeapRegion::GrainBytes, hr->hrm_index());
495 failures += 1;
496 }
497
498 // Verify the bit, for this region, in the actual and expected
499 // (which was just calculated) region bit maps.
500 uint index = hr->hrm_index();
501
|
268
269 class G1CreateCardLiveDataTask: public AbstractGangTask {
270 // Aggregate the counting data that was constructed concurrently
271 // with marking.
272 class G1CreateLiveDataClosure : public HeapRegionClosure {
273 G1CardLiveDataHelper _helper;
274
275 G1CMBitMap* _mark_bitmap;
276
277 G1ConcurrentMark* _cm;
278 public:
279 G1CreateLiveDataClosure(G1CollectedHeap* g1h,
280 G1ConcurrentMark* cm,
281 G1CMBitMap* mark_bitmap,
282 G1CardLiveData* live_data) :
283 HeapRegionClosure(),
284 _helper(live_data, g1h->reserved_region().start()),
285 _mark_bitmap(mark_bitmap),
286 _cm(cm) { }
287
288 bool do_heap_region(HeapRegion* hr) {
289 size_t marked_bytes = _helper.mark_marked_during_marking(_mark_bitmap, hr);
290 if (marked_bytes > 0) {
291 hr->add_to_marked_bytes(marked_bytes);
292 }
293
294 return (_cm->do_yield_check() && _cm->has_aborted());
295 }
296 };
297
298 G1ConcurrentMark* _cm;
299 G1CardLiveData* _live_data;
300 HeapRegionClaimer _hr_claimer;
301
302 public:
303 G1CreateCardLiveDataTask(G1CMBitMap* bitmap,
304 G1CardLiveData* live_data,
305 uint n_workers) :
306 AbstractGangTask("G1 Create Live Data"),
307 _live_data(live_data),
308 _hr_claimer(n_workers) {
335 // (which contains the implicitly live objects) in the
336 // card liveness bitmap. Also sets the bit for each region
337 // containing live data, in the region liveness bitmap.
338 class G1FinalizeCardLiveDataClosure: public HeapRegionClosure {
339 private:
340 G1CardLiveDataHelper _helper;
341
342 uint _gc_timestamp_at_create;
343
344 bool has_been_reclaimed(HeapRegion* hr) const {
345 return hr->get_gc_time_stamp() > _gc_timestamp_at_create;
346 }
347 public:
348 G1FinalizeCardLiveDataClosure(G1CollectedHeap* g1h,
349 G1CMBitMap* bitmap,
350 G1CardLiveData* live_data) :
351 HeapRegionClosure(),
352 _helper(live_data, g1h->reserved_region().start()),
353 _gc_timestamp_at_create(live_data->gc_timestamp_at_create()) { }
354
355 bool do_heap_region(HeapRegion* hr) {
356 if (has_been_reclaimed(hr)) {
357 _helper.reset_live_data(hr);
358 }
359 bool allocated_since_marking = _helper.mark_allocated_since_marking(hr);
360 if (allocated_since_marking || hr->next_marked_bytes() > 0) {
361 _helper.set_bit_for_region(hr);
362 }
363 return false;
364 }
365 };
366
367 G1CMBitMap* _bitmap;
368
369 G1CardLiveData* _live_data;
370
371 HeapRegionClaimer _hr_claimer;
372
373 public:
374 G1FinalizeCardLiveDataTask(G1CMBitMap* bitmap, G1CardLiveData* live_data, uint n_workers) :
375 AbstractGangTask("G1 Finalize Card Live Data"),
461 bool allocated_since_marking = _helper.mark_allocated_since_marking(hr);
462 if (allocated_since_marking || bytes_marked > 0) {
463 _helper.set_bit_for_region(hr);
464 }
465 return bytes_marked;
466 }
467 public:
468 G1VerifyCardLiveDataClosure(G1CollectedHeap* g1h,
469 G1CMBitMap* mark_bitmap,
470 G1CardLiveData* act_live_data,
471 G1CardLiveData* exp_live_data) :
472 _g1h(g1h),
473 _mark_bitmap(mark_bitmap),
474 _helper(exp_live_data, g1h->reserved_region().start()),
475 _act_live_data(act_live_data),
476 _exp_live_data(exp_live_data),
477 _failures(0) { }
478
479 int failures() const { return _failures; }
480
481 bool do_heap_region(HeapRegion* hr) {
482 int failures = 0;
483
484 // Walk the marking bitmap for this region and set the corresponding bits
485 // in the expected region and card bitmaps.
486 size_t exp_marked_bytes = create_live_data_count(hr);
487 size_t act_marked_bytes = hr->next_marked_bytes();
488 // Verify the marked bytes for this region.
489
490 if (exp_marked_bytes != act_marked_bytes) {
491 log_error(gc)("Expected marked bytes " SIZE_FORMAT " != actual marked bytes " SIZE_FORMAT " in region %u", exp_marked_bytes, act_marked_bytes, hr->hrm_index());
492 failures += 1;
493 } else if (exp_marked_bytes > HeapRegion::GrainBytes) {
494 log_error(gc)("Expected marked bytes " SIZE_FORMAT " larger than possible " SIZE_FORMAT " in region %u", exp_marked_bytes, HeapRegion::GrainBytes, hr->hrm_index());
495 failures += 1;
496 }
497
498 // Verify the bit, for this region, in the actual and expected
499 // (which was just calculated) region bit maps.
500 uint index = hr->hrm_index();
501
|