Skip to content

Commit a347ecd

Browse files
author
William Kemper
committed
8350905: Shenandoah: Releasing a WeakHandle's referent may extend its lifetime
Reviewed-by: shade, ysr
1 parent 5502ce7 commit a347ecd

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/hotspot/share/gc/shenandoah/shenandoahBarrierSet.inline.hpp

+10
Original file line numberDiff line numberDiff line change
@@ -152,10 +152,19 @@ inline void ShenandoahBarrierSet::enqueue(oop obj) {
152152

153153
template <DecoratorSet decorators, typename T>
154154
inline void ShenandoahBarrierSet::satb_barrier(T *field) {
155+
// Uninitialized and no-keepalive stores do not need barrier.
155156
if (HasDecorator<decorators, IS_DEST_UNINITIALIZED>::value ||
156157
HasDecorator<decorators, AS_NO_KEEPALIVE>::value) {
157158
return;
158159
}
160+
161+
// Stores to weak/phantom require no barrier. The original references would
162+
// have been enqueued in the SATB buffer by the load barrier if they were needed.
163+
if (HasDecorator<decorators, ON_WEAK_OOP_REF>::value ||
164+
HasDecorator<decorators, ON_PHANTOM_OOP_REF>::value) {
165+
return;
166+
}
167+
159168
if (ShenandoahSATBBarrier && _heap->is_concurrent_mark_in_progress()) {
160169
T heap_oop = RawAccess<>::oop_load(field);
161170
if (!CompressedOops::is_null(heap_oop)) {
@@ -260,6 +269,7 @@ inline void ShenandoahBarrierSet::AccessBarrier<decorators, BarrierSetT>::oop_st
260269
template <DecoratorSet decorators, typename BarrierSetT>
261270
template <typename T>
262271
inline void ShenandoahBarrierSet::AccessBarrier<decorators, BarrierSetT>::oop_store_not_in_heap(T* addr, oop value) {
272+
assert((decorators & ON_UNKNOWN_OOP_REF) == 0, "Reference strength must be known");
263273
oop_store_common(addr, value);
264274
}
265275

0 commit comments

Comments
 (0)