| OLD | NEW |
| 1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 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 // The routines exported by this module are subtle. If you use them, even if | 5 // The routines exported by this module are subtle. If you use them, even if |
| 6 // you get the code right, it will depend on careful reasoning about atomicity | 6 // you get the code right, it will depend on careful reasoning about atomicity |
| 7 // and memory ordering; it will be less readable, and harder to maintain. If | 7 // and memory ordering; it will be less readable, and harder to maintain. If |
| 8 // you plan to use these routines, you should have a good reason, such as solid | 8 // you plan to use these routines, you should have a good reason, such as solid |
| 9 // evidence that performance would otherwise suffer, or there being no | 9 // evidence that performance would otherwise suffer, or there being no |
| 10 // alternative. You should assume only properties explicitly guaranteed by the | 10 // alternative. You should assume only properties explicitly guaranteed by the |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 // (http://msdn.microsoft.com/en-us/library/windows/desktop/ms684208.aspx) | 35 // (http://msdn.microsoft.com/en-us/library/windows/desktop/ms684208.aspx) |
| 36 // implementation directly. | 36 // implementation directly. |
| 37 #undef MemoryBarrier | 37 #undef MemoryBarrier |
| 38 #endif | 38 #endif |
| 39 | 39 |
| 40 namespace v8 { | 40 namespace v8 { |
| 41 namespace base { | 41 namespace base { |
| 42 | 42 |
| 43 typedef char Atomic8; | 43 typedef char Atomic8; |
| 44 typedef int32_t Atomic32; | 44 typedef int32_t Atomic32; |
| 45 #ifdef V8_HOST_ARCH_64_BIT | 45 #if defined(__native_client__) |
| 46 typedef int64_t Atomic64; |
| 47 #elif defined(V8_HOST_ARCH_64_BIT) |
| 46 // We need to be able to go between Atomic64 and AtomicWord implicitly. This | 48 // We need to be able to go between Atomic64 and AtomicWord implicitly. This |
| 47 // means Atomic64 and AtomicWord should be the same type on 64-bit. | 49 // means Atomic64 and AtomicWord should be the same type on 64-bit. |
| 48 #if defined(__ILP32__) | 50 #if defined(__ILP32__) |
| 49 typedef int64_t Atomic64; | 51 typedef int64_t Atomic64; |
| 50 #else | 52 #else |
| 51 typedef intptr_t Atomic64; | 53 typedef intptr_t Atomic64; |
| 52 #endif | 54 #endif // defined(V8_HOST_ARCH_64_BIT) |
| 53 #endif | 55 #endif // defined(__native_client__) |
| 54 | 56 |
| 55 // Use AtomicWord for a machine-sized pointer. It will use the Atomic32 or | 57 // Use AtomicWord for a machine-sized pointer. It will use the Atomic32 or |
| 56 // Atomic64 routines below, depending on your architecture. | 58 // Atomic64 routines below, depending on your architecture. |
| 57 typedef intptr_t AtomicWord; | 59 typedef intptr_t AtomicWord; |
| 58 | 60 |
| 59 // Atomically execute: | 61 // Atomically execute: |
| 60 // result = *ptr; | 62 // result = *ptr; |
| 61 // if (*ptr == old_value) | 63 // if (*ptr == old_value) |
| 62 // *ptr = new_value; | 64 // *ptr = new_value; |
| 63 // return result; | 65 // return result; |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 133 | 135 |
| 134 } } // namespace v8::base | 136 } } // namespace v8::base |
| 135 | 137 |
| 136 // Include our platform specific implementation. | 138 // Include our platform specific implementation. |
| 137 #if defined(THREAD_SANITIZER) | 139 #if defined(THREAD_SANITIZER) |
| 138 #include "src/base/atomicops_internals_tsan.h" | 140 #include "src/base/atomicops_internals_tsan.h" |
| 139 #elif defined(_MSC_VER) && (V8_HOST_ARCH_IA32 || V8_HOST_ARCH_X64) | 141 #elif defined(_MSC_VER) && (V8_HOST_ARCH_IA32 || V8_HOST_ARCH_X64) |
| 140 #include "src/base/atomicops_internals_x86_msvc.h" | 142 #include "src/base/atomicops_internals_x86_msvc.h" |
| 141 #elif defined(__APPLE__) | 143 #elif defined(__APPLE__) |
| 142 #include "src/base/atomicops_internals_mac.h" | 144 #include "src/base/atomicops_internals_mac.h" |
| 145 #elif defined(__native_client__) |
| 146 #include "src/base/atomicops_internals_portable.h" |
| 143 #elif defined(__GNUC__) && V8_HOST_ARCH_ARM64 | 147 #elif defined(__GNUC__) && V8_HOST_ARCH_ARM64 |
| 144 #include "src/base/atomicops_internals_arm64_gcc.h" | 148 #include "src/base/atomicops_internals_arm64_gcc.h" |
| 145 #elif defined(__GNUC__) && V8_HOST_ARCH_ARM | 149 #elif defined(__GNUC__) && V8_HOST_ARCH_ARM |
| 146 #include "src/base/atomicops_internals_arm_gcc.h" | 150 #include "src/base/atomicops_internals_arm_gcc.h" |
| 147 #elif defined(__GNUC__) && (V8_HOST_ARCH_IA32 || V8_HOST_ARCH_X64) | 151 #elif defined(__GNUC__) && (V8_HOST_ARCH_IA32 || V8_HOST_ARCH_X64) |
| 148 #include "src/base/atomicops_internals_x86_gcc.h" | 152 #include "src/base/atomicops_internals_x86_gcc.h" |
| 149 #elif defined(__GNUC__) && V8_HOST_ARCH_MIPS | 153 #elif defined(__GNUC__) && V8_HOST_ARCH_MIPS |
| 150 #include "src/base/atomicops_internals_mips_gcc.h" | 154 #include "src/base/atomicops_internals_mips_gcc.h" |
| 151 #elif defined(__GNUC__) && V8_HOST_ARCH_MIPS64 | 155 #elif defined(__GNUC__) && V8_HOST_ARCH_MIPS64 |
| 152 #include "src/base/atomicops_internals_mips64_gcc.h" | 156 #include "src/base/atomicops_internals_mips64_gcc.h" |
| 153 #else | 157 #else |
| 154 #error "Atomic operations are not supported on your platform" | 158 #error "Atomic operations are not supported on your platform" |
| 155 #endif | 159 #endif |
| 156 | 160 |
| 157 // On some platforms we need additional declarations to make | 161 // On some platforms we need additional declarations to make |
| 158 // AtomicWord compatible with our other Atomic* types. | 162 // AtomicWord compatible with our other Atomic* types. |
| 159 #if defined(__APPLE__) || defined(__OpenBSD__) | 163 #if defined(__APPLE__) || defined(__OpenBSD__) |
| 160 #include "src/base/atomicops_internals_atomicword_compat.h" | 164 #include "src/base/atomicops_internals_atomicword_compat.h" |
| 161 #endif | 165 #endif |
| 162 | 166 |
| 163 #endif // V8_BASE_ATOMICOPS_H_ | 167 #endif // V8_BASE_ATOMICOPS_H_ |
| OLD | NEW |