| 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 // 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_X86_GCC_H_ | 7 #ifndef V8_BASE_ATOMICOPS_INTERNALS_X86_GCC_H_ |
| 8 #define V8_BASE_ATOMICOPS_INTERNALS_X86_GCC_H_ | 8 #define V8_BASE_ATOMICOPS_INTERNALS_X86_GCC_H_ |
| 9 | 9 |
| 10 namespace v8 { | 10 namespace v8 { |
| 11 namespace base { | 11 namespace base { |
| 12 | 12 |
| 13 // This struct is not part of the public API of this module; clients may not | 13 // This struct is not part of the public API of this module; clients may not |
| 14 // use it. | 14 // use it. |
| 15 // Features of this x86. Values may not be correct before main() is run, | 15 // Features of this x86. Values may not be correct before main() is run, |
| 16 // but are set conservatively. | 16 // but are set conservatively. |
| 17 struct AtomicOps_x86CPUFeatureStruct { | 17 struct AtomicOps_x86CPUFeatureStruct { |
| 18 bool has_amd_lock_mb_bug; // Processor has AMD memory-barrier bug; do lfence | 18 bool has_amd_lock_mb_bug; // Processor has AMD memory-barrier bug; do lfence |
| 19 // after acquire compare-and-swap. | 19 // after acquire compare-and-swap. |
| 20 #if !defined(__SSE2__) |
| 20 bool has_sse2; // Processor has SSE2. | 21 bool has_sse2; // Processor has SSE2. |
| 22 #endif |
| 21 }; | 23 }; |
| 22 extern struct AtomicOps_x86CPUFeatureStruct AtomicOps_Internalx86CPUFeatures; | 24 extern struct AtomicOps_x86CPUFeatureStruct AtomicOps_Internalx86CPUFeatures; |
| 23 | 25 |
| 24 #define ATOMICOPS_COMPILER_BARRIER() __asm__ __volatile__("" : : : "memory") | 26 #define ATOMICOPS_COMPILER_BARRIER() __asm__ __volatile__("" : : : "memory") |
| 25 | 27 |
| 26 // 32-bit low-level operations on any platform. | 28 // 32-bit low-level operations on any platform. |
| 27 | 29 |
| 28 inline Atomic32 NoBarrier_CompareAndSwap(volatile Atomic32* ptr, | 30 inline Atomic32 NoBarrier_CompareAndSwap(volatile Atomic32* ptr, |
| 29 Atomic32 old_value, | 31 Atomic32 old_value, |
| 30 Atomic32 new_value) { | 32 Atomic32 new_value) { |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 } | 87 } |
| 86 | 88 |
| 87 inline void NoBarrier_Store(volatile Atomic8* ptr, Atomic8 value) { | 89 inline void NoBarrier_Store(volatile Atomic8* ptr, Atomic8 value) { |
| 88 *ptr = value; | 90 *ptr = value; |
| 89 } | 91 } |
| 90 | 92 |
| 91 inline void NoBarrier_Store(volatile Atomic32* ptr, Atomic32 value) { | 93 inline void NoBarrier_Store(volatile Atomic32* ptr, Atomic32 value) { |
| 92 *ptr = value; | 94 *ptr = value; |
| 93 } | 95 } |
| 94 | 96 |
| 95 #if defined(__x86_64__) | 97 #if defined(__x86_64__) || defined(__SSE2__) |
| 96 | 98 |
| 97 // 64-bit implementations of memory barrier can be simpler, because it | 99 // 64-bit implementations of memory barrier can be simpler, because it |
| 98 // "mfence" is guaranteed to exist. | 100 // "mfence" is guaranteed to exist. |
| 99 inline void MemoryBarrier() { | 101 inline void MemoryBarrier() { |
| 100 __asm__ __volatile__("mfence" : : : "memory"); | 102 __asm__ __volatile__("mfence" : : : "memory"); |
| 101 } | 103 } |
| 102 | 104 |
| 103 inline void Acquire_Store(volatile Atomic32* ptr, Atomic32 value) { | 105 inline void Acquire_Store(volatile Atomic32* ptr, Atomic32 value) { |
| 104 *ptr = value; | 106 *ptr = value; |
| 105 MemoryBarrier(); | 107 MemoryBarrier(); |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 263 return NoBarrier_CompareAndSwap(ptr, old_value, new_value); | 265 return NoBarrier_CompareAndSwap(ptr, old_value, new_value); |
| 264 } | 266 } |
| 265 | 267 |
| 266 #endif // defined(__x86_64__) | 268 #endif // defined(__x86_64__) |
| 267 | 269 |
| 268 } } // namespace v8::base | 270 } } // namespace v8::base |
| 269 | 271 |
| 270 #undef ATOMICOPS_COMPILER_BARRIER | 272 #undef ATOMICOPS_COMPILER_BARRIER |
| 271 | 273 |
| 272 #endif // V8_BASE_ATOMICOPS_INTERNALS_X86_GCC_H_ | 274 #endif // V8_BASE_ATOMICOPS_INTERNALS_X86_GCC_H_ |
| OLD | NEW |