593
594 bool is_bad = !(from->is_young()
595 || to->rem_set()->contains_reference(p)
596 || (_containing_obj->is_objArray() ?
597 cv_field == dirty :
598 cv_obj == dirty || cv_field == dirty));
599 if (is_bad) {
600 MutexLockerEx x(ParGCRareEvent_lock,
601 Mutex::_no_safepoint_check_flag);
602
603 if (!_failures) {
604 log.error("----------");
605 }
606 log.error("Missing rem set entry:");
607 log.error("Field " PTR_FORMAT " of obj " PTR_FORMAT ", in region " HR_FORMAT,
608 p2i(p), p2i(_containing_obj), HR_FORMAT_PARAMS(from));
609 ResourceMark rm;
610 LogStream ls(log.error());
611 _containing_obj->print_on(&ls);
612 log.error("points to obj " PTR_FORMAT " in region " HR_FORMAT, p2i(obj), HR_FORMAT_PARAMS(to));
613 if (obj->is_oop()) {
614 obj->print_on(&ls);
615 }
616 log.error("Obj head CTE = %d, field CTE = %d.", cv_obj, cv_field);
617 log.error("----------");
618 _failures = true;
619 _n_failures++;
620 }
621 }
622 }
623 }
624 };
625
626 // Closure that applies the given two closures in sequence.
627 class G1Mux2Closure : public OopClosure {
628 OopClosure* _c1;
629 OopClosure* _c2;
630 public:
631 G1Mux2Closure(OopClosure *c1, OopClosure *c2) { _c1 = c1; _c2 = c2; }
632 template <class T> inline void do_oop_work(T* p) {
633 // Apply first closure; then apply the second.
640
641 // This really ought to be commoned up into OffsetTableContigSpace somehow.
642 // We would need a mechanism to make that code skip dead objects.
643
644 void HeapRegion::verify(VerifyOption vo,
645 bool* failures) const {
646 G1CollectedHeap* g1 = G1CollectedHeap::heap();
647 *failures = false;
648 HeapWord* p = bottom();
649 HeapWord* prev_p = NULL;
650 VerifyLiveClosure vl_cl(g1, vo);
651 VerifyRemSetClosure vr_cl(g1, vo);
652 bool is_region_humongous = is_humongous();
653 size_t object_num = 0;
654 while (p < top()) {
655 oop obj = oop(p);
656 size_t obj_size = block_size(p);
657 object_num += 1;
658
659 if (!g1->is_obj_dead_cond(obj, this, vo)) {
660 if (obj->is_oop()) {
661 Klass* klass = obj->klass();
662 bool is_metaspace_object = Metaspace::contains(klass) ||
663 (vo == VerifyOption_G1UsePrevMarking &&
664 ClassLoaderDataGraph::unload_list_contains(klass));
665 if (!is_metaspace_object) {
666 log_error(gc, verify)("klass " PTR_FORMAT " of object " PTR_FORMAT " "
667 "not metadata", p2i(klass), p2i(obj));
668 *failures = true;
669 return;
670 } else if (!klass->is_klass()) {
671 log_error(gc, verify)("klass " PTR_FORMAT " of object " PTR_FORMAT " "
672 "not a klass", p2i(klass), p2i(obj));
673 *failures = true;
674 return;
675 } else {
676 vl_cl.set_containing_obj(obj);
677 if (!g1->collector_state()->full_collection() || G1VerifyRSetsDuringFullGC) {
678 // verify liveness and rem_set
679 vr_cl.set_containing_obj(obj);
680 G1Mux2Closure mux(&vl_cl, &vr_cl);
786
787 verify_strong_code_roots(vo, failures);
788 }
789
790 void HeapRegion::verify() const {
791 bool dummy = false;
792 verify(VerifyOption_G1UsePrevMarking, /* failures */ &dummy);
793 }
794
795 void HeapRegion::verify_rem_set(VerifyOption vo, bool* failures) const {
796 G1CollectedHeap* g1 = G1CollectedHeap::heap();
797 *failures = false;
798 HeapWord* p = bottom();
799 HeapWord* prev_p = NULL;
800 VerifyRemSetClosure vr_cl(g1, vo);
801 while (p < top()) {
802 oop obj = oop(p);
803 size_t obj_size = block_size(p);
804
805 if (!g1->is_obj_dead_cond(obj, this, vo)) {
806 if (obj->is_oop()) {
807 vr_cl.set_containing_obj(obj);
808 obj->oop_iterate_no_header(&vr_cl);
809
810 if (vr_cl.failures()) {
811 *failures = true;
812 }
813 if (G1MaxVerifyFailures >= 0 &&
814 vr_cl.n_failures() >= G1MaxVerifyFailures) {
815 return;
816 }
817 } else {
818 log_error(gc, verify)(PTR_FORMAT " not an oop", p2i(obj));
819 *failures = true;
820 return;
821 }
822 }
823
824 prev_p = p;
825 p += obj_size;
826 }
|
593
594 bool is_bad = !(from->is_young()
595 || to->rem_set()->contains_reference(p)
596 || (_containing_obj->is_objArray() ?
597 cv_field == dirty :
598 cv_obj == dirty || cv_field == dirty));
599 if (is_bad) {
600 MutexLockerEx x(ParGCRareEvent_lock,
601 Mutex::_no_safepoint_check_flag);
602
603 if (!_failures) {
604 log.error("----------");
605 }
606 log.error("Missing rem set entry:");
607 log.error("Field " PTR_FORMAT " of obj " PTR_FORMAT ", in region " HR_FORMAT,
608 p2i(p), p2i(_containing_obj), HR_FORMAT_PARAMS(from));
609 ResourceMark rm;
610 LogStream ls(log.error());
611 _containing_obj->print_on(&ls);
612 log.error("points to obj " PTR_FORMAT " in region " HR_FORMAT, p2i(obj), HR_FORMAT_PARAMS(to));
613 if (oopDesc::is_oop(obj)) {
614 obj->print_on(&ls);
615 }
616 log.error("Obj head CTE = %d, field CTE = %d.", cv_obj, cv_field);
617 log.error("----------");
618 _failures = true;
619 _n_failures++;
620 }
621 }
622 }
623 }
624 };
625
626 // Closure that applies the given two closures in sequence.
627 class G1Mux2Closure : public OopClosure {
628 OopClosure* _c1;
629 OopClosure* _c2;
630 public:
631 G1Mux2Closure(OopClosure *c1, OopClosure *c2) { _c1 = c1; _c2 = c2; }
632 template <class T> inline void do_oop_work(T* p) {
633 // Apply first closure; then apply the second.
640
641 // This really ought to be commoned up into OffsetTableContigSpace somehow.
642 // We would need a mechanism to make that code skip dead objects.
643
644 void HeapRegion::verify(VerifyOption vo,
645 bool* failures) const {
646 G1CollectedHeap* g1 = G1CollectedHeap::heap();
647 *failures = false;
648 HeapWord* p = bottom();
649 HeapWord* prev_p = NULL;
650 VerifyLiveClosure vl_cl(g1, vo);
651 VerifyRemSetClosure vr_cl(g1, vo);
652 bool is_region_humongous = is_humongous();
653 size_t object_num = 0;
654 while (p < top()) {
655 oop obj = oop(p);
656 size_t obj_size = block_size(p);
657 object_num += 1;
658
659 if (!g1->is_obj_dead_cond(obj, this, vo)) {
660 if (oopDesc::is_oop(obj)) {
661 Klass* klass = obj->klass();
662 bool is_metaspace_object = Metaspace::contains(klass) ||
663 (vo == VerifyOption_G1UsePrevMarking &&
664 ClassLoaderDataGraph::unload_list_contains(klass));
665 if (!is_metaspace_object) {
666 log_error(gc, verify)("klass " PTR_FORMAT " of object " PTR_FORMAT " "
667 "not metadata", p2i(klass), p2i(obj));
668 *failures = true;
669 return;
670 } else if (!klass->is_klass()) {
671 log_error(gc, verify)("klass " PTR_FORMAT " of object " PTR_FORMAT " "
672 "not a klass", p2i(klass), p2i(obj));
673 *failures = true;
674 return;
675 } else {
676 vl_cl.set_containing_obj(obj);
677 if (!g1->collector_state()->full_collection() || G1VerifyRSetsDuringFullGC) {
678 // verify liveness and rem_set
679 vr_cl.set_containing_obj(obj);
680 G1Mux2Closure mux(&vl_cl, &vr_cl);
786
787 verify_strong_code_roots(vo, failures);
788 }
789
790 void HeapRegion::verify() const {
791 bool dummy = false;
792 verify(VerifyOption_G1UsePrevMarking, /* failures */ &dummy);
793 }
794
795 void HeapRegion::verify_rem_set(VerifyOption vo, bool* failures) const {
796 G1CollectedHeap* g1 = G1CollectedHeap::heap();
797 *failures = false;
798 HeapWord* p = bottom();
799 HeapWord* prev_p = NULL;
800 VerifyRemSetClosure vr_cl(g1, vo);
801 while (p < top()) {
802 oop obj = oop(p);
803 size_t obj_size = block_size(p);
804
805 if (!g1->is_obj_dead_cond(obj, this, vo)) {
806 if (oopDesc::is_oop(obj)) {
807 vr_cl.set_containing_obj(obj);
808 obj->oop_iterate_no_header(&vr_cl);
809
810 if (vr_cl.failures()) {
811 *failures = true;
812 }
813 if (G1MaxVerifyFailures >= 0 &&
814 vr_cl.n_failures() >= G1MaxVerifyFailures) {
815 return;
816 }
817 } else {
818 log_error(gc, verify)(PTR_FORMAT " not an oop", p2i(obj));
819 *failures = true;
820 return;
821 }
822 }
823
824 prev_p = p;
825 p += obj_size;
826 }
|