| Index: Source/wtf/Atomics.h
|
| diff --git a/Source/wtf/Atomics.h b/Source/wtf/Atomics.h
|
| index aaad9c9e90cbe954fd9d30ec7a89488822201298..df9e9750eb5d42035c2ef484a573c6774221195a 100644
|
| --- a/Source/wtf/Atomics.h
|
| +++ b/Source/wtf/Atomics.h
|
| @@ -43,6 +43,10 @@
|
| #include <sanitizer/tsan_interface_atomic.h>
|
| #endif
|
|
|
| +#if defined(ADDRESS_SANITIZER)
|
| +#include <sanitizer/asan_interface.h>
|
| +#endif
|
| +
|
| namespace WTF {
|
|
|
| #if COMPILER(MSVC)
|
| @@ -106,6 +110,7 @@ ALWAYS_INLINE void atomicSetOneToZero(int volatile* ptr)
|
| #endif
|
|
|
| #if defined(THREAD_SANITIZER)
|
| +
|
| ALWAYS_INLINE void releaseStore(volatile int* ptr, int value)
|
| {
|
| __tsan_atomic32_store(ptr, value, __tsan_memory_order_release);
|
| @@ -125,6 +130,7 @@ ALWAYS_INLINE unsigned acquireLoad(volatile const unsigned* ptr)
|
| {
|
| return static_cast<unsigned>(__tsan_atomic32_load(reinterpret_cast<volatile const int*>(ptr), __tsan_memory_order_acquire));
|
| }
|
| +
|
| #else
|
|
|
| #if CPU(X86) || CPU(X86_64)
|
| @@ -179,10 +185,41 @@ ALWAYS_INLINE unsigned acquireLoad(volatile const unsigned* ptr)
|
| return value;
|
| }
|
|
|
| +#if defined(ADDRESS_SANITIZER)
|
| +
|
| +__attribute__((no_sanitize_address)) ALWAYS_INLINE void asanUnsafeReleaseStore(volatile unsigned* ptr, unsigned value)
|
| +{
|
| + MEMORY_BARRIER();
|
| + *ptr = value;
|
| +}
|
| +
|
| +__attribute__((no_sanitize_address)) ALWAYS_INLINE unsigned asanUnsafeAcquireLoad(volatile const unsigned* ptr)
|
| +{
|
| + unsigned value = *ptr;
|
| + MEMORY_BARRIER();
|
| + return value;
|
| +}
|
| +
|
| +#endif // defined(ADDRESS_SANITIZER)
|
| +
|
| #undef MEMORY_BARRIER
|
|
|
| #endif
|
|
|
| +#if !defined(ADDRESS_SANITIZER)
|
| +
|
| +ALWAYS_INLINE void asanUnsafeReleaseStore(volatile unsigned* ptr, unsigned value)
|
| +{
|
| + releaseStore(ptr, value);
|
| +}
|
| +
|
| +ALWAYS_INLINE unsigned asanUnsafeAcquireLoad(volatile const unsigned* ptr)
|
| +{
|
| + return acquireLoad(ptr);
|
| +}
|
| +
|
| +#endif
|
| +
|
| } // namespace WTF
|
|
|
| using WTF::atomicAdd;
|
| @@ -194,4 +231,10 @@ using WTF::atomicSetOneToZero;
|
| using WTF::acquireLoad;
|
| using WTF::releaseStore;
|
|
|
| +// These methods allow loading from and storing to poisoned memory. Only
|
| +// use these methods if you know what you are doing since they will
|
| +// silence use-after-poison errors from ASan.
|
| +using WTF::asanUnsafeAcquireLoad;
|
| +using WTF::asanUnsafeReleaseStore;
|
| +
|
| #endif // Atomics_h
|
|
|