diff --git a/src/hotspot/share/gc/g1/g1HeapRegion.inline.hpp b/src/hotspot/share/gc/g1/g1HeapRegion.inline.hpp index f92e37fee3c..619aef35a9a 100644 --- a/src/hotspot/share/gc/g1/g1HeapRegion.inline.hpp +++ b/src/hotspot/share/gc/g1/g1HeapRegion.inline.hpp @@ -187,7 +187,16 @@ inline void G1HeapRegion::apply_to_marked_objects(G1CMBitMap* bitmap, ApplyToMar } } - assert(next_addr == limit, "Should stop the scan at the limit."); +#ifdef ASSERT + if (is_starts_humongous() && bitmap->is_marked(bottom())) { + HeapWord* humongous_end = bottom() + cast_to_oop(bottom())->size(); + assert(next_addr == MAX2(limit, humongous_end), + "Should stop the scan at limit or end of humongous object. r %u (%s)", + hrm_index(), get_short_type_str()); + } else { + assert(next_addr == limit, "Should stop the scan at the limit. r %u (%s)", hrm_index(), get_short_type_str()); + } +#endif } inline HeapWord* G1HeapRegion::par_allocate(size_t min_word_size, diff --git a/src/hotspot/share/gc/g1/g1HeapVerifier.cpp b/src/hotspot/share/gc/g1/g1HeapVerifier.cpp index 714a2473a08..304722c13a1 100644 --- a/src/hotspot/share/gc/g1/g1HeapVerifier.cpp +++ b/src/hotspot/share/gc/g1/g1HeapVerifier.cpp @@ -461,35 +461,34 @@ public: G1ConcurrentMark* cm = G1CollectedHeap::heap()->concurrent_mark(); - bool part_of_marking = r->is_old_or_humongous() && !r->is_collection_set_candidate(); HeapWord* top_at_mark_start = cm->top_at_mark_start(r); - if (part_of_marking) { - guarantee(r->bottom() != top_at_mark_start, - "region %u (%s) does not have TAMS set", - r->hrm_index(), r->get_short_type_str()); - size_t marked_bytes = cm->live_bytes(r->hrm_index()); - + if (r->is_old_or_humongous()) { + if (!cm->is_root_region(r)) { + guarantee(r->bottom() != top_at_mark_start, + "region %u (%s) does not have TAMS set although it's going to be marked through", + r->hrm_index(), r->get_short_type_str()); + } MarkedBytesClosure cl; r->apply_to_marked_objects(cm->mark_bitmap(), &cl); + size_t marked_bytes = cm->live_bytes(r->hrm_index()); guarantee(cl.marked_bytes() == marked_bytes, "region %u (%s) live bytes actual %zu and cache %zu differ", r->hrm_index(), r->get_short_type_str(), cl.marked_bytes(), marked_bytes); - } else { + } else if (r->is_young()) { guarantee(r->bottom() == top_at_mark_start, "region %u (%s) has TAMS set " PTR_FORMAT " " PTR_FORMAT, r->hrm_index(), r->get_short_type_str(), p2i(r->bottom()), p2i(top_at_mark_start)); guarantee(cm->live_bytes(r->hrm_index()) == 0, "region %u (%s) has %zu live bytes recorded", r->hrm_index(), r->get_short_type_str(), cm->live_bytes(r->hrm_index())); - guarantee(cm->mark_bitmap()->get_next_marked_addr(r->bottom(), r->end()) == r->end(), - "region %u (%s) has mark", - r->hrm_index(), r->get_short_type_str()); - guarantee(cm->is_root_region(r), - "region %u (%s) should be root region", - r->hrm_index(), r->get_short_type_str()); + guarantee(cm->is_root_region(r), "must be for %u (%s)", r->hrm_index(), r->get_short_type_str()); } + + guarantee(cm->mark_bitmap()->get_next_marked_addr(top_at_mark_start, r->end()) == r->end(), + "region %u (%s) has mark from TAMS to top", + r->hrm_index(), r->get_short_type_str()); return false; } };