478 assert(Thread::current()->is_VM_thread(),
479 "Expected to be executed serially by the VM thread at this point");
480
481 log_debug(gc, verify)("Roots");
482 VerifyRootsClosure rootsCl(vo);
483 VerifyCLDClosure cldCl(_g1h, &rootsCl);
484
485 // We apply the relevant closures to all the oops in the
486 // system dictionary, class loader data graph, the string table
487 // and the nmethods in the code cache.
488 G1VerifyCodeRootOopClosure codeRootsCl(_g1h, &rootsCl, vo);
489 G1VerifyCodeRootBlobClosure blobsCl(&codeRootsCl);
490
491 {
492 G1RootProcessor root_processor(_g1h, 1);
493 root_processor.process_all_roots(&rootsCl, &cldCl, &blobsCl);
494 }
495
496 bool failures = rootsCl.failures() || codeRootsCl.failures();
497
498 if (!_g1h->g1_policy()->collector_state()->in_full_gc()) {
499 // If we're verifying during a full GC then the region sets
500 // will have been torn down at the start of the GC. Therefore
501 // verifying the region sets will fail. So we only verify
502 // the region sets when not in a full GC.
503 log_debug(gc, verify)("HeapRegionSets");
504 verify_region_sets();
505 }
506
507 log_debug(gc, verify)("HeapRegions");
508 if (GCParallelVerificationEnabled && ParallelGCThreads > 1) {
509
510 G1ParVerifyTask task(_g1h, vo);
511 _g1h->workers()->run_task(&task);
512 if (task.failures()) {
513 failures = true;
514 }
515
516 } else {
517 VerifyRegionClosure blk(false, vo);
518 _g1h->heap_region_iterate(&blk);
613 }
614 }
615
616 double G1HeapVerifier::verify(G1VerifyType type, VerifyOption vo, const char* msg) {
617 double verify_time_ms = 0.0;
618
619 if (should_verify(type) && _g1h->total_collections() >= VerifyGCStartAt) {
620 double verify_start = os::elapsedTime();
621 HandleMark hm; // Discard invalid handles created during verification
622 prepare_for_verify();
623 Universe::verify(vo, msg);
624 verify_time_ms = (os::elapsedTime() - verify_start) * 1000;
625 }
626
627 return verify_time_ms;
628 }
629
630 void G1HeapVerifier::verify_before_gc(G1VerifyType type) {
631 if (VerifyBeforeGC) {
632 double verify_time_ms = verify(type, VerifyOption_G1UsePrevMarking, "Before GC");
633 _g1h->g1_policy()->phase_times()->record_verify_before_time_ms(verify_time_ms);
634 }
635 }
636
637 void G1HeapVerifier::verify_after_gc(G1VerifyType type) {
638 if (VerifyAfterGC) {
639 double verify_time_ms = verify(type, VerifyOption_G1UsePrevMarking, "After GC");
640 _g1h->g1_policy()->phase_times()->record_verify_after_time_ms(verify_time_ms);
641 }
642 }
643
644
645 #ifndef PRODUCT
646 class G1VerifyCardTableCleanup: public HeapRegionClosure {
647 G1HeapVerifier* _verifier;
648 public:
649 G1VerifyCardTableCleanup(G1HeapVerifier* verifier)
650 : _verifier(verifier) { }
651 virtual bool do_heap_region(HeapRegion* r) {
652 if (r->is_survivor()) {
653 _verifier->verify_dirty_region(r);
654 } else {
655 _verifier->verify_not_dirty_region(r);
656 }
657 return false;
658 }
659 };
660
|
478 assert(Thread::current()->is_VM_thread(),
479 "Expected to be executed serially by the VM thread at this point");
480
481 log_debug(gc, verify)("Roots");
482 VerifyRootsClosure rootsCl(vo);
483 VerifyCLDClosure cldCl(_g1h, &rootsCl);
484
485 // We apply the relevant closures to all the oops in the
486 // system dictionary, class loader data graph, the string table
487 // and the nmethods in the code cache.
488 G1VerifyCodeRootOopClosure codeRootsCl(_g1h, &rootsCl, vo);
489 G1VerifyCodeRootBlobClosure blobsCl(&codeRootsCl);
490
491 {
492 G1RootProcessor root_processor(_g1h, 1);
493 root_processor.process_all_roots(&rootsCl, &cldCl, &blobsCl);
494 }
495
496 bool failures = rootsCl.failures() || codeRootsCl.failures();
497
498 if (!_g1h->policy()->collector_state()->in_full_gc()) {
499 // If we're verifying during a full GC then the region sets
500 // will have been torn down at the start of the GC. Therefore
501 // verifying the region sets will fail. So we only verify
502 // the region sets when not in a full GC.
503 log_debug(gc, verify)("HeapRegionSets");
504 verify_region_sets();
505 }
506
507 log_debug(gc, verify)("HeapRegions");
508 if (GCParallelVerificationEnabled && ParallelGCThreads > 1) {
509
510 G1ParVerifyTask task(_g1h, vo);
511 _g1h->workers()->run_task(&task);
512 if (task.failures()) {
513 failures = true;
514 }
515
516 } else {
517 VerifyRegionClosure blk(false, vo);
518 _g1h->heap_region_iterate(&blk);
613 }
614 }
615
616 double G1HeapVerifier::verify(G1VerifyType type, VerifyOption vo, const char* msg) {
617 double verify_time_ms = 0.0;
618
619 if (should_verify(type) && _g1h->total_collections() >= VerifyGCStartAt) {
620 double verify_start = os::elapsedTime();
621 HandleMark hm; // Discard invalid handles created during verification
622 prepare_for_verify();
623 Universe::verify(vo, msg);
624 verify_time_ms = (os::elapsedTime() - verify_start) * 1000;
625 }
626
627 return verify_time_ms;
628 }
629
630 void G1HeapVerifier::verify_before_gc(G1VerifyType type) {
631 if (VerifyBeforeGC) {
632 double verify_time_ms = verify(type, VerifyOption_G1UsePrevMarking, "Before GC");
633 _g1h->policy()->phase_times()->record_verify_before_time_ms(verify_time_ms);
634 }
635 }
636
637 void G1HeapVerifier::verify_after_gc(G1VerifyType type) {
638 if (VerifyAfterGC) {
639 double verify_time_ms = verify(type, VerifyOption_G1UsePrevMarking, "After GC");
640 _g1h->policy()->phase_times()->record_verify_after_time_ms(verify_time_ms);
641 }
642 }
643
644
645 #ifndef PRODUCT
646 class G1VerifyCardTableCleanup: public HeapRegionClosure {
647 G1HeapVerifier* _verifier;
648 public:
649 G1VerifyCardTableCleanup(G1HeapVerifier* verifier)
650 : _verifier(verifier) { }
651 virtual bool do_heap_region(HeapRegion* r) {
652 if (r->is_survivor()) {
653 _verifier->verify_dirty_region(r);
654 } else {
655 _verifier->verify_not_dirty_region(r);
656 }
657 return false;
658 }
659 };
660
|