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") == 0) {
381 enable_verification_type(G1VerifyYoung);
382 } else if (strcmp(type, "mixed") == 0) {
383 enable_verification_type(G1VerifyMixed);
384 } else if (strcmp(type, "remark") == 0) {
385 enable_verification_type(G1VerifyRemark);
386 } else if (strcmp(type, "cleanup") == 0) {
387 enable_verification_type(G1VerifyCleanup);
388 } else if (strcmp(type, "full") == 0) {
389 enable_verification_type(G1VerifyFull);
390 } else {
391 log_warning(gc, verify)("VerifyGCType: '%s' is unknown. Available are: young, mixed, remark, cleanup and full ", type);
392 }
393 }
394
395 void G1HeapVerifier::enable_verification_type(G1VerifyType type) {
396 // First enable will clear _types.
397 if (_enabled_verification_types == G1VerifyAll) {
398 _enabled_verification_types = type;
399 } else {
400 _enabled_verification_types |= type;
401 }
402 }
403
404 bool G1HeapVerifier::should_verify(G1VerifyType type) {
405 return (_enabled_verification_types & type) == type;
406 }
407
408 void G1HeapVerifier::verify(VerifyOption vo) {
409 if (!SafepointSynchronize::is_at_safepoint()) {
410 log_info(gc, verify)("Skipping verification. Not at safepoint.");
411 }
412
413 assert(Thread::current()->is_VM_thread(),
414 "Expected to be executed serially by the VM thread at this point");
415
416 log_debug(gc, verify)("Roots");
417 VerifyRootsClosure rootsCl(vo);
418 VerifyCLDClosure cldCl(_g1h, &rootsCl);
419
420 // We apply the relevant closures to all the oops in the
421 // system dictionary, class loader data graph, the string table
422 // and the nmethods in the code cache.
423 G1VerifyCodeRootOopClosure codeRootsCl(_g1h, &rootsCl, vo);
424 G1VerifyCodeRootBlobClosure blobsCl(&codeRootsCl);
425
426 {
552
553 // Make sure we append the secondary_free_list on the free_list so
554 // that all free regions we will come across can be safely
555 // attributed to the free_list.
556 _g1h->append_secondary_free_list_if_not_empty_with_lock();
557
558 // Finally, make sure that the region accounting in the lists is
559 // consistent with what we see in the heap.
560
561 VerifyRegionListsClosure cl(&_g1h->_old_set, &_g1h->_humongous_set, &_g1h->_hrm);
562 _g1h->heap_region_iterate(&cl);
563 cl.verify_counts(&_g1h->_old_set, &_g1h->_humongous_set, &_g1h->_hrm);
564 }
565
566 void G1HeapVerifier::prepare_for_verify() {
567 if (SafepointSynchronize::is_at_safepoint() || ! UseTLAB) {
568 _g1h->ensure_parsability(false);
569 }
570 }
571
572 double G1HeapVerifier::verify(G1VerifyType type, VerifyOption vo, const char* msg) {
573 double verify_time_ms = 0.0;
574
575 if (should_verify(type) && _g1h->total_collections() >= VerifyGCStartAt) {
576 double verify_start = os::elapsedTime();
577 HandleMark hm; // Discard invalid handles created during verification
578 prepare_for_verify();
579 Universe::verify(vo, msg);
580 verify_time_ms = (os::elapsedTime() - verify_start) * 1000;
581 }
582
583 return verify_time_ms;
584 }
585
586 void G1HeapVerifier::verify_before_gc(G1VerifyType type) {
587 if (VerifyBeforeGC) {
588 double verify_time_ms = verify(type, VerifyOption_G1UsePrevMarking, "Before GC");
589 _g1h->g1_policy()->phase_times()->record_verify_before_time_ms(verify_time_ms);
590 }
591 }
592
593 void G1HeapVerifier::verify_after_gc(G1VerifyType type) {
594 if (VerifyAfterGC) {
595 double verify_time_ms = verify(type, VerifyOption_G1UsePrevMarking, "After GC");
596 _g1h->g1_policy()->phase_times()->record_verify_after_time_ms(verify_time_ms);
597 }
598 }
599
600
601 #ifndef PRODUCT
602 class G1VerifyCardTableCleanup: public HeapRegionClosure {
603 G1HeapVerifier* _verifier;
604 G1SATBCardTableModRefBS* _ct_bs;
605 public:
606 G1VerifyCardTableCleanup(G1HeapVerifier* verifier, G1SATBCardTableModRefBS* ct_bs)
607 : _verifier(verifier), _ct_bs(ct_bs) { }
608 virtual bool doHeapRegion(HeapRegion* r) {
609 if (r->is_survivor()) {
610 _verifier->verify_dirty_region(r);
611 } else {
612 _verifier->verify_not_dirty_region(r);
613 }
614 return false;
615 }
616 };
617
|