comparison src/os_cpu/bsd_zero/vm/atomic_bsd_zero.inline.hpp @ 22854:4ebc1b290dbd

8067331: Zero: Atomic::xchg and Atomic::xchg_ptr need full memory barrier Reviewed-by: dholmes, coleenp
author sgehwolf
date Tue, 24 Feb 2015 21:17:59 -0500
parents 63e54c37ac64
children
comparison
equal deleted inserted replaced
22853:cae03a88934b 22854:4ebc1b290dbd
236 #else 236 #else
237 // __sync_lock_test_and_set is a bizarrely named atomic exchange 237 // __sync_lock_test_and_set is a bizarrely named atomic exchange
238 // operation. Note that some platforms only support this with the 238 // operation. Note that some platforms only support this with the
239 // limitation that the only valid value to store is the immediate 239 // limitation that the only valid value to store is the immediate
240 // constant 1. There is a test for this in JNI_CreateJavaVM(). 240 // constant 1. There is a test for this in JNI_CreateJavaVM().
241 return __sync_lock_test_and_set (dest, exchange_value); 241 jint result = __sync_lock_test_and_set (dest, exchange_value);
242 // All atomic operations are expected to be full memory barriers
243 // (see atomic.hpp). However, __sync_lock_test_and_set is not
244 // a full memory barrier, but an acquire barrier. Hence, this added
245 // barrier.
246 __sync_synchronize();
247 return result;
242 #endif // M68K 248 #endif // M68K
243 #endif // ARM 249 #endif // ARM
244 } 250 }
245 251
246 inline intptr_t Atomic::xchg_ptr(intptr_t exchange_value, 252 inline intptr_t Atomic::xchg_ptr(intptr_t exchange_value,
249 return arm_lock_test_and_set(dest, exchange_value); 255 return arm_lock_test_and_set(dest, exchange_value);
250 #else 256 #else
251 #ifdef M68K 257 #ifdef M68K
252 return m68k_lock_test_and_set(dest, exchange_value); 258 return m68k_lock_test_and_set(dest, exchange_value);
253 #else 259 #else
254 return __sync_lock_test_and_set (dest, exchange_value); 260 intptr_t result = __sync_lock_test_and_set (dest, exchange_value);
261 __sync_synchronize();
262 return result;
255 #endif // M68K 263 #endif // M68K
256 #endif // ARM 264 #endif // ARM
257 } 265 }
258 266
259 inline void* Atomic::xchg_ptr(void* exchange_value, volatile void* dest) { 267 inline void* Atomic::xchg_ptr(void* exchange_value, volatile void* dest) {