| OLD | NEW |
| 1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 27 | 27 |
| 28 // This file is an internal atomic implementation, use atomicops.h instead. | 28 // This file is an internal atomic implementation, use atomicops.h instead. |
| 29 | 29 |
| 30 #ifndef V8_ATOMICOPS_INTERNALS_X86_GCC_H_ | 30 #ifndef V8_ATOMICOPS_INTERNALS_X86_GCC_H_ |
| 31 #define V8_ATOMICOPS_INTERNALS_X86_GCC_H_ | 31 #define V8_ATOMICOPS_INTERNALS_X86_GCC_H_ |
| 32 | 32 |
| 33 namespace v8 { |
| 34 namespace internal { |
| 35 |
| 33 // This struct is not part of the public API of this module; clients may not | 36 // This struct is not part of the public API of this module; clients may not |
| 34 // use it. | 37 // use it. |
| 35 // Features of this x86. Values may not be correct before main() is run, | 38 // Features of this x86. Values may not be correct before main() is run, |
| 36 // but are set conservatively. | 39 // but are set conservatively. |
| 37 struct AtomicOps_x86CPUFeatureStruct { | 40 struct AtomicOps_x86CPUFeatureStruct { |
| 38 bool has_amd_lock_mb_bug; // Processor has AMD memory-barrier bug; do lfence | 41 bool has_amd_lock_mb_bug; // Processor has AMD memory-barrier bug; do lfence |
| 39 // after acquire compare-and-swap. | 42 // after acquire compare-and-swap. |
| 40 bool has_sse2; // Processor has SSE2. | 43 bool has_sse2; // Processor has SSE2. |
| 41 }; | 44 }; |
| 42 extern struct AtomicOps_x86CPUFeatureStruct AtomicOps_Internalx86CPUFeatures; | 45 extern struct AtomicOps_x86CPUFeatureStruct AtomicOps_Internalx86CPUFeatures; |
| 43 | 46 |
| 44 #define ATOMICOPS_COMPILER_BARRIER() __asm__ __volatile__("" : : : "memory") | 47 #define ATOMICOPS_COMPILER_BARRIER() __asm__ __volatile__("" : : : "memory") |
| 45 | 48 |
| 46 namespace v8 { | |
| 47 namespace internal { | |
| 48 | |
| 49 // 32-bit low-level operations on any platform. | 49 // 32-bit low-level operations on any platform. |
| 50 | 50 |
| 51 inline Atomic32 NoBarrier_CompareAndSwap(volatile Atomic32* ptr, | 51 inline Atomic32 NoBarrier_CompareAndSwap(volatile Atomic32* ptr, |
| 52 Atomic32 old_value, | 52 Atomic32 old_value, |
| 53 Atomic32 new_value) { | 53 Atomic32 new_value) { |
| 54 Atomic32 prev; | 54 Atomic32 prev; |
| 55 __asm__ __volatile__("lock; cmpxchgl %1,%2" | 55 __asm__ __volatile__("lock; cmpxchgl %1,%2" |
| 56 : "=a" (prev) | 56 : "=a" (prev) |
| 57 : "q" (new_value), "m" (*ptr), "0" (old_value) | 57 : "q" (new_value), "m" (*ptr), "0" (old_value) |
| 58 : "memory"); | 58 : "memory"); |
| (...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 278 return NoBarrier_CompareAndSwap(ptr, old_value, new_value); | 278 return NoBarrier_CompareAndSwap(ptr, old_value, new_value); |
| 279 } | 279 } |
| 280 | 280 |
| 281 #endif // defined(__x86_64__) | 281 #endif // defined(__x86_64__) |
| 282 | 282 |
| 283 } } // namespace v8::internal | 283 } } // namespace v8::internal |
| 284 | 284 |
| 285 #undef ATOMICOPS_COMPILER_BARRIER | 285 #undef ATOMICOPS_COMPILER_BARRIER |
| 286 | 286 |
| 287 #endif // V8_ATOMICOPS_INTERNALS_X86_GCC_H_ | 287 #endif // V8_ATOMICOPS_INTERNALS_X86_GCC_H_ |
| OLD | NEW |