From a347ecdedc098bd23598ba6acf28d77db01be066 Mon Sep 17 00:00:00 2001 From: William Kemper Date: Wed, 12 Mar 2025 20:42:41 +0000 Subject: [PATCH] 8350905: Shenandoah: Releasing a WeakHandle's referent may extend its lifetime Reviewed-by: shade, ysr --- .../gc/shenandoah/shenandoahBarrierSet.inline.hpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/hotspot/share/gc/shenandoah/shenandoahBarrierSet.inline.hpp b/src/hotspot/share/gc/shenandoah/shenandoahBarrierSet.inline.hpp index 4f114690f53..20937b9d08e 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahBarrierSet.inline.hpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahBarrierSet.inline.hpp @@ -152,10 +152,19 @@ inline void ShenandoahBarrierSet::enqueue(oop obj) { template inline void ShenandoahBarrierSet::satb_barrier(T *field) { + // Uninitialized and no-keepalive stores do not need barrier. if (HasDecorator::value || HasDecorator::value) { return; } + + // Stores to weak/phantom require no barrier. The original references would + // have been enqueued in the SATB buffer by the load barrier if they were needed. + if (HasDecorator::value || + HasDecorator::value) { + return; + } + if (ShenandoahSATBBarrier && _heap->is_concurrent_mark_in_progress()) { T heap_oop = RawAccess<>::oop_load(field); if (!CompressedOops::is_null(heap_oop)) { @@ -260,6 +269,7 @@ inline void ShenandoahBarrierSet::AccessBarrier::oop_st template template inline void ShenandoahBarrierSet::AccessBarrier::oop_store_not_in_heap(T* addr, oop value) { + assert((decorators & ON_UNKNOWN_OOP_REF) == 0, "Reference strength must be known"); oop_store_common(addr, value); }