Bug 1600312 - Use atomic load instead of fence for RefCounted with TSan. r=froydnj

Differential Revision: https://phabricator.services.mozilla.com/D55948

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Christian Holler 2019-12-09 14:00:22 +00:00
parent 85117004f2
commit 1636d4ab1f

View File

@ -131,7 +131,14 @@ class RC<T, AtomicRefCount, Recording> {
// acquire semantics to synchronize with the memory released by
// the last release on other threads, that is, to ensure that
// writes prior to that release are now visible on this thread.
#ifdef MOZ_TSAN
// TSan doesn't understand std::atomic_thread_fence, so in order
// to avoid a false positive for every time a refcounted object
// is deleted, we replace the fence with an atomic operation.
mValue.load(std::memory_order_acquire);
#else
std::atomic_thread_fence(std::memory_order_acquire);
#endif
}
return result;
}