< prev index next >

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

Print this page




  46   bool             _failures;
  47 public:
  48   // _vo == UsePrevMarking -> use "prev" marking information,
  49   // _vo == UseNextMarking -> use "next" marking information,
  50   // _vo == UseMarkWord    -> use mark word from object header.
  51   VerifyRootsClosure(VerifyOption vo) :
  52     _g1h(G1CollectedHeap::heap()),
  53     _vo(vo),
  54     _failures(false) { }
  55 
  56   bool failures() { return _failures; }
  57 
  58   template <class T> void do_oop_nv(T* p) {
  59     T heap_oop = oopDesc::load_heap_oop(p);
  60     if (!oopDesc::is_null(heap_oop)) {
  61       oop obj = oopDesc::decode_heap_oop_not_null(heap_oop);
  62       if (_g1h->is_obj_dead_cond(obj, _vo)) {
  63         LogHandle(gc, verify) log;
  64         log.info("Root location " PTR_FORMAT " points to dead obj " PTR_FORMAT, p2i(p), p2i(obj));
  65         if (_vo == VerifyOption_G1UseMarkWord) {
  66           log.info("  Mark word: " PTR_FORMAT, p2i(obj->mark()));
  67         }
  68         ResourceMark rm;
  69         obj->print_on(log.info_stream());
  70         _failures = true;
  71       }
  72     }
  73   }
  74 
  75   void do_oop(oop* p)       { do_oop_nv(p); }
  76   void do_oop(narrowOop* p) { do_oop_nv(p); }
  77 };
  78 
  79 class G1VerifyCodeRootOopClosure: public OopClosure {
  80   G1CollectedHeap* _g1h;
  81   OopClosure* _root_cl;
  82   nmethod* _nm;
  83   VerifyOption _vo;
  84   bool _failures;
  85 
  86   template <class T> void do_oop_work(T* p) {
  87     // First verify that this root is live
  88     _root_cl->do_oop(p);
  89 


  94 
  95     // Don't check the code roots during marking verification in a full GC
  96     if (_vo == VerifyOption_G1UseMarkWord) {
  97       return;
  98     }
  99 
 100     // Now verify that the current nmethod (which contains p) is
 101     // in the code root list of the heap region containing the
 102     // object referenced by p.
 103 
 104     T heap_oop = oopDesc::load_heap_oop(p);
 105     if (!oopDesc::is_null(heap_oop)) {
 106       oop obj = oopDesc::decode_heap_oop_not_null(heap_oop);
 107 
 108       // Now fetch the region containing the object
 109       HeapRegion* hr = _g1h->heap_region_containing(obj);
 110       HeapRegionRemSet* hrrs = hr->rem_set();
 111       // Verify that the strong code root list for this region
 112       // contains the nmethod
 113       if (!hrrs->strong_code_roots_list_contains(_nm)) {
 114         log_info(gc, verify)("Code root location " PTR_FORMAT " "
 115                              "from nmethod " PTR_FORMAT " not in strong "
 116                              "code roots for region [" PTR_FORMAT "," PTR_FORMAT ")",
 117                              p2i(p), p2i(_nm), p2i(hr->bottom()), p2i(hr->end()));
 118         _failures = true;
 119       }
 120     }
 121   }
 122 
 123 public:
 124   G1VerifyCodeRootOopClosure(G1CollectedHeap* g1h, OopClosure* root_cl, VerifyOption vo):
 125     _g1h(g1h), _root_cl(root_cl), _vo(vo), _nm(NULL), _failures(false) {}
 126 
 127   void do_oop(oop* p) { do_oop_work(p); }
 128   void do_oop(narrowOop* p) { do_oop_work(p); }
 129 
 130   void set_nmethod(nmethod* nm) { _nm = nm; }
 131   bool failures() { return _failures; }
 132 };
 133 
 134 class G1VerifyCodeRootBlobClosure: public CodeBlobClosure {


 275   }
 276 
 277   bool doHeapRegion(HeapRegion* r) {
 278     // For archive regions, verify there are no heap pointers to
 279     // non-pinned regions. For all others, verify liveness info.
 280     if (r->is_archive()) {
 281       VerifyArchiveRegionClosure verify_oop_pointers(r);
 282       r->object_iterate(&verify_oop_pointers);
 283       return true;
 284     }
 285     if (!r->is_continues_humongous()) {
 286       bool failures = false;
 287       r->verify(_vo, &failures);
 288       if (failures) {
 289         _failures = true;
 290       } else if (!r->is_starts_humongous()) {
 291         VerifyObjsInRegionClosure not_dead_yet_cl(r, _vo);
 292         r->object_iterate(&not_dead_yet_cl);
 293         if (_vo != VerifyOption_G1UseNextMarking) {
 294           if (r->max_live_bytes() < not_dead_yet_cl.live_bytes()) {
 295             log_info(gc, verify)("[" PTR_FORMAT "," PTR_FORMAT "] max_live_bytes " SIZE_FORMAT " < calculated " SIZE_FORMAT,
 296                                  p2i(r->bottom()), p2i(r->end()), r->max_live_bytes(), not_dead_yet_cl.live_bytes());
 297             _failures = true;
 298           }
 299         } else {
 300           // When vo == UseNextMarking we cannot currently do a sanity
 301           // check on the live bytes as the calculation has not been
 302           // finalized yet.
 303         }
 304       }
 305     }
 306     return false; // stop the region iteration if we hit a failure
 307   }
 308 };
 309 
 310 // This is the task used for parallel verification of the heap regions
 311 
 312 class G1ParVerifyTask: public AbstractGangTask {
 313 private:
 314   G1CollectedHeap*  _g1h;
 315   VerifyOption      _vo;


 385     G1ParVerifyTask task(_g1h, vo);
 386     _g1h->workers()->run_task(&task);
 387     if (task.failures()) {
 388       failures = true;
 389     }
 390 
 391   } else {
 392     VerifyRegionClosure blk(false, vo);
 393     _g1h->heap_region_iterate(&blk);
 394     if (blk.failures()) {
 395       failures = true;
 396     }
 397   }
 398 
 399   if (G1StringDedup::is_enabled()) {
 400     log_debug(gc, verify)("StrDedup");
 401     G1StringDedup::verify();
 402   }
 403 
 404   if (failures) {
 405     log_info(gc, verify)("Heap after failed verification:");
 406     // It helps to have the per-region information in the output to
 407     // help us track down what went wrong. This is why we call
 408     // print_extended_on() instead of print_on().
 409     LogHandle(gc, verify) log;
 410     ResourceMark rm;
 411     _g1h->print_extended_on(log.info_stream());
 412   }
 413   guarantee(!failures, "there should not have been any failures");
 414 }
 415 
 416 // Heap region set verification
 417 
 418 class VerifyRegionListsClosure : public HeapRegionClosure {
 419 private:
 420   HeapRegionSet*   _old_set;
 421   HeapRegionSet*   _humongous_set;
 422   HeapRegionManager*   _hrm;
 423 
 424 public:
 425   uint _old_count;
 426   uint _humongous_count;
 427   uint _free_count;
 428 
 429   VerifyRegionListsClosure(HeapRegionSet* old_set,
 430                            HeapRegionSet* humongous_set,
 431                            HeapRegionManager* hrm) :


 580   }
 581 }
 582 
 583 void G1HeapVerifier::verify_dirty_young_list(HeapRegion* head) {
 584   G1SATBCardTableModRefBS* ct_bs = _g1h->g1_barrier_set();
 585   for (HeapRegion* hr = head; hr != NULL; hr = hr->get_next_young_region()) {
 586     verify_dirty_region(hr);
 587   }
 588 }
 589 
 590 void G1HeapVerifier::verify_dirty_young_regions() {
 591   verify_dirty_young_list(_g1h->young_list()->first_region());
 592 }
 593 
 594 bool G1HeapVerifier::verify_no_bits_over_tams(const char* bitmap_name, G1CMBitMapRO* bitmap,
 595                                                HeapWord* tams, HeapWord* end) {
 596   guarantee(tams <= end,
 597             "tams: " PTR_FORMAT " end: " PTR_FORMAT, p2i(tams), p2i(end));
 598   HeapWord* result = bitmap->getNextMarkedWordAddress(tams, end);
 599   if (result < end) {
 600     log_info(gc, verify)("## wrong marked address on %s bitmap: " PTR_FORMAT, bitmap_name, p2i(result));
 601     log_info(gc, verify)("## %s tams: " PTR_FORMAT " end: " PTR_FORMAT, bitmap_name, p2i(tams), p2i(end));
 602     return false;
 603   }
 604   return true;
 605 }
 606 
 607 bool G1HeapVerifier::verify_bitmaps(const char* caller, HeapRegion* hr) {
 608   G1CMBitMapRO* prev_bitmap = _g1h->concurrent_mark()->prevMarkBitMap();
 609   G1CMBitMapRO* next_bitmap = (G1CMBitMapRO*) _g1h->concurrent_mark()->nextMarkBitMap();
 610 
 611   HeapWord* bottom = hr->bottom();
 612   HeapWord* ptams  = hr->prev_top_at_mark_start();
 613   HeapWord* ntams  = hr->next_top_at_mark_start();
 614   HeapWord* end    = hr->end();
 615 
 616   bool res_p = verify_no_bits_over_tams("prev", prev_bitmap, ptams, end);
 617 
 618   bool res_n = true;
 619   // We reset mark_in_progress() before we reset _cmThread->in_progress() and in this window
 620   // we do the clearing of the next bitmap concurrently. Thus, we can not verify the bitmap
 621   // if we happen to be in that state.
 622   if (_g1h->collector_state()->mark_in_progress() || !_g1h->_cmThread->in_progress()) {
 623     res_n = verify_no_bits_over_tams("next", next_bitmap, ntams, end);
 624   }
 625   if (!res_p || !res_n) {
 626     log_info(gc, verify)("#### Bitmap verification failed for " HR_FORMAT, HR_FORMAT_PARAMS(hr));
 627     log_info(gc, verify)("#### Caller: %s", caller);
 628     return false;
 629   }
 630   return true;
 631 }
 632 
 633 void G1HeapVerifier::check_bitmaps(const char* caller, HeapRegion* hr) {
 634   if (!G1VerifyBitmaps) return;
 635 
 636   guarantee(verify_bitmaps(caller, hr), "bitmap verification");
 637 }
 638 
 639 class G1VerifyBitmapClosure : public HeapRegionClosure {
 640 private:
 641   const char* _caller;
 642   G1HeapVerifier* _verifier;
 643   bool _failures;
 644 
 645 public:
 646   G1VerifyBitmapClosure(const char* caller, G1HeapVerifier* verifier) :
 647     _caller(caller), _verifier(verifier), _failures(false) { }


 659 
 660 void G1HeapVerifier::check_bitmaps(const char* caller) {
 661   if (!G1VerifyBitmaps) return;
 662 
 663   G1VerifyBitmapClosure cl(caller, this);
 664   _g1h->heap_region_iterate(&cl);
 665   guarantee(!cl.failures(), "bitmap verification");
 666 }
 667 
 668 class G1CheckCSetFastTableClosure : public HeapRegionClosure {
 669  private:
 670   bool _failures;
 671  public:
 672   G1CheckCSetFastTableClosure() : HeapRegionClosure(), _failures(false) { }
 673 
 674   virtual bool doHeapRegion(HeapRegion* hr) {
 675     uint i = hr->hrm_index();
 676     InCSetState cset_state = (InCSetState) G1CollectedHeap::heap()->_in_cset_fast_test.get_by_index(i);
 677     if (hr->is_humongous()) {
 678       if (hr->in_collection_set()) {
 679         log_info(gc, verify)("## humongous region %u in CSet", i);
 680         _failures = true;
 681         return true;
 682       }
 683       if (cset_state.is_in_cset()) {
 684         log_info(gc, verify)("## inconsistent cset state " CSETSTATE_FORMAT " for humongous region %u", cset_state.value(), i);
 685         _failures = true;
 686         return true;
 687       }
 688       if (hr->is_continues_humongous() && cset_state.is_humongous()) {
 689         log_info(gc, verify)("## inconsistent cset state " CSETSTATE_FORMAT " for continues humongous region %u", cset_state.value(), i);
 690         _failures = true;
 691         return true;
 692       }
 693     } else {
 694       if (cset_state.is_humongous()) {
 695         log_info(gc, verify)("## inconsistent cset state " CSETSTATE_FORMAT " for non-humongous region %u", cset_state.value(), i);
 696         _failures = true;
 697         return true;
 698       }
 699       if (hr->in_collection_set() != cset_state.is_in_cset()) {
 700         log_info(gc, verify)("## in CSet %d / cset state " CSETSTATE_FORMAT " inconsistency for region %u",
 701                              hr->in_collection_set(), cset_state.value(), i);
 702         _failures = true;
 703         return true;
 704       }
 705       if (cset_state.is_in_cset()) {
 706         if (hr->is_young() != (cset_state.is_young())) {
 707           log_info(gc, verify)("## is_young %d / cset state " CSETSTATE_FORMAT " inconsistency for region %u",
 708                                hr->is_young(), cset_state.value(), i);
 709           _failures = true;
 710           return true;
 711         }
 712         if (hr->is_old() != (cset_state.is_old())) {
 713           log_info(gc, verify)("## is_old %d / cset state " CSETSTATE_FORMAT " inconsistency for region %u",
 714                                hr->is_old(), cset_state.value(), i);
 715           _failures = true;
 716           return true;
 717         }
 718       }
 719     }
 720     return false;
 721   }
 722 
 723   bool failures() const { return _failures; }
 724 };
 725 
 726 bool G1HeapVerifier::check_cset_fast_test() {
 727   G1CheckCSetFastTableClosure cl;
 728   _g1h->_hrm.iterate(&cl);
 729   return !cl.failures();
 730 }
 731 #endif // PRODUCT


  46   bool             _failures;
  47 public:
  48   // _vo == UsePrevMarking -> use "prev" marking information,
  49   // _vo == UseNextMarking -> use "next" marking information,
  50   // _vo == UseMarkWord    -> use mark word from object header.
  51   VerifyRootsClosure(VerifyOption vo) :
  52     _g1h(G1CollectedHeap::heap()),
  53     _vo(vo),
  54     _failures(false) { }
  55 
  56   bool failures() { return _failures; }
  57 
  58   template <class T> void do_oop_nv(T* p) {
  59     T heap_oop = oopDesc::load_heap_oop(p);
  60     if (!oopDesc::is_null(heap_oop)) {
  61       oop obj = oopDesc::decode_heap_oop_not_null(heap_oop);
  62       if (_g1h->is_obj_dead_cond(obj, _vo)) {
  63         LogHandle(gc, verify) log;
  64         log.info("Root location " PTR_FORMAT " points to dead obj " PTR_FORMAT, p2i(p), p2i(obj));
  65         if (_vo == VerifyOption_G1UseMarkWord) {
  66           log.error("  Mark word: " PTR_FORMAT, p2i(obj->mark()));
  67         }
  68         ResourceMark rm;
  69         obj->print_on(log.error_stream());
  70         _failures = true;
  71       }
  72     }
  73   }
  74 
  75   void do_oop(oop* p)       { do_oop_nv(p); }
  76   void do_oop(narrowOop* p) { do_oop_nv(p); }
  77 };
  78 
  79 class G1VerifyCodeRootOopClosure: public OopClosure {
  80   G1CollectedHeap* _g1h;
  81   OopClosure* _root_cl;
  82   nmethod* _nm;
  83   VerifyOption _vo;
  84   bool _failures;
  85 
  86   template <class T> void do_oop_work(T* p) {
  87     // First verify that this root is live
  88     _root_cl->do_oop(p);
  89 


  94 
  95     // Don't check the code roots during marking verification in a full GC
  96     if (_vo == VerifyOption_G1UseMarkWord) {
  97       return;
  98     }
  99 
 100     // Now verify that the current nmethod (which contains p) is
 101     // in the code root list of the heap region containing the
 102     // object referenced by p.
 103 
 104     T heap_oop = oopDesc::load_heap_oop(p);
 105     if (!oopDesc::is_null(heap_oop)) {
 106       oop obj = oopDesc::decode_heap_oop_not_null(heap_oop);
 107 
 108       // Now fetch the region containing the object
 109       HeapRegion* hr = _g1h->heap_region_containing(obj);
 110       HeapRegionRemSet* hrrs = hr->rem_set();
 111       // Verify that the strong code root list for this region
 112       // contains the nmethod
 113       if (!hrrs->strong_code_roots_list_contains(_nm)) {
 114         log_error(gc, verify)("Code root location " PTR_FORMAT " "
 115                               "from nmethod " PTR_FORMAT " not in strong "
 116                               "code roots for region [" PTR_FORMAT "," PTR_FORMAT ")",
 117                               p2i(p), p2i(_nm), p2i(hr->bottom()), p2i(hr->end()));
 118         _failures = true;
 119       }
 120     }
 121   }
 122 
 123 public:
 124   G1VerifyCodeRootOopClosure(G1CollectedHeap* g1h, OopClosure* root_cl, VerifyOption vo):
 125     _g1h(g1h), _root_cl(root_cl), _vo(vo), _nm(NULL), _failures(false) {}
 126 
 127   void do_oop(oop* p) { do_oop_work(p); }
 128   void do_oop(narrowOop* p) { do_oop_work(p); }
 129 
 130   void set_nmethod(nmethod* nm) { _nm = nm; }
 131   bool failures() { return _failures; }
 132 };
 133 
 134 class G1VerifyCodeRootBlobClosure: public CodeBlobClosure {


 275   }
 276 
 277   bool doHeapRegion(HeapRegion* r) {
 278     // For archive regions, verify there are no heap pointers to
 279     // non-pinned regions. For all others, verify liveness info.
 280     if (r->is_archive()) {
 281       VerifyArchiveRegionClosure verify_oop_pointers(r);
 282       r->object_iterate(&verify_oop_pointers);
 283       return true;
 284     }
 285     if (!r->is_continues_humongous()) {
 286       bool failures = false;
 287       r->verify(_vo, &failures);
 288       if (failures) {
 289         _failures = true;
 290       } else if (!r->is_starts_humongous()) {
 291         VerifyObjsInRegionClosure not_dead_yet_cl(r, _vo);
 292         r->object_iterate(&not_dead_yet_cl);
 293         if (_vo != VerifyOption_G1UseNextMarking) {
 294           if (r->max_live_bytes() < not_dead_yet_cl.live_bytes()) {
 295             log_error(gc, verify)("[" PTR_FORMAT "," PTR_FORMAT "] max_live_bytes " SIZE_FORMAT " < calculated " SIZE_FORMAT,
 296                                   p2i(r->bottom()), p2i(r->end()), r->max_live_bytes(), not_dead_yet_cl.live_bytes());
 297             _failures = true;
 298           }
 299         } else {
 300           // When vo == UseNextMarking we cannot currently do a sanity
 301           // check on the live bytes as the calculation has not been
 302           // finalized yet.
 303         }
 304       }
 305     }
 306     return false; // stop the region iteration if we hit a failure
 307   }
 308 };
 309 
 310 // This is the task used for parallel verification of the heap regions
 311 
 312 class G1ParVerifyTask: public AbstractGangTask {
 313 private:
 314   G1CollectedHeap*  _g1h;
 315   VerifyOption      _vo;


 385     G1ParVerifyTask task(_g1h, vo);
 386     _g1h->workers()->run_task(&task);
 387     if (task.failures()) {
 388       failures = true;
 389     }
 390 
 391   } else {
 392     VerifyRegionClosure blk(false, vo);
 393     _g1h->heap_region_iterate(&blk);
 394     if (blk.failures()) {
 395       failures = true;
 396     }
 397   }
 398 
 399   if (G1StringDedup::is_enabled()) {
 400     log_debug(gc, verify)("StrDedup");
 401     G1StringDedup::verify();
 402   }
 403 
 404   if (failures) {
 405     log_error(gc, verify)("Heap after failed verification:");
 406     // It helps to have the per-region information in the output to
 407     // help us track down what went wrong. This is why we call
 408     // print_extended_on() instead of print_on().
 409     LogHandle(gc, verify) log;
 410     ResourceMark rm;
 411     _g1h->print_extended_on(log.error_stream());
 412   }
 413   guarantee(!failures, "there should not have been any failures");
 414 }
 415 
 416 // Heap region set verification
 417 
 418 class VerifyRegionListsClosure : public HeapRegionClosure {
 419 private:
 420   HeapRegionSet*   _old_set;
 421   HeapRegionSet*   _humongous_set;
 422   HeapRegionManager*   _hrm;
 423 
 424 public:
 425   uint _old_count;
 426   uint _humongous_count;
 427   uint _free_count;
 428 
 429   VerifyRegionListsClosure(HeapRegionSet* old_set,
 430                            HeapRegionSet* humongous_set,
 431                            HeapRegionManager* hrm) :


 580   }
 581 }
 582 
 583 void G1HeapVerifier::verify_dirty_young_list(HeapRegion* head) {
 584   G1SATBCardTableModRefBS* ct_bs = _g1h->g1_barrier_set();
 585   for (HeapRegion* hr = head; hr != NULL; hr = hr->get_next_young_region()) {
 586     verify_dirty_region(hr);
 587   }
 588 }
 589 
 590 void G1HeapVerifier::verify_dirty_young_regions() {
 591   verify_dirty_young_list(_g1h->young_list()->first_region());
 592 }
 593 
 594 bool G1HeapVerifier::verify_no_bits_over_tams(const char* bitmap_name, G1CMBitMapRO* bitmap,
 595                                                HeapWord* tams, HeapWord* end) {
 596   guarantee(tams <= end,
 597             "tams: " PTR_FORMAT " end: " PTR_FORMAT, p2i(tams), p2i(end));
 598   HeapWord* result = bitmap->getNextMarkedWordAddress(tams, end);
 599   if (result < end) {
 600     log_error(gc, verify)("## wrong marked address on %s bitmap: " PTR_FORMAT, bitmap_name, p2i(result));
 601     log_error(gc, verify)("## %s tams: " PTR_FORMAT " end: " PTR_FORMAT, bitmap_name, p2i(tams), p2i(end));
 602     return false;
 603   }
 604   return true;
 605 }
 606 
 607 bool G1HeapVerifier::verify_bitmaps(const char* caller, HeapRegion* hr) {
 608   G1CMBitMapRO* prev_bitmap = _g1h->concurrent_mark()->prevMarkBitMap();
 609   G1CMBitMapRO* next_bitmap = (G1CMBitMapRO*) _g1h->concurrent_mark()->nextMarkBitMap();
 610 
 611   HeapWord* bottom = hr->bottom();
 612   HeapWord* ptams  = hr->prev_top_at_mark_start();
 613   HeapWord* ntams  = hr->next_top_at_mark_start();
 614   HeapWord* end    = hr->end();
 615 
 616   bool res_p = verify_no_bits_over_tams("prev", prev_bitmap, ptams, end);
 617 
 618   bool res_n = true;
 619   // We reset mark_in_progress() before we reset _cmThread->in_progress() and in this window
 620   // we do the clearing of the next bitmap concurrently. Thus, we can not verify the bitmap
 621   // if we happen to be in that state.
 622   if (_g1h->collector_state()->mark_in_progress() || !_g1h->_cmThread->in_progress()) {
 623     res_n = verify_no_bits_over_tams("next", next_bitmap, ntams, end);
 624   }
 625   if (!res_p || !res_n) {
 626     log_error(gc, verify)("#### Bitmap verification failed for " HR_FORMAT, HR_FORMAT_PARAMS(hr));
 627     log_error(gc, verify)("#### Caller: %s", caller);
 628     return false;
 629   }
 630   return true;
 631 }
 632 
 633 void G1HeapVerifier::check_bitmaps(const char* caller, HeapRegion* hr) {
 634   if (!G1VerifyBitmaps) return;
 635 
 636   guarantee(verify_bitmaps(caller, hr), "bitmap verification");
 637 }
 638 
 639 class G1VerifyBitmapClosure : public HeapRegionClosure {
 640 private:
 641   const char* _caller;
 642   G1HeapVerifier* _verifier;
 643   bool _failures;
 644 
 645 public:
 646   G1VerifyBitmapClosure(const char* caller, G1HeapVerifier* verifier) :
 647     _caller(caller), _verifier(verifier), _failures(false) { }


 659 
 660 void G1HeapVerifier::check_bitmaps(const char* caller) {
 661   if (!G1VerifyBitmaps) return;
 662 
 663   G1VerifyBitmapClosure cl(caller, this);
 664   _g1h->heap_region_iterate(&cl);
 665   guarantee(!cl.failures(), "bitmap verification");
 666 }
 667 
 668 class G1CheckCSetFastTableClosure : public HeapRegionClosure {
 669  private:
 670   bool _failures;
 671  public:
 672   G1CheckCSetFastTableClosure() : HeapRegionClosure(), _failures(false) { }
 673 
 674   virtual bool doHeapRegion(HeapRegion* hr) {
 675     uint i = hr->hrm_index();
 676     InCSetState cset_state = (InCSetState) G1CollectedHeap::heap()->_in_cset_fast_test.get_by_index(i);
 677     if (hr->is_humongous()) {
 678       if (hr->in_collection_set()) {
 679         log_error(gc, verify)("## humongous region %u in CSet", i);
 680         _failures = true;
 681         return true;
 682       }
 683       if (cset_state.is_in_cset()) {
 684         log_error(gc, verify)("## inconsistent cset state " CSETSTATE_FORMAT " for humongous region %u", cset_state.value(), i);
 685         _failures = true;
 686         return true;
 687       }
 688       if (hr->is_continues_humongous() && cset_state.is_humongous()) {
 689         log_error(gc, verify)("## inconsistent cset state " CSETSTATE_FORMAT " for continues humongous region %u", cset_state.value(), i);
 690         _failures = true;
 691         return true;
 692       }
 693     } else {
 694       if (cset_state.is_humongous()) {
 695         log_error(gc, verify)("## inconsistent cset state " CSETSTATE_FORMAT " for non-humongous region %u", cset_state.value(), i);
 696         _failures = true;
 697         return true;
 698       }
 699       if (hr->in_collection_set() != cset_state.is_in_cset()) {
 700         log_error(gc, verify)("## in CSet %d / cset state " CSETSTATE_FORMAT " inconsistency for region %u",
 701                              hr->in_collection_set(), cset_state.value(), i);
 702         _failures = true;
 703         return true;
 704       }
 705       if (cset_state.is_in_cset()) {
 706         if (hr->is_young() != (cset_state.is_young())) {
 707           log_error(gc, verify)("## is_young %d / cset state " CSETSTATE_FORMAT " inconsistency for region %u",
 708                                hr->is_young(), cset_state.value(), i);
 709           _failures = true;
 710           return true;
 711         }
 712         if (hr->is_old() != (cset_state.is_old())) {
 713           log_error(gc, verify)("## is_old %d / cset state " CSETSTATE_FORMAT " inconsistency for region %u",
 714                                hr->is_old(), cset_state.value(), i);
 715           _failures = true;
 716           return true;
 717         }
 718       }
 719     }
 720     return false;
 721   }
 722 
 723   bool failures() const { return _failures; }
 724 };
 725 
 726 bool G1HeapVerifier::check_cset_fast_test() {
 727   G1CheckCSetFastTableClosure cl;
 728   _g1h->_hrm.iterate(&cl);
 729   return !cl.failures();
 730 }
 731 #endif // PRODUCT
< prev index next >