518 verify_time_ms = (os::elapsedTime() - verify_start) * 1000;
519 }
520
521 return verify_time_ms;
522 }
523
524 void G1HeapVerifier::verify_before_gc() {
525 double verify_time_ms = verify(VerifyBeforeGC, "Before GC");
526 _g1h->g1_policy()->phase_times()->record_verify_before_time_ms(verify_time_ms);
527 }
528
529 void G1HeapVerifier::verify_after_gc() {
530 double verify_time_ms = verify(VerifyAfterGC, "After GC");
531 _g1h->g1_policy()->phase_times()->record_verify_after_time_ms(verify_time_ms);
532 }
533
534
535 #ifndef PRODUCT
536 class G1VerifyCardTableCleanup: public HeapRegionClosure {
537 G1HeapVerifier* _verifier;
538 G1SATBCardTableModRefBS* _ct_bs;
539 public:
540 G1VerifyCardTableCleanup(G1HeapVerifier* verifier, G1SATBCardTableModRefBS* ct_bs)
541 : _verifier(verifier), _ct_bs(ct_bs) { }
542 virtual bool doHeapRegion(HeapRegion* r) {
543 if (r->is_survivor()) {
544 _verifier->verify_dirty_region(r);
545 } else {
546 _verifier->verify_not_dirty_region(r);
547 }
548 return false;
549 }
550 };
551
552 void G1HeapVerifier::verify_card_table_cleanup() {
553 if (G1VerifyCTCleanup || VerifyAfterGC) {
554 G1VerifyCardTableCleanup cleanup_verifier(this, _g1h->g1_barrier_set());
555 _g1h->heap_region_iterate(&cleanup_verifier);
556 }
557 }
558
559 void G1HeapVerifier::verify_not_dirty_region(HeapRegion* hr) {
560 // All of the region should be clean.
561 G1SATBCardTableModRefBS* ct_bs = _g1h->g1_barrier_set();
562 MemRegion mr(hr->bottom(), hr->end());
563 ct_bs->verify_not_dirty_region(mr);
564 }
565
566 void G1HeapVerifier::verify_dirty_region(HeapRegion* hr) {
567 // We cannot guarantee that [bottom(),end()] is dirty. Threads
568 // dirty allocated blocks as they allocate them. The thread that
569 // retires each region and replaces it with a new one will do a
570 // maximal allocation to fill in [pre_dummy_top(),end()] but will
571 // not dirty that area (one less thing to have to do while holding
572 // a lock). So we can only verify that [bottom(),pre_dummy_top()]
573 // is dirty.
574 G1SATBCardTableModRefBS* ct_bs = _g1h->g1_barrier_set();
575 MemRegion mr(hr->bottom(), hr->pre_dummy_top());
576 if (hr->is_young()) {
577 ct_bs->verify_g1_young_region(mr);
578 } else {
579 ct_bs->verify_dirty_region(mr);
580 }
581 }
582
583 class G1VerifyDirtyYoungListClosure : public HeapRegionClosure {
584 private:
585 G1HeapVerifier* _verifier;
586 public:
587 G1VerifyDirtyYoungListClosure(G1HeapVerifier* verifier) : HeapRegionClosure(), _verifier(verifier) { }
588 virtual bool doHeapRegion(HeapRegion* r) {
589 _verifier->verify_dirty_region(r);
590 return false;
591 }
592 };
593
594 void G1HeapVerifier::verify_dirty_young_regions() {
595 G1VerifyDirtyYoungListClosure cl(this);
596 _g1h->collection_set()->iterate(&cl);
597 }
598
599 bool G1HeapVerifier::verify_no_bits_over_tams(const char* bitmap_name, G1CMBitMapRO* bitmap,
|
518 verify_time_ms = (os::elapsedTime() - verify_start) * 1000;
519 }
520
521 return verify_time_ms;
522 }
523
524 void G1HeapVerifier::verify_before_gc() {
525 double verify_time_ms = verify(VerifyBeforeGC, "Before GC");
526 _g1h->g1_policy()->phase_times()->record_verify_before_time_ms(verify_time_ms);
527 }
528
529 void G1HeapVerifier::verify_after_gc() {
530 double verify_time_ms = verify(VerifyAfterGC, "After GC");
531 _g1h->g1_policy()->phase_times()->record_verify_after_time_ms(verify_time_ms);
532 }
533
534
535 #ifndef PRODUCT
536 class G1VerifyCardTableCleanup: public HeapRegionClosure {
537 G1HeapVerifier* _verifier;
538 G1CardTable* _ct;
539 public:
540 G1VerifyCardTableCleanup(G1HeapVerifier* verifier, G1CardTable* ct)
541 : _verifier(verifier), _ct(ct) { }
542 virtual bool doHeapRegion(HeapRegion* r) {
543 if (r->is_survivor()) {
544 _verifier->verify_dirty_region(r);
545 } else {
546 _verifier->verify_not_dirty_region(r);
547 }
548 return false;
549 }
550 };
551
552 void G1HeapVerifier::verify_card_table_cleanup() {
553 if (G1VerifyCTCleanup || VerifyAfterGC) {
554 G1VerifyCardTableCleanup cleanup_verifier(this, _g1h->g1_card_table());
555 _g1h->heap_region_iterate(&cleanup_verifier);
556 }
557 }
558
559 void G1HeapVerifier::verify_not_dirty_region(HeapRegion* hr) {
560 // All of the region should be clean.
561 G1CardTable* ct = _g1h->g1_card_table();
562 MemRegion mr(hr->bottom(), hr->end());
563 ct->verify_not_dirty_region(mr);
564 }
565
566 void G1HeapVerifier::verify_dirty_region(HeapRegion* hr) {
567 // We cannot guarantee that [bottom(),end()] is dirty. Threads
568 // dirty allocated blocks as they allocate them. The thread that
569 // retires each region and replaces it with a new one will do a
570 // maximal allocation to fill in [pre_dummy_top(),end()] but will
571 // not dirty that area (one less thing to have to do while holding
572 // a lock). So we can only verify that [bottom(),pre_dummy_top()]
573 // is dirty.
574 G1CardTable* ct = _g1h->g1_card_table();
575 MemRegion mr(hr->bottom(), hr->pre_dummy_top());
576 if (hr->is_young()) {
577 ct->verify_g1_young_region(mr);
578 } else {
579 ct->verify_dirty_region(mr);
580 }
581 }
582
583 class G1VerifyDirtyYoungListClosure : public HeapRegionClosure {
584 private:
585 G1HeapVerifier* _verifier;
586 public:
587 G1VerifyDirtyYoungListClosure(G1HeapVerifier* verifier) : HeapRegionClosure(), _verifier(verifier) { }
588 virtual bool doHeapRegion(HeapRegion* r) {
589 _verifier->verify_dirty_region(r);
590 return false;
591 }
592 };
593
594 void G1HeapVerifier::verify_dirty_young_regions() {
595 G1VerifyDirtyYoungListClosure cl(this);
596 _g1h->collection_set()->iterate(&cl);
597 }
598
599 bool G1HeapVerifier::verify_no_bits_over_tams(const char* bitmap_name, G1CMBitMapRO* bitmap,
|