Chromium Code Reviews| Index: Source/wtf/Atomics.h |
| diff --git a/Source/wtf/Atomics.h b/Source/wtf/Atomics.h |
| index aaad9c9e90cbe954fd9d30ec7a89488822201298..6c4b00e529b08dcf8eb175177b56e329ac1d23fd 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) |
| @@ -125,6 +129,21 @@ 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)); |
| } |
| + |
| +#if defined(ADDRESS_SANITIZER) |
| + |
| +__attribute__((no_sanitize_address)) ALWAYS_INLINE void asanReleaseStore(volatile unsigned* ptr, unsigned value) |
| +{ |
| + __tsan_atomic32_store(reinterpret_cast<volatile int*>(ptr), static_cast<int>(value), __tsan_memory_order_release); |
| +} |
| + |
| +__attribute__((no_sanitize_address)) ALWAYS_INLINE unsigned asanAcquireLoad(volatile const unsigned* ptr) |
| +{ |
| + return static_cast<unsigned>(__tsan_atomic32_load(reinterpret_cast<volatile const int*>(ptr), __tsan_memory_order_acquire)); |
| +} |
| + |
| +#endif // defined(ADDRESS_SANITIZER) |
| + |
| #else |
| #if CPU(X86) || CPU(X86_64) |
| @@ -179,6 +198,23 @@ ALWAYS_INLINE unsigned acquireLoad(volatile const unsigned* ptr) |
| return value; |
| } |
| +#if defined(ADDRESS_SANITIZER) |
| + |
| +__attribute__((no_sanitize_address)) ALWAYS_INLINE void asanReleaseStore(volatile unsigned* ptr, unsigned value) |
| +{ |
| + MEMORY_BARRIER(); |
| + *ptr = value; |
| +} |
| + |
| +__attribute__((no_sanitize_address)) ALWAYS_INLINE unsigned asanAcquireLoad(volatile const unsigned* ptr) |
| +{ |
| + unsigned value = *ptr; |
| + MEMORY_BARRIER(); |
| + return value; |
| +} |
| + |
| +#endif |
| + |
| #undef MEMORY_BARRIER |
|
zerny-chromium
2014/09/09 06:01:28
Could we add:
#if !defined(ADDRESS_SANITIZER)
ALW
Mads Ager (chromium)
2014/09/09 08:22:14
Done.
|
| #endif |
| @@ -194,4 +230,12 @@ using WTF::atomicSetOneToZero; |
| using WTF::acquireLoad; |
| using WTF::releaseStore; |
| +#if defined(ADDRESS_SANITIZER) |
|
zerny-chromium
2014/09/09 06:01:29
and then remove the #if here too.
Mads Ager (chromium)
2014/09/09 08:22:15
Done.
|
| +// 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::asanAcquireLoad; |
| +using WTF::asanReleaseStore; |
| +#endif |
| + |
| #endif // Atomics_h |