| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // This file is an internal atomic implementation, use atomicops.h instead. | 5 // This file is an internal atomic implementation, use atomicops.h instead. |
| 6 | 6 |
| 7 #ifndef V8_BASE_ATOMICOPS_INTERNALS_ARM_GCC_H_ | 7 #ifndef V8_BASE_ATOMICOPS_INTERNALS_ARM_GCC_H_ |
| 8 #define V8_BASE_ATOMICOPS_INTERNALS_ARM_GCC_H_ | 8 #define V8_BASE_ATOMICOPS_INTERNALS_ARM_GCC_H_ |
| 9 | 9 |
| 10 namespace v8 { | 10 namespace v8 { |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 "0: \n\t" | 32 "0: \n\t" |
| 33 "ldxr %w[prev], %[ptr] \n\t" // Load the previous value. | 33 "ldxr %w[prev], %[ptr] \n\t" // Load the previous value. |
| 34 "cmp %w[prev], %w[old_value] \n\t" | 34 "cmp %w[prev], %w[old_value] \n\t" |
| 35 "bne 1f \n\t" | 35 "bne 1f \n\t" |
| 36 "stxr %w[temp], %w[new_value], %[ptr] \n\t" // Try to store the new value. | 36 "stxr %w[temp], %w[new_value], %[ptr] \n\t" // Try to store the new value. |
| 37 "cbnz %w[temp], 0b \n\t" // Retry if it did not work. | 37 "cbnz %w[temp], 0b \n\t" // Retry if it did not work. |
| 38 "1: \n\t" | 38 "1: \n\t" |
| 39 : [prev]"=&r" (prev), | 39 : [prev]"=&r" (prev), |
| 40 [temp]"=&r" (temp), | 40 [temp]"=&r" (temp), |
| 41 [ptr]"+Q" (*ptr) | 41 [ptr]"+Q" (*ptr) |
| 42 #ifdef __clang__ |
| 43 // Workaround for Clang (https://llvm.org/bugs/show_bug.cgi?id=23575). |
| 44 : [old_value]"Ir" (old_value), |
| 45 #else |
| 42 : [old_value]"IJr" (old_value), | 46 : [old_value]"IJr" (old_value), |
| 47 #endif |
| 43 [new_value]"r" (new_value) | 48 [new_value]"r" (new_value) |
| 44 : "cc", "memory" | 49 : "cc", "memory" |
| 45 ); // NOLINT | 50 ); // NOLINT |
| 46 | 51 |
| 47 return prev; | 52 return prev; |
| 48 } | 53 } |
| 49 | 54 |
| 50 inline Atomic32 NoBarrier_AtomicExchange(volatile Atomic32* ptr, | 55 inline Atomic32 NoBarrier_AtomicExchange(volatile Atomic32* ptr, |
| 51 Atomic32 new_value) { | 56 Atomic32 new_value) { |
| 52 Atomic32 result; | 57 Atomic32 result; |
| (...skipping 21 matching lines...) Expand all Loading... |
| 74 | 79 |
| 75 __asm__ __volatile__ ( // NOLINT | 80 __asm__ __volatile__ ( // NOLINT |
| 76 "0: \n\t" | 81 "0: \n\t" |
| 77 "ldxr %w[result], %[ptr] \n\t" // Load the previous value. | 82 "ldxr %w[result], %[ptr] \n\t" // Load the previous value. |
| 78 "add %w[result], %w[result], %w[increment]\n\t" | 83 "add %w[result], %w[result], %w[increment]\n\t" |
| 79 "stxr %w[temp], %w[result], %[ptr] \n\t" // Try to store the result. | 84 "stxr %w[temp], %w[result], %[ptr] \n\t" // Try to store the result. |
| 80 "cbnz %w[temp], 0b \n\t" // Retry on failure. | 85 "cbnz %w[temp], 0b \n\t" // Retry on failure. |
| 81 : [result]"=&r" (result), | 86 : [result]"=&r" (result), |
| 82 [temp]"=&r" (temp), | 87 [temp]"=&r" (temp), |
| 83 [ptr]"+Q" (*ptr) | 88 [ptr]"+Q" (*ptr) |
| 89 #ifdef __clang__ |
| 90 // Workaround for Clang (https://llvm.org/bugs/show_bug.cgi?id=23575). |
| 91 : [increment]"Ir" (increment) |
| 92 #else |
| 84 : [increment]"IJr" (increment) | 93 : [increment]"IJr" (increment) |
| 94 #endif |
| 85 : "memory" | 95 : "memory" |
| 86 ); // NOLINT | 96 ); // NOLINT |
| 87 | 97 |
| 88 return result; | 98 return result; |
| 89 } | 99 } |
| 90 | 100 |
| 91 inline Atomic32 Barrier_AtomicIncrement(volatile Atomic32* ptr, | 101 inline Atomic32 Barrier_AtomicIncrement(volatile Atomic32* ptr, |
| 92 Atomic32 increment) { | 102 Atomic32 increment) { |
| 93 Atomic32 result; | 103 Atomic32 result; |
| 94 | 104 |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 182 "0: \n\t" | 192 "0: \n\t" |
| 183 "ldxr %[prev], %[ptr] \n\t" | 193 "ldxr %[prev], %[ptr] \n\t" |
| 184 "cmp %[prev], %[old_value] \n\t" | 194 "cmp %[prev], %[old_value] \n\t" |
| 185 "bne 1f \n\t" | 195 "bne 1f \n\t" |
| 186 "stxr %w[temp], %[new_value], %[ptr] \n\t" | 196 "stxr %w[temp], %[new_value], %[ptr] \n\t" |
| 187 "cbnz %w[temp], 0b \n\t" | 197 "cbnz %w[temp], 0b \n\t" |
| 188 "1: \n\t" | 198 "1: \n\t" |
| 189 : [prev]"=&r" (prev), | 199 : [prev]"=&r" (prev), |
| 190 [temp]"=&r" (temp), | 200 [temp]"=&r" (temp), |
| 191 [ptr]"+Q" (*ptr) | 201 [ptr]"+Q" (*ptr) |
| 202 #ifdef __clang__ |
| 203 // Workaround for Clang (https://llvm.org/bugs/show_bug.cgi?id=23575). |
| 204 : [old_value]"Ir" (old_value), |
| 205 #else |
| 192 : [old_value]"IJr" (old_value), | 206 : [old_value]"IJr" (old_value), |
| 207 #endif |
| 193 [new_value]"r" (new_value) | 208 [new_value]"r" (new_value) |
| 194 : "cc", "memory" | 209 : "cc", "memory" |
| 195 ); // NOLINT | 210 ); // NOLINT |
| 196 | 211 |
| 197 return prev; | 212 return prev; |
| 198 } | 213 } |
| 199 | 214 |
| 200 inline Atomic64 NoBarrier_AtomicExchange(volatile Atomic64* ptr, | 215 inline Atomic64 NoBarrier_AtomicExchange(volatile Atomic64* ptr, |
| 201 Atomic64 new_value) { | 216 Atomic64 new_value) { |
| 202 Atomic64 result; | 217 Atomic64 result; |
| (...skipping 21 matching lines...) Expand all Loading... |
| 224 | 239 |
| 225 __asm__ __volatile__ ( // NOLINT | 240 __asm__ __volatile__ ( // NOLINT |
| 226 "0: \n\t" | 241 "0: \n\t" |
| 227 "ldxr %[result], %[ptr] \n\t" | 242 "ldxr %[result], %[ptr] \n\t" |
| 228 "add %[result], %[result], %[increment] \n\t" | 243 "add %[result], %[result], %[increment] \n\t" |
| 229 "stxr %w[temp], %[result], %[ptr] \n\t" | 244 "stxr %w[temp], %[result], %[ptr] \n\t" |
| 230 "cbnz %w[temp], 0b \n\t" | 245 "cbnz %w[temp], 0b \n\t" |
| 231 : [result]"=&r" (result), | 246 : [result]"=&r" (result), |
| 232 [temp]"=&r" (temp), | 247 [temp]"=&r" (temp), |
| 233 [ptr]"+Q" (*ptr) | 248 [ptr]"+Q" (*ptr) |
| 249 #ifdef __clang__ |
| 250 // Workaround for Clang (https://llvm.org/bugs/show_bug.cgi?id=23575). |
| 251 : [increment]"Ir" (increment) |
| 252 #else |
| 234 : [increment]"IJr" (increment) | 253 : [increment]"IJr" (increment) |
| 254 #endif |
| 235 : "memory" | 255 : "memory" |
| 236 ); // NOLINT | 256 ); // NOLINT |
| 237 | 257 |
| 238 return result; | 258 return result; |
| 239 } | 259 } |
| 240 | 260 |
| 241 inline Atomic64 Barrier_AtomicIncrement(volatile Atomic64* ptr, | 261 inline Atomic64 Barrier_AtomicIncrement(volatile Atomic64* ptr, |
| 242 Atomic64 increment) { | 262 Atomic64 increment) { |
| 243 Atomic64 result; | 263 Atomic64 result; |
| 244 | 264 |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 307 } | 327 } |
| 308 | 328 |
| 309 inline Atomic64 Release_Load(volatile const Atomic64* ptr) { | 329 inline Atomic64 Release_Load(volatile const Atomic64* ptr) { |
| 310 MemoryBarrier(); | 330 MemoryBarrier(); |
| 311 return *ptr; | 331 return *ptr; |
| 312 } | 332 } |
| 313 | 333 |
| 314 } } // namespace v8::base | 334 } } // namespace v8::base |
| 315 | 335 |
| 316 #endif // V8_BASE_ATOMICOPS_INTERNALS_ARM_GCC_H_ | 336 #endif // V8_BASE_ATOMICOPS_INTERNALS_ARM_GCC_H_ |
| OLD | NEW |