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 #if defined(__native_client__) | 45 #if defined(V8_HOST_ARCH_64_BIT) |
46 typedef int64_t Atomic64; | |
47 #elif defined(V8_HOST_ARCH_64_BIT) | |
48 // We need to be able to go between Atomic64 and AtomicWord implicitly. This | 46 // We need to be able to go between Atomic64 and AtomicWord implicitly. This |
49 // means Atomic64 and AtomicWord should be the same type on 64-bit. | 47 // means Atomic64 and AtomicWord should be the same type on 64-bit. |
50 #if defined(__ILP32__) | 48 #if defined(__ILP32__) |
51 typedef int64_t Atomic64; | 49 typedef int64_t Atomic64; |
52 #else | 50 #else |
53 typedef intptr_t Atomic64; | 51 typedef intptr_t Atomic64; |
| 52 #endif // defined(__ILP32__) |
54 #endif // defined(V8_HOST_ARCH_64_BIT) | 53 #endif // defined(V8_HOST_ARCH_64_BIT) |
55 #endif // defined(__native_client__) | |
56 | 54 |
57 // Use AtomicWord for a machine-sized pointer. It will use the Atomic32 or | 55 // Use AtomicWord for a machine-sized pointer. It will use the Atomic32 or |
58 // Atomic64 routines below, depending on your architecture. | 56 // Atomic64 routines below, depending on your architecture. |
59 typedef intptr_t AtomicWord; | 57 typedef intptr_t AtomicWord; |
60 | 58 |
61 // Atomically execute: | 59 // Atomically execute: |
62 // result = *ptr; | 60 // result = *ptr; |
63 // if (*ptr == old_value) | 61 // if (*ptr == old_value) |
64 // *ptr = new_value; | 62 // *ptr = new_value; |
65 // return result; | 63 // return result; |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 } // namespace base | 134 } // namespace base |
137 } // namespace v8 | 135 } // namespace v8 |
138 | 136 |
139 // Include our platform specific implementation. | 137 // Include our platform specific implementation. |
140 #if defined(THREAD_SANITIZER) | 138 #if defined(THREAD_SANITIZER) |
141 #include "src/base/atomicops_internals_tsan.h" | 139 #include "src/base/atomicops_internals_tsan.h" |
142 #elif defined(_MSC_VER) && (V8_HOST_ARCH_IA32 || V8_HOST_ARCH_X64) | 140 #elif defined(_MSC_VER) && (V8_HOST_ARCH_IA32 || V8_HOST_ARCH_X64) |
143 #include "src/base/atomicops_internals_x86_msvc.h" | 141 #include "src/base/atomicops_internals_x86_msvc.h" |
144 #elif defined(__APPLE__) | 142 #elif defined(__APPLE__) |
145 #include "src/base/atomicops_internals_mac.h" | 143 #include "src/base/atomicops_internals_mac.h" |
146 #elif defined(__native_client__) | |
147 #include "src/base/atomicops_internals_portable.h" | |
148 #elif defined(__GNUC__) && V8_HOST_ARCH_ARM64 | 144 #elif defined(__GNUC__) && V8_HOST_ARCH_ARM64 |
149 #include "src/base/atomicops_internals_arm64_gcc.h" | 145 #include "src/base/atomicops_internals_arm64_gcc.h" |
150 #elif defined(__GNUC__) && V8_HOST_ARCH_ARM | 146 #elif defined(__GNUC__) && V8_HOST_ARCH_ARM |
151 #include "src/base/atomicops_internals_arm_gcc.h" | 147 #include "src/base/atomicops_internals_arm_gcc.h" |
152 #elif defined(__GNUC__) && V8_HOST_ARCH_PPC | 148 #elif defined(__GNUC__) && V8_HOST_ARCH_PPC |
153 #include "src/base/atomicops_internals_ppc_gcc.h" | 149 #include "src/base/atomicops_internals_ppc_gcc.h" |
154 #elif defined(__GNUC__) && (V8_HOST_ARCH_IA32 || V8_HOST_ARCH_X64) | 150 #elif defined(__GNUC__) && (V8_HOST_ARCH_IA32 || V8_HOST_ARCH_X64) |
155 #include "src/base/atomicops_internals_x86_gcc.h" | 151 #include "src/base/atomicops_internals_x86_gcc.h" |
156 #elif defined(__GNUC__) && V8_HOST_ARCH_MIPS | 152 #elif defined(__GNUC__) && V8_HOST_ARCH_MIPS |
157 #include "src/base/atomicops_internals_mips_gcc.h" | 153 #include "src/base/atomicops_internals_mips_gcc.h" |
158 #elif defined(__GNUC__) && V8_HOST_ARCH_MIPS64 | 154 #elif defined(__GNUC__) && V8_HOST_ARCH_MIPS64 |
159 #include "src/base/atomicops_internals_mips64_gcc.h" | 155 #include "src/base/atomicops_internals_mips64_gcc.h" |
160 #elif defined(__GNUC__) && V8_HOST_ARCH_S390 | 156 #elif defined(__GNUC__) && V8_HOST_ARCH_S390 |
161 #include "src/base/atomicops_internals_s390_gcc.h" | 157 #include "src/base/atomicops_internals_s390_gcc.h" |
162 #else | 158 #else |
163 #error "Atomic operations are not supported on your platform" | 159 #error "Atomic operations are not supported on your platform" |
164 #endif | 160 #endif |
165 | 161 |
166 // On some platforms we need additional declarations to make | 162 // On some platforms we need additional declarations to make |
167 // AtomicWord compatible with our other Atomic* types. | 163 // AtomicWord compatible with our other Atomic* types. |
168 #if defined(__APPLE__) || defined(__OpenBSD__) || defined(V8_OS_AIX) | 164 #if defined(__APPLE__) || defined(__OpenBSD__) || defined(V8_OS_AIX) |
169 #include "src/base/atomicops_internals_atomicword_compat.h" | 165 #include "src/base/atomicops_internals_atomicword_compat.h" |
170 #endif | 166 #endif |
171 | 167 |
172 #endif // V8_BASE_ATOMICOPS_H_ | 168 #endif // V8_BASE_ATOMICOPS_H_ |
OLD | NEW |