8350905: Shenandoah: Releasing a WeakHandle's referent may extend its lifetime

Reviewed-by: shade, ysr
This commit is contained in:
William Kemper 2025-03-12 20:42:41 +00:00
parent 5502ce733e
commit a347ecdedc

View File

@ -152,10 +152,19 @@ inline void ShenandoahBarrierSet::enqueue(oop obj) {
template <DecoratorSet decorators, typename T>
inline void ShenandoahBarrierSet::satb_barrier(T *field) {
// Uninitialized and no-keepalive stores do not need barrier.
if (HasDecorator<decorators, IS_DEST_UNINITIALIZED>::value ||
HasDecorator<decorators, AS_NO_KEEPALIVE>::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<decorators, ON_WEAK_OOP_REF>::value ||
HasDecorator<decorators, ON_PHANTOM_OOP_REF>::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<decorators, BarrierSetT>::oop_st
template <DecoratorSet decorators, typename BarrierSetT>
template <typename T>
inline void ShenandoahBarrierSet::AccessBarrier<decorators, BarrierSetT>::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);
}