@@ -152,10 +152,19 @@ inline void ShenandoahBarrierSet::enqueue(oop obj) {
152152
153153template <DecoratorSet decorators, typename T>
154154inline 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
260269template <DecoratorSet decorators, typename BarrierSetT>
261270template <typename T>
262271inline 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