src/share/vm/gc_implementation/g1/heapRegion.cpp
Print this page
*** 637,648 ****
st->print(" PTAMS "PTR_FORMAT" NTAMS "PTR_FORMAT,
prev_top_at_mark_start(), next_top_at_mark_start());
G1OffsetTableContigSpace::print_on(st);
}
! class VerifyLiveClosure: public OopClosure {
! private:
G1CollectedHeap* _g1h;
CardTableModRefBS* _bs;
oop _containing_obj;
bool _failures;
int _n_failures;
--- 637,648 ----
st->print(" PTAMS "PTR_FORMAT" NTAMS "PTR_FORMAT,
prev_top_at_mark_start(), next_top_at_mark_start());
G1OffsetTableContigSpace::print_on(st);
}
! class G1VerificationClosure : public OopClosure {
! protected:
G1CollectedHeap* _g1h;
CardTableModRefBS* _bs;
oop _containing_obj;
bool _failures;
int _n_failures;
*** 649,659 ****
VerifyOption _vo;
public:
// _vo == UsePrevMarking -> use "prev" marking information,
// _vo == UseNextMarking -> use "next" marking information,
// _vo == UseMarkWord -> use mark word from object header.
! VerifyLiveClosure(G1CollectedHeap* g1h, VerifyOption vo) :
_g1h(g1h), _bs(NULL), _containing_obj(NULL),
_failures(false), _n_failures(0), _vo(vo)
{
BarrierSet* bs = _g1h->barrier_set();
if (bs->is_a(BarrierSet::CardTableModRef))
--- 649,659 ----
VerifyOption _vo;
public:
// _vo == UsePrevMarking -> use "prev" marking information,
// _vo == UseNextMarking -> use "next" marking information,
// _vo == UseMarkWord -> use mark word from object header.
! G1VerificationClosure(G1CollectedHeap* g1h, VerifyOption vo) :
_g1h(g1h), _bs(NULL), _containing_obj(NULL),
_failures(false), _n_failures(0), _vo(vo)
{
BarrierSet* bs = _g1h->barrier_set();
if (bs->is_a(BarrierSet::CardTableModRef))
*** 665,692 ****
}
bool failures() { return _failures; }
int n_failures() { return _n_failures; }
- virtual void do_oop(narrowOop* p) { do_oop_work(p); }
- virtual void do_oop( oop* p) { do_oop_work(p); }
-
void print_object(outputStream* out, oop obj) {
#ifdef PRODUCT
Klass* k = obj->klass();
const char* class_name = InstanceKlass::cast(k)->external_name();
out->print_cr("class name %s", class_name);
#else // PRODUCT
obj->print_on(out);
#endif // PRODUCT
}
template <class T>
void do_oop_work(T* p) {
assert(_containing_obj != NULL, "Precondition");
assert(!_g1h->is_obj_dead_cond(_containing_obj, _vo),
"Precondition");
T heap_oop = oopDesc::load_heap_oop(p);
if (!oopDesc::is_null(heap_oop)) {
oop obj = oopDesc::decode_heap_oop_not_null(heap_oop);
bool failed = false;
if (!_g1h->is_in_closed_subset(obj) || _g1h->is_obj_dead_cond(obj, _vo)) {
--- 665,701 ----
}
bool failures() { return _failures; }
int n_failures() { return _n_failures; }
void print_object(outputStream* out, oop obj) {
#ifdef PRODUCT
Klass* k = obj->klass();
const char* class_name = InstanceKlass::cast(k)->external_name();
out->print_cr("class name %s", class_name);
#else // PRODUCT
obj->print_on(out);
#endif // PRODUCT
}
+ };
+ class VerifyLiveClosure : public G1VerificationClosure {
+ public:
+ VerifyLiveClosure(G1CollectedHeap* g1h, VerifyOption vo) : G1VerificationClosure(g1h, vo) {}
+ virtual void do_oop(narrowOop* p) { do_oop_work(p); }
+ virtual void do_oop(oop* p) { do_oop_work(p); }
+
template <class T>
void do_oop_work(T* p) {
assert(_containing_obj != NULL, "Precondition");
assert(!_g1h->is_obj_dead_cond(_containing_obj, _vo),
"Precondition");
+ verify_liveness(p);
+ }
+
+ template <class T>
+ void verify_liveness(T* p) {
T heap_oop = oopDesc::load_heap_oop(p);
if (!oopDesc::is_null(heap_oop)) {
oop obj = oopDesc::decode_heap_oop_not_null(heap_oop);
bool failed = false;
if (!_g1h->is_in_closed_subset(obj) || _g1h->is_obj_dead_cond(obj, _vo)) {
*** 725,736 ****
gclog_or_tty->flush();
_failures = true;
failed = true;
_n_failures++;
}
! if (!_g1h->full_collection() || G1VerifyRSetsDuringFullGC) {
HeapRegion* from = _g1h->heap_region_containing((HeapWord*)p);
HeapRegion* to = _g1h->heap_region_containing(obj);
if (from != NULL && to != NULL &&
from != to &&
!to->isHumongous()) {
--- 734,767 ----
gclog_or_tty->flush();
_failures = true;
failed = true;
_n_failures++;
}
+ }
+ }
+ };
! class VerifyRemSetClosure : public G1VerificationClosure {
! public:
! VerifyRemSetClosure(G1CollectedHeap* g1h, VerifyOption vo) : G1VerificationClosure(g1h, vo) {}
! virtual void do_oop(narrowOop* p) { do_oop_work(p); }
! virtual void do_oop(oop* p) { do_oop_work(p); }
!
! template <class T>
! void do_oop_work(T* p) {
! assert(_containing_obj != NULL, "Precondition");
! assert(!_g1h->is_obj_dead_cond(_containing_obj, _vo),
! "Precondition");
! verify_remembered_set(p);
! }
!
! template <class T>
! void verify_remembered_set(T* p) {
! T heap_oop = oopDesc::load_heap_oop(p);
! if (!oopDesc::is_null(heap_oop)) {
! oop obj = oopDesc::decode_heap_oop_not_null(heap_oop);
! bool failed = false;
HeapRegion* from = _g1h->heap_region_containing((HeapWord*)p);
HeapRegion* to = _g1h->heap_region_containing(obj);
if (from != NULL && to != NULL &&
from != to &&
!to->isHumongous()) {
*** 772,782 ****
if (!failed) _n_failures++;
}
}
}
}
- }
};
// This really ought to be commoned up into OffsetTableContigSpace somehow.
// We would need a mechanism to make that code skip dead objects.
--- 803,812 ----
*** 785,794 ****
--- 815,825 ----
G1CollectedHeap* g1 = G1CollectedHeap::heap();
*failures = false;
HeapWord* p = bottom();
HeapWord* prev_p = NULL;
VerifyLiveClosure vl_cl(g1, vo);
+ VerifyRemSetClosure vr_cl(g1, vo);
bool is_humongous = isHumongous();
bool do_bot_verify = !is_young();
size_t object_num = 0;
while (p < top()) {
oop obj = oop(p);
*** 830,850 ****
"not a klass", klass, (void *)obj);
*failures = true;
return;
} else {
vl_cl.set_containing_obj(obj);
obj->oop_iterate_no_header(&vl_cl);
if (vl_cl.failures()) {
*failures = true;
}
if (G1MaxVerifyFailures >= 0 &&
vl_cl.n_failures() >= G1MaxVerifyFailures) {
return;
}
}
} else {
! gclog_or_tty->print_cr(PTR_FORMAT" no an oop", (void *)obj);
*failures = true;
return;
}
}
prev_p = p;
--- 861,897 ----
"not a klass", klass, (void *)obj);
*failures = true;
return;
} else {
vl_cl.set_containing_obj(obj);
+ if (!g1->full_collection() || G1VerifyRSetsDuringFullGC) {
+ // verify liveness and rem_set
+ vr_cl.set_containing_obj(obj);
+ G1Mux2Closure mux(&vl_cl, &vr_cl);
+ obj->oop_iterate_no_header(&mux);
+
+ if (vr_cl.failures()) {
+ *failures = true;
+ }
+ if (G1MaxVerifyFailures >= 0 &&
+ vr_cl.n_failures() >= G1MaxVerifyFailures) {
+ return;
+ }
+ } else {
+ // verify only liveness
obj->oop_iterate_no_header(&vl_cl);
+ }
if (vl_cl.failures()) {
*failures = true;
}
if (G1MaxVerifyFailures >= 0 &&
vl_cl.n_failures() >= G1MaxVerifyFailures) {
return;
}
}
} else {
! gclog_or_tty->print_cr(PTR_FORMAT" not an oop", (void *)obj);
*failures = true;
return;
}
}
prev_p = p;
*** 928,937 ****
--- 975,1024 ----
void HeapRegion::verify() const {
bool dummy = false;
verify(VerifyOption_G1UsePrevMarking, /* failures */ &dummy);
}
+ void HeapRegion::verify_rem_set(VerifyOption vo, bool* failures) const {
+ G1CollectedHeap* g1 = G1CollectedHeap::heap();
+ *failures = false;
+ HeapWord* p = bottom();
+ HeapWord* prev_p = NULL;
+ VerifyRemSetClosure vr_cl(g1, vo);
+ while (p < top()) {
+ oop obj = oop(p);
+ size_t obj_size = block_size(p);
+
+ if (!g1->is_obj_dead_cond(obj, this, vo)) {
+ if (obj->is_oop()) {
+ vr_cl.set_containing_obj(obj);
+ obj->oop_iterate_no_header(&vr_cl);
+
+ if (vr_cl.failures()) {
+ *failures = true;
+ }
+ if (G1MaxVerifyFailures >= 0 &&
+ vr_cl.n_failures() >= G1MaxVerifyFailures) {
+ return;
+ }
+ } else {
+ gclog_or_tty->print_cr(PTR_FORMAT " not an oop", p2i(obj));
+ *failures = true;
+ return;
+ }
+ }
+
+ prev_p = p;
+ p += obj_size;
+ }
+ }
+
+ void HeapRegion::verify_rem_set() const {
+ bool failures = false;
+ verify_rem_set(VerifyOption_G1UsePrevMarking, &failures);
+ guarantee(!failures, "HeapRegion RemSet verification failed");
+ }
+
// G1OffsetTableContigSpace code; copied from space.cpp. Hope this can go
// away eventually.
void G1OffsetTableContigSpace::clear(bool mangle_space) {
set_top(bottom());