From 5cd603e5686291030afe3b4d947f8f79159032b5 Mon Sep 17 00:00:00 2001 From: Albert Yang Date: Wed, 5 Nov 2025 11:11:09 +0100 Subject: [PATCH] g1-zap --- src/hotspot/share/gc/g1/g1HeapRegion.cpp | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) diff --git a/src/hotspot/share/gc/g1/g1HeapRegion.cpp b/src/hotspot/share/gc/g1/g1HeapRegion.cpp index 63d64503316fc..b1eeb333d8dce 100644 --- a/src/hotspot/share/gc/g1/g1HeapRegion.cpp +++ b/src/hotspot/share/gc/g1/g1HeapRegion.cpp @@ -787,23 +787,13 @@ void G1HeapRegion::fill_range_with_dead_objects(HeapWord* start, HeapWord* end) // possible that there is a pinned object that is not any more referenced by // Java code (only by native). // - // In this case we must not zap contents of such an array but we can overwrite - // the header; since only pinned typearrays are allowed, this fits nicely with - // putting filler arrays into the dead range as the object header sizes match and - // no user data is overwritten. + // In this case we should not zap, because that would overwrite + // user-observable data. Memory corresponding to obj-header is safe to + // change, since it's not directly user-observable. // // In particular String Deduplication might change the reference to the character // array of the j.l.String after native code obtained a raw reference to it (via // GetStringCritical()). - CollectedHeap::fill_with_objects(start, range_size, !has_pinned_objects()); - HeapWord* current = start; - do { - // Update the BOT if the a threshold is crossed. - size_t obj_size = cast_to_oop(current)->size(); - update_bot_for_block(current, current + obj_size); - - // Advance to the next object. - current += obj_size; - guarantee(current <= end, "Should never go past end"); - } while (current != end); + CollectedHeap::fill_with_object(start, range_size, !has_pinned_objects()); + update_bot_for_block(start, start + range_size); }