< prev index next >

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

Print this page
rev 13288 : imported patch 8181917-refactor-ul-logstream
rev 13289 : [mq]: 8181917-refactor-ul-logstream-delta


  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),


 576         jbyte cv_obj = *_bs->byte_for_const(_containing_obj);
 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           || (_containing_obj->is_objArray() ?
 583                 cv_field == dirty :
 584                 cv_obj == dirty || cv_field == dirty));
 585         if (is_bad) {
 586           MutexLockerEx x(ParGCRareEvent_lock,
 587             Mutex::_no_safepoint_check_flag);
 588 
 589           if (!_failures) {
 590             log.error("----------");
 591           }
 592           log.error("Missing rem set entry:");
 593           log.error("Field " PTR_FORMAT " of obj " PTR_FORMAT ", in region " HR_FORMAT,
 594             p2i(p), p2i(_containing_obj), HR_FORMAT_PARAMS(from));
 595           ResourceMark rm;
 596           _containing_obj->print_on(log.error_stream());

 597           log.error("points to obj " PTR_FORMAT " in region " HR_FORMAT, p2i(obj), HR_FORMAT_PARAMS(to));
 598           if (obj->is_oop()) {
 599             obj->print_on(log.error_stream());
 600           }
 601           log.error("Obj head CTE = %d, field CTE = %d.", cv_obj, cv_field);
 602           log.error("----------");
 603           _failures = true;
 604           _n_failures++;
 605         }
 606       }
 607     }
 608   }
 609 };
 610 
 611 // Closure that applies the given two closures in sequence.
 612 class G1Mux2Closure : public OopClosure {
 613   OopClosure* _c1;
 614   OopClosure* _c2;
 615 public:
 616   G1Mux2Closure(OopClosure *c1, OopClosure *c2) { _c1 = c1; _c2 = c2; }
 617   template <class T> inline void do_oop_work(T* p) {
 618     // Apply first closure; then apply the second.
 619     _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           LogStream ls(log.error());
 532           print_object(&ls, _containing_obj);
 533           log.error("points to obj " PTR_FORMAT " not in the heap", p2i(obj));
 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 [" PTR_FORMAT ", " PTR_FORMAT ")",
 538             p2i(p), p2i(_containing_obj), p2i(from->bottom()), p2i(from->end()));
 539           LogStream ls(log.error());
 540           print_object(&ls, _containing_obj);
 541           log.error("points to dead obj " PTR_FORMAT " in region [" PTR_FORMAT ", " PTR_FORMAT ")",
 542             p2i(obj), p2i(to->bottom()), p2i(to->end()));
 543           print_object(&ls, obj);
 544         }
 545         log.error("----------");
 546         _failures = true;
 547         failed = true;
 548         _n_failures++;
 549       }
 550     }
 551   }
 552 };
 553 
 554 class VerifyRemSetClosure : public G1VerificationClosure {
 555 public:
 556   VerifyRemSetClosure(G1CollectedHeap* g1h, VerifyOption vo) : G1VerificationClosure(g1h, vo) {}
 557   virtual void do_oop(narrowOop* p) { do_oop_work(p); }
 558   virtual void do_oop(oop* p) { do_oop_work(p); }
 559 
 560   template <class T>
 561   void do_oop_work(T* p) {
 562     assert(_containing_obj != NULL, "Precondition");
 563     assert(!_g1h->is_obj_dead_cond(_containing_obj, _vo),


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


< prev index next >