From 27dafac7537ebd1963a5be0f8dfb7750fc645d4c Mon Sep 17 00:00:00 2001 From: Xiaolong Peng Date: Wed, 21 Jan 2026 15:13:13 -0800 Subject: [PATCH] Remove _active_alloc_region flag and directly use field _atomic_top to determine atomic alloc region --- .../share/gc/shenandoah/shenandoahHeapRegion.cpp | 1 - .../share/gc/shenandoah/shenandoahHeapRegion.hpp | 13 ++++--------- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/hotspot/share/gc/shenandoah/shenandoahHeapRegion.cpp b/src/hotspot/share/gc/shenandoah/shenandoahHeapRegion.cpp index 2c6e0140bf1..79bfe389502 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahHeapRegion.cpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahHeapRegion.cpp @@ -90,7 +90,6 @@ ShenandoahHeapRegion::ShenandoahHeapRegion(HeapWord* start, size_t index, bool c SpaceMangler::mangle_region(MemRegion(_bottom, _end)); } _recycling.unset(); - _active_alloc_region.unset(); } void ShenandoahHeapRegion::report_illegal_transition(const char *method) { diff --git a/src/hotspot/share/gc/shenandoah/shenandoahHeapRegion.hpp b/src/hotspot/share/gc/shenandoah/shenandoahHeapRegion.hpp index b62e545b480..2602c1b1aec 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahHeapRegion.hpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahHeapRegion.hpp @@ -270,8 +270,6 @@ private: bool _needs_bitmap_reset; - ShenandoahSharedFlag _active_alloc_region; // Flag indicates that whether the region is an active alloc region. - public: ShenandoahHeapRegion(HeapWord* start, size_t index, bool committed); @@ -563,11 +561,9 @@ public: inline void set_active_alloc_region() { shenandoah_assert_heaplocked(); - assert(_active_alloc_region.is_unset(), "Must be"); - // Sync _top to _atomic_top before setting _active_alloc_region flag to prepare for CAS allocation assert(atomic_top() == nullptr, "Must be"); + // Sync _top to _atomic_top to set the region as an active atomic alloc region AtomicAccess::release_store(&_atomic_top, top()); - _active_alloc_region.set(); } // Unset a heap region as active alloc region, @@ -593,13 +589,12 @@ public: } current_atomic_top = prior_atomic_top; } - OrderAccess::fence(); - assert(top() == current_atomic_top, "Value of _atomic_top must have synced to _top."); - _active_alloc_region.unset(); + assert(top() == current_atomic_top, "Value of _atomic_top must have synced to _top"); } inline bool is_active_alloc_region() const { - return _active_alloc_region.is_set(); + // region is an active atomic alloc region if the atomic top is set + return atomic_top() != nullptr; } private: