578 ct_bs->verify_dirty_region(mr);
579 }
580 }
581
582 class G1VerifyDirtyYoungListClosure : public HeapRegionClosure {
583 private:
584 G1HeapVerifier* _verifier;
585 public:
586 G1VerifyDirtyYoungListClosure(G1HeapVerifier* verifier) : HeapRegionClosure(), _verifier(verifier) { }
587 virtual bool doHeapRegion(HeapRegion* r) {
588 _verifier->verify_dirty_region(r);
589 return false;
590 }
591 };
592
593 void G1HeapVerifier::verify_dirty_young_regions() {
594 G1VerifyDirtyYoungListClosure cl(this);
595 _g1h->collection_set()->iterate(&cl);
596 }
597
598 bool G1HeapVerifier::verify_no_bits_over_tams(const char* bitmap_name, G1CMBitMapRO* bitmap,
599 HeapWord* tams, HeapWord* end) {
600 guarantee(tams <= end,
601 "tams: " PTR_FORMAT " end: " PTR_FORMAT, p2i(tams), p2i(end));
602 HeapWord* result = bitmap->getNextMarkedWordAddress(tams, end);
603 if (result < end) {
604 log_error(gc, verify)("## wrong marked address on %s bitmap: " PTR_FORMAT, bitmap_name, p2i(result));
605 log_error(gc, verify)("## %s tams: " PTR_FORMAT " end: " PTR_FORMAT, bitmap_name, p2i(tams), p2i(end));
606 return false;
607 }
608 return true;
609 }
610
611 bool G1HeapVerifier::verify_bitmaps(const char* caller, HeapRegion* hr) {
612 G1CMBitMapRO* prev_bitmap = _g1h->concurrent_mark()->prevMarkBitMap();
613 G1CMBitMapRO* next_bitmap = (G1CMBitMapRO*) _g1h->concurrent_mark()->nextMarkBitMap();
614
615 HeapWord* bottom = hr->bottom();
616 HeapWord* ptams = hr->prev_top_at_mark_start();
617 HeapWord* ntams = hr->next_top_at_mark_start();
618 HeapWord* end = hr->end();
619
620 bool res_p = verify_no_bits_over_tams("prev", prev_bitmap, ptams, end);
621
622 bool res_n = true;
623 // We reset mark_in_progress() before we reset _cmThread->in_progress() and in this window
624 // we do the clearing of the next bitmap concurrently. Thus, we can not verify the bitmap
625 // if we happen to be in that state.
626 if (_g1h->collector_state()->mark_in_progress() || !_g1h->_cmThread->in_progress()) {
627 res_n = verify_no_bits_over_tams("next", next_bitmap, ntams, end);
628 }
629 if (!res_p || !res_n) {
630 log_error(gc, verify)("#### Bitmap verification failed for " HR_FORMAT, HR_FORMAT_PARAMS(hr));
631 log_error(gc, verify)("#### Caller: %s", caller);
632 return false;
633 }
634 return true;
635 }
|
578 ct_bs->verify_dirty_region(mr);
579 }
580 }
581
582 class G1VerifyDirtyYoungListClosure : public HeapRegionClosure {
583 private:
584 G1HeapVerifier* _verifier;
585 public:
586 G1VerifyDirtyYoungListClosure(G1HeapVerifier* verifier) : HeapRegionClosure(), _verifier(verifier) { }
587 virtual bool doHeapRegion(HeapRegion* r) {
588 _verifier->verify_dirty_region(r);
589 return false;
590 }
591 };
592
593 void G1HeapVerifier::verify_dirty_young_regions() {
594 G1VerifyDirtyYoungListClosure cl(this);
595 _g1h->collection_set()->iterate(&cl);
596 }
597
598 bool G1HeapVerifier::verify_no_bits_over_tams(const char* bitmap_name, const G1CMBitMap* const bitmap,
599 HeapWord* tams, HeapWord* end) {
600 guarantee(tams <= end,
601 "tams: " PTR_FORMAT " end: " PTR_FORMAT, p2i(tams), p2i(end));
602 HeapWord* result = bitmap->get_next_marked_addr(tams, end);
603 if (result < end) {
604 log_error(gc, verify)("## wrong marked address on %s bitmap: " PTR_FORMAT, bitmap_name, p2i(result));
605 log_error(gc, verify)("## %s tams: " PTR_FORMAT " end: " PTR_FORMAT, bitmap_name, p2i(tams), p2i(end));
606 return false;
607 }
608 return true;
609 }
610
611 bool G1HeapVerifier::verify_bitmaps(const char* caller, HeapRegion* hr) {
612 const G1CMBitMap* const prev_bitmap = _g1h->concurrent_mark()->prevMarkBitMap();
613 const G1CMBitMap* const next_bitmap = _g1h->concurrent_mark()->nextMarkBitMap();
614
615 HeapWord* ptams = hr->prev_top_at_mark_start();
616 HeapWord* ntams = hr->next_top_at_mark_start();
617 HeapWord* end = hr->end();
618
619 bool res_p = verify_no_bits_over_tams("prev", prev_bitmap, ptams, end);
620
621 bool res_n = true;
622 // We reset mark_in_progress() before we reset _cmThread->in_progress() and in this window
623 // we do the clearing of the next bitmap concurrently. Thus, we can not verify the bitmap
624 // if we happen to be in that state.
625 if (_g1h->collector_state()->mark_in_progress() || !_g1h->_cmThread->in_progress()) {
626 res_n = verify_no_bits_over_tams("next", next_bitmap, ntams, end);
627 }
628 if (!res_p || !res_n) {
629 log_error(gc, verify)("#### Bitmap verification failed for " HR_FORMAT, HR_FORMAT_PARAMS(hr));
630 log_error(gc, verify)("#### Caller: %s", caller);
631 return false;
632 }
633 return true;
634 }
|