8357954: G1: No SATB barriers applied for runtime IN_NATIVE atomics

Reviewed-by: shade, kbarrett, tschatzl
This commit is contained in:
Erik Österlund 2025-06-03 14:27:41 +00:00
parent 4618374269
commit d3f54dae30
2 changed files with 27 additions and 0 deletions

View File

@ -112,6 +112,11 @@ class G1BarrierSet: public CardTableBarrierSet {
// Defensive: will catch weak oops at addresses in heap
template <typename T>
static oop oop_load_in_heap(T* addr);
template <typename T>
static oop oop_atomic_cmpxchg_not_in_heap(T* addr, oop compare_value, oop new_value);
template <typename T>
static oop oop_atomic_xchg_not_in_heap(T* addr, oop new_value);
};
};

View File

@ -132,4 +132,26 @@ oop_store_not_in_heap(T* addr, oop new_value) {
Raw::oop_store(addr, new_value);
}
template <DecoratorSet decorators, typename BarrierSetT>
template <typename T>
inline oop G1BarrierSet::AccessBarrier<decorators, BarrierSetT>::
oop_atomic_cmpxchg_not_in_heap(T* addr, oop compare_value, oop new_value) {
// Apply SATB barriers for all non-heap references, to allow
// concurrent scanning of such references.
G1BarrierSet *bs = barrier_set_cast<G1BarrierSet>(BarrierSet::barrier_set());
bs->write_ref_field_pre<decorators>(addr);
return Raw::oop_atomic_cmpxchg(addr, compare_value, new_value);
}
template <DecoratorSet decorators, typename BarrierSetT>
template <typename T>
inline oop G1BarrierSet::AccessBarrier<decorators, BarrierSetT>::
oop_atomic_xchg_not_in_heap(T* addr, oop new_value) {
// Apply SATB barriers for all non-heap references, to allow
// concurrent scanning of such references.
G1BarrierSet *bs = barrier_set_cast<G1BarrierSet>(BarrierSet::barrier_set());
bs->write_ref_field_pre<decorators>(addr);
return Raw::oop_atomic_xchg(addr, new_value);
}
#endif // SHARE_GC_G1_G1BARRIERSET_INLINE_HPP