PKGBUILDs/extra/webkitgtk/ARM64-GCC-generates-wrong-code-with-O2-flag-in-WTF-weakCompareAndSwap.patch
2016-03-19 02:21:13 +00:00

75 lines
2 KiB
Diff

Index: trunk/Source/WTF/wtf/Atomics.h
===================================================================
--- trunk/Source/WTF/wtf/Atomics.h (revision 166233)
+++ trunk/Source/WTF/wtf/Atomics.h (revision 166234)
@@ -105,20 +105,34 @@
"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:"
: "+Q"(*location), "=&r"(result), "=&r"(tmp)
: "r"(expected), "r"(newValue)
: "memory");
result = !result;
+#elif CPU(ARM64) && COMPILER(GCC)
+ unsigned tmp;
+ unsigned result;
+ asm volatile(
+ "mov %w1, #1\n\t"
+ "ldxr %w2, [%0]\n\t"
+ "cmp %w3, %w2\n\t"
+ "b.ne 0f\n\t"
+ "stxr %w1, %w4, [%0]\n\t"
+ "0:"
+ : "+r"(location), "=&r"(result), "=&r"(tmp)
+ : "r"(expected), "r"(newValue)
+ : "memory");
+ result = !result;
#elif CPU(ARM64)
unsigned tmp;
unsigned result;
asm volatile(
"mov %w1, #1\n\t"
"ldxr %w2, %0\n\t"
"cmp %w3, %w2\n\t"
"b.ne 0f\n\t"
"stxr %w1, %w4, %0\n\t"
"0:"
@@ -145,20 +159,34 @@
#if CPU(X86_64)
bool result;
asm volatile(
"lock; cmpxchgq %3, %2\n\t"
"sete %1"
: "+a"(expected), "=q"(result), "+m"(*location)
: "r"(newValue)
: "memory"
);
return result;
+#elif CPU(ARM64) && COMPILER(GCC)
+ bool result;
+ void* tmp;
+ asm volatile(
+ "mov %w1, #1\n\t"
+ "ldxr %x2, [%0]\n\t"
+ "cmp %x3, %x2\n\t"
+ "b.ne 0f\n\t"
+ "stxr %w1, %x4, [%0]\n\t"
+ "0:"
+ : "+r"(location), "=&r"(result), "=&r"(tmp)
+ : "r"(expected), "r"(newValue)
+ : "memory");
+ return !result;
#elif CPU(ARM64)
bool result;
void* tmp;
asm volatile(
"mov %w1, #1\n\t"
"ldxr %x2, %0\n\t"
"cmp %x3, %x2\n\t"
"b.ne 0f\n\t"
"stxr %w1, %x4, %0\n\t"
"0:"