< prev index next >

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

Print this page




 497 public:
 498   VerifyLiveClosure(G1CollectedHeap* g1h, VerifyOption vo) : G1VerificationClosure(g1h, vo) {}
 499   virtual void do_oop(narrowOop* p) { do_oop_work(p); }
 500   virtual void do_oop(oop* p) { do_oop_work(p); }
 501 
 502   template <class T>
 503   void do_oop_work(T* p) {
 504     assert(_containing_obj != NULL, "Precondition");
 505     assert(!_g1h->is_obj_dead_cond(_containing_obj, _vo),
 506       "Precondition");
 507     verify_liveness(p);
 508   }
 509 
 510   template <class T>
 511   void verify_liveness(T* p) {
 512     T heap_oop = RawAccess<>::oop_load(p);
 513     Log(gc, verify) log;
 514     if (!CompressedOops::is_null(heap_oop)) {
 515       oop obj = CompressedOops::decode_not_null(heap_oop);
 516       bool failed = false;
 517       if (!_g1h->is_in_closed_subset(obj) || _g1h->is_obj_dead_cond(obj, _vo)) {
 518         MutexLockerEx x(ParGCRareEvent_lock,
 519           Mutex::_no_safepoint_check_flag);
 520 
 521         if (!_failures) {
 522           log.error("----------");
 523         }
 524         ResourceMark rm;
 525         if (!_g1h->is_in_closed_subset(obj)) {
 526           HeapRegion* from = _g1h->heap_region_containing((HeapWord*)p);
 527           log.error("Field " PTR_FORMAT " of live obj " PTR_FORMAT " in region " HR_FORMAT,
 528                     p2i(p), p2i(_containing_obj), HR_FORMAT_PARAMS(from));
 529           LogStream ls(log.error());
 530           print_object(&ls, _containing_obj);
 531           HeapRegion* const to = _g1h->heap_region_containing(obj);
 532           log.error("points to obj " PTR_FORMAT " in region " HR_FORMAT " remset %s",
 533                     p2i(obj), HR_FORMAT_PARAMS(to), to->rem_set()->get_state_str());
 534         } else {
 535           HeapRegion* from = _g1h->heap_region_containing((HeapWord*)p);
 536           HeapRegion* to = _g1h->heap_region_containing((HeapWord*)obj);
 537           log.error("Field " PTR_FORMAT " of live obj " PTR_FORMAT " in region " HR_FORMAT,
 538                     p2i(p), p2i(_containing_obj), HR_FORMAT_PARAMS(from));
 539           LogStream ls(log.error());
 540           print_object(&ls, _containing_obj);
 541           log.error("points to dead obj " PTR_FORMAT " in region " HR_FORMAT,
 542                     p2i(obj), HR_FORMAT_PARAMS(to));
 543           print_object(&ls, obj);
 544         }
 545         log.error("----------");




 497 public:
 498   VerifyLiveClosure(G1CollectedHeap* g1h, VerifyOption vo) : G1VerificationClosure(g1h, vo) {}
 499   virtual void do_oop(narrowOop* p) { do_oop_work(p); }
 500   virtual void do_oop(oop* p) { do_oop_work(p); }
 501 
 502   template <class T>
 503   void do_oop_work(T* p) {
 504     assert(_containing_obj != NULL, "Precondition");
 505     assert(!_g1h->is_obj_dead_cond(_containing_obj, _vo),
 506       "Precondition");
 507     verify_liveness(p);
 508   }
 509 
 510   template <class T>
 511   void verify_liveness(T* p) {
 512     T heap_oop = RawAccess<>::oop_load(p);
 513     Log(gc, verify) log;
 514     if (!CompressedOops::is_null(heap_oop)) {
 515       oop obj = CompressedOops::decode_not_null(heap_oop);
 516       bool failed = false;
 517       if (!_g1h->is_in(obj) || _g1h->is_obj_dead_cond(obj, _vo)) {
 518         MutexLockerEx x(ParGCRareEvent_lock,
 519           Mutex::_no_safepoint_check_flag);
 520 
 521         if (!_failures) {
 522           log.error("----------");
 523         }
 524         ResourceMark rm;
 525         if (!_g1h->is_in(obj)) {
 526           HeapRegion* from = _g1h->heap_region_containing((HeapWord*)p);
 527           log.error("Field " PTR_FORMAT " of live obj " PTR_FORMAT " in region " HR_FORMAT,
 528                     p2i(p), p2i(_containing_obj), HR_FORMAT_PARAMS(from));
 529           LogStream ls(log.error());
 530           print_object(&ls, _containing_obj);
 531           HeapRegion* const to = _g1h->heap_region_containing(obj);
 532           log.error("points to obj " PTR_FORMAT " in region " HR_FORMAT " remset %s",
 533                     p2i(obj), HR_FORMAT_PARAMS(to), to->rem_set()->get_state_str());
 534         } else {
 535           HeapRegion* from = _g1h->heap_region_containing((HeapWord*)p);
 536           HeapRegion* to = _g1h->heap_region_containing((HeapWord*)obj);
 537           log.error("Field " PTR_FORMAT " of live obj " PTR_FORMAT " in region " HR_FORMAT,
 538                     p2i(p), p2i(_containing_obj), HR_FORMAT_PARAMS(from));
 539           LogStream ls(log.error());
 540           print_object(&ls, _containing_obj);
 541           log.error("points to dead obj " PTR_FORMAT " in region " HR_FORMAT,
 542                     p2i(obj), HR_FORMAT_PARAMS(to));
 543           print_object(&ls, obj);
 544         }
 545         log.error("----------");


< prev index next >