< prev index next >

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

Print this page
rev 49513 : imported patch 8200362-g1muxclosure-disable-implicit-verification
rev 49514 : imported patch 8200362-stefanj-review
rev 49525 : [mq]: 8200426-sangheon-review


 613   OopClosure* _c2;
 614 public:
 615   G1Mux2Closure(OopClosure *c1, OopClosure *c2) { _c1 = c1; _c2 = c2; }
 616   template <class T> inline void do_oop_work(T* p) {
 617     // Apply first closure; then apply the second.
 618     _c1->do_oop(p);
 619     _c2->do_oop(p);
 620   }
 621   virtual inline void do_oop(oop* p) { do_oop_work(p); }
 622   virtual inline void do_oop(narrowOop* p) { do_oop_work(p); }
 623 
 624   // This closure provides its own oop verification code.
 625   debug_only(virtual bool should_verify_oops() { return false; })
 626 };
 627 
 628 // This really ought to be commoned up into OffsetTableContigSpace somehow.
 629 // We would need a mechanism to make that code skip dead objects.
 630 
 631 void HeapRegion::verify(VerifyOption vo,
 632                         bool* failures) const {
 633   G1CollectedHeap* g1 = G1CollectedHeap::heap();
 634   *failures = false;
 635   HeapWord* p = bottom();
 636   HeapWord* prev_p = NULL;
 637   VerifyLiveClosure vl_cl(g1, vo);
 638   VerifyRemSetClosure vr_cl(g1, vo);
 639   bool is_region_humongous = is_humongous();
 640   size_t object_num = 0;
 641   while (p < top()) {
 642     oop obj = oop(p);
 643     size_t obj_size = block_size(p);
 644     object_num += 1;
 645 
 646     if (!g1->is_obj_dead_cond(obj, this, vo)) {
 647       if (oopDesc::is_oop(obj)) {
 648         Klass* klass = obj->klass();
 649         bool is_metaspace_object = Metaspace::contains(klass);
 650         if (!is_metaspace_object) {
 651           log_error(gc, verify)("klass " PTR_FORMAT " of object " PTR_FORMAT " "
 652                                 "not metadata", p2i(klass), p2i(obj));
 653           *failures = true;
 654           return;
 655         } else if (!klass->is_klass()) {
 656           log_error(gc, verify)("klass " PTR_FORMAT " of object " PTR_FORMAT " "
 657                                 "not a klass", p2i(klass), p2i(obj));
 658           *failures = true;
 659           return;
 660         } else {
 661           vl_cl.set_containing_obj(obj);
 662           if (!g1->collector_state()->in_full_gc() || G1VerifyRSetsDuringFullGC) {
 663             // verify liveness and rem_set
 664             vr_cl.set_containing_obj(obj);
 665             G1Mux2Closure mux(&vl_cl, &vr_cl);
 666             obj->oop_iterate(&mux);
 667 
 668             if (vr_cl.failures()) {
 669               *failures = true;
 670             }
 671             if (G1MaxVerifyFailures >= 0 &&
 672               vr_cl.n_failures() >= G1MaxVerifyFailures) {
 673               return;
 674             }
 675           } else {
 676             // verify only liveness
 677             obj->oop_iterate(&vl_cl);
 678           }
 679           if (vl_cl.failures()) {
 680             *failures = true;
 681           }
 682           if (G1MaxVerifyFailures >= 0 &&


 761     HeapWord* addr_4 = the_end - 1;
 762     HeapWord* b_start_4 = _bot_part.block_start_const(addr_4);
 763     if (b_start_4 != p) {
 764       log_error(gc, verify)("BOT look up for end - 1: " PTR_FORMAT " "
 765                             " yielded " PTR_FORMAT ", expecting " PTR_FORMAT,
 766                             p2i(addr_4), p2i(b_start_4), p2i(p));
 767       *failures = true;
 768       return;
 769     }
 770   }
 771 
 772   verify_strong_code_roots(vo, failures);
 773 }
 774 
 775 void HeapRegion::verify() const {
 776   bool dummy = false;
 777   verify(VerifyOption_G1UsePrevMarking, /* failures */ &dummy);
 778 }
 779 
 780 void HeapRegion::verify_rem_set(VerifyOption vo, bool* failures) const {
 781   G1CollectedHeap* g1 = G1CollectedHeap::heap();
 782   *failures = false;
 783   HeapWord* p = bottom();
 784   HeapWord* prev_p = NULL;
 785   VerifyRemSetClosure vr_cl(g1, vo);
 786   while (p < top()) {
 787     oop obj = oop(p);
 788     size_t obj_size = block_size(p);
 789 
 790     if (!g1->is_obj_dead_cond(obj, this, vo)) {
 791       if (oopDesc::is_oop(obj)) {
 792         vr_cl.set_containing_obj(obj);
 793         obj->oop_iterate(&vr_cl);
 794 
 795         if (vr_cl.failures()) {
 796           *failures = true;
 797         }
 798         if (G1MaxVerifyFailures >= 0 &&
 799           vr_cl.n_failures() >= G1MaxVerifyFailures) {
 800           return;
 801         }
 802       } else {
 803         log_error(gc, verify)(PTR_FORMAT " not an oop", p2i(obj));
 804         *failures = true;
 805         return;
 806       }
 807     }
 808 
 809     prev_p = p;
 810     p += obj_size;




 613   OopClosure* _c2;
 614 public:
 615   G1Mux2Closure(OopClosure *c1, OopClosure *c2) { _c1 = c1; _c2 = c2; }
 616   template <class T> inline void do_oop_work(T* p) {
 617     // Apply first closure; then apply the second.
 618     _c1->do_oop(p);
 619     _c2->do_oop(p);
 620   }
 621   virtual inline void do_oop(oop* p) { do_oop_work(p); }
 622   virtual inline void do_oop(narrowOop* p) { do_oop_work(p); }
 623 
 624   // This closure provides its own oop verification code.
 625   debug_only(virtual bool should_verify_oops() { return false; })
 626 };
 627 
 628 // This really ought to be commoned up into OffsetTableContigSpace somehow.
 629 // We would need a mechanism to make that code skip dead objects.
 630 
 631 void HeapRegion::verify(VerifyOption vo,
 632                         bool* failures) const {
 633   G1CollectedHeap* g1h = G1CollectedHeap::heap();
 634   *failures = false;
 635   HeapWord* p = bottom();
 636   HeapWord* prev_p = NULL;
 637   VerifyLiveClosure vl_cl(g1h, vo);
 638   VerifyRemSetClosure vr_cl(g1h, vo);
 639   bool is_region_humongous = is_humongous();
 640   size_t object_num = 0;
 641   while (p < top()) {
 642     oop obj = oop(p);
 643     size_t obj_size = block_size(p);
 644     object_num += 1;
 645 
 646     if (!g1h->is_obj_dead_cond(obj, this, vo)) {
 647       if (oopDesc::is_oop(obj)) {
 648         Klass* klass = obj->klass();
 649         bool is_metaspace_object = Metaspace::contains(klass);
 650         if (!is_metaspace_object) {
 651           log_error(gc, verify)("klass " PTR_FORMAT " of object " PTR_FORMAT " "
 652                                 "not metadata", p2i(klass), p2i(obj));
 653           *failures = true;
 654           return;
 655         } else if (!klass->is_klass()) {
 656           log_error(gc, verify)("klass " PTR_FORMAT " of object " PTR_FORMAT " "
 657                                 "not a klass", p2i(klass), p2i(obj));
 658           *failures = true;
 659           return;
 660         } else {
 661           vl_cl.set_containing_obj(obj);
 662           if (!g1h->collector_state()->in_full_gc() || G1VerifyRSetsDuringFullGC) {
 663             // verify liveness and rem_set
 664             vr_cl.set_containing_obj(obj);
 665             G1Mux2Closure mux(&vl_cl, &vr_cl);
 666             obj->oop_iterate(&mux);
 667 
 668             if (vr_cl.failures()) {
 669               *failures = true;
 670             }
 671             if (G1MaxVerifyFailures >= 0 &&
 672               vr_cl.n_failures() >= G1MaxVerifyFailures) {
 673               return;
 674             }
 675           } else {
 676             // verify only liveness
 677             obj->oop_iterate(&vl_cl);
 678           }
 679           if (vl_cl.failures()) {
 680             *failures = true;
 681           }
 682           if (G1MaxVerifyFailures >= 0 &&


 761     HeapWord* addr_4 = the_end - 1;
 762     HeapWord* b_start_4 = _bot_part.block_start_const(addr_4);
 763     if (b_start_4 != p) {
 764       log_error(gc, verify)("BOT look up for end - 1: " PTR_FORMAT " "
 765                             " yielded " PTR_FORMAT ", expecting " PTR_FORMAT,
 766                             p2i(addr_4), p2i(b_start_4), p2i(p));
 767       *failures = true;
 768       return;
 769     }
 770   }
 771 
 772   verify_strong_code_roots(vo, failures);
 773 }
 774 
 775 void HeapRegion::verify() const {
 776   bool dummy = false;
 777   verify(VerifyOption_G1UsePrevMarking, /* failures */ &dummy);
 778 }
 779 
 780 void HeapRegion::verify_rem_set(VerifyOption vo, bool* failures) const {
 781   G1CollectedHeap* g1h = G1CollectedHeap::heap();
 782   *failures = false;
 783   HeapWord* p = bottom();
 784   HeapWord* prev_p = NULL;
 785   VerifyRemSetClosure vr_cl(g1h, vo);
 786   while (p < top()) {
 787     oop obj = oop(p);
 788     size_t obj_size = block_size(p);
 789 
 790     if (!g1h->is_obj_dead_cond(obj, this, vo)) {
 791       if (oopDesc::is_oop(obj)) {
 792         vr_cl.set_containing_obj(obj);
 793         obj->oop_iterate(&vr_cl);
 794 
 795         if (vr_cl.failures()) {
 796           *failures = true;
 797         }
 798         if (G1MaxVerifyFailures >= 0 &&
 799           vr_cl.n_failures() >= G1MaxVerifyFailures) {
 800           return;
 801         }
 802       } else {
 803         log_error(gc, verify)(PTR_FORMAT " not an oop", p2i(obj));
 804         *failures = true;
 805         return;
 806       }
 807     }
 808 
 809     prev_p = p;
 810     p += obj_size;


< prev index next >