104
105 template <DecoratorSet expected_mo_decorators>
106 static void verify_primitive_decorators() {
107 const DecoratorSet primitive_decorators = (AS_DECORATOR_MASK ^ AS_NO_KEEPALIVE ^ AS_DEST_NOT_INITIALIZED) |
108 IN_HEAP | IN_HEAP_ARRAY;
109 verify_decorators<expected_mo_decorators | primitive_decorators>();
110 }
111
112 template <DecoratorSet expected_mo_decorators>
113 static void verify_oop_decorators() {
114 const DecoratorSet oop_decorators = AS_DECORATOR_MASK | IN_DECORATOR_MASK |
115 (ON_DECORATOR_MASK ^ ON_UNKNOWN_OOP_REF) | // no unknown oop refs outside of the heap
116 OOP_DECORATOR_MASK;
117 verify_decorators<expected_mo_decorators | oop_decorators>();
118 }
119
120 template <DecoratorSet expected_mo_decorators>
121 static void verify_heap_oop_decorators() {
122 const DecoratorSet heap_oop_decorators = AS_DECORATOR_MASK | ON_DECORATOR_MASK |
123 OOP_DECORATOR_MASK | (IN_DECORATOR_MASK ^
124 (IN_ROOT | IN_CONCURRENT_ROOT)); // no root accesses in the heap
125 verify_decorators<expected_mo_decorators | heap_oop_decorators>();
126 }
127
128 static const DecoratorSet load_mo_decorators = MO_UNORDERED | MO_VOLATILE | MO_RELAXED | MO_ACQUIRE | MO_SEQ_CST;
129 static const DecoratorSet store_mo_decorators = MO_UNORDERED | MO_VOLATILE | MO_RELAXED | MO_RELEASE | MO_SEQ_CST;
130 static const DecoratorSet atomic_xchg_mo_decorators = MO_SEQ_CST;
131 static const DecoratorSet atomic_cmpxchg_mo_decorators = MO_RELAXED | MO_SEQ_CST;
132
133 protected:
134 template <typename T>
135 static inline bool oop_arraycopy(arrayOop src_obj, size_t src_offset_in_bytes, const T* src_raw,
136 arrayOop dst_obj, size_t dst_offset_in_bytes, T* dst_raw,
137 size_t length) {
138 verify_decorators<ARRAYCOPY_DECORATOR_MASK | IN_HEAP | IN_HEAP_ARRAY |
139 AS_DECORATOR_MASK>();
140 return AccessInternal::arraycopy<decorators | INTERNAL_VALUE_IS_OOP>(src_obj, src_offset_in_bytes, src_raw,
141 dst_obj, dst_offset_in_bytes, dst_raw,
142 length);
143 }
144
279
280 static bool equals(oop o1, oop o2) {
281 verify_decorators<INTERNAL_EMPTY>();
282 return AccessInternal::equals<decorators>(o1, o2);
283 }
284 };
285
286 // Helper for performing raw accesses (knows only of memory ordering
287 // atomicity decorators as well as compressed oops)
288 template <DecoratorSet decorators = INTERNAL_EMPTY>
289 class RawAccess: public Access<AS_RAW | decorators> {};
290
291 // Helper for performing normal accesses on the heap. These accesses
292 // may resolve an accessor on a GC barrier set
293 template <DecoratorSet decorators = INTERNAL_EMPTY>
294 class HeapAccess: public Access<IN_HEAP | decorators> {};
295
296 // Helper for performing normal accesses in roots. These accesses
297 // may resolve an accessor on a GC barrier set
298 template <DecoratorSet decorators = INTERNAL_EMPTY>
299 class NativeAccess: public Access<IN_ROOT | decorators> {};
300
301 // Helper for array access.
302 template <DecoratorSet decorators = INTERNAL_EMPTY>
303 class ArrayAccess: public HeapAccess<IN_HEAP_ARRAY | decorators> {
304 typedef HeapAccess<IN_HEAP_ARRAY | decorators> AccessT;
305 public:
306 template <typename T>
307 static inline void arraycopy(arrayOop src_obj, size_t src_offset_in_bytes,
308 arrayOop dst_obj, size_t dst_offset_in_bytes,
309 size_t length) {
310 AccessT::arraycopy(src_obj, src_offset_in_bytes, reinterpret_cast<const T*>(NULL),
311 dst_obj, dst_offset_in_bytes, reinterpret_cast<T*>(NULL),
312 length);
313 }
314
315 template <typename T>
316 static inline void arraycopy_to_native(arrayOop src_obj, size_t src_offset_in_bytes,
317 T* dst,
318 size_t length) {
319 AccessT::arraycopy(src_obj, src_offset_in_bytes, reinterpret_cast<const T*>(NULL),
359 (barrier_strength_decorators ^ AS_NORMAL) == 0
360 ));
361 const DecoratorSet ref_strength_decorators = decorators & ON_DECORATOR_MASK;
362 STATIC_ASSERT(ref_strength_decorators == 0 || ( // make sure ref strength decorators are disjoint if set
363 (ref_strength_decorators ^ ON_STRONG_OOP_REF) == 0 ||
364 (ref_strength_decorators ^ ON_WEAK_OOP_REF) == 0 ||
365 (ref_strength_decorators ^ ON_PHANTOM_OOP_REF) == 0 ||
366 (ref_strength_decorators ^ ON_UNKNOWN_OOP_REF) == 0
367 ));
368 const DecoratorSet memory_ordering_decorators = decorators & MO_DECORATOR_MASK;
369 STATIC_ASSERT(memory_ordering_decorators == 0 || ( // make sure memory ordering decorators are disjoint if set
370 (memory_ordering_decorators ^ MO_UNORDERED) == 0 ||
371 (memory_ordering_decorators ^ MO_VOLATILE) == 0 ||
372 (memory_ordering_decorators ^ MO_RELAXED) == 0 ||
373 (memory_ordering_decorators ^ MO_ACQUIRE) == 0 ||
374 (memory_ordering_decorators ^ MO_RELEASE) == 0 ||
375 (memory_ordering_decorators ^ MO_SEQ_CST) == 0
376 ));
377 const DecoratorSet location_decorators = decorators & IN_DECORATOR_MASK;
378 STATIC_ASSERT(location_decorators == 0 || ( // make sure location decorators are disjoint if set
379 (location_decorators ^ IN_ROOT) == 0 ||
380 (location_decorators ^ IN_HEAP) == 0 ||
381 (location_decorators ^ (IN_HEAP | IN_HEAP_ARRAY)) == 0 ||
382 (location_decorators ^ (IN_ROOT | IN_CONCURRENT_ROOT)) == 0
383 ));
384 }
385
386 #endif // SHARE_OOPS_ACCESS_HPP
|
104
105 template <DecoratorSet expected_mo_decorators>
106 static void verify_primitive_decorators() {
107 const DecoratorSet primitive_decorators = (AS_DECORATOR_MASK ^ AS_NO_KEEPALIVE ^ AS_DEST_NOT_INITIALIZED) |
108 IN_HEAP | IN_HEAP_ARRAY;
109 verify_decorators<expected_mo_decorators | primitive_decorators>();
110 }
111
112 template <DecoratorSet expected_mo_decorators>
113 static void verify_oop_decorators() {
114 const DecoratorSet oop_decorators = AS_DECORATOR_MASK | IN_DECORATOR_MASK |
115 (ON_DECORATOR_MASK ^ ON_UNKNOWN_OOP_REF) | // no unknown oop refs outside of the heap
116 OOP_DECORATOR_MASK;
117 verify_decorators<expected_mo_decorators | oop_decorators>();
118 }
119
120 template <DecoratorSet expected_mo_decorators>
121 static void verify_heap_oop_decorators() {
122 const DecoratorSet heap_oop_decorators = AS_DECORATOR_MASK | ON_DECORATOR_MASK |
123 OOP_DECORATOR_MASK | (IN_DECORATOR_MASK ^
124 (IN_NATIVE | IN_CONCURRENT_ROOT)); // no root accesses in the heap
125 verify_decorators<expected_mo_decorators | heap_oop_decorators>();
126 }
127
128 static const DecoratorSet load_mo_decorators = MO_UNORDERED | MO_VOLATILE | MO_RELAXED | MO_ACQUIRE | MO_SEQ_CST;
129 static const DecoratorSet store_mo_decorators = MO_UNORDERED | MO_VOLATILE | MO_RELAXED | MO_RELEASE | MO_SEQ_CST;
130 static const DecoratorSet atomic_xchg_mo_decorators = MO_SEQ_CST;
131 static const DecoratorSet atomic_cmpxchg_mo_decorators = MO_RELAXED | MO_SEQ_CST;
132
133 protected:
134 template <typename T>
135 static inline bool oop_arraycopy(arrayOop src_obj, size_t src_offset_in_bytes, const T* src_raw,
136 arrayOop dst_obj, size_t dst_offset_in_bytes, T* dst_raw,
137 size_t length) {
138 verify_decorators<ARRAYCOPY_DECORATOR_MASK | IN_HEAP | IN_HEAP_ARRAY |
139 AS_DECORATOR_MASK>();
140 return AccessInternal::arraycopy<decorators | INTERNAL_VALUE_IS_OOP>(src_obj, src_offset_in_bytes, src_raw,
141 dst_obj, dst_offset_in_bytes, dst_raw,
142 length);
143 }
144
279
280 static bool equals(oop o1, oop o2) {
281 verify_decorators<INTERNAL_EMPTY>();
282 return AccessInternal::equals<decorators>(o1, o2);
283 }
284 };
285
286 // Helper for performing raw accesses (knows only of memory ordering
287 // atomicity decorators as well as compressed oops)
288 template <DecoratorSet decorators = INTERNAL_EMPTY>
289 class RawAccess: public Access<AS_RAW | decorators> {};
290
291 // Helper for performing normal accesses on the heap. These accesses
292 // may resolve an accessor on a GC barrier set
293 template <DecoratorSet decorators = INTERNAL_EMPTY>
294 class HeapAccess: public Access<IN_HEAP | decorators> {};
295
296 // Helper for performing normal accesses in roots. These accesses
297 // may resolve an accessor on a GC barrier set
298 template <DecoratorSet decorators = INTERNAL_EMPTY>
299 class NativeAccess: public Access<IN_NATIVE | decorators> {};
300
301 // Helper for array access.
302 template <DecoratorSet decorators = INTERNAL_EMPTY>
303 class ArrayAccess: public HeapAccess<IN_HEAP_ARRAY | decorators> {
304 typedef HeapAccess<IN_HEAP_ARRAY | decorators> AccessT;
305 public:
306 template <typename T>
307 static inline void arraycopy(arrayOop src_obj, size_t src_offset_in_bytes,
308 arrayOop dst_obj, size_t dst_offset_in_bytes,
309 size_t length) {
310 AccessT::arraycopy(src_obj, src_offset_in_bytes, reinterpret_cast<const T*>(NULL),
311 dst_obj, dst_offset_in_bytes, reinterpret_cast<T*>(NULL),
312 length);
313 }
314
315 template <typename T>
316 static inline void arraycopy_to_native(arrayOop src_obj, size_t src_offset_in_bytes,
317 T* dst,
318 size_t length) {
319 AccessT::arraycopy(src_obj, src_offset_in_bytes, reinterpret_cast<const T*>(NULL),
359 (barrier_strength_decorators ^ AS_NORMAL) == 0
360 ));
361 const DecoratorSet ref_strength_decorators = decorators & ON_DECORATOR_MASK;
362 STATIC_ASSERT(ref_strength_decorators == 0 || ( // make sure ref strength decorators are disjoint if set
363 (ref_strength_decorators ^ ON_STRONG_OOP_REF) == 0 ||
364 (ref_strength_decorators ^ ON_WEAK_OOP_REF) == 0 ||
365 (ref_strength_decorators ^ ON_PHANTOM_OOP_REF) == 0 ||
366 (ref_strength_decorators ^ ON_UNKNOWN_OOP_REF) == 0
367 ));
368 const DecoratorSet memory_ordering_decorators = decorators & MO_DECORATOR_MASK;
369 STATIC_ASSERT(memory_ordering_decorators == 0 || ( // make sure memory ordering decorators are disjoint if set
370 (memory_ordering_decorators ^ MO_UNORDERED) == 0 ||
371 (memory_ordering_decorators ^ MO_VOLATILE) == 0 ||
372 (memory_ordering_decorators ^ MO_RELAXED) == 0 ||
373 (memory_ordering_decorators ^ MO_ACQUIRE) == 0 ||
374 (memory_ordering_decorators ^ MO_RELEASE) == 0 ||
375 (memory_ordering_decorators ^ MO_SEQ_CST) == 0
376 ));
377 const DecoratorSet location_decorators = decorators & IN_DECORATOR_MASK;
378 STATIC_ASSERT(location_decorators == 0 || ( // make sure location decorators are disjoint if set
379 (location_decorators ^ IN_NATIVE) == 0 ||
380 (location_decorators ^ IN_HEAP) == 0 ||
381 (location_decorators ^ (IN_HEAP | IN_HEAP_ARRAY)) == 0 ||
382 (location_decorators ^ (IN_NATIVE | IN_CONCURRENT_ROOT)) == 0
383 ));
384 }
385
386 #endif // SHARE_OOPS_ACCESS_HPP
|