提交 68769616 编写于 作者: S sgehwolf

8067331: Zero: Atomic::xchg and Atomic::xchg_ptr need full memory barrier

Reviewed-by: dholmes, coleenp
上级 d223357e
...@@ -238,7 +238,13 @@ inline jint Atomic::xchg(jint exchange_value, volatile jint* dest) { ...@@ -238,7 +238,13 @@ inline jint Atomic::xchg(jint exchange_value, volatile jint* dest) {
// operation. Note that some platforms only support this with the // operation. Note that some platforms only support this with the
// limitation that the only valid value to store is the immediate // limitation that the only valid value to store is the immediate
// constant 1. There is a test for this in JNI_CreateJavaVM(). // constant 1. There is a test for this in JNI_CreateJavaVM().
return __sync_lock_test_and_set (dest, exchange_value); jint result = __sync_lock_test_and_set (dest, exchange_value);
// All atomic operations are expected to be full memory barriers
// (see atomic.hpp). However, __sync_lock_test_and_set is not
// a full memory barrier, but an acquire barrier. Hence, this added
// barrier.
__sync_synchronize();
return result;
#endif // M68K #endif // M68K
#endif // ARM #endif // ARM
} }
...@@ -251,7 +257,9 @@ inline intptr_t Atomic::xchg_ptr(intptr_t exchange_value, ...@@ -251,7 +257,9 @@ inline intptr_t Atomic::xchg_ptr(intptr_t exchange_value,
#ifdef M68K #ifdef M68K
return m68k_lock_test_and_set(dest, exchange_value); return m68k_lock_test_and_set(dest, exchange_value);
#else #else
return __sync_lock_test_and_set (dest, exchange_value); intptr_t result = __sync_lock_test_and_set (dest, exchange_value);
__sync_synchronize();
return result;
#endif // M68K #endif // M68K
#endif // ARM #endif // ARM
} }
......
/* /*
* Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2003, 2014, Oracle and/or its affiliates. All rights reserved.
* Copyright 2007, 2008, 2011 Red Hat, Inc. * Copyright 2007, 2008, 2011, 2015, Red Hat, Inc.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -232,7 +232,13 @@ inline jint Atomic::xchg(jint exchange_value, volatile jint* dest) { ...@@ -232,7 +232,13 @@ inline jint Atomic::xchg(jint exchange_value, volatile jint* dest) {
// operation. Note that some platforms only support this with the // operation. Note that some platforms only support this with the
// limitation that the only valid value to store is the immediate // limitation that the only valid value to store is the immediate
// constant 1. There is a test for this in JNI_CreateJavaVM(). // constant 1. There is a test for this in JNI_CreateJavaVM().
return __sync_lock_test_and_set (dest, exchange_value); jint result = __sync_lock_test_and_set (dest, exchange_value);
// All atomic operations are expected to be full memory barriers
// (see atomic.hpp). However, __sync_lock_test_and_set is not
// a full memory barrier, but an acquire barrier. Hence, this added
// barrier.
__sync_synchronize();
return result;
#endif // M68K #endif // M68K
#endif // ARM #endif // ARM
} }
...@@ -245,7 +251,9 @@ inline intptr_t Atomic::xchg_ptr(intptr_t exchange_value, ...@@ -245,7 +251,9 @@ inline intptr_t Atomic::xchg_ptr(intptr_t exchange_value,
#ifdef M68K #ifdef M68K
return m68k_lock_test_and_set(dest, exchange_value); return m68k_lock_test_and_set(dest, exchange_value);
#else #else
return __sync_lock_test_and_set (dest, exchange_value); intptr_t result = __sync_lock_test_and_set (dest, exchange_value);
__sync_synchronize();
return result;
#endif // M68K #endif // M68K
#endif // ARM #endif // ARM
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册