зеркало из https://github.com/mozilla/gecko-dev.git
[Bug 445818] Using explicit assembly to implement compare-and-swap on x86-64 to avoid __sync_bool_compare_and_swap (GCC intrinsic) as the latter is buggy at least on ARM. r=brendan
This commit is contained in:
Родитель
a1072e86a3
Коммит
d68ca228cc
|
@ -120,6 +120,23 @@ NativeCompareAndSwap(jsword *w, jsword ov, jsword nv)
|
|||
return (int)res;
|
||||
}
|
||||
|
||||
#elif defined(__GNUC__) && defined(__x86_64__)
|
||||
static JS_INLINE int
|
||||
NativeCompareAndSwap(jsword *w, jsword ov, jsword nv)
|
||||
{
|
||||
unsigned int res;
|
||||
|
||||
__asm__ __volatile__ (
|
||||
"lock\n"
|
||||
"cmpxchgq %2, (%1)\n"
|
||||
"sete %%al\n"
|
||||
"movzbl %%al, %%eax\n"
|
||||
: "=a" (res)
|
||||
: "r" (w), "r" (nv), "a" (ov)
|
||||
: "cc", "memory");
|
||||
return (int)res;
|
||||
}
|
||||
|
||||
#elif defined(SOLARIS) && defined(sparc) && defined(ULTRA_SPARC)
|
||||
|
||||
static JS_INLINE int
|
||||
|
@ -174,15 +191,6 @@ NativeCompareAndSwap(jsword *w, jsword ov, jsword nv)
|
|||
return !__kernel_cmpxchg(ov, nv, vp);
|
||||
}
|
||||
|
||||
#elif defined(__GNUC__) && \
|
||||
(__GNUC__ >= 5 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 1))
|
||||
|
||||
static JS_INLINE int
|
||||
NativeCompareAndSwap(jsword *w, jsword ov, jsword nv)
|
||||
{
|
||||
return __sync_bool_compare_and_swap(w, ov, nv);
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
#error "JS_HAS_NATIVE_COMPARE_AND_SWAP should be 0 if your platform lacks a compare-and-swap instruction."
|
||||
|
|
|
@ -56,11 +56,10 @@ JS_BEGIN_EXTERN_C
|
|||
|
||||
#if (defined(_WIN32) && defined(_M_IX86)) || \
|
||||
(defined(__GNUC__) && defined(__i386__)) || \
|
||||
(defined(__GNUC__) && defined(__x86_64__)) || \
|
||||
(defined(SOLARIS) && defined(sparc) && defined(ULTRA_SPARC)) || \
|
||||
defined(AIX) || \
|
||||
defined(USE_ARM_KUSER) || \
|
||||
(defined(__GNUC__) && \
|
||||
(__GNUC__ >= 5 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 1)))
|
||||
defined(USE_ARM_KUSER)
|
||||
# define JS_HAS_NATIVE_COMPARE_AND_SWAP 1
|
||||
#else
|
||||
# define JS_HAS_NATIVE_COMPARE_AND_SWAP 0
|
||||
|
|
Загрузка…
Ссылка в новой задаче