< prev index next >

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

Print this page
rev 13105 : imported patch 8181917-refactor-ul-logstream-alt1-callsite-changes


  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #include "precompiled.hpp"
  26 #include "code/nmethod.hpp"
  27 #include "gc/g1/g1BlockOffsetTable.inline.hpp"
  28 #include "gc/g1/g1CollectedHeap.inline.hpp"
  29 #include "gc/g1/g1HeapRegionTraceType.hpp"
  30 #include "gc/g1/g1OopClosures.inline.hpp"
  31 #include "gc/g1/heapRegion.inline.hpp"
  32 #include "gc/g1/heapRegionBounds.inline.hpp"
  33 #include "gc/g1/heapRegionManager.inline.hpp"
  34 #include "gc/g1/heapRegionRemSet.hpp"
  35 #include "gc/g1/heapRegionTracer.hpp"
  36 #include "gc/shared/genOopClosures.inline.hpp"
  37 #include "gc/shared/space.inline.hpp"
  38 #include "logging/log.hpp"

  39 #include "memory/iterator.hpp"
  40 #include "memory/resourceArea.hpp"
  41 #include "oops/oop.inline.hpp"
  42 #include "runtime/atomic.hpp"
  43 #include "runtime/orderAccess.inline.hpp"
  44 
  45 int    HeapRegion::LogOfHRGrainBytes = 0;
  46 int    HeapRegion::LogOfHRGrainWords = 0;
  47 size_t HeapRegion::GrainBytes        = 0;
  48 size_t HeapRegion::GrainWords        = 0;
  49 size_t HeapRegion::CardsPerRegion    = 0;
  50 
  51 size_t HeapRegion::max_region_size() {
  52   return HeapRegionBounds::max_size();
  53 }
  54 
  55 size_t HeapRegion::min_region_size_in_words() {
  56   return HeapRegionBounds::min_size() >> LogHeapWordSize;
  57 }
  58 


 510 
 511   template <class T>
 512   void verify_liveness(T* p) {
 513     T heap_oop = oopDesc::load_heap_oop(p);
 514     Log(gc, verify) log;
 515     if (!oopDesc::is_null(heap_oop)) {
 516       oop obj = oopDesc::decode_heap_oop_not_null(heap_oop);
 517       bool failed = false;
 518       if (!_g1h->is_in_closed_subset(obj) || _g1h->is_obj_dead_cond(obj, _vo)) {
 519         MutexLockerEx x(ParGCRareEvent_lock,
 520           Mutex::_no_safepoint_check_flag);
 521 
 522         if (!_failures) {
 523           log.error("----------");
 524         }
 525         ResourceMark rm;
 526         if (!_g1h->is_in_closed_subset(obj)) {
 527           HeapRegion* from = _g1h->heap_region_containing((HeapWord*)p);
 528           log.error("Field " PTR_FORMAT " of live obj " PTR_FORMAT " in region [" PTR_FORMAT ", " PTR_FORMAT ")",
 529             p2i(p), p2i(_containing_obj), p2i(from->bottom()), p2i(from->end()));
 530           print_object(log.error_stream(), _containing_obj);


 531           log.error("points to obj " PTR_FORMAT " not in the heap", p2i(obj));
 532         } else {
 533           HeapRegion* from = _g1h->heap_region_containing((HeapWord*)p);
 534           HeapRegion* to = _g1h->heap_region_containing((HeapWord*)obj);
 535           log.error("Field " PTR_FORMAT " of live obj " PTR_FORMAT " in region [" PTR_FORMAT ", " PTR_FORMAT ")",
 536             p2i(p), p2i(_containing_obj), p2i(from->bottom()), p2i(from->end()));
 537           print_object(log.error_stream(), _containing_obj);


 538           log.error("points to dead obj " PTR_FORMAT " in region [" PTR_FORMAT ", " PTR_FORMAT ")",
 539             p2i(obj), p2i(to->bottom()), p2i(to->end()));
 540           print_object(log.error_stream(), obj);
 541         }
 542         log.error("----------");
 543         _failures = true;
 544         failed = true;
 545         _n_failures++;
 546       }
 547     }
 548   }
 549 };
 550 
 551 class VerifyRemSetClosure : public G1VerificationClosure {
 552 public:
 553   VerifyRemSetClosure(G1CollectedHeap* g1h, VerifyOption vo) : G1VerificationClosure(g1h, vo) {}
 554   virtual void do_oop(narrowOop* p) { do_oop_work(p); }
 555   virtual void do_oop(oop* p) { do_oop_work(p); }
 556 
 557   template <class T>
 558   void do_oop_work(T* p) {
 559     assert(_containing_obj != NULL, "Precondition");
 560     assert(!_g1h->is_obj_dead_cond(_containing_obj, _vo),


 577         jbyte cv_field = *_bs->byte_for_const(p);
 578         const jbyte dirty = CardTableModRefBS::dirty_card_val();
 579 
 580         bool is_bad = !(from->is_young()
 581           || to->rem_set()->contains_reference(p)
 582           || !G1HRRSFlushLogBuffersOnVerify && // buffers were not flushed
 583           (_containing_obj->is_objArray() ?
 584           cv_field == dirty
 585           : cv_obj == dirty || cv_field == dirty));
 586         if (is_bad) {
 587           MutexLockerEx x(ParGCRareEvent_lock,
 588             Mutex::_no_safepoint_check_flag);
 589 
 590           if (!_failures) {
 591             log.error("----------");
 592           }
 593           log.error("Missing rem set entry:");
 594           log.error("Field " PTR_FORMAT " of obj " PTR_FORMAT ", in region " HR_FORMAT,
 595             p2i(p), p2i(_containing_obj), HR_FORMAT_PARAMS(from));
 596           ResourceMark rm;
 597           _containing_obj->print_on(log.error_stream());


 598           log.error("points to obj " PTR_FORMAT " in region " HR_FORMAT, p2i(obj), HR_FORMAT_PARAMS(to));
 599           if (obj->is_oop()) {
 600             obj->print_on(log.error_stream());
 601           }
 602           log.error("Obj head CTE = %d, field CTE = %d.", cv_obj, cv_field);
 603           log.error("----------");
 604           _failures = true;
 605           _n_failures++;
 606         }
 607       }
 608     }
 609   }
 610 };
 611 
 612 // Closure that applies the given two closures in sequence.
 613 class G1Mux2Closure : public OopClosure {
 614   OopClosure* _c1;
 615   OopClosure* _c2;
 616 public:
 617   G1Mux2Closure(OopClosure *c1, OopClosure *c2) { _c1 = c1; _c2 = c2; }
 618   template <class T> inline void do_oop_work(T* p) {
 619     // Apply first closure; then apply the second.
 620     _c1->do_oop(p);




  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #include "precompiled.hpp"
  26 #include "code/nmethod.hpp"
  27 #include "gc/g1/g1BlockOffsetTable.inline.hpp"
  28 #include "gc/g1/g1CollectedHeap.inline.hpp"
  29 #include "gc/g1/g1HeapRegionTraceType.hpp"
  30 #include "gc/g1/g1OopClosures.inline.hpp"
  31 #include "gc/g1/heapRegion.inline.hpp"
  32 #include "gc/g1/heapRegionBounds.inline.hpp"
  33 #include "gc/g1/heapRegionManager.inline.hpp"
  34 #include "gc/g1/heapRegionRemSet.hpp"
  35 #include "gc/g1/heapRegionTracer.hpp"
  36 #include "gc/shared/genOopClosures.inline.hpp"
  37 #include "gc/shared/space.inline.hpp"
  38 #include "logging/log.hpp"
  39 #include "logging/logStream.hpp"
  40 #include "memory/iterator.hpp"
  41 #include "memory/resourceArea.hpp"
  42 #include "oops/oop.inline.hpp"
  43 #include "runtime/atomic.hpp"
  44 #include "runtime/orderAccess.inline.hpp"
  45 
  46 int    HeapRegion::LogOfHRGrainBytes = 0;
  47 int    HeapRegion::LogOfHRGrainWords = 0;
  48 size_t HeapRegion::GrainBytes        = 0;
  49 size_t HeapRegion::GrainWords        = 0;
  50 size_t HeapRegion::CardsPerRegion    = 0;
  51 
  52 size_t HeapRegion::max_region_size() {
  53   return HeapRegionBounds::max_size();
  54 }
  55 
  56 size_t HeapRegion::min_region_size_in_words() {
  57   return HeapRegionBounds::min_size() >> LogHeapWordSize;
  58 }
  59 


 511 
 512   template <class T>
 513   void verify_liveness(T* p) {
 514     T heap_oop = oopDesc::load_heap_oop(p);
 515     Log(gc, verify) log;
 516     if (!oopDesc::is_null(heap_oop)) {
 517       oop obj = oopDesc::decode_heap_oop_not_null(heap_oop);
 518       bool failed = false;
 519       if (!_g1h->is_in_closed_subset(obj) || _g1h->is_obj_dead_cond(obj, _vo)) {
 520         MutexLockerEx x(ParGCRareEvent_lock,
 521           Mutex::_no_safepoint_check_flag);
 522 
 523         if (!_failures) {
 524           log.error("----------");
 525         }
 526         ResourceMark rm;
 527         if (!_g1h->is_in_closed_subset(obj)) {
 528           HeapRegion* from = _g1h->heap_region_containing((HeapWord*)p);
 529           log.error("Field " PTR_FORMAT " of live obj " PTR_FORMAT " in region [" PTR_FORMAT ", " PTR_FORMAT ")",
 530             p2i(p), p2i(_containing_obj), p2i(from->bottom()), p2i(from->end()));
 531           // Unconditional write?
 532           LogStream ls(log.error());
 533           print_object(&ls, _containing_obj);
 534           log.error("points to obj " PTR_FORMAT " not in the heap", p2i(obj));
 535         } else {
 536           HeapRegion* from = _g1h->heap_region_containing((HeapWord*)p);
 537           HeapRegion* to = _g1h->heap_region_containing((HeapWord*)obj);
 538           log.error("Field " PTR_FORMAT " of live obj " PTR_FORMAT " in region [" PTR_FORMAT ", " PTR_FORMAT ")",
 539             p2i(p), p2i(_containing_obj), p2i(from->bottom()), p2i(from->end()));
 540           // Unconditional write?
 541           LogStream ls(log.error());
 542           print_object(&ls, _containing_obj);
 543           log.error("points to dead obj " PTR_FORMAT " in region [" PTR_FORMAT ", " PTR_FORMAT ")",
 544             p2i(obj), p2i(to->bottom()), p2i(to->end()));
 545           print_object(&ls, obj);
 546         }
 547         log.error("----------");
 548         _failures = true;
 549         failed = true;
 550         _n_failures++;
 551       }
 552     }
 553   }
 554 };
 555 
 556 class VerifyRemSetClosure : public G1VerificationClosure {
 557 public:
 558   VerifyRemSetClosure(G1CollectedHeap* g1h, VerifyOption vo) : G1VerificationClosure(g1h, vo) {}
 559   virtual void do_oop(narrowOop* p) { do_oop_work(p); }
 560   virtual void do_oop(oop* p) { do_oop_work(p); }
 561 
 562   template <class T>
 563   void do_oop_work(T* p) {
 564     assert(_containing_obj != NULL, "Precondition");
 565     assert(!_g1h->is_obj_dead_cond(_containing_obj, _vo),


 582         jbyte cv_field = *_bs->byte_for_const(p);
 583         const jbyte dirty = CardTableModRefBS::dirty_card_val();
 584 
 585         bool is_bad = !(from->is_young()
 586           || to->rem_set()->contains_reference(p)
 587           || !G1HRRSFlushLogBuffersOnVerify && // buffers were not flushed
 588           (_containing_obj->is_objArray() ?
 589           cv_field == dirty
 590           : cv_obj == dirty || cv_field == dirty));
 591         if (is_bad) {
 592           MutexLockerEx x(ParGCRareEvent_lock,
 593             Mutex::_no_safepoint_check_flag);
 594 
 595           if (!_failures) {
 596             log.error("----------");
 597           }
 598           log.error("Missing rem set entry:");
 599           log.error("Field " PTR_FORMAT " of obj " PTR_FORMAT ", in region " HR_FORMAT,
 600             p2i(p), p2i(_containing_obj), HR_FORMAT_PARAMS(from));
 601           ResourceMark rm;
 602           // Unconditional write?
 603           LogStream ls(log.error());
 604           _containing_obj->print_on(&ls);
 605           log.error("points to obj " PTR_FORMAT " in region " HR_FORMAT, p2i(obj), HR_FORMAT_PARAMS(to));
 606           if (obj->is_oop()) {
 607             obj->print_on(&ls);
 608           }
 609           log.error("Obj head CTE = %d, field CTE = %d.", cv_obj, cv_field);
 610           log.error("----------");
 611           _failures = true;
 612           _n_failures++;
 613         }
 614       }
 615     }
 616   }
 617 };
 618 
 619 // Closure that applies the given two closures in sequence.
 620 class G1Mux2Closure : public OopClosure {
 621   OopClosure* _c1;
 622   OopClosure* _c2;
 623 public:
 624   G1Mux2Closure(OopClosure *c1, OopClosure *c2) { _c1 = c1; _c2 = c2; }
 625   template <class T> inline void do_oop_work(T* p) {
 626     // Apply first closure; then apply the second.
 627     _c1->do_oop(p);


< prev index next >