522 // There are no other valid region types. Check for one invalid
523 // one we can identify: pinned without old or humongous set.
524 assert(!hr->is_pinned(), "Heap region %u is pinned but not old (archive) or humongous.", hr->hrm_index());
525 ShouldNotReachHere();
526 }
527 return false;
528 }
529
530 void verify_counts(HeapRegionSet* old_set, HeapRegionSet* archive_set, HeapRegionSet* humongous_set, HeapRegionManager* free_list) {
531 guarantee(old_set->length() == _old_count, "Old set count mismatch. Expected %u, actual %u.", old_set->length(), _old_count);
532 guarantee(archive_set->length() == _archive_count, "Archive set count mismatch. Expected %u, actual %u.", archive_set->length(), _archive_count);
533 guarantee(humongous_set->length() == _humongous_count, "Hum set count mismatch. Expected %u, actual %u.", humongous_set->length(), _humongous_count);
534 guarantee(free_list->num_free_regions() == _free_count, "Free list count mismatch. Expected %u, actual %u.", free_list->num_free_regions(), _free_count);
535 }
536 };
537
538 void G1HeapVerifier::verify_region_sets() {
539 assert_heap_locked_or_at_safepoint(true /* should_be_vm_thread */);
540
541 // First, check the explicit lists.
542 _g1h->_hrm.verify();
543
544 // Finally, make sure that the region accounting in the lists is
545 // consistent with what we see in the heap.
546
547 VerifyRegionListsClosure cl(&_g1h->_old_set, &_g1h->_archive_set, &_g1h->_humongous_set, &_g1h->_hrm);
548 _g1h->heap_region_iterate(&cl);
549 cl.verify_counts(&_g1h->_old_set, &_g1h->_archive_set, &_g1h->_humongous_set, &_g1h->_hrm);
550 }
551
552 void G1HeapVerifier::prepare_for_verify() {
553 if (SafepointSynchronize::is_at_safepoint() || ! UseTLAB) {
554 _g1h->ensure_parsability(false);
555 }
556 }
557
558 double G1HeapVerifier::verify(G1VerifyType type, VerifyOption vo, const char* msg) {
559 double verify_time_ms = 0.0;
560
561 if (should_verify(type) && _g1h->total_collections() >= VerifyGCStartAt) {
562 double verify_start = os::elapsedTime();
563 HandleMark hm; // Discard invalid handles created during verification
564 prepare_for_verify();
565 Universe::verify(vo, msg);
566 verify_time_ms = (os::elapsedTime() - verify_start) * 1000;
567 }
568
569 return verify_time_ms;
770 hr->is_young(), cset_state.value(), i);
771 _failures = true;
772 return true;
773 }
774 if (hr->is_old() != (cset_state.is_old())) {
775 log_error(gc, verify)("## is_old %d / cset state " CSETSTATE_FORMAT " inconsistency for region %u",
776 hr->is_old(), cset_state.value(), i);
777 _failures = true;
778 return true;
779 }
780 }
781 }
782 return false;
783 }
784
785 bool failures() const { return _failures; }
786 };
787
788 bool G1HeapVerifier::check_cset_fast_test() {
789 G1CheckCSetFastTableClosure cl;
790 _g1h->_hrm.iterate(&cl);
791 return !cl.failures();
792 }
793 #endif // PRODUCT
|
522 // There are no other valid region types. Check for one invalid
523 // one we can identify: pinned without old or humongous set.
524 assert(!hr->is_pinned(), "Heap region %u is pinned but not old (archive) or humongous.", hr->hrm_index());
525 ShouldNotReachHere();
526 }
527 return false;
528 }
529
530 void verify_counts(HeapRegionSet* old_set, HeapRegionSet* archive_set, HeapRegionSet* humongous_set, HeapRegionManager* free_list) {
531 guarantee(old_set->length() == _old_count, "Old set count mismatch. Expected %u, actual %u.", old_set->length(), _old_count);
532 guarantee(archive_set->length() == _archive_count, "Archive set count mismatch. Expected %u, actual %u.", archive_set->length(), _archive_count);
533 guarantee(humongous_set->length() == _humongous_count, "Hum set count mismatch. Expected %u, actual %u.", humongous_set->length(), _humongous_count);
534 guarantee(free_list->num_free_regions() == _free_count, "Free list count mismatch. Expected %u, actual %u.", free_list->num_free_regions(), _free_count);
535 }
536 };
537
538 void G1HeapVerifier::verify_region_sets() {
539 assert_heap_locked_or_at_safepoint(true /* should_be_vm_thread */);
540
541 // First, check the explicit lists.
542 _g1h->_hrm->verify();
543
544 // Finally, make sure that the region accounting in the lists is
545 // consistent with what we see in the heap.
546
547 VerifyRegionListsClosure cl(&_g1h->_old_set, &_g1h->_archive_set, &_g1h->_humongous_set, _g1h->_hrm);
548 _g1h->heap_region_iterate(&cl);
549 cl.verify_counts(&_g1h->_old_set, &_g1h->_archive_set, &_g1h->_humongous_set, _g1h->_hrm);
550 }
551
552 void G1HeapVerifier::prepare_for_verify() {
553 if (SafepointSynchronize::is_at_safepoint() || ! UseTLAB) {
554 _g1h->ensure_parsability(false);
555 }
556 }
557
558 double G1HeapVerifier::verify(G1VerifyType type, VerifyOption vo, const char* msg) {
559 double verify_time_ms = 0.0;
560
561 if (should_verify(type) && _g1h->total_collections() >= VerifyGCStartAt) {
562 double verify_start = os::elapsedTime();
563 HandleMark hm; // Discard invalid handles created during verification
564 prepare_for_verify();
565 Universe::verify(vo, msg);
566 verify_time_ms = (os::elapsedTime() - verify_start) * 1000;
567 }
568
569 return verify_time_ms;
770 hr->is_young(), cset_state.value(), i);
771 _failures = true;
772 return true;
773 }
774 if (hr->is_old() != (cset_state.is_old())) {
775 log_error(gc, verify)("## is_old %d / cset state " CSETSTATE_FORMAT " inconsistency for region %u",
776 hr->is_old(), cset_state.value(), i);
777 _failures = true;
778 return true;
779 }
780 }
781 }
782 return false;
783 }
784
785 bool failures() const { return _failures; }
786 };
787
788 bool G1HeapVerifier::check_cset_fast_test() {
789 G1CheckCSetFastTableClosure cl;
790 _g1h->_hrm->iterate(&cl);
791 return !cl.failures();
792 }
793 #endif // PRODUCT
|