122 struct PostRuntimeDispatch<GCBarrierType, BARRIER_ATOMIC_CMPXCHG, decorators>: public AllStatic {
123 template <typename T>
124 static T access_barrier(T new_value, void* addr, T compare_value) {
125 return GCBarrierType::atomic_cmpxchg_in_heap(new_value, reinterpret_cast<T*>(addr), compare_value);
126 }
127
128 static oop oop_access_barrier(oop new_value, void* addr, oop compare_value) {
129 typedef typename HeapOopType<decorators>::type OopType;
130 if (HasDecorator<decorators, IN_HEAP>::value) {
131 return GCBarrierType::oop_atomic_cmpxchg_in_heap(new_value, reinterpret_cast<OopType*>(addr), compare_value);
132 } else {
133 return GCBarrierType::oop_atomic_cmpxchg_not_in_heap(new_value, reinterpret_cast<OopType*>(addr), compare_value);
134 }
135 }
136 };
137
138 template <class GCBarrierType, DecoratorSet decorators>
139 struct PostRuntimeDispatch<GCBarrierType, BARRIER_ARRAYCOPY, decorators>: public AllStatic {
140 template <typename T>
141 static bool access_barrier(arrayOop src_obj, arrayOop dst_obj, T* src, T* dst, size_t length) {
142 return GCBarrierType::arraycopy_in_heap(src_obj, dst_obj, src, dst, length);
143 }
144
145 template <typename T>
146 static bool oop_access_barrier(arrayOop src_obj, arrayOop dst_obj, T* src, T* dst, size_t length) {
147 typedef typename HeapOopType<decorators>::type OopType;
148 return GCBarrierType::oop_arraycopy_in_heap(src_obj, dst_obj,
149 reinterpret_cast<OopType*>(src),
150 reinterpret_cast<OopType*>(dst), length);
151 }
152 };
153
154 template <class GCBarrierType, DecoratorSet decorators>
155 struct PostRuntimeDispatch<GCBarrierType, BARRIER_STORE_AT, decorators>: public AllStatic {
156 template <typename T>
157 static void access_barrier(oop base, ptrdiff_t offset, T value) {
158 GCBarrierType::store_in_heap_at(base, offset, value);
159 }
160
161 static void oop_access_barrier(oop base, ptrdiff_t offset, oop value) {
162 GCBarrierType::oop_store_in_heap_at(base, offset, value);
746 return atomic_xchg<decorators>(new_value, field_addr(base, offset));
747 }
748
749 template <DecoratorSet decorators, typename T>
750 inline static typename EnableIf<
751 !HasDecorator<decorators, AS_RAW>::value, T>::type
752 atomic_xchg_at(T new_value, oop base, ptrdiff_t offset) {
753 if (is_hardwired_primitive<decorators>()) {
754 const DecoratorSet expanded_decorators = decorators | AS_RAW;
755 return PreRuntimeDispatch::atomic_xchg<expanded_decorators>(new_value, base, offset);
756 } else {
757 return RuntimeDispatch<decorators, T, BARRIER_ATOMIC_XCHG_AT>::atomic_xchg_at(new_value, base, offset);
758 }
759 }
760
761 template <DecoratorSet decorators, typename T>
762 inline static typename EnableIf<
763 HasDecorator<decorators, AS_RAW>::value, bool>::type
764 arraycopy(arrayOop src_obj, arrayOop dst_obj, T *src, T* dst, size_t length) {
765 typedef RawAccessBarrier<decorators & RAW_DECORATOR_MASK> Raw;
766 return Raw::arraycopy(src, dst, length);
767 }
768
769 template <DecoratorSet decorators, typename T>
770 inline static typename EnableIf<
771 !HasDecorator<decorators, AS_RAW>::value, bool>::type
772 arraycopy(arrayOop src_obj, arrayOop dst_obj, T *src, T* dst, size_t length) {
773 typedef RawAccessBarrier<decorators & RAW_DECORATOR_MASK> Raw;
774 if (is_hardwired_primitive<decorators>()) {
775 const DecoratorSet expanded_decorators = decorators | AS_RAW;
776 return PreRuntimeDispatch::arraycopy<expanded_decorators>(src_obj, dst_obj, src, dst, length);
777 } else {
778 return RuntimeDispatch<decorators, T, BARRIER_ARRAYCOPY>::arraycopy(src_obj, dst_obj, src, dst, length);
779 }
780 }
781
782 template <DecoratorSet decorators>
783 inline static typename EnableIf<
784 HasDecorator<decorators, AS_RAW>::value>::type
785 clone(oop src, oop dst, size_t size) {
786 typedef RawAccessBarrier<decorators & RAW_DECORATOR_MASK> Raw;
1060 // atomic_xchg is only available in SEQ_CST flavour.
1061 const DecoratorSet expanded_decorators = DecoratorFixup<decorators | MO_SEQ_CST>::value;
1062 return atomic_xchg_reduce_types<expanded_decorators>(new_decayed_value,
1063 const_cast<DecayedP*>(addr));
1064 }
1065
1066 template <DecoratorSet decorators, typename T>
1067 inline T atomic_xchg_at(T new_value, oop base, ptrdiff_t offset) {
1068 verify_types<decorators, T>();
1069 typedef typename Decay<T>::type DecayedT;
1070 DecayedT new_decayed_value = new_value;
1071 // atomic_xchg is only available in SEQ_CST flavour.
1072 const DecoratorSet expanded_decorators = DecoratorFixup<decorators | MO_SEQ_CST |
1073 (HasDecorator<decorators, INTERNAL_VALUE_IS_OOP>::value ?
1074 INTERNAL_CONVERT_COMPRESSED_OOP : INTERNAL_EMPTY)>::value;
1075 return PreRuntimeDispatch::atomic_xchg_at<expanded_decorators>(new_decayed_value, base, offset);
1076 }
1077
1078 template <DecoratorSet decorators, typename T>
1079 inline bool arraycopy(arrayOop src_obj, arrayOop dst_obj, T *src, T *dst, size_t length) {
1080 verify_types<decorators, T>();
1081 typedef typename Decay<T>::type DecayedT;
1082 const DecoratorSet expanded_decorators = DecoratorFixup<decorators | IN_HEAP_ARRAY | IN_HEAP |
1083 (HasDecorator<decorators, INTERNAL_VALUE_IS_OOP>::value ?
1084 INTERNAL_CONVERT_COMPRESSED_OOP : INTERNAL_EMPTY)>::value;
1085 return PreRuntimeDispatch::arraycopy<expanded_decorators>(src_obj, dst_obj,
1086 const_cast<DecayedT*>(src),
1087 const_cast<DecayedT*>(dst),
1088 length);
1089 }
1090
1091 template <DecoratorSet decorators>
1092 inline void clone(oop src, oop dst, size_t size) {
1093 const DecoratorSet expanded_decorators = DecoratorFixup<decorators>::value;
1094 PreRuntimeDispatch::clone<expanded_decorators>(src, dst, size);
1095 }
1096
1097 template <DecoratorSet decorators>
1098 inline oop resolve(oop obj) {
1099 const DecoratorSet expanded_decorators = DecoratorFixup<decorators>::value;
1100 return PreRuntimeDispatch::resolve<expanded_decorators>(obj);
|
122 struct PostRuntimeDispatch<GCBarrierType, BARRIER_ATOMIC_CMPXCHG, decorators>: public AllStatic {
123 template <typename T>
124 static T access_barrier(T new_value, void* addr, T compare_value) {
125 return GCBarrierType::atomic_cmpxchg_in_heap(new_value, reinterpret_cast<T*>(addr), compare_value);
126 }
127
128 static oop oop_access_barrier(oop new_value, void* addr, oop compare_value) {
129 typedef typename HeapOopType<decorators>::type OopType;
130 if (HasDecorator<decorators, IN_HEAP>::value) {
131 return GCBarrierType::oop_atomic_cmpxchg_in_heap(new_value, reinterpret_cast<OopType*>(addr), compare_value);
132 } else {
133 return GCBarrierType::oop_atomic_cmpxchg_not_in_heap(new_value, reinterpret_cast<OopType*>(addr), compare_value);
134 }
135 }
136 };
137
138 template <class GCBarrierType, DecoratorSet decorators>
139 struct PostRuntimeDispatch<GCBarrierType, BARRIER_ARRAYCOPY, decorators>: public AllStatic {
140 template <typename T>
141 static bool access_barrier(arrayOop src_obj, arrayOop dst_obj, T* src, T* dst, size_t length) {
142 GCBarrierType::arraycopy_in_heap(src_obj, dst_obj, src, dst, length);
143 return true;
144 }
145
146 template <typename T>
147 static bool oop_access_barrier(arrayOop src_obj, arrayOop dst_obj, T* src, T* dst, size_t length) {
148 typedef typename HeapOopType<decorators>::type OopType;
149 return GCBarrierType::oop_arraycopy_in_heap(src_obj, dst_obj,
150 reinterpret_cast<OopType*>(src),
151 reinterpret_cast<OopType*>(dst), length);
152 }
153 };
154
155 template <class GCBarrierType, DecoratorSet decorators>
156 struct PostRuntimeDispatch<GCBarrierType, BARRIER_STORE_AT, decorators>: public AllStatic {
157 template <typename T>
158 static void access_barrier(oop base, ptrdiff_t offset, T value) {
159 GCBarrierType::store_in_heap_at(base, offset, value);
160 }
161
162 static void oop_access_barrier(oop base, ptrdiff_t offset, oop value) {
163 GCBarrierType::oop_store_in_heap_at(base, offset, value);
747 return atomic_xchg<decorators>(new_value, field_addr(base, offset));
748 }
749
750 template <DecoratorSet decorators, typename T>
751 inline static typename EnableIf<
752 !HasDecorator<decorators, AS_RAW>::value, T>::type
753 atomic_xchg_at(T new_value, oop base, ptrdiff_t offset) {
754 if (is_hardwired_primitive<decorators>()) {
755 const DecoratorSet expanded_decorators = decorators | AS_RAW;
756 return PreRuntimeDispatch::atomic_xchg<expanded_decorators>(new_value, base, offset);
757 } else {
758 return RuntimeDispatch<decorators, T, BARRIER_ATOMIC_XCHG_AT>::atomic_xchg_at(new_value, base, offset);
759 }
760 }
761
762 template <DecoratorSet decorators, typename T>
763 inline static typename EnableIf<
764 HasDecorator<decorators, AS_RAW>::value, bool>::type
765 arraycopy(arrayOop src_obj, arrayOop dst_obj, T *src, T* dst, size_t length) {
766 typedef RawAccessBarrier<decorators & RAW_DECORATOR_MASK> Raw;
767 return Raw::arraycopy(src_obj, dst_obj, src, dst, length);
768 }
769
770 template <DecoratorSet decorators, typename T>
771 inline static typename EnableIf<
772 !HasDecorator<decorators, AS_RAW>::value, bool>::type
773 arraycopy(arrayOop src_obj, arrayOop dst_obj, T *src, T* dst, size_t length) {
774 typedef RawAccessBarrier<decorators & RAW_DECORATOR_MASK> Raw;
775 if (is_hardwired_primitive<decorators>()) {
776 const DecoratorSet expanded_decorators = decorators | AS_RAW;
777 return PreRuntimeDispatch::arraycopy<expanded_decorators>(src_obj, dst_obj, src, dst, length);
778 } else {
779 return RuntimeDispatch<decorators, T, BARRIER_ARRAYCOPY>::arraycopy(src_obj, dst_obj, src, dst, length);
780 }
781 }
782
783 template <DecoratorSet decorators>
784 inline static typename EnableIf<
785 HasDecorator<decorators, AS_RAW>::value>::type
786 clone(oop src, oop dst, size_t size) {
787 typedef RawAccessBarrier<decorators & RAW_DECORATOR_MASK> Raw;
1061 // atomic_xchg is only available in SEQ_CST flavour.
1062 const DecoratorSet expanded_decorators = DecoratorFixup<decorators | MO_SEQ_CST>::value;
1063 return atomic_xchg_reduce_types<expanded_decorators>(new_decayed_value,
1064 const_cast<DecayedP*>(addr));
1065 }
1066
1067 template <DecoratorSet decorators, typename T>
1068 inline T atomic_xchg_at(T new_value, oop base, ptrdiff_t offset) {
1069 verify_types<decorators, T>();
1070 typedef typename Decay<T>::type DecayedT;
1071 DecayedT new_decayed_value = new_value;
1072 // atomic_xchg is only available in SEQ_CST flavour.
1073 const DecoratorSet expanded_decorators = DecoratorFixup<decorators | MO_SEQ_CST |
1074 (HasDecorator<decorators, INTERNAL_VALUE_IS_OOP>::value ?
1075 INTERNAL_CONVERT_COMPRESSED_OOP : INTERNAL_EMPTY)>::value;
1076 return PreRuntimeDispatch::atomic_xchg_at<expanded_decorators>(new_decayed_value, base, offset);
1077 }
1078
1079 template <DecoratorSet decorators, typename T>
1080 inline bool arraycopy(arrayOop src_obj, arrayOop dst_obj, T *src, T *dst, size_t length) {
1081 STATIC_ASSERT((HasDecorator<decorators, INTERNAL_VALUE_IS_OOP>::value ||
1082 (IsSame<T, void>::value || IsIntegral<T>::value) ||
1083 IsFloatingPoint<T>::value)); // arraycopy allows type erased void elements
1084 typedef typename Decay<T>::type DecayedT;
1085 const DecoratorSet expanded_decorators = DecoratorFixup<decorators | IN_HEAP_ARRAY | IN_HEAP |
1086 (HasDecorator<decorators, INTERNAL_VALUE_IS_OOP>::value ?
1087 INTERNAL_CONVERT_COMPRESSED_OOP : INTERNAL_EMPTY)>::value;
1088 return PreRuntimeDispatch::arraycopy<expanded_decorators>(src_obj, dst_obj,
1089 const_cast<DecayedT*>(src),
1090 const_cast<DecayedT*>(dst),
1091 length);
1092 }
1093
1094 template <DecoratorSet decorators>
1095 inline void clone(oop src, oop dst, size_t size) {
1096 const DecoratorSet expanded_decorators = DecoratorFixup<decorators>::value;
1097 PreRuntimeDispatch::clone<expanded_decorators>(src, dst, size);
1098 }
1099
1100 template <DecoratorSet decorators>
1101 inline oop resolve(oop obj) {
1102 const DecoratorSet expanded_decorators = DecoratorFixup<decorators>::value;
1103 return PreRuntimeDispatch::resolve<expanded_decorators>(obj);
|