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 | 5 |
6 // This file is an internal atomic implementation for compiler-based | 6 // This file is an internal atomic implementation for compiler-based |
7 // ThreadSanitizer. Use base/atomicops.h instead. | 7 // ThreadSanitizer. Use base/atomicops.h instead. |
8 | 8 |
9 #ifndef V8_BASE_ATOMICOPS_INTERNALS_TSAN_H_ | 9 #ifndef V8_BASE_ATOMICOPS_INTERNALS_TSAN_H_ |
10 #define V8_BASE_ATOMICOPS_INTERNALS_TSAN_H_ | 10 #define V8_BASE_ATOMICOPS_INTERNALS_TSAN_H_ |
11 | 11 |
12 namespace v8 { | 12 namespace v8 { |
13 namespace base { | 13 namespace base { |
14 | 14 |
15 #ifndef TSAN_INTERFACE_ATOMIC_H | 15 #ifndef TSAN_INTERFACE_ATOMIC_H |
16 #define TSAN_INTERFACE_ATOMIC_H | 16 #define TSAN_INTERFACE_ATOMIC_H |
17 | 17 |
18 // This struct is not part of the public API of this module; clients may not | |
19 // use it. (However, it's exported via BASE_EXPORT because clients implicitly | |
20 // do use it at link time by inlining these functions.) | |
21 // Features of this x86. Values may not be correct before main() is run, | |
22 // but are set conservatively. | |
23 struct AtomicOps_x86CPUFeatureStruct { | |
24 bool has_amd_lock_mb_bug; // Processor has AMD memory-barrier bug; do lfence | |
25 // after acquire compare-and-swap. | |
26 bool has_sse2; // Processor has SSE2. | |
27 }; | |
28 extern struct AtomicOps_x86CPUFeatureStruct | |
29 AtomicOps_Internalx86CPUFeatures; | |
30 | |
31 #define ATOMICOPS_COMPILER_BARRIER() __asm__ __volatile__("" : : : "memory") | |
32 | 18 |
33 extern "C" { | 19 extern "C" { |
34 typedef char __tsan_atomic8; | 20 typedef char __tsan_atomic8; |
35 typedef short __tsan_atomic16; // NOLINT | 21 typedef short __tsan_atomic16; // NOLINT |
36 typedef int __tsan_atomic32; | 22 typedef int __tsan_atomic32; |
37 typedef long __tsan_atomic64; // NOLINT | 23 typedef long __tsan_atomic64; // NOLINT |
38 | 24 |
39 #if defined(__SIZEOF_INT128__) \ | 25 #if defined(__SIZEOF_INT128__) \ |
40 || (__clang_major__ * 100 + __clang_minor__ >= 302) | 26 || (__clang_major__ * 100 + __clang_minor__ >= 302) |
41 typedef __int128 __tsan_atomic128; | 27 typedef __int128 __tsan_atomic128; |
(...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
367 return cmp; | 353 return cmp; |
368 } | 354 } |
369 | 355 |
370 inline void MemoryBarrier() { | 356 inline void MemoryBarrier() { |
371 __tsan_atomic_thread_fence(__tsan_memory_order_seq_cst); | 357 __tsan_atomic_thread_fence(__tsan_memory_order_seq_cst); |
372 } | 358 } |
373 | 359 |
374 } // namespace base | 360 } // namespace base |
375 } // namespace v8 | 361 } // namespace v8 |
376 | 362 |
377 #undef ATOMICOPS_COMPILER_BARRIER | |
378 | |
379 #endif // V8_BASE_ATOMICOPS_INTERNALS_TSAN_H_ | 363 #endif // V8_BASE_ATOMICOPS_INTERNALS_TSAN_H_ |
OLD | NEW |