--- old/src/share/vm/gc/g1/g1HeapVerifier.cpp 2017-08-04 01:01:57.430914494 -0400 +++ new/src/share/vm/gc/g1/g1HeapVerifier.cpp 2017-08-04 01:01:56.038835725 -0400 @@ -60,7 +60,8 @@ T heap_oop = oopDesc::load_heap_oop(p); if (!oopDesc::is_null(heap_oop)) { oop obj = oopDesc::decode_heap_oop_not_null(heap_oop); - if (_g1h->is_obj_dead_cond(obj, _vo)) { + HeapRegion* hr = _g1h->heap_region_containing(obj); + if (_g1h->is_obj_dead_cond(obj, _vo) && !hr->is_archive()) { Log(gc, verify) log; log.info("Root location " PTR_FORMAT " points to dead obj " PTR_FORMAT, p2i(p), p2i(obj)); if (_vo == VerifyOption_G1UseMarkWord) { @@ -234,30 +235,74 @@ }; class VerifyArchiveOopClosure: public OopClosure { + HeapRegion* _hr; + bool _verbose; public: - VerifyArchiveOopClosure(HeapRegion *hr) { } + VerifyArchiveOopClosure(HeapRegion *hr, bool verbose) + : _hr(hr), _verbose(verbose) { } void do_oop(narrowOop *p) { do_oop_work(p); } void do_oop( oop *p) { do_oop_work(p); } template void do_oop_work(T *p) { oop obj = oopDesc::load_decode_heap_oop(p); - guarantee(obj == NULL || G1ArchiveAllocator::is_archive_object(obj), - "Archive object at " PTR_FORMAT " references a non-archive object at " PTR_FORMAT, - p2i(p), p2i(obj)); + if (_verbose) { + if (obj != NULL) { + obj->print(); + } + } + + if (_hr->is_open_archive()) { + guarantee(obj == NULL || G1ArchiveAllocator::is_archive_object(obj), + "Archive object at " PTR_FORMAT " references a non-archive object at " PTR_FORMAT, + p2i(p), p2i(obj)); + } else { + assert(_hr->is_closed_archive(), "should be archive region"); + guarantee(obj == NULL || G1ArchiveAllocator::is_closed_archive_object(obj), + "Archive object at " PTR_FORMAT " references a non-archive object at " PTR_FORMAT, + p2i(p), p2i(obj)); + } } }; -class VerifyArchiveRegionClosure: public ObjectClosure { +class VerifyObjectInArchiveRegionClosure: public ObjectClosure { + HeapRegion* _hr; + bool _verbose; public: - VerifyArchiveRegionClosure(HeapRegion *hr) { } + VerifyObjectInArchiveRegionClosure(HeapRegion *hr, bool verbose) + : _hr(hr), _verbose(verbose) { } // Verify that all object pointers are to archive regions. void do_object(oop o) { - VerifyArchiveOopClosure checkOop(NULL); + if (_verbose) { + o->print(); + } + + VerifyArchiveOopClosure checkOop(_hr, _verbose); assert(o != NULL, "Should not be here for NULL oops"); o->oop_iterate_no_header(&checkOop); } }; +// Should be only used at CDS dump time +class VerifyArchivePointerRegionClosure: public HeapRegionClosure { +private: + G1CollectedHeap* _g1h; +public: + VerifyArchivePointerRegionClosure(G1CollectedHeap* g1h) { } + virtual bool doHeapRegion(HeapRegion* r) { + if (r->is_archive()) { + VerifyObjectInArchiveRegionClosure verify_oop_pointers(r, false); + r->object_iterate(&verify_oop_pointers); + } + return false; + } +}; + +void G1HeapVerifier::verify_archive_regions() { + G1CollectedHeap* g1h = G1CollectedHeap::heap(); + VerifyArchivePointerRegionClosure cl(NULL); + g1h->heap_region_iterate(&cl); +} + class VerifyRegionClosure: public HeapRegionClosure { private: bool _par; @@ -279,12 +324,15 @@ bool doHeapRegion(HeapRegion* r) { // For archive regions, verify there are no heap pointers to // non-pinned regions. For all others, verify liveness info. - if (r->is_archive()) { - VerifyArchiveRegionClosure verify_oop_pointers(r); + if (r->is_closed_archive()) { + VerifyObjectInArchiveRegionClosure verify_oop_pointers(r, false); r->object_iterate(&verify_oop_pointers); return true; - } - if (!r->is_continues_humongous()) { + } else if (r->is_open_archive()) { + VerifyObjsInRegionClosure verify_open_archive_oop(r, _vo); + r->object_iterate(&verify_open_archive_oop); + return true; + } else if (!r->is_continues_humongous()) { bool failures = false; r->verify(_vo, &failures); if (failures) {