50 // _vo == UseNextMarking -> use "next" marking information,
51 // _vo == UseMarkWord -> use mark word from object header.
52 VerifyRootsClosure(VerifyOption vo) :
53 _g1h(G1CollectedHeap::heap()),
54 _vo(vo),
55 _failures(false) { }
56
57 bool failures() { return _failures; }
58
59 template <class T> void do_oop_nv(T* p) {
60 T heap_oop = oopDesc::load_heap_oop(p);
61 if (!oopDesc::is_null(heap_oop)) {
62 oop obj = oopDesc::decode_heap_oop_not_null(heap_oop);
63 if (_g1h->is_obj_dead_cond(obj, _vo)) {
64 Log(gc, verify) log;
65 log.info("Root location " PTR_FORMAT " points to dead obj " PTR_FORMAT, p2i(p), p2i(obj));
66 if (_vo == VerifyOption_G1UseMarkWord) {
67 log.error(" Mark word: " PTR_FORMAT, p2i(obj->mark()));
68 }
69 ResourceMark rm;
70 // Unconditional write?
71 LogStream ls(log.error());
72 obj->print_on(&ls);
73 _failures = true;
74 }
75 }
76 }
77
78 void do_oop(oop* p) { do_oop_nv(p); }
79 void do_oop(narrowOop* p) { do_oop_nv(p); }
80 };
81
82 class G1VerifyCodeRootOopClosure: public OopClosure {
83 G1CollectedHeap* _g1h;
84 OopClosure* _root_cl;
85 nmethod* _nm;
86 VerifyOption _vo;
87 bool _failures;
88
89 template <class T> void do_oop_work(T* p) {
90 // First verify that this root is live
394 } else {
395 VerifyRegionClosure blk(false, vo);
396 _g1h->heap_region_iterate(&blk);
397 if (blk.failures()) {
398 failures = true;
399 }
400 }
401
402 if (G1StringDedup::is_enabled()) {
403 log_debug(gc, verify)("StrDedup");
404 G1StringDedup::verify();
405 }
406
407 if (failures) {
408 log_error(gc, verify)("Heap after failed verification:");
409 // It helps to have the per-region information in the output to
410 // help us track down what went wrong. This is why we call
411 // print_extended_on() instead of print_on().
412 Log(gc, verify) log;
413 ResourceMark rm;
414 // Unconditional write?
415 LogStream ls(log.error());
416 _g1h->print_extended_on(&ls);
417 }
418 guarantee(!failures, "there should not have been any failures");
419 }
420
421 // Heap region set verification
422
423 class VerifyRegionListsClosure : public HeapRegionClosure {
424 private:
425 HeapRegionSet* _old_set;
426 HeapRegionSet* _humongous_set;
427 HeapRegionManager* _hrm;
428
429 public:
430 uint _old_count;
431 uint _humongous_count;
432 uint _free_count;
433
434 VerifyRegionListsClosure(HeapRegionSet* old_set,
|
50 // _vo == UseNextMarking -> use "next" marking information,
51 // _vo == UseMarkWord -> use mark word from object header.
52 VerifyRootsClosure(VerifyOption vo) :
53 _g1h(G1CollectedHeap::heap()),
54 _vo(vo),
55 _failures(false) { }
56
57 bool failures() { return _failures; }
58
59 template <class T> void do_oop_nv(T* p) {
60 T heap_oop = oopDesc::load_heap_oop(p);
61 if (!oopDesc::is_null(heap_oop)) {
62 oop obj = oopDesc::decode_heap_oop_not_null(heap_oop);
63 if (_g1h->is_obj_dead_cond(obj, _vo)) {
64 Log(gc, verify) log;
65 log.info("Root location " PTR_FORMAT " points to dead obj " PTR_FORMAT, p2i(p), p2i(obj));
66 if (_vo == VerifyOption_G1UseMarkWord) {
67 log.error(" Mark word: " PTR_FORMAT, p2i(obj->mark()));
68 }
69 ResourceMark rm;
70 LogStream ls(log.error());
71 obj->print_on(&ls);
72 _failures = true;
73 }
74 }
75 }
76
77 void do_oop(oop* p) { do_oop_nv(p); }
78 void do_oop(narrowOop* p) { do_oop_nv(p); }
79 };
80
81 class G1VerifyCodeRootOopClosure: public OopClosure {
82 G1CollectedHeap* _g1h;
83 OopClosure* _root_cl;
84 nmethod* _nm;
85 VerifyOption _vo;
86 bool _failures;
87
88 template <class T> void do_oop_work(T* p) {
89 // First verify that this root is live
393 } else {
394 VerifyRegionClosure blk(false, vo);
395 _g1h->heap_region_iterate(&blk);
396 if (blk.failures()) {
397 failures = true;
398 }
399 }
400
401 if (G1StringDedup::is_enabled()) {
402 log_debug(gc, verify)("StrDedup");
403 G1StringDedup::verify();
404 }
405
406 if (failures) {
407 log_error(gc, verify)("Heap after failed verification:");
408 // It helps to have the per-region information in the output to
409 // help us track down what went wrong. This is why we call
410 // print_extended_on() instead of print_on().
411 Log(gc, verify) log;
412 ResourceMark rm;
413 LogStream ls(log.error());
414 _g1h->print_extended_on(&ls);
415 }
416 guarantee(!failures, "there should not have been any failures");
417 }
418
419 // Heap region set verification
420
421 class VerifyRegionListsClosure : public HeapRegionClosure {
422 private:
423 HeapRegionSet* _old_set;
424 HeapRegionSet* _humongous_set;
425 HeapRegionManager* _hrm;
426
427 public:
428 uint _old_count;
429 uint _humongous_count;
430 uint _free_count;
431
432 VerifyRegionListsClosure(HeapRegionSet* old_set,
|