Modified: trunk/Source/_javascript_Core/ChangeLog (102294 => 102295)
--- trunk/Source/_javascript_Core/ChangeLog 2011-12-08 02:02:13 UTC (rev 102294)
+++ trunk/Source/_javascript_Core/ChangeLog 2011-12-08 02:09:14 UTC (rev 102295)
@@ -1,5 +1,19 @@
2011-12-07 Filip Pizlo <[email protected]>
+ Compare and Swap should be enabled on ARMv7
+ https://bugs.webkit.org/show_bug.cgi?id=74023
+
+ Reviewed by Geoff Garen.
+
+ Implemented weakCompareAndSwap in terms of LDREX/STREX and enabled PARALLEL_GC.
+ It gives the expected speed-up on multi-core ARMv7 devices.
+
+ * wtf/Atomics.h:
+ (WTF::weakCompareAndSwap):
+ * wtf/Platform.h:
+
+2011-12-07 Filip Pizlo <[email protected]>
+
DFG CSE is overzealous with GetByVal
https://bugs.webkit.org/show_bug.cgi?id=74042
Modified: trunk/Source/_javascript_Core/wtf/Atomics.h (102294 => 102295)
--- trunk/Source/_javascript_Core/wtf/Atomics.h 2011-12-08 02:02:13 UTC (rev 102294)
+++ trunk/Source/_javascript_Core/wtf/Atomics.h 2011-12-08 02:09:14 UTC (rev 102295)
@@ -60,6 +60,7 @@
#define Atomics_h
#include "Platform.h"
+#include "StdLibExtras.h"
#include "UnusedParam.h"
#if OS(WINDOWS)
@@ -119,10 +120,9 @@
inline bool weakCompareAndSwap(unsigned* location, unsigned expected, unsigned newValue)
{
- // FIXME: Implement COMPARE_AND_SWAP on other architectures and compilers. Currently
- // it only works on X86 or X86_64 with a GCC-style compiler.
#if ENABLE(COMPARE_AND_SWAP)
bool result;
+#if CPU(X86) || CPU(X86_64)
asm volatile(
"lock; cmpxchgl %3, %2\n\t"
"sete %1"
@@ -130,6 +130,22 @@
: "r"(newValue)
: "memory"
);
+#elif CPU(ARM_THUMB2)
+ unsigned tmp;
+ asm volatile(
+ "movw %1, #1\n\t"
+ "ldrex %2, %0\n\t"
+ "cmp %3, %2\n\t"
+ "bne.n 0f\n\t"
+ "strex %1, %4, %0\n\t"
+ "0:"
+ : "+m"(*location), "=&r"(result), "=&r"(tmp)
+ : "r"(expected), "r"(newValue)
+ : "memory");
+ result = !result;
+#else
+#error "Bad architecture for compare and swap."
+#endif
return result;
#else
UNUSED_PARAM(location);
@@ -142,22 +158,20 @@
inline bool weakCompareAndSwap(void*volatile* location, void* expected, void* newValue)
{
- // FIXME: Implement COMPARE_AND_SWAP on other architectures and compilers. Currently
- // it only works on X86 or X86_64 with a GCC-style compiler.
#if ENABLE(COMPARE_AND_SWAP)
+#if CPU(X86_64)
bool result;
asm volatile(
-#if CPU(X86_64)
"lock; cmpxchgq %3, %2\n\t"
-#else
- "lock; cmpxchgl %3, %2\n\t"
-#endif
"sete %1"
: "+a"(expected), "=q"(result), "+m"(*location)
: "r"(newValue)
: "memory"
);
return result;
+#else
+ return weakCompareAndSwap(bitwise_cast<unsigned*>(location), bitwise_cast<unsigned>(expected), bitwise_cast<unsigned>(newValue));
+#endif
#else // ENABLE(COMPARE_AND_SWAP)
UNUSED_PARAM(location);
UNUSED_PARAM(expected);
Modified: trunk/Source/_javascript_Core/wtf/Platform.h (102294 => 102295)
--- trunk/Source/_javascript_Core/wtf/Platform.h 2011-12-08 02:02:13 UTC (rev 102294)
+++ trunk/Source/_javascript_Core/wtf/Platform.h 2011-12-08 02:09:14 UTC (rev 102295)
@@ -1105,11 +1105,11 @@
#define WTF_USE_UNIX_DOMAIN_SOCKETS 1
#endif
-#if !defined(ENABLE_COMPARE_AND_SWAP) && COMPILER(GCC) && (CPU(X86) || CPU(X86_64))
+#if !defined(ENABLE_COMPARE_AND_SWAP) && COMPILER(GCC) && (CPU(X86) || CPU(X86_64) || CPU(ARM_THUMB2))
#define ENABLE_COMPARE_AND_SWAP 1
#endif
-#if !defined(ENABLE_PARALLEL_GC) && PLATFORM(MAC) && ENABLE(COMPARE_AND_SWAP)
+#if !defined(ENABLE_PARALLEL_GC) && (PLATFORM(MAC) || PLATFORM(IOS)) && ENABLE(COMPARE_AND_SWAP)
#define ENABLE_PARALLEL_GC 1
#endif