diff --git a/src/hotspot/share/gc/g1/g1BarrierSet.hpp b/src/hotspot/share/gc/g1/g1BarrierSet.hpp index 8c2605b9746..2b1074fcd7a 100644 --- a/src/hotspot/share/gc/g1/g1BarrierSet.hpp +++ b/src/hotspot/share/gc/g1/g1BarrierSet.hpp @@ -112,6 +112,11 @@ class G1BarrierSet: public CardTableBarrierSet { // Defensive: will catch weak oops at addresses in heap template static oop oop_load_in_heap(T* addr); + + template + static oop oop_atomic_cmpxchg_not_in_heap(T* addr, oop compare_value, oop new_value); + template + static oop oop_atomic_xchg_not_in_heap(T* addr, oop new_value); }; }; diff --git a/src/hotspot/share/gc/g1/g1BarrierSet.inline.hpp b/src/hotspot/share/gc/g1/g1BarrierSet.inline.hpp index a032f072aed..33c153e9e5d 100644 --- a/src/hotspot/share/gc/g1/g1BarrierSet.inline.hpp +++ b/src/hotspot/share/gc/g1/g1BarrierSet.inline.hpp @@ -132,4 +132,26 @@ oop_store_not_in_heap(T* addr, oop new_value) { Raw::oop_store(addr, new_value); } +template +template +inline oop G1BarrierSet::AccessBarrier:: +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(BarrierSet::barrier_set()); + bs->write_ref_field_pre(addr); + return Raw::oop_atomic_cmpxchg(addr, compare_value, new_value); +} + +template +template +inline oop G1BarrierSet::AccessBarrier:: +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(BarrierSet::barrier_set()); + bs->write_ref_field_pre(addr); + return Raw::oop_atomic_xchg(addr, new_value); +} + #endif // SHARE_GC_G1_G1BARRIERSET_INLINE_HPP