< prev index next >

src/share/vm/gc_implementation/shenandoah/shenandoahAsserts.cpp

Print this page
rev 10497 : [backport] Verifier should dump raw memory around the problematic oops
rev 10580 : [backport] Refactor to group marking bitmap and TAMS structure in one class ShenandoahMarkingContext
rev 10581 : [backport] Refactor alive-closures to deal better with new marking contexts
rev 10609 : [backport] shenandoah_assert_correct should check object/forwardee klasses
rev 10614 : [backport] Replace custom asserts with shenandoah_assert_*
rev 10626 : [backport] shenandoah_assert_correct should verify classes before claiming _safe_oop
rev 10637 : [backport] Purge partial heuristics and connection matrix infrastructure

*** 25,50 **** #include "gc_implementation/shenandoah/brooksPointer.hpp" #include "gc_implementation/shenandoah/shenandoahAsserts.hpp" #include "gc_implementation/shenandoah/shenandoahHeap.hpp" #include "gc_implementation/shenandoah/shenandoahHeap.inline.hpp" #include "memory/resourceArea.hpp" void ShenandoahAsserts::print_obj(ShenandoahMessageBuffer& msg, oop obj) { ShenandoahHeap* heap = ShenandoahHeap::heap(); ShenandoahHeapRegion *r = heap->heap_region_containing(obj); ResourceMark rm; stringStream ss; r->print_on(&ss); msg.append(" " PTR_FORMAT " - klass " PTR_FORMAT " %s\n", p2i(obj), p2i(obj->klass()), obj->klass()->external_name()); ! msg.append(" %3s allocated after complete mark start\n", heap->allocated_after_complete_mark_start((HeapWord *) obj) ? "" : "not"); ! msg.append(" %3s allocated after next mark start\n", heap->allocated_after_next_mark_start((HeapWord *) obj) ? "" : "not"); ! msg.append(" %3s marked complete\n", heap->is_marked_complete(obj) ? "" : "not"); ! msg.append(" %3s marked next\n", heap->is_marked_next(obj) ? "" : "not"); msg.append(" %3s in collection set\n", heap->in_collection_set(obj) ? "" : "not"); msg.append(" region: %s", ss.as_string()); } void ShenandoahAsserts::print_non_obj(ShenandoahMessageBuffer& msg, void* loc) { --- 25,75 ---- #include "gc_implementation/shenandoah/brooksPointer.hpp" #include "gc_implementation/shenandoah/shenandoahAsserts.hpp" #include "gc_implementation/shenandoah/shenandoahHeap.hpp" #include "gc_implementation/shenandoah/shenandoahHeap.inline.hpp" + #include "gc_implementation/shenandoah/shenandoahMarkingContext.inline.hpp" #include "memory/resourceArea.hpp" + void print_raw_memory(ShenandoahMessageBuffer &msg, void* loc) { + // Be extra safe. Only access data that is guaranteed to be safe: + // should be in heap, in known committed region, within that region. + + ShenandoahHeap* heap = ShenandoahHeap::heap(); + if (!heap->is_in(loc)) return; + + ShenandoahHeapRegion* r = heap->heap_region_containing(loc); + if (r != NULL && r->is_committed()) { + + address start = MAX2((address) r->bottom(), (address) loc - 32); + address end = MIN2((address) r->end(), (address) loc + 128); + if (start >= end) return; + + stringStream ss; + os::print_hex_dump(&ss, start, end, 4); + msg.append("\n"); + msg.append("Raw heap memory:\n%s", ss.as_string()); + } + } + void ShenandoahAsserts::print_obj(ShenandoahMessageBuffer& msg, oop obj) { ShenandoahHeap* heap = ShenandoahHeap::heap(); ShenandoahHeapRegion *r = heap->heap_region_containing(obj); ResourceMark rm; stringStream ss; r->print_on(&ss); + ShenandoahMarkingContext* const next_ctx = heap->next_marking_context(); + ShenandoahMarkingContext* const compl_ctx = heap->complete_marking_context(); + msg.append(" " PTR_FORMAT " - klass " PTR_FORMAT " %s\n", p2i(obj), p2i(obj->klass()), obj->klass()->external_name()); ! msg.append(" %3s allocated after complete mark start\n", compl_ctx->allocated_after_mark_start((HeapWord *) obj) ? "" : "not"); ! msg.append(" %3s allocated after next mark start\n", next_ctx->allocated_after_mark_start((HeapWord *) obj) ? "" : "not"); ! msg.append(" %3s marked complete\n", compl_ctx->is_marked(obj) ? "" : "not"); ! msg.append(" %3s marked next\n", next_ctx->is_marked(obj) ? "" : "not"); msg.append(" %3s in collection set\n", heap->in_collection_set(obj) ? "" : "not"); msg.append(" region: %s", ss.as_string()); } void ShenandoahAsserts::print_non_obj(ShenandoahMessageBuffer& msg, void* loc) {
*** 72,81 **** --- 97,107 ---- ShenandoahHeapRegion* r = heap->heap_region_containing(loc); if (r != NULL) { stringStream ss; r->print_on(&ss); msg.append(" region: %s", ss.as_string()); + print_raw_memory(msg, loc); } } } void ShenandoahAsserts::print_failure(SafeLevel level, oop obj, void* interior_loc, oop loc,
*** 83,93 **** const char* file, int line) { ShenandoahHeap* heap = ShenandoahHeap::heap(); ResourceMark rm; bool loc_in_heap = (loc != NULL && heap->is_in(loc)); - bool interior_loc_in_heap = (interior_loc != NULL && heap->is_in(interior_loc)); ShenandoahMessageBuffer msg("%s; %s\n\n", phase, label); msg.append("Referenced from:\n"); if (interior_loc != NULL) { --- 109,118 ----
*** 149,197 **** } void ShenandoahAsserts::assert_correct(void* interior_loc, oop obj, const char* file, int line) { ShenandoahHeap* heap = ShenandoahHeap::heap_no_check(); ! // Step 1. Check that both obj and its fwdptr are in heap. // After this step, it is safe to call heap_region_containing(). if (!heap->is_in(obj)) { print_failure(_safe_unknown, obj, interior_loc, NULL, "Shenandoah assert_correct failed", "oop must point to a heap address", file, line); } ! oop fwd = oop(BrooksPointer::get_raw_unchecked(obj)); ! if (!heap->is_in(fwd)) { ! print_failure(_safe_oop, obj, interior_loc, NULL, "Shenandoah assert_correct failed", ! "Forwardee must point to a heap address", ! file, line); } ! bool is_forwarded = !oopDesc::unsafe_equals(obj, fwd); // When Full GC moves the objects, we cannot trust fwdptrs. If we got here, it means something // tries fwdptr manipulation when Full GC is running. The only exception is using the fwdptr // that still points to the object itself. ! ! if (is_forwarded && heap->is_full_gc_move_in_progress()) { ! print_failure(_safe_all, obj, interior_loc, NULL, "Shenandoah assert_correct failed", "Non-trivial forwarding pointer during Full GC moves, probable bug.", file, line); } ! // Step 2. Check that forwardee points to correct region. ! if (is_forwarded && ! (heap->heap_region_index_containing(fwd) == ! heap->heap_region_index_containing(obj))) { print_failure(_safe_all, obj, interior_loc, NULL, "Shenandoah assert_correct failed", ! "Forwardee should be self, or another region", file, line); } ! // Step 3. Check for multiple forwardings ! if (is_forwarded) { oop fwd2 = oop(BrooksPointer::get_raw_unchecked(fwd)); if (!oopDesc::unsafe_equals(fwd, fwd2)) { print_failure(_safe_all, obj, interior_loc, NULL, "Shenandoah assert_correct failed", "Multiple forwardings", file, line); --- 174,238 ---- } void ShenandoahAsserts::assert_correct(void* interior_loc, oop obj, const char* file, int line) { ShenandoahHeap* heap = ShenandoahHeap::heap_no_check(); ! // Step 1. Check that obj is correct. // After this step, it is safe to call heap_region_containing(). if (!heap->is_in(obj)) { print_failure(_safe_unknown, obj, interior_loc, NULL, "Shenandoah assert_correct failed", "oop must point to a heap address", file, line); } ! Klass* obj_klass = obj->klass_or_null(); ! if (obj_klass == NULL) { ! print_failure(_safe_unknown, obj, interior_loc, NULL, "Shenandoah assert_correct failed", ! "Object klass pointer should not be NULL", ! file,line); ! } ! if (!Metaspace::contains(obj_klass)) { ! print_failure(_safe_unknown, obj, interior_loc, NULL, "Shenandoah assert_correct failed", ! "Object klass pointer must go to metaspace", ! file,line); } ! oop fwd = oop(BrooksPointer::get_raw_unchecked(obj)); ! ! if (!oopDesc::unsafe_equals(obj, fwd)) { // When Full GC moves the objects, we cannot trust fwdptrs. If we got here, it means something // tries fwdptr manipulation when Full GC is running. The only exception is using the fwdptr // that still points to the object itself. ! if (heap->is_full_gc_move_in_progress()) { ! print_failure(_safe_oop, obj, interior_loc, NULL, "Shenandoah assert_correct failed", "Non-trivial forwarding pointer during Full GC moves, probable bug.", file, line); } ! // Step 2. Check that forwardee is correct ! if (!heap->is_in(fwd)) { ! print_failure(_safe_oop, obj, interior_loc, NULL, "Shenandoah assert_correct failed", ! "Forwardee must point to a heap address", ! file, line); ! } ! ! if (obj_klass != fwd->klass()) { ! print_failure(_safe_oop, obj, interior_loc, NULL, "Shenandoah assert_correct failed", ! "Forwardee klass disagrees with object class", ! file, line); ! } ! ! // Step 3. Check that forwardee points to correct region ! if (heap->heap_region_index_containing(fwd) == heap->heap_region_index_containing(obj)) { print_failure(_safe_all, obj, interior_loc, NULL, "Shenandoah assert_correct failed", ! "Non-trivial forwardee should in another region", file, line); } ! // Step 4. Check for multiple forwardings oop fwd2 = oop(BrooksPointer::get_raw_unchecked(fwd)); if (!oopDesc::unsafe_equals(fwd, fwd2)) { print_failure(_safe_all, obj, interior_loc, NULL, "Shenandoah assert_correct failed", "Multiple forwardings", file, line);
*** 254,281 **** void ShenandoahAsserts::assert_marked_complete(void* interior_loc, oop obj, const char* file, int line) { assert_correct(interior_loc, obj, file, line); ShenandoahHeap* heap = ShenandoahHeap::heap_no_check(); ! if (!heap->is_marked_complete(obj)) { print_failure(_safe_all, obj, interior_loc, NULL, "Shenandoah assert_marked_complete failed", "Object should be marked (complete)", file, line); } } void ShenandoahAsserts::assert_marked_next(void* interior_loc, oop obj, const char* file, int line) { assert_correct(interior_loc, obj, file, line); ShenandoahHeap* heap = ShenandoahHeap::heap_no_check(); ! if (!heap->is_marked_next(obj)) { print_failure(_safe_all, obj, interior_loc, NULL, "Shenandoah assert_marked_next failed", "Object should be marked (next)", file, line); } } void ShenandoahAsserts::assert_not_in_cset(void* interior_loc, oop obj, const char* file, int line) { assert_correct(interior_loc, obj, file, line); ShenandoahHeap* heap = ShenandoahHeap::heap_no_check(); if (heap->in_collection_set(obj)) { --- 295,333 ---- void ShenandoahAsserts::assert_marked_complete(void* interior_loc, oop obj, const char* file, int line) { assert_correct(interior_loc, obj, file, line); ShenandoahHeap* heap = ShenandoahHeap::heap_no_check(); ! if (!heap->complete_marking_context()->is_marked(obj)) { print_failure(_safe_all, obj, interior_loc, NULL, "Shenandoah assert_marked_complete failed", "Object should be marked (complete)", file, line); } } void ShenandoahAsserts::assert_marked_next(void* interior_loc, oop obj, const char* file, int line) { assert_correct(interior_loc, obj, file, line); ShenandoahHeap* heap = ShenandoahHeap::heap_no_check(); ! if (!heap->next_marking_context()->is_marked(obj)) { print_failure(_safe_all, obj, interior_loc, NULL, "Shenandoah assert_marked_next failed", "Object should be marked (next)", file, line); } } + void ShenandoahAsserts::assert_in_cset(void* interior_loc, oop obj, const char* file, int line) { + assert_correct(interior_loc, obj, file, line); + + ShenandoahHeap* heap = ShenandoahHeap::heap_no_check(); + if (!heap->in_collection_set(obj)) { + print_failure(_safe_all, obj, interior_loc, NULL, "Shenandoah assert_in_cset failed", + "Object should be in collection set", + file, line); + } + } + void ShenandoahAsserts::assert_not_in_cset(void* interior_loc, oop obj, const char* file, int line) { assert_correct(interior_loc, obj, file, line); ShenandoahHeap* heap = ShenandoahHeap::heap_no_check(); if (heap->in_collection_set(obj)) {
*** 292,324 **** "Interior location should not be in collection set", file, line); } } ! void ShenandoahAsserts::print_rp_failure(const char *label, BoolObjectClosure* actual, BoolObjectClosure* expected, const char *file, int line) { ShenandoahHeap* heap = ShenandoahHeap::heap(); ShenandoahMessageBuffer msg("%s\n", label); msg.append(" Actual: " PTR_FORMAT "\n", p2i(actual)); - msg.append(" Expected: " PTR_FORMAT "\n", p2i(expected)); - msg.append(" SH->_is_alive: " PTR_FORMAT "\n", p2i(&heap->_is_alive)); - msg.append(" SH->_forwarded_is_alive: " PTR_FORMAT "\n", p2i(&heap->_forwarded_is_alive)); report_vm_error(file, line, msg.buffer()); } void ShenandoahAsserts::assert_rp_isalive_not_installed(const char *file, int line) { ShenandoahHeap* heap = ShenandoahHeap::heap(); ReferenceProcessor* rp = heap->ref_processor(); if (rp->is_alive_non_header() != NULL) { ! print_rp_failure("Shenandoah assert_rp_isalive_not_installed failed", rp->is_alive_non_header(), NULL, file, line); } } void ShenandoahAsserts::assert_rp_isalive_installed(const char *file, int line) { ShenandoahHeap* heap = ShenandoahHeap::heap(); ReferenceProcessor* rp = heap->ref_processor(); ! if (rp->is_alive_non_header() != heap->is_alive_closure()) { ! print_rp_failure("Shenandoah assert_rp_isalive_installed failed", rp->is_alive_non_header(), heap->is_alive_closure(), file, line); } } --- 344,373 ---- "Interior location should not be in collection set", file, line); } } ! void ShenandoahAsserts::print_rp_failure(const char *label, BoolObjectClosure* actual, const char *file, int line) { ShenandoahHeap* heap = ShenandoahHeap::heap(); ShenandoahMessageBuffer msg("%s\n", label); msg.append(" Actual: " PTR_FORMAT "\n", p2i(actual)); report_vm_error(file, line, msg.buffer()); } void ShenandoahAsserts::assert_rp_isalive_not_installed(const char *file, int line) { ShenandoahHeap* heap = ShenandoahHeap::heap(); ReferenceProcessor* rp = heap->ref_processor(); if (rp->is_alive_non_header() != NULL) { ! print_rp_failure("Shenandoah assert_rp_isalive_not_installed failed", rp->is_alive_non_header(), file, line); } } void ShenandoahAsserts::assert_rp_isalive_installed(const char *file, int line) { ShenandoahHeap* heap = ShenandoahHeap::heap(); ReferenceProcessor* rp = heap->ref_processor(); ! if (rp->is_alive_non_header() == NULL) { ! print_rp_failure("Shenandoah assert_rp_isalive_installed failed", rp->is_alive_non_header(), file, line); } }
< prev index next >