Chromium Code Reviews| Index: Source/wtf/Atomics.h |
| diff --git a/Source/wtf/Atomics.h b/Source/wtf/Atomics.h |
| index aaad9c9e90cbe954fd9d30ec7a89488822201298..2de5c628b976007e79c84d43746d3087aa320b84 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) |
| + |
|
Alexander Potapenko
2014/09/09 09:57:30
Did you mean adding these blank lines? (Here and b
Mads Ager (chromium)
2014/09/09 10:02:40
Yeah, I did to make the formatting a bit more unif
|
| 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 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 // defined(ADDRESS_SANITIZER) |
| + |
| #undef MEMORY_BARRIER |
| #endif |
| +#if !defined(ADDRESS_SANITIZER) |
| + |
| +ALWAYS_INLINE void asanReleaseStore(volatile unsigned* ptr, unsigned value) |
| +{ |
| + releaseStore(ptr, value); |
| +} |
| + |
| +ALWAYS_INLINE unsigned asanAcquireLoad(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::asanAcquireLoad; |
|
Alexander Potapenko
2014/09/09 09:57:30
How about 'asanUnsafe{AcquireLoad,ReleaseStore}'?
Mads Ager (chromium)
2014/09/09 10:02:40
Good idea, will do. I like the addition of unsafe
|
| +using WTF::asanReleaseStore; |
| + |
| #endif // Atomics_h |