36 // an access needs to use compressed oops or not.
37 template <DecoratorSet decorators>
38 struct HeapOopType: AllStatic {
39 static const bool needs_oop_compress = HasDecorator<decorators, INTERNAL_CONVERT_COMPRESSED_OOP>::value &&
40 HasDecorator<decorators, INTERNAL_RT_USE_COMPRESSED_OOPS>::value;
41 typedef typename Conditional<needs_oop_compress, narrowOop, oop>::type type;
42 };
43
44 namespace AccessInternal {
45 enum BarrierType {
46 BARRIER_STORE,
47 BARRIER_STORE_AT,
48 BARRIER_LOAD,
49 BARRIER_LOAD_AT,
50 BARRIER_ATOMIC_CMPXCHG,
51 BARRIER_ATOMIC_CMPXCHG_AT,
52 BARRIER_ATOMIC_XCHG,
53 BARRIER_ATOMIC_XCHG_AT,
54 BARRIER_ARRAYCOPY,
55 BARRIER_CLONE,
56 BARRIER_RESOLVE
57 };
58
59 template <DecoratorSet decorators, typename T>
60 struct MustConvertCompressedOop: public IntegralConstant<bool,
61 HasDecorator<decorators, INTERNAL_VALUE_IS_OOP>::value &&
62 IsSame<typename HeapOopType<decorators>::type, narrowOop>::value &&
63 IsSame<T, oop>::value> {};
64
65 // This metafunction returns an appropriate oop type if the value is oop-like
66 // and otherwise returns the same type T.
67 template <DecoratorSet decorators, typename T>
68 struct EncodedType: AllStatic {
69 typedef typename Conditional<
70 HasDecorator<decorators, INTERNAL_VALUE_IS_OOP>::value,
71 typename HeapOopType<decorators>::type, T>::type type;
72 };
73
74 template <DecoratorSet decorators>
75 inline typename HeapOopType<decorators>::type*
76 oop_field_addr(oop base, ptrdiff_t byte_offset) {
85 struct PossiblyLockedAccess: public IntegralConstant<bool, false> {};
86 #else
87 struct PossiblyLockedAccess: public IntegralConstant<bool, (sizeof(T) > 4)> {};
88 #endif
89
90 template <DecoratorSet decorators, typename T>
91 struct AccessFunctionTypes {
92 typedef T (*load_at_func_t)(oop base, ptrdiff_t offset);
93 typedef void (*store_at_func_t)(oop base, ptrdiff_t offset, T value);
94 typedef T (*atomic_cmpxchg_at_func_t)(T new_value, oop base, ptrdiff_t offset, T compare_value);
95 typedef T (*atomic_xchg_at_func_t)(T new_value, oop base, ptrdiff_t offset);
96
97 typedef T (*load_func_t)(void* addr);
98 typedef void (*store_func_t)(void* addr, T value);
99 typedef T (*atomic_cmpxchg_func_t)(T new_value, void* addr, T compare_value);
100 typedef T (*atomic_xchg_func_t)(T new_value, void* addr);
101
102 typedef bool (*arraycopy_func_t)(arrayOop src_obj, arrayOop dst_obj, T* src, T* dst, size_t length);
103 typedef void (*clone_func_t)(oop src, oop dst, size_t size);
104 typedef oop (*resolve_func_t)(oop obj);
105 };
106
107 template <DecoratorSet decorators>
108 struct AccessFunctionTypes<decorators, void> {
109 typedef bool (*arraycopy_func_t)(arrayOop src_obj, arrayOop dst_obj, void* src, void* dst, size_t length);
110 };
111
112 template <DecoratorSet decorators, typename T, BarrierType barrier> struct AccessFunction {};
113
114 #define ACCESS_GENERATE_ACCESS_FUNCTION(bt, func) \
115 template <DecoratorSet decorators, typename T> \
116 struct AccessFunction<decorators, T, bt>: AllStatic{ \
117 typedef typename AccessFunctionTypes<decorators, T>::func type; \
118 }
119 ACCESS_GENERATE_ACCESS_FUNCTION(BARRIER_STORE, store_func_t);
120 ACCESS_GENERATE_ACCESS_FUNCTION(BARRIER_STORE_AT, store_at_func_t);
121 ACCESS_GENERATE_ACCESS_FUNCTION(BARRIER_LOAD, load_func_t);
122 ACCESS_GENERATE_ACCESS_FUNCTION(BARRIER_LOAD_AT, load_at_func_t);
123 ACCESS_GENERATE_ACCESS_FUNCTION(BARRIER_ATOMIC_CMPXCHG, atomic_cmpxchg_func_t);
124 ACCESS_GENERATE_ACCESS_FUNCTION(BARRIER_ATOMIC_CMPXCHG_AT, atomic_cmpxchg_at_func_t);
125 ACCESS_GENERATE_ACCESS_FUNCTION(BARRIER_ATOMIC_XCHG, atomic_xchg_func_t);
126 ACCESS_GENERATE_ACCESS_FUNCTION(BARRIER_ATOMIC_XCHG_AT, atomic_xchg_at_func_t);
127 ACCESS_GENERATE_ACCESS_FUNCTION(BARRIER_ARRAYCOPY, arraycopy_func_t);
128 ACCESS_GENERATE_ACCESS_FUNCTION(BARRIER_CLONE, clone_func_t);
129 ACCESS_GENERATE_ACCESS_FUNCTION(BARRIER_RESOLVE, resolve_func_t);
130 #undef ACCESS_GENERATE_ACCESS_FUNCTION
131
132 template <DecoratorSet decorators, typename T, BarrierType barrier_type>
133 typename AccessFunction<decorators, T, barrier_type>::type resolve_barrier();
134
135 template <DecoratorSet decorators, typename T, BarrierType barrier_type>
136 typename AccessFunction<decorators, T, barrier_type>::type resolve_oop_barrier();
137
138 class AccessLocker {
139 public:
140 AccessLocker();
141 ~AccessLocker();
142 };
143 bool wide_atomic_needs_locking();
144
145 void* field_addr(oop base, ptrdiff_t offset);
146
147 // Forward calls to Copy:: in the cpp file to reduce dependencies and allow
148 // faster build times, given how frequently included access is.
149 void arraycopy_arrayof_conjoint_oops(void* src, void* dst, size_t length);
371 static T load_at(oop base, ptrdiff_t offset) {
372 return load<T>(field_addr(base, offset));
373 }
374
375 template <typename T>
376 static T atomic_cmpxchg_at(T new_value, oop base, ptrdiff_t offset, T compare_value) {
377 return atomic_cmpxchg(new_value, field_addr(base, offset), compare_value);
378 }
379
380 template <typename T>
381 static T atomic_xchg_at(T new_value, oop base, ptrdiff_t offset) {
382 return atomic_xchg(new_value, field_addr(base, offset));
383 }
384
385 template <typename T>
386 static bool oop_arraycopy(arrayOop src_obj, arrayOop dst_obj, T* src, T* dst, size_t length);
387
388 static void clone(oop src, oop dst, size_t size);
389
390 static oop resolve(oop obj) { return obj; }
391 };
392
393 #endif // SHARE_VM_RUNTIME_ACCESSBACKEND_HPP
|
36 // an access needs to use compressed oops or not.
37 template <DecoratorSet decorators>
38 struct HeapOopType: AllStatic {
39 static const bool needs_oop_compress = HasDecorator<decorators, INTERNAL_CONVERT_COMPRESSED_OOP>::value &&
40 HasDecorator<decorators, INTERNAL_RT_USE_COMPRESSED_OOPS>::value;
41 typedef typename Conditional<needs_oop_compress, narrowOop, oop>::type type;
42 };
43
44 namespace AccessInternal {
45 enum BarrierType {
46 BARRIER_STORE,
47 BARRIER_STORE_AT,
48 BARRIER_LOAD,
49 BARRIER_LOAD_AT,
50 BARRIER_ATOMIC_CMPXCHG,
51 BARRIER_ATOMIC_CMPXCHG_AT,
52 BARRIER_ATOMIC_XCHG,
53 BARRIER_ATOMIC_XCHG_AT,
54 BARRIER_ARRAYCOPY,
55 BARRIER_CLONE,
56 BARRIER_RESOLVE,
57 BARRIER_EQUALS
58 };
59
60 template <DecoratorSet decorators, typename T>
61 struct MustConvertCompressedOop: public IntegralConstant<bool,
62 HasDecorator<decorators, INTERNAL_VALUE_IS_OOP>::value &&
63 IsSame<typename HeapOopType<decorators>::type, narrowOop>::value &&
64 IsSame<T, oop>::value> {};
65
66 // This metafunction returns an appropriate oop type if the value is oop-like
67 // and otherwise returns the same type T.
68 template <DecoratorSet decorators, typename T>
69 struct EncodedType: AllStatic {
70 typedef typename Conditional<
71 HasDecorator<decorators, INTERNAL_VALUE_IS_OOP>::value,
72 typename HeapOopType<decorators>::type, T>::type type;
73 };
74
75 template <DecoratorSet decorators>
76 inline typename HeapOopType<decorators>::type*
77 oop_field_addr(oop base, ptrdiff_t byte_offset) {
86 struct PossiblyLockedAccess: public IntegralConstant<bool, false> {};
87 #else
88 struct PossiblyLockedAccess: public IntegralConstant<bool, (sizeof(T) > 4)> {};
89 #endif
90
91 template <DecoratorSet decorators, typename T>
92 struct AccessFunctionTypes {
93 typedef T (*load_at_func_t)(oop base, ptrdiff_t offset);
94 typedef void (*store_at_func_t)(oop base, ptrdiff_t offset, T value);
95 typedef T (*atomic_cmpxchg_at_func_t)(T new_value, oop base, ptrdiff_t offset, T compare_value);
96 typedef T (*atomic_xchg_at_func_t)(T new_value, oop base, ptrdiff_t offset);
97
98 typedef T (*load_func_t)(void* addr);
99 typedef void (*store_func_t)(void* addr, T value);
100 typedef T (*atomic_cmpxchg_func_t)(T new_value, void* addr, T compare_value);
101 typedef T (*atomic_xchg_func_t)(T new_value, void* addr);
102
103 typedef bool (*arraycopy_func_t)(arrayOop src_obj, arrayOop dst_obj, T* src, T* dst, size_t length);
104 typedef void (*clone_func_t)(oop src, oop dst, size_t size);
105 typedef oop (*resolve_func_t)(oop obj);
106 typedef bool (*equals_func_t)(oop o1, oop o2);
107 };
108
109 template <DecoratorSet decorators>
110 struct AccessFunctionTypes<decorators, void> {
111 typedef bool (*arraycopy_func_t)(arrayOop src_obj, arrayOop dst_obj, void* src, void* dst, size_t length);
112 };
113
114 template <DecoratorSet decorators, typename T, BarrierType barrier> struct AccessFunction {};
115
116 #define ACCESS_GENERATE_ACCESS_FUNCTION(bt, func) \
117 template <DecoratorSet decorators, typename T> \
118 struct AccessFunction<decorators, T, bt>: AllStatic{ \
119 typedef typename AccessFunctionTypes<decorators, T>::func type; \
120 }
121 ACCESS_GENERATE_ACCESS_FUNCTION(BARRIER_STORE, store_func_t);
122 ACCESS_GENERATE_ACCESS_FUNCTION(BARRIER_STORE_AT, store_at_func_t);
123 ACCESS_GENERATE_ACCESS_FUNCTION(BARRIER_LOAD, load_func_t);
124 ACCESS_GENERATE_ACCESS_FUNCTION(BARRIER_LOAD_AT, load_at_func_t);
125 ACCESS_GENERATE_ACCESS_FUNCTION(BARRIER_ATOMIC_CMPXCHG, atomic_cmpxchg_func_t);
126 ACCESS_GENERATE_ACCESS_FUNCTION(BARRIER_ATOMIC_CMPXCHG_AT, atomic_cmpxchg_at_func_t);
127 ACCESS_GENERATE_ACCESS_FUNCTION(BARRIER_ATOMIC_XCHG, atomic_xchg_func_t);
128 ACCESS_GENERATE_ACCESS_FUNCTION(BARRIER_ATOMIC_XCHG_AT, atomic_xchg_at_func_t);
129 ACCESS_GENERATE_ACCESS_FUNCTION(BARRIER_ARRAYCOPY, arraycopy_func_t);
130 ACCESS_GENERATE_ACCESS_FUNCTION(BARRIER_CLONE, clone_func_t);
131 ACCESS_GENERATE_ACCESS_FUNCTION(BARRIER_RESOLVE, resolve_func_t);
132 ACCESS_GENERATE_ACCESS_FUNCTION(BARRIER_EQUALS, equals_func_t);
133 #undef ACCESS_GENERATE_ACCESS_FUNCTION
134
135 template <DecoratorSet decorators, typename T, BarrierType barrier_type>
136 typename AccessFunction<decorators, T, barrier_type>::type resolve_barrier();
137
138 template <DecoratorSet decorators, typename T, BarrierType barrier_type>
139 typename AccessFunction<decorators, T, barrier_type>::type resolve_oop_barrier();
140
141 class AccessLocker {
142 public:
143 AccessLocker();
144 ~AccessLocker();
145 };
146 bool wide_atomic_needs_locking();
147
148 void* field_addr(oop base, ptrdiff_t offset);
149
150 // Forward calls to Copy:: in the cpp file to reduce dependencies and allow
151 // faster build times, given how frequently included access is.
152 void arraycopy_arrayof_conjoint_oops(void* src, void* dst, size_t length);
374 static T load_at(oop base, ptrdiff_t offset) {
375 return load<T>(field_addr(base, offset));
376 }
377
378 template <typename T>
379 static T atomic_cmpxchg_at(T new_value, oop base, ptrdiff_t offset, T compare_value) {
380 return atomic_cmpxchg(new_value, field_addr(base, offset), compare_value);
381 }
382
383 template <typename T>
384 static T atomic_xchg_at(T new_value, oop base, ptrdiff_t offset) {
385 return atomic_xchg(new_value, field_addr(base, offset));
386 }
387
388 template <typename T>
389 static bool oop_arraycopy(arrayOop src_obj, arrayOop dst_obj, T* src, T* dst, size_t length);
390
391 static void clone(oop src, oop dst, size_t size);
392
393 static oop resolve(oop obj) { return obj; }
394
395 static bool equals(oop o1, oop o2) { return o1 == o2; }
396 };
397
398 #endif // SHARE_VM_RUNTIME_ACCESSBACKEND_HPP
|