comparison src/share/vm/gc_implementation/g1/heapRegion.cpp @ 811:830ca2573896

6850846: G1: extend G1 marking verification Summary: extend G1 marking verification to use either the "prev" or "next" marking information, as appropriate. Reviewed-by: johnc, ysr
author tonyp
date Fri, 12 Jun 2009 16:20:16 -0400
parents 29e7d79232b9
children 0316eac49d5a
comparison
equal deleted inserted replaced
809:6e2afda171db 811:830ca2573896
38 _r_bottom(r->bottom()), _r_end(r->end()), 38 _r_bottom(r->bottom()), _r_end(r->end()),
39 _oc(oc), _out_of_region(0) 39 _oc(oc), _out_of_region(0)
40 {} 40 {}
41 41
42 class VerifyLiveClosure: public OopClosure { 42 class VerifyLiveClosure: public OopClosure {
43 private:
43 G1CollectedHeap* _g1h; 44 G1CollectedHeap* _g1h;
44 CardTableModRefBS* _bs; 45 CardTableModRefBS* _bs;
45 oop _containing_obj; 46 oop _containing_obj;
46 bool _failures; 47 bool _failures;
47 int _n_failures; 48 int _n_failures;
49 bool _use_prev_marking;
48 public: 50 public:
49 VerifyLiveClosure(G1CollectedHeap* g1h) : 51 // use_prev_marking == true -> use "prev" marking information,
52 // use_prev_marking == false -> use "next" marking information
53 VerifyLiveClosure(G1CollectedHeap* g1h, bool use_prev_marking) :
50 _g1h(g1h), _bs(NULL), _containing_obj(NULL), 54 _g1h(g1h), _bs(NULL), _containing_obj(NULL),
51 _failures(false), _n_failures(0) 55 _failures(false), _n_failures(0), _use_prev_marking(use_prev_marking)
52 { 56 {
53 BarrierSet* bs = _g1h->barrier_set(); 57 BarrierSet* bs = _g1h->barrier_set();
54 if (bs->is_a(BarrierSet::CardTableModRef)) 58 if (bs->is_a(BarrierSet::CardTableModRef))
55 _bs = (CardTableModRefBS*)bs; 59 _bs = (CardTableModRefBS*)bs;
56 } 60 }
66 guarantee(false, "NYI"); 70 guarantee(false, "NYI");
67 } 71 }
68 72
69 void do_oop(oop* p) { 73 void do_oop(oop* p) {
70 assert(_containing_obj != NULL, "Precondition"); 74 assert(_containing_obj != NULL, "Precondition");
71 assert(!_g1h->is_obj_dead(_containing_obj), "Precondition"); 75 assert(!_g1h->is_obj_dead_cond(_containing_obj, _use_prev_marking),
76 "Precondition");
72 oop obj = *p; 77 oop obj = *p;
73 if (obj != NULL) { 78 if (obj != NULL) {
74 bool failed = false; 79 bool failed = false;
75 if (!_g1h->is_in_closed_subset(obj) || _g1h->is_obj_dead(obj)) { 80 if (!_g1h->is_in_closed_subset(obj) ||
81 _g1h->is_obj_dead_cond(obj, _use_prev_marking)) {
76 if (!_failures) { 82 if (!_failures) {
77 gclog_or_tty->print_cr(""); 83 gclog_or_tty->print_cr("");
78 gclog_or_tty->print_cr("----------"); 84 gclog_or_tty->print_cr("----------");
79 } 85 }
80 if (!_g1h->is_in_closed_subset(obj)) { 86 if (!_g1h->is_in_closed_subset(obj)) {
645 st->print(" "); 651 st->print(" ");
646 st->print(" %d", _gc_time_stamp); 652 st->print(" %d", _gc_time_stamp);
647 G1OffsetTableContigSpace::print_on(st); 653 G1OffsetTableContigSpace::print_on(st);
648 } 654 }
649 655
656 void HeapRegion::verify(bool allow_dirty) const {
657 verify(allow_dirty, /* use_prev_marking */ true);
658 }
659
650 #define OBJ_SAMPLE_INTERVAL 0 660 #define OBJ_SAMPLE_INTERVAL 0
651 #define BLOCK_SAMPLE_INTERVAL 100 661 #define BLOCK_SAMPLE_INTERVAL 100
652 662
653 // This really ought to be commoned up into OffsetTableContigSpace somehow. 663 // This really ought to be commoned up into OffsetTableContigSpace somehow.
654 // We would need a mechanism to make that code skip dead objects. 664 // We would need a mechanism to make that code skip dead objects.
655 665
656 void HeapRegion::verify(bool allow_dirty) const { 666 void HeapRegion::verify(bool allow_dirty, bool use_prev_marking) const {
657 G1CollectedHeap* g1 = G1CollectedHeap::heap(); 667 G1CollectedHeap* g1 = G1CollectedHeap::heap();
658 HeapWord* p = bottom(); 668 HeapWord* p = bottom();
659 HeapWord* prev_p = NULL; 669 HeapWord* prev_p = NULL;
660 int objs = 0; 670 int objs = 0;
661 int blocks = 0; 671 int blocks = 0;
662 VerifyLiveClosure vl_cl(g1); 672 VerifyLiveClosure vl_cl(g1, use_prev_marking);
663 while (p < top()) { 673 while (p < top()) {
664 size_t size = oop(p)->size(); 674 size_t size = oop(p)->size();
665 if (blocks == BLOCK_SAMPLE_INTERVAL) { 675 if (blocks == BLOCK_SAMPLE_INTERVAL) {
666 guarantee(p == block_start_const(p + (size/2)), 676 guarantee(p == block_start_const(p + (size/2)),
667 "check offset computation"); 677 "check offset computation");
669 } else { 679 } else {
670 blocks++; 680 blocks++;
671 } 681 }
672 if (objs == OBJ_SAMPLE_INTERVAL) { 682 if (objs == OBJ_SAMPLE_INTERVAL) {
673 oop obj = oop(p); 683 oop obj = oop(p);
674 if (!g1->is_obj_dead(obj, this)) { 684 if (!g1->is_obj_dead_cond(obj, this, use_prev_marking)) {
675 obj->verify(); 685 obj->verify();
676 vl_cl.set_containing_obj(obj); 686 vl_cl.set_containing_obj(obj);
677 obj->oop_iterate(&vl_cl); 687 obj->oop_iterate(&vl_cl);
678 if (G1MaxVerifyFailures >= 0 688 if (G1MaxVerifyFailures >= 0
679 && vl_cl.n_failures() >= G1MaxVerifyFailures) break; 689 && vl_cl.n_failures() >= G1MaxVerifyFailures) break;