Skip to content

Commit ca96366

Browse files
committed
8372528: Unify atomic exchange and compare exchange
Reviewed-by: kbarrett, stefank
1 parent 81b26ba commit ca96366

File tree

16 files changed

+137
-147
lines changed

16 files changed

+137
-147
lines changed

‎src/hotspot/cpu/ppc/atomicAccess_ppc.hpp‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,9 @@ inline D AtomicAccess::PlatformAdd<8>::add_then_fetch(D volatile* dest, I add_va
157157
return result;
158158
}
159159

160+
template<>
161+
struct AtomicAccess::PlatformXchg<1> : AtomicAccess::XchgUsingCmpxchg<1> {};
162+
160163
template<>
161164
template<typename T>
162165
inline T AtomicAccess::PlatformXchg<4>::operator()(T volatile* dest,

‎src/hotspot/os_cpu/bsd_aarch64/atomicAccess_bsd_aarch64.hpp‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,16 @@ struct AtomicAccess::PlatformAdd {
5252
}
5353
};
5454

55+
template<>
56+
struct AtomicAccess::PlatformXchg<1> : AtomicAccess::XchgUsingCmpxchg<1> {};
57+
5558
template<size_t byte_size>
5659
template<typename T>
5760
inline T AtomicAccess::PlatformXchg<byte_size>::operator()(T volatile* dest,
5861
T exchange_value,
5962
atomic_memory_order order) const {
6063
STATIC_ASSERT(byte_size == sizeof(T));
64+
STATIC_ASSERT(byte_size == 4 || byte_size == 8);
6165
T res = __atomic_exchange_n(dest, exchange_value, __ATOMIC_RELEASE);
6266
FULL_MEM_BARRIER;
6367
return res;

‎src/hotspot/os_cpu/bsd_x86/atomicAccess_bsd_x86.hpp‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,9 @@ inline D AtomicAccess::PlatformAdd<4>::fetch_then_add(D volatile* dest, I add_va
5252
return old_value;
5353
}
5454

55+
template<>
56+
struct AtomicAccess::PlatformXchg<1> : AtomicAccess::XchgUsingCmpxchg<1> {};
57+
5558
template<>
5659
template<typename T>
5760
inline T AtomicAccess::PlatformXchg<4>::operator()(T volatile* dest,

‎src/hotspot/os_cpu/bsd_zero/atomicAccess_bsd_zero.hpp‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,9 @@ inline D AtomicAccess::PlatformAdd<8>::add_then_fetch(D volatile* dest, I add_va
6666
return res;
6767
}
6868

69+
template<>
70+
struct AtomicAccess::PlatformXchg<1> : AtomicAccess::XchgUsingCmpxchg<1> {};
71+
6972
template<>
7073
template<typename T>
7174
inline T AtomicAccess::PlatformXchg<4>::operator()(T volatile* dest,

‎src/hotspot/os_cpu/linux_aarch64/atomicAccess_linux_aarch64.hpp‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,9 @@ inline D AtomicAccess::PlatformAdd<8>::fetch_then_add(D volatile* dest, I add_va
113113
return atomic_fastcall(stub, dest, add_value);
114114
}
115115

116+
template<>
117+
struct AtomicAccess::PlatformXchg<1> : AtomicAccess::XchgUsingCmpxchg<1> {};
118+
116119
template<>
117120
template<typename T>
118121
inline T AtomicAccess::PlatformXchg<4>::operator()(T volatile* dest,

‎src/hotspot/os_cpu/linux_arm/atomicAccess_linux_arm.hpp‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,8 @@ inline D AtomicAccess::PlatformAdd<4>::add_then_fetch(D volatile* dest, I add_va
118118
return add_using_helper<int32_t>(ARMAtomicFuncs::_add_func, dest, add_value);
119119
}
120120

121+
template<>
122+
struct AtomicAccess::PlatformXchg<1> : AtomicAccess::XchgUsingCmpxchg<1> {};
121123

122124
template<>
123125
template<typename T>

‎src/hotspot/os_cpu/linux_riscv/atomicAccess_linux_riscv.hpp‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,9 @@ inline T AtomicAccess::PlatformCmpxchg<4>::operator()(T volatile* dest __attribu
152152
}
153153
#endif
154154

155+
template<>
156+
struct AtomicAccess::PlatformXchg<1> : AtomicAccess::XchgUsingCmpxchg<1> {};
157+
155158
template<size_t byte_size>
156159
template<typename T>
157160
inline T AtomicAccess::PlatformXchg<byte_size>::operator()(T volatile* dest,
@@ -164,6 +167,7 @@ inline T AtomicAccess::PlatformXchg<byte_size>::operator()(T volatile* dest,
164167
#endif
165168

166169
STATIC_ASSERT(byte_size == sizeof(T));
170+
STATIC_ASSERT(byte_size == 4 || byte_size == 8);
167171

168172
if (order != memory_order_relaxed) {
169173
FULL_MEM_BARRIER;

‎src/hotspot/os_cpu/linux_s390/atomicAccess_linux_s390.hpp‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,9 @@ inline D AtomicAccess::PlatformAdd<8>::add_then_fetch(D volatile* dest, I inc,
209209
//
210210
// The return value is the (unchanged) value from memory as it was when the
211211
// replacement succeeded.
212+
template<>
213+
struct AtomicAccess::PlatformXchg<1> : AtomicAccess::XchgUsingCmpxchg<1> {};
214+
212215
template<>
213216
template<typename T>
214217
inline T AtomicAccess::PlatformXchg<4>::operator()(T volatile* dest,

‎src/hotspot/os_cpu/linux_x86/atomicAccess_linux_x86.hpp‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,9 @@ inline D AtomicAccess::PlatformAdd<4>::fetch_then_add(D volatile* dest, I add_va
5252
return old_value;
5353
}
5454

55+
template<>
56+
struct AtomicAccess::PlatformXchg<1> : AtomicAccess::XchgUsingCmpxchg<1> {};
57+
5558
template<>
5659
template<typename T>
5760
inline T AtomicAccess::PlatformXchg<4>::operator()(T volatile* dest,

‎src/hotspot/os_cpu/linux_zero/atomicAccess_linux_zero.hpp‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,9 @@ inline D AtomicAccess::PlatformAdd<8>::add_then_fetch(D volatile* dest, I add_va
6565
return res;
6666
}
6767

68+
template<>
69+
struct AtomicAccess::PlatformXchg<1> : AtomicAccess::XchgUsingCmpxchg<1> {};
70+
6871
template<>
6972
template<typename T>
7073
inline T AtomicAccess::PlatformXchg<4>::operator()(T volatile* dest,

0 commit comments

Comments
 (0)