Changeset 102295 in webkit for trunk/Source/JavaScriptCore/wtf/Atomics.h
- Timestamp:
- Dec 7, 2011, 6:09:14 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/wtf/Atomics.h
r99374 r102295 61 61 62 62 #include "Platform.h" 63 #include "StdLibExtras.h" 63 64 #include "UnusedParam.h" 64 65 … … 120 121 inline bool weakCompareAndSwap(unsigned* location, unsigned expected, unsigned newValue) 121 122 { 122 // FIXME: Implement COMPARE_AND_SWAP on other architectures and compilers. Currently123 // it only works on X86 or X86_64 with a GCC-style compiler.124 123 #if ENABLE(COMPARE_AND_SWAP) 125 124 bool result; 125 #if CPU(X86) || CPU(X86_64) 126 126 asm volatile( 127 127 "lock; cmpxchgl %3, %2\n\t" … … 131 131 : "memory" 132 132 ); 133 #elif CPU(ARM_THUMB2) 134 unsigned tmp; 135 asm volatile( 136 "movw %1, #1\n\t" 137 "ldrex %2, %0\n\t" 138 "cmp %3, %2\n\t" 139 "bne.n 0f\n\t" 140 "strex %1, %4, %0\n\t" 141 "0:" 142 : "+m"(*location), "=&r"(result), "=&r"(tmp) 143 : "r"(expected), "r"(newValue) 144 : "memory"); 145 result = !result; 146 #else 147 #error "Bad architecture for compare and swap." 148 #endif 133 149 return result; 134 150 #else … … 143 159 inline bool weakCompareAndSwap(void*volatile* location, void* expected, void* newValue) 144 160 { 145 // FIXME: Implement COMPARE_AND_SWAP on other architectures and compilers. Currently146 // it only works on X86 or X86_64 with a GCC-style compiler.147 161 #if ENABLE(COMPARE_AND_SWAP) 162 #if CPU(X86_64) 148 163 bool result; 149 164 asm volatile( 150 #if CPU(X86_64)151 165 "lock; cmpxchgq %3, %2\n\t" 152 #else153 "lock; cmpxchgl %3, %2\n\t"154 #endif155 166 "sete %1" 156 167 : "+a"(expected), "=q"(result), "+m"(*location) … … 159 170 ); 160 171 return result; 172 #else 173 return weakCompareAndSwap(bitwise_cast<unsigned*>(location), bitwise_cast<unsigned>(expected), bitwise_cast<unsigned>(newValue)); 174 #endif 161 175 #else // ENABLE(COMPARE_AND_SWAP) 162 176 UNUSED_PARAM(location);
Note:
See TracChangeset
for help on using the changeset viewer.