53
54 // Causes all refs in "mr" to be assumed to be modified (by this JavaThread).
55 virtual void invalidate(MemRegion mr) = 0;
56 // Causes all refs in "mr" to be assumed to be modified by the given JavaThread.
57 virtual void write_region(JavaThread* thread, MemRegion mr) = 0;
58
59 // Operations on arrays, or general regions (e.g., for "clone") may be
60 // optimized by some barriers.
61
62 // Below length is the # array elements being written
63 virtual void write_ref_array_pre(oop* dst, size_t length,
64 bool dest_uninitialized = false) {}
65 virtual void write_ref_array_pre(narrowOop* dst, size_t length,
66 bool dest_uninitialized = false) {}
67 // Below count is the # array elements being written, starting
68 // at the address "start", which may not necessarily be HeapWord-aligned
69 inline void write_ref_array(HeapWord* start, size_t count);
70
71 protected:
72 virtual void write_ref_array_work(MemRegion mr) = 0;
73
74 public:
75 // The ModRef abstraction introduces pre and post barriers
76 template <DecoratorSet decorators, typename BarrierSetT>
77 class AccessBarrier: public BarrierSet::AccessBarrier<decorators, BarrierSetT> {
78 typedef BarrierSet::AccessBarrier<decorators, BarrierSetT> Raw;
79
80 public:
81 template <typename T>
82 static void oop_store_in_heap(T* addr, oop value);
83 template <typename T>
84 static oop oop_atomic_cmpxchg_in_heap(T* addr, oop compare_value, oop new_value);
85 template <typename T>
86 static oop oop_atomic_xchg_in_heap(T* addr, oop new_value);
87
88 template <typename T>
89 static bool oop_arraycopy_in_heap(arrayOop src_obj, size_t src_offset_in_bytes, T* src_raw,
90 arrayOop dst_obj, size_t dst_offset_in_bytes, T* dst_raw,
91 size_t length);
92
93 static void clone_in_heap(oop src, oop dst, size_t size);
94
95 static void oop_store_in_heap_at(oop base, ptrdiff_t offset, oop value) {
96 oop_store_in_heap(AccessInternal::oop_field_addr<decorators>(base, offset), value);
97 }
98
99 static oop oop_atomic_xchg_in_heap_at(oop base, ptrdiff_t offset, oop new_value) {
100 return oop_atomic_xchg_in_heap(AccessInternal::oop_field_addr<decorators>(base, offset), new_value);
101 }
102
103 static oop oop_atomic_cmpxchg_in_heap_at(oop base, ptrdiff_t offset, oop compare_value, oop new_value) {
104 return oop_atomic_cmpxchg_in_heap(AccessInternal::oop_field_addr<decorators>(base, offset), compare_value, new_value);
105 }
106 };
107 };
108
109 template<>
110 struct BarrierSet::GetName<ModRefBarrierSet> {
111 static const BarrierSet::Name value = BarrierSet::ModRef;
112 };
113
114 #endif // SHARE_GC_SHARED_MODREFBARRIERSET_HPP
|
53
54 // Causes all refs in "mr" to be assumed to be modified (by this JavaThread).
55 virtual void invalidate(MemRegion mr) = 0;
56 // Causes all refs in "mr" to be assumed to be modified by the given JavaThread.
57 virtual void write_region(JavaThread* thread, MemRegion mr) = 0;
58
59 // Operations on arrays, or general regions (e.g., for "clone") may be
60 // optimized by some barriers.
61
62 // Below length is the # array elements being written
63 virtual void write_ref_array_pre(oop* dst, size_t length,
64 bool dest_uninitialized = false) {}
65 virtual void write_ref_array_pre(narrowOop* dst, size_t length,
66 bool dest_uninitialized = false) {}
67 // Below count is the # array elements being written, starting
68 // at the address "start", which may not necessarily be HeapWord-aligned
69 inline void write_ref_array(HeapWord* start, size_t count);
70
71 protected:
72 virtual void write_ref_array_work(MemRegion mr) = 0;
73 public:
74 // The ModRef abstraction introduces pre and post barriers
75 template <DecoratorSet decorators, typename BarrierSetT>
76 class AccessBarrier: public BarrierSet::AccessBarrier<decorators, BarrierSetT> {
77 typedef BarrierSet::AccessBarrier<decorators, BarrierSetT> Raw;
78
79 public:
80 template <typename T>
81 static void oop_store_in_heap(T* addr, oop value);
82 template <typename T>
83 static oop oop_atomic_cmpxchg_in_heap(T* addr, oop compare_value, oop new_value);
84 template <typename T>
85 static oop oop_atomic_xchg_in_heap(T* addr, oop new_value);
86
87 template <typename T>
88 static void oop_arraycopy_in_heap(arrayOop src_obj, size_t src_offset_in_bytes, T* src_raw,
89 arrayOop dst_obj, size_t dst_offset_in_bytes, T* dst_raw,
90 size_t length);
91 private:
92 // Failing checkcast or check null during copy, still needs barrier
93 template <typename T>
94 static inline void oop_arraycopy_partial_barrier(BarrierSetT *bs, T* dst_raw, T* p);
95 public:
96 static void clone_in_heap(oop src, oop dst, size_t size);
97
98 static void oop_store_in_heap_at(oop base, ptrdiff_t offset, oop value) {
99 oop_store_in_heap(AccessInternal::oop_field_addr<decorators>(base, offset), value);
100 }
101
102 static oop oop_atomic_xchg_in_heap_at(oop base, ptrdiff_t offset, oop new_value) {
103 return oop_atomic_xchg_in_heap(AccessInternal::oop_field_addr<decorators>(base, offset), new_value);
104 }
105
106 static oop oop_atomic_cmpxchg_in_heap_at(oop base, ptrdiff_t offset, oop compare_value, oop new_value) {
107 return oop_atomic_cmpxchg_in_heap(AccessInternal::oop_field_addr<decorators>(base, offset), compare_value, new_value);
108 }
109
110 static void value_copy_in_heap(void* src, void* dst, InlineKlass* md);
111 };
112 };
113
114 template<>
115 struct BarrierSet::GetName<ModRefBarrierSet> {
116 static const BarrierSet::Name value = BarrierSet::ModRef;
117 };
118
119 #endif // SHARE_GC_SHARED_MODREFBARRIERSET_HPP
|