src/os_cpu/linux_zero/vm/atomic_linux_zero.inline.hpp

Print this page
@  rev 7557 : 8067331: Zero: Atomic::xchg and Atomic::xchg_ptr need full memory barrier
|


 214 
 215 inline void Atomic::dec_ptr(volatile intptr_t* dest) {
 216   add_ptr(-1, dest);
 217 }
 218 
 219 inline void Atomic::dec_ptr(volatile void* dest) {
 220   add_ptr(-1, dest);
 221 }
 222 
 223 inline jint Atomic::xchg(jint exchange_value, volatile jint* dest) {
 224 #ifdef ARM
 225   return arm_lock_test_and_set(dest, exchange_value);
 226 #else
 227 #ifdef M68K
 228   return m68k_lock_test_and_set(dest, exchange_value);
 229 #else
 230   // __sync_lock_test_and_set is a bizarrely named atomic exchange
 231   // operation.  Note that some platforms only support this with the
 232   // limitation that the only valid value to store is the immediate
 233   // constant 1.  There is a test for this in JNI_CreateJavaVM().
 234   return __sync_lock_test_and_set (dest, exchange_value);






 235 #endif // M68K
 236 #endif // ARM
 237 }
 238 
 239 inline intptr_t Atomic::xchg_ptr(intptr_t exchange_value,
 240                                  volatile intptr_t* dest) {
 241 #ifdef ARM
 242   return arm_lock_test_and_set(dest, exchange_value);
 243 #else
 244 #ifdef M68K
 245   return m68k_lock_test_and_set(dest, exchange_value);
 246 #else
 247   return __sync_lock_test_and_set (dest, exchange_value);


 248 #endif // M68K
 249 #endif // ARM
 250 }
 251 
 252 inline void* Atomic::xchg_ptr(void* exchange_value, volatile void* dest) {
 253   return (void *) xchg_ptr((intptr_t) exchange_value,
 254                            (volatile intptr_t*) dest);
 255 }
 256 
 257 inline jint Atomic::cmpxchg(jint exchange_value,
 258                             volatile jint* dest,
 259                             jint compare_value) {
 260 #ifdef ARM
 261   return arm_compare_and_swap(dest, compare_value, exchange_value);
 262 #else
 263 #ifdef M68K
 264   return m68k_compare_and_swap(dest, compare_value, exchange_value);
 265 #else
 266   return __sync_val_compare_and_swap(dest, compare_value, exchange_value);
 267 #endif // M68K




 214 
 215 inline void Atomic::dec_ptr(volatile intptr_t* dest) {
 216   add_ptr(-1, dest);
 217 }
 218 
 219 inline void Atomic::dec_ptr(volatile void* dest) {
 220   add_ptr(-1, dest);
 221 }
 222 
 223 inline jint Atomic::xchg(jint exchange_value, volatile jint* dest) {
 224 #ifdef ARM
 225   return arm_lock_test_and_set(dest, exchange_value);
 226 #else
 227 #ifdef M68K
 228   return m68k_lock_test_and_set(dest, exchange_value);
 229 #else
 230   // __sync_lock_test_and_set is a bizarrely named atomic exchange
 231   // operation.  Note that some platforms only support this with the
 232   // limitation that the only valid value to store is the immediate
 233   // constant 1.  There is a test for this in JNI_CreateJavaVM().
 234   jint result = __sync_lock_test_and_set (dest, exchange_value);
 235   // All atomic operations are expected to be full memory barriers
 236   // (see atomic.hpp). However, __sync_lock_test_and_set is not
 237   // a full memory barrier, but an acquire barrier. Hence, this added
 238   // barrier.
 239   __sync_synchronize();
 240   return result;
 241 #endif // M68K
 242 #endif // ARM
 243 }
 244 
 245 inline intptr_t Atomic::xchg_ptr(intptr_t exchange_value,
 246                                  volatile intptr_t* dest) {
 247 #ifdef ARM
 248   return arm_lock_test_and_set(dest, exchange_value);
 249 #else
 250 #ifdef M68K
 251   return m68k_lock_test_and_set(dest, exchange_value);
 252 #else
 253   intptr_t result = __sync_lock_test_and_set (dest, exchange_value);
 254   __sync_synchronize();
 255   return result;
 256 #endif // M68K
 257 #endif // ARM
 258 }
 259 
 260 inline void* Atomic::xchg_ptr(void* exchange_value, volatile void* dest) {
 261   return (void *) xchg_ptr((intptr_t) exchange_value,
 262                            (volatile intptr_t*) dest);
 263 }
 264 
 265 inline jint Atomic::cmpxchg(jint exchange_value,
 266                             volatile jint* dest,
 267                             jint compare_value) {
 268 #ifdef ARM
 269   return arm_compare_and_swap(dest, compare_value, exchange_value);
 270 #else
 271 #ifdef M68K
 272   return m68k_compare_and_swap(dest, compare_value, exchange_value);
 273 #else
 274   return __sync_val_compare_and_swap(dest, compare_value, exchange_value);
 275 #endif // M68K