Mercurial > hg > graal-jvmci-8
comparison src/os_cpu/linux_zero/vm/atomic_linux_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 |
---|---|
1 /* | 1 /* |
2 * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved. | 2 * Copyright (c) 2003, 2014, Oracle and/or its affiliates. All rights reserved. |
3 * Copyright 2007, 2008, 2011 Red Hat, Inc. | 3 * Copyright 2007, 2008, 2011, 2015, Red Hat, Inc. |
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | 4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
5 * | 5 * |
6 * This code is free software; you can redistribute it and/or modify it | 6 * This code is free software; you can redistribute it and/or modify it |
7 * under the terms of the GNU General Public License version 2 only, as | 7 * under the terms of the GNU General Public License version 2 only, as |
8 * published by the Free Software Foundation. | 8 * published by the Free Software Foundation. |
230 #else | 230 #else |
231 // __sync_lock_test_and_set is a bizarrely named atomic exchange | 231 // __sync_lock_test_and_set is a bizarrely named atomic exchange |
232 // operation. Note that some platforms only support this with the | 232 // operation. Note that some platforms only support this with the |
233 // limitation that the only valid value to store is the immediate | 233 // limitation that the only valid value to store is the immediate |
234 // constant 1. There is a test for this in JNI_CreateJavaVM(). | 234 // constant 1. There is a test for this in JNI_CreateJavaVM(). |
235 return __sync_lock_test_and_set (dest, exchange_value); | 235 jint result = __sync_lock_test_and_set (dest, exchange_value); |
236 // All atomic operations are expected to be full memory barriers | |
237 // (see atomic.hpp). However, __sync_lock_test_and_set is not | |
238 // a full memory barrier, but an acquire barrier. Hence, this added | |
239 // barrier. | |
240 __sync_synchronize(); | |
241 return result; | |
236 #endif // M68K | 242 #endif // M68K |
237 #endif // ARM | 243 #endif // ARM |
238 } | 244 } |
239 | 245 |
240 inline intptr_t Atomic::xchg_ptr(intptr_t exchange_value, | 246 inline intptr_t Atomic::xchg_ptr(intptr_t exchange_value, |
243 return arm_lock_test_and_set(dest, exchange_value); | 249 return arm_lock_test_and_set(dest, exchange_value); |
244 #else | 250 #else |
245 #ifdef M68K | 251 #ifdef M68K |
246 return m68k_lock_test_and_set(dest, exchange_value); | 252 return m68k_lock_test_and_set(dest, exchange_value); |
247 #else | 253 #else |
248 return __sync_lock_test_and_set (dest, exchange_value); | 254 intptr_t result = __sync_lock_test_and_set (dest, exchange_value); |
255 __sync_synchronize(); | |
256 return result; | |
249 #endif // M68K | 257 #endif // M68K |
250 #endif // ARM | 258 #endif // ARM |
251 } | 259 } |
252 | 260 |
253 inline void* Atomic::xchg_ptr(void* exchange_value, volatile void* dest) { | 261 inline void* Atomic::xchg_ptr(void* exchange_value, volatile void* dest) { |