634 HeapWord* result = bitmap->get_next_marked_addr(tams, end);
635 if (result < end) {
636 log_error(gc, verify)("## wrong marked address on %s bitmap: " PTR_FORMAT, bitmap_name, p2i(result));
637 log_error(gc, verify)("## %s tams: " PTR_FORMAT " end: " PTR_FORMAT, bitmap_name, p2i(tams), p2i(end));
638 return false;
639 }
640 return true;
641 }
642
643 bool G1HeapVerifier::verify_bitmaps(const char* caller, HeapRegion* hr) {
644 const G1CMBitMap* const prev_bitmap = _g1h->concurrent_mark()->prev_mark_bitmap();
645 const G1CMBitMap* const next_bitmap = _g1h->concurrent_mark()->next_mark_bitmap();
646
647 HeapWord* ptams = hr->prev_top_at_mark_start();
648 HeapWord* ntams = hr->next_top_at_mark_start();
649 HeapWord* end = hr->end();
650
651 bool res_p = verify_no_bits_over_tams("prev", prev_bitmap, ptams, end);
652
653 bool res_n = true;
654 // We reset mark_or_rebuild_in_progress() before we reset _cmThread->in_progress() and in this window
655 // we do the clearing of the next bitmap concurrently. Thus, we can not verify the bitmap
656 // if we happen to be in that state.
657 if (_g1h->collector_state()->mark_or_rebuild_in_progress() || !_g1h->_cmThread->in_progress()) {
658 res_n = verify_no_bits_over_tams("next", next_bitmap, ntams, end);
659 }
660 if (!res_p || !res_n) {
661 log_error(gc, verify)("#### Bitmap verification failed for " HR_FORMAT, HR_FORMAT_PARAMS(hr));
662 log_error(gc, verify)("#### Caller: %s", caller);
663 return false;
664 }
665 return true;
666 }
667
668 void G1HeapVerifier::check_bitmaps(const char* caller, HeapRegion* hr) {
669 if (!G1VerifyBitmaps) return;
670
671 guarantee(verify_bitmaps(caller, hr), "bitmap verification");
672 }
673
674 class G1VerifyBitmapClosure : public HeapRegionClosure {
675 private:
676 const char* _caller;
677 G1HeapVerifier* _verifier;
678 bool _failures;
679
680 public:
681 G1VerifyBitmapClosure(const char* caller, G1HeapVerifier* verifier) :
682 _caller(caller), _verifier(verifier), _failures(false) { }
683
684 bool failures() { return _failures; }
685
686 virtual bool do_heap_region(HeapRegion* hr) {
687 bool result = _verifier->verify_bitmaps(_caller, hr);
688 if (!result) {
689 _failures = true;
690 }
691 return false;
692 }
693 };
694
695 void G1HeapVerifier::check_bitmaps(const char* caller) {
696 if (!G1VerifyBitmaps) return;
697
698 G1VerifyBitmapClosure cl(caller, this);
699 _g1h->heap_region_iterate(&cl);
700 guarantee(!cl.failures(), "bitmap verification");
701 }
702
703 class G1CheckCSetFastTableClosure : public HeapRegionClosure {
704 private:
705 bool _failures;
706 public:
707 G1CheckCSetFastTableClosure() : HeapRegionClosure(), _failures(false) { }
708
709 virtual bool do_heap_region(HeapRegion* hr) {
710 uint i = hr->hrm_index();
711 InCSetState cset_state = (InCSetState) G1CollectedHeap::heap()->_in_cset_fast_test.get_by_index(i);
712 if (hr->is_humongous()) {
713 if (hr->in_collection_set()) {
714 log_error(gc, verify)("## humongous region %u in CSet", i);
715 _failures = true;
716 return true;
|
634 HeapWord* result = bitmap->get_next_marked_addr(tams, end);
635 if (result < end) {
636 log_error(gc, verify)("## wrong marked address on %s bitmap: " PTR_FORMAT, bitmap_name, p2i(result));
637 log_error(gc, verify)("## %s tams: " PTR_FORMAT " end: " PTR_FORMAT, bitmap_name, p2i(tams), p2i(end));
638 return false;
639 }
640 return true;
641 }
642
643 bool G1HeapVerifier::verify_bitmaps(const char* caller, HeapRegion* hr) {
644 const G1CMBitMap* const prev_bitmap = _g1h->concurrent_mark()->prev_mark_bitmap();
645 const G1CMBitMap* const next_bitmap = _g1h->concurrent_mark()->next_mark_bitmap();
646
647 HeapWord* ptams = hr->prev_top_at_mark_start();
648 HeapWord* ntams = hr->next_top_at_mark_start();
649 HeapWord* end = hr->end();
650
651 bool res_p = verify_no_bits_over_tams("prev", prev_bitmap, ptams, end);
652
653 bool res_n = true;
654 // We cannot verify the next bitmap while we are about to clear it.
655 if (!_g1h->collector_state()->clearing_next_bitmap()) {
656 res_n = verify_no_bits_over_tams("next", next_bitmap, ntams, end);
657 }
658 if (!res_p || !res_n) {
659 log_error(gc, verify)("#### Bitmap verification failed for " HR_FORMAT, HR_FORMAT_PARAMS(hr));
660 log_error(gc, verify)("#### Caller: %s", caller);
661 return false;
662 }
663 return true;
664 }
665
666 void G1HeapVerifier::check_bitmaps(const char* caller, HeapRegion* hr) {
667 if (!G1VerifyBitmaps) {
668 return;
669 }
670
671 guarantee(verify_bitmaps(caller, hr), "bitmap verification");
672 }
673
674 class G1VerifyBitmapClosure : public HeapRegionClosure {
675 private:
676 const char* _caller;
677 G1HeapVerifier* _verifier;
678 bool _failures;
679
680 public:
681 G1VerifyBitmapClosure(const char* caller, G1HeapVerifier* verifier) :
682 _caller(caller), _verifier(verifier), _failures(false) { }
683
684 bool failures() { return _failures; }
685
686 virtual bool do_heap_region(HeapRegion* hr) {
687 bool result = _verifier->verify_bitmaps(_caller, hr);
688 if (!result) {
689 _failures = true;
690 }
691 return false;
692 }
693 };
694
695 void G1HeapVerifier::check_bitmaps(const char* caller) {
696 if (!G1VerifyBitmaps) {
697 return;
698 }
699
700 G1VerifyBitmapClosure cl(caller, this);
701 _g1h->heap_region_iterate(&cl);
702 guarantee(!cl.failures(), "bitmap verification");
703 }
704
705 class G1CheckCSetFastTableClosure : public HeapRegionClosure {
706 private:
707 bool _failures;
708 public:
709 G1CheckCSetFastTableClosure() : HeapRegionClosure(), _failures(false) { }
710
711 virtual bool do_heap_region(HeapRegion* hr) {
712 uint i = hr->hrm_index();
713 InCSetState cset_state = (InCSetState) G1CollectedHeap::heap()->_in_cset_fast_test.get_by_index(i);
714 if (hr->is_humongous()) {
715 if (hr->in_collection_set()) {
716 log_error(gc, verify)("## humongous region %u in CSet", i);
717 _failures = true;
718 return true;
|