Bug 1202367 - reinitialize expected value inside CAS loop. r=sstangl
authorLars T Hansen <lhansen@mozilla.com>
Wed, 09 Sep 2015 08:29:35 +0200
changeset 294121 7d3d866c692efdbcca587f8a955617ba8fdd5315
parent 294091 7793b201f3894ed6caf46703afba4db073004f5f
child 294122 61ae725b23eefd22f30e8bd54384b1ec7c61e8b4
push id5245
push userraliiev@mozilla.com
push dateThu, 29 Oct 2015 11:30:51 +0000
treeherdermozilla-beta@dac831dc1bd0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssstangl
bugs1202367
milestone43.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1202367 - reinitialize expected value inside CAS loop. r=sstangl
js/src/jit/arm/AtomicOperations-arm.h
js/src/jit/arm64/AtomicOperations-arm64.h
js/src/jit/x86-shared/AtomicOperations-x86-shared.h
--- a/js/src/jit/arm/AtomicOperations-arm.h
+++ b/js/src/jit/arm/AtomicOperations-arm.h
@@ -186,18 +186,20 @@ inline void
 js::jit::RegionLock::acquire(void* addr)
 {
 # ifdef ATOMICS_IMPLEMENTED_WITH_SYNC_INTRINSICS
     while (!__sync_bool_compare_and_swap(&spinlock, 0, 1))
         ;
 # else
     uint32_t zero = 0;
     uint32_t one = 1;
-    while (!__atomic_compare_exchange(&spinlock, &zero, &one, false, __ATOMIC_ACQUIRE, __ATOMIC_ACQUIRE))
+    while (!__atomic_compare_exchange(&spinlock, &zero, &one, false, __ATOMIC_ACQUIRE, __ATOMIC_ACQUIRE)) {
+        zero = 0;
         continue;
+    }
 # endif
 }
 
 template<size_t nbytes>
 inline void
 js::jit::RegionLock::release(void* addr)
 {
     MOZ_ASSERT(AtomicOperations::loadSeqCst(&spinlock) == 1, "releasing unlocked region lock");
--- a/js/src/jit/arm64/AtomicOperations-arm64.h
+++ b/js/src/jit/arm64/AtomicOperations-arm64.h
@@ -105,18 +105,20 @@ js::jit::AtomicOperations::fetchXorSeqCs
 }
 
 template<size_t nbytes>
 inline void
 js::jit::RegionLock::acquire(void* addr)
 {
     uint32_t zero = 0;
     uint32_t one = 1;
-    while (!__atomic_compare_exchange(&spinlock, &zero, &one, false, __ATOMIC_ACQUIRE, __ATOMIC_ACQUIRE))
+    while (!__atomic_compare_exchange(&spinlock, &zero, &one, false, __ATOMIC_ACQUIRE, __ATOMIC_ACQUIRE)) {
+        zero = 0;
         continue;
+    }
 }
 
 template<size_t nbytes>
 inline void
 js::jit::RegionLock::release(void* addr)
 {
     MOZ_ASSERT(AtomicOperations::loadSeqCst(&spinlock) == 1, "releasing unlocked region lock");
     uint32_t zero = 0;
--- a/js/src/jit/x86-shared/AtomicOperations-x86-shared.h
+++ b/js/src/jit/x86-shared/AtomicOperations-x86-shared.h
@@ -326,18 +326,20 @@ inline void
 js::jit::RegionLock::acquire(void* addr)
 {
 # ifdef ATOMICS_IMPLEMENTED_WITH_SYNC_INTRINSICS
     while (!__sync_bool_compare_and_swap(&spinlock, 0, 1))
         continue;
 # else
     uint32_t zero = 0;
     uint32_t one = 1;
-    while (!__atomic_compare_exchange(&spinlock, &zero, &one, false, __ATOMIC_ACQUIRE, __ATOMIC_ACQUIRE))
+    while (!__atomic_compare_exchange(&spinlock, &zero, &one, false, __ATOMIC_ACQUIRE, __ATOMIC_ACQUIRE)) {
+        zero = 0;
         continue;
+    }
 # endif
 }
 
 template<size_t nbytes>
 inline void
 js::jit::RegionLock::release(void* addr)
 {
     MOZ_ASSERT(AtomicOperations::loadSeqCst(&spinlock) == 1, "releasing unlocked region lock");