diff a/src/hotspot/share/gc/z/zPage.cpp b/src/hotspot/share/gc/z/zPage.cpp --- a/src/hotspot/share/gc/z/zPage.cpp +++ b/src/hotspot/share/gc/z/zPage.cpp @@ -191,17 +191,23 @@ void ZPage::print() const { print_on(tty); } -void ZPage::verify_live(uint32_t live_objects, size_t live_bytes, bool in_place) const { +void ZPage::verify_live(uint32_t live_objects, size_t live_bytes, uint32_t no_move_expand_count, bool in_place) const { if (!in_place) { // In-place relocation has changed the page to allocating assert_zpage_mark_state(); } guarantee(live_objects == _livemap.live_objects(), "Invalid number of live objects"); - guarantee(live_bytes == _livemap.live_bytes(), "Invalid number of live bytes"); + // live_bytes is computed from TO-space sizes. Expanding objects (is_hashed_not_expanded at + // mark time, expand_for_hash) contribute one extra HeapWord each in TO space. Non-moving + // in-place objects that would expand but stayed at the same address did NOT expand, so they + // are excluded via no_move_expand_count. + const size_t expected_live_bytes = _livemap.live_bytes() + + ((size_t)(_livemap.will_expand_objects() - no_move_expand_count)) * HeapWordSize; + guarantee(live_bytes == expected_live_bytes, "Invalid number of live bytes"); } void ZPage::fatal_msg(const char* msg) const { stringStream ss; print_on_msg(&ss, msg);