< prev index next >

src/hotspot/share/gc/g1/g1HeapVerifier.cpp

Print this page
rev 48019 : 8191821: Finer granularity for GC verification
Reviewed-by:
rev 48020 : [mq]: 8191821-rev-sang-poonam
rev 48021 : [mq]: 8191821-rev-tsch


 359       AbstractGangTask("Parallel verify task"),
 360       _g1h(g1h),
 361       _vo(vo),
 362       _failures(false),
 363       _hrclaimer(g1h->workers()->active_workers()) {}
 364 
 365   bool failures() {
 366     return _failures;
 367   }
 368 
 369   void work(uint worker_id) {
 370     HandleMark hm;
 371     VerifyRegionClosure blk(true, _vo);
 372     _g1h->heap_region_par_iterate_from_worker_offset(&blk, &_hrclaimer, worker_id);
 373     if (blk.failures()) {
 374       _failures = true;
 375     }
 376   }
 377 };
 378 































 379 
 380 void G1HeapVerifier::verify(VerifyOption vo) {
 381   if (!SafepointSynchronize::is_at_safepoint()) {
 382     log_info(gc, verify)("Skipping verification. Not at safepoint.");
 383   }
 384 
 385   assert(Thread::current()->is_VM_thread(),
 386          "Expected to be executed serially by the VM thread at this point");
 387 
 388   log_debug(gc, verify)("Roots");
 389   VerifyRootsClosure rootsCl(vo);
 390   VerifyCLDClosure cldCl(_g1h, &rootsCl);
 391 
 392   // We apply the relevant closures to all the oops in the
 393   // system dictionary, class loader data graph, the string table
 394   // and the nmethods in the code cache.
 395   G1VerifyCodeRootOopClosure codeRootsCl(_g1h, &rootsCl, vo);
 396   G1VerifyCodeRootBlobClosure blobsCl(&codeRootsCl);
 397 
 398   {


 524 
 525   // Make sure we append the secondary_free_list on the free_list so
 526   // that all free regions we will come across can be safely
 527   // attributed to the free_list.
 528   _g1h->append_secondary_free_list_if_not_empty_with_lock();
 529 
 530   // Finally, make sure that the region accounting in the lists is
 531   // consistent with what we see in the heap.
 532 
 533   VerifyRegionListsClosure cl(&_g1h->_old_set, &_g1h->_humongous_set, &_g1h->_hrm);
 534   _g1h->heap_region_iterate(&cl);
 535   cl.verify_counts(&_g1h->_old_set, &_g1h->_humongous_set, &_g1h->_hrm);
 536 }
 537 
 538 void G1HeapVerifier::prepare_for_verify() {
 539   if (SafepointSynchronize::is_at_safepoint() || ! UseTLAB) {
 540     _g1h->ensure_parsability(false);
 541   }
 542 }
 543 
 544 double G1HeapVerifier::verify(bool guard, const char* msg) {
 545   double verify_time_ms = 0.0;
 546 
 547   if (guard && _g1h->total_collections() >= VerifyGCStartAt) {
 548     double verify_start = os::elapsedTime();
 549     HandleMark hm;  // Discard invalid handles created during verification
 550     prepare_for_verify();
 551     Universe::verify(VerifyOption_G1UsePrevMarking, msg);
 552     verify_time_ms = (os::elapsedTime() - verify_start) * 1000;
 553   }
 554 
 555   return verify_time_ms;
 556 }
 557 
 558 void G1HeapVerifier::verify_before_gc() {
 559   double verify_time_ms = verify(VerifyBeforeGC, "Before GC");

 560   _g1h->g1_policy()->phase_times()->record_verify_before_time_ms(verify_time_ms);

 561 }
 562 
 563 void G1HeapVerifier::verify_after_gc() {
 564   double verify_time_ms = verify(VerifyAfterGC, "After GC");

 565   _g1h->g1_policy()->phase_times()->record_verify_after_time_ms(verify_time_ms);

 566 }
 567 
 568 
 569 #ifndef PRODUCT
 570 class G1VerifyCardTableCleanup: public HeapRegionClosure {
 571   G1HeapVerifier* _verifier;
 572   G1SATBCardTableModRefBS* _ct_bs;
 573 public:
 574   G1VerifyCardTableCleanup(G1HeapVerifier* verifier, G1SATBCardTableModRefBS* ct_bs)
 575     : _verifier(verifier), _ct_bs(ct_bs) { }
 576   virtual bool doHeapRegion(HeapRegion* r) {
 577     if (r->is_survivor()) {
 578       _verifier->verify_dirty_region(r);
 579     } else {
 580       _verifier->verify_not_dirty_region(r);
 581     }
 582     return false;
 583   }
 584 };
 585 




 359       AbstractGangTask("Parallel verify task"),
 360       _g1h(g1h),
 361       _vo(vo),
 362       _failures(false),
 363       _hrclaimer(g1h->workers()->active_workers()) {}
 364 
 365   bool failures() {
 366     return _failures;
 367   }
 368 
 369   void work(uint worker_id) {
 370     HandleMark hm;
 371     VerifyRegionClosure blk(true, _vo);
 372     _g1h->heap_region_par_iterate_from_worker_offset(&blk, &_hrclaimer, worker_id);
 373     if (blk.failures()) {
 374       _failures = true;
 375     }
 376   }
 377 };
 378 
 379 void G1HeapVerifier::parse_verification_type(const char* type) {
 380   if (strcmp(type, "young-only") == 0) {
 381     enable_verification_type(G1VerifyYoungOnly);
 382   } else if (strcmp(type, "initial-mark") == 0) {
 383     enable_verification_type(G1VerifyInitialMark);
 384   } else if (strcmp(type, "mixed") == 0) {
 385     enable_verification_type(G1VerifyMixed);
 386   } else if (strcmp(type, "remark") == 0) {
 387     enable_verification_type(G1VerifyRemark);
 388   } else if (strcmp(type, "cleanup") == 0) {
 389     enable_verification_type(G1VerifyCleanup);
 390   } else if (strcmp(type, "full") == 0) {
 391     enable_verification_type(G1VerifyFull);
 392   } else {
 393     log_warning(gc, verify)("VerifyGCType: '%s' is unknown. Available types are: "
 394                             "young-only, initial-mark, mixed, remark, cleanup and full", type);
 395   }
 396 }
 397 
 398 void G1HeapVerifier::enable_verification_type(G1VerifyType type) {
 399   // First enable will clear _enabled_verification_types.
 400   if (_enabled_verification_types == G1VerifyAll) {
 401     _enabled_verification_types = type;
 402   } else {
 403     _enabled_verification_types |= type;
 404   }
 405 }
 406 
 407 bool G1HeapVerifier::should_verify(G1VerifyType type) {
 408   return (_enabled_verification_types & type) == type;
 409 }
 410 
 411 void G1HeapVerifier::verify(VerifyOption vo) {
 412   if (!SafepointSynchronize::is_at_safepoint()) {
 413     log_info(gc, verify)("Skipping verification. Not at safepoint.");
 414   }
 415 
 416   assert(Thread::current()->is_VM_thread(),
 417          "Expected to be executed serially by the VM thread at this point");
 418 
 419   log_debug(gc, verify)("Roots");
 420   VerifyRootsClosure rootsCl(vo);
 421   VerifyCLDClosure cldCl(_g1h, &rootsCl);
 422 
 423   // We apply the relevant closures to all the oops in the
 424   // system dictionary, class loader data graph, the string table
 425   // and the nmethods in the code cache.
 426   G1VerifyCodeRootOopClosure codeRootsCl(_g1h, &rootsCl, vo);
 427   G1VerifyCodeRootBlobClosure blobsCl(&codeRootsCl);
 428 
 429   {


 555 
 556   // Make sure we append the secondary_free_list on the free_list so
 557   // that all free regions we will come across can be safely
 558   // attributed to the free_list.
 559   _g1h->append_secondary_free_list_if_not_empty_with_lock();
 560 
 561   // Finally, make sure that the region accounting in the lists is
 562   // consistent with what we see in the heap.
 563 
 564   VerifyRegionListsClosure cl(&_g1h->_old_set, &_g1h->_humongous_set, &_g1h->_hrm);
 565   _g1h->heap_region_iterate(&cl);
 566   cl.verify_counts(&_g1h->_old_set, &_g1h->_humongous_set, &_g1h->_hrm);
 567 }
 568 
 569 void G1HeapVerifier::prepare_for_verify() {
 570   if (SafepointSynchronize::is_at_safepoint() || ! UseTLAB) {
 571     _g1h->ensure_parsability(false);
 572   }
 573 }
 574 
 575 double G1HeapVerifier::verify(G1VerifyType type, VerifyOption vo, const char* msg) {
 576   double verify_time_ms = 0.0;
 577 
 578   if (should_verify(type) && _g1h->total_collections() >= VerifyGCStartAt) {
 579     double verify_start = os::elapsedTime();
 580     HandleMark hm;  // Discard invalid handles created during verification
 581     prepare_for_verify();
 582     Universe::verify(vo, msg);
 583     verify_time_ms = (os::elapsedTime() - verify_start) * 1000;
 584   }
 585 
 586   return verify_time_ms;
 587 }
 588 
 589 void G1HeapVerifier::verify_before_gc(G1VerifyType type) {
 590   if (VerifyBeforeGC) {
 591     double verify_time_ms = verify(type, VerifyOption_G1UsePrevMarking, "Before GC");
 592     _g1h->g1_policy()->phase_times()->record_verify_before_time_ms(verify_time_ms);
 593   }
 594 }
 595 
 596 void G1HeapVerifier::verify_after_gc(G1VerifyType type) {
 597   if (VerifyAfterGC) {
 598     double verify_time_ms = verify(type, VerifyOption_G1UsePrevMarking, "After GC");
 599     _g1h->g1_policy()->phase_times()->record_verify_after_time_ms(verify_time_ms);
 600   }
 601 }
 602 
 603 
 604 #ifndef PRODUCT
 605 class G1VerifyCardTableCleanup: public HeapRegionClosure {
 606   G1HeapVerifier* _verifier;
 607   G1SATBCardTableModRefBS* _ct_bs;
 608 public:
 609   G1VerifyCardTableCleanup(G1HeapVerifier* verifier, G1SATBCardTableModRefBS* ct_bs)
 610     : _verifier(verifier), _ct_bs(ct_bs) { }
 611   virtual bool doHeapRegion(HeapRegion* r) {
 612     if (r->is_survivor()) {
 613       _verifier->verify_dirty_region(r);
 614     } else {
 615       _verifier->verify_not_dirty_region(r);
 616     }
 617     return false;
 618   }
 619 };
 620 


< prev index next >