Loading mozglue/misc/Mutex_posix.cpp +10 −3 Original line number Original line Diff line number Diff line Loading @@ -5,6 +5,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "mozilla/Assertions.h" #include "mozilla/Assertions.h" #include "mozilla/Maybe.h" #include <algorithm> #include <algorithm> #include <errno.h> #include <errno.h> Loading Loading @@ -35,7 +36,8 @@ // CPU count. Read concurrently from multiple threads. Written once during the // CPU count. Read concurrently from multiple threads. Written once during the // first mutex initialization; re-initialization is safe hence relaxed ordering // first mutex initialization; re-initialization is safe hence relaxed ordering // is OK. // is OK. static mozilla::Atomic<uint32_t, mozilla::MemoryOrdering::Relaxed> sCPUCount(0); static mozilla::Atomic<uint32_t, mozilla::MemoryOrdering::Relaxed, mozilla::recordreplay::Behavior::DontPreserve> sCPUCount(0); static void static void EnsureCPUCount() EnsureCPUCount() Loading @@ -59,13 +61,18 @@ EnsureCPUCount() #endif // XP_DARWIN #endif // XP_DARWIN mozilla::detail::MutexImpl::MutexImpl() mozilla::detail::MutexImpl::MutexImpl(recordreplay::Behavior aRecorded) #ifdef XP_DARWIN #ifdef XP_DARWIN : averageSpins(0) : averageSpins(0) #endif #endif { { pthread_mutexattr_t* attrp = nullptr; pthread_mutexattr_t* attrp = nullptr; mozilla::Maybe<mozilla::recordreplay::AutoEnsurePassThroughThreadEvents> pt; if (aRecorded == recordreplay::Behavior::DontPreserve) { pt.emplace(); } // Linux with glibc and FreeBSD support adaptive mutexes that spin // Linux with glibc and FreeBSD support adaptive mutexes that spin // for a short number of tries before sleeping. NSPR's locks did // for a short number of tries before sleeping. NSPR's locks did // this, too, and it seems like a reasonable thing to do. // this, too, and it seems like a reasonable thing to do. Loading Loading @@ -149,7 +156,7 @@ mozilla::detail::MutexImpl::lock() // feature. // feature. MOZ_ASSERT(sCPUCount); MOZ_ASSERT(sCPUCount); if (sCPUCount == 1) { if (sCPUCount == 1 || recordreplay::IsRecordingOrReplaying()) { mutexLock(); mutexLock(); return; return; } } Loading mozglue/misc/Mutex_windows.cpp +1 −1 Original line number Original line Diff line number Diff line Loading @@ -12,7 +12,7 @@ #include "MutexPlatformData_windows.h" #include "MutexPlatformData_windows.h" mozilla::detail::MutexImpl::MutexImpl() mozilla::detail::MutexImpl::MutexImpl(recordreplay::Behavior aRecorded) { { InitializeSRWLock(&platformData()->lock); InitializeSRWLock(&platformData()->lock); } } Loading mozglue/misc/PlatformMutex.h +4 −2 Original line number Original line Diff line number Diff line Loading @@ -10,6 +10,7 @@ #include "mozilla/Atomics.h" #include "mozilla/Atomics.h" #include "mozilla/Attributes.h" #include "mozilla/Attributes.h" #include "mozilla/Move.h" #include "mozilla/Move.h" #include "mozilla/RecordReplay.h" #if !defined(XP_WIN) #if !defined(XP_WIN) # include <pthread.h> # include <pthread.h> Loading @@ -26,7 +27,7 @@ class MutexImpl public: public: struct PlatformData; struct PlatformData; MFBT_API MutexImpl(); explicit MFBT_API MutexImpl(recordreplay::Behavior aRecorded = recordreplay::Behavior::Preserve); MFBT_API ~MutexImpl(); MFBT_API ~MutexImpl(); protected: protected: Loading Loading @@ -56,7 +57,8 @@ private: // Moving average of the number of spins it takes to acquire the mutex if we // Moving average of the number of spins it takes to acquire the mutex if we // have to wait. May be accessed by multiple threads concurrently. Getting the // have to wait. May be accessed by multiple threads concurrently. Getting the // latest value is not essential hence relaxed memory ordering is sufficient. // latest value is not essential hence relaxed memory ordering is sufficient. mozilla::Atomic<int32_t, mozilla::MemoryOrdering::Relaxed> averageSpins; mozilla::Atomic<int32_t, mozilla::MemoryOrdering::Relaxed, recordreplay::Behavior::DontPreserve> averageSpins; #endif #endif #else #else void* platformData_[6]; void* platformData_[6]; Loading xpcom/threads/Monitor.h +3 −2 Original line number Original line Diff line number Diff line Loading @@ -24,8 +24,9 @@ namespace mozilla { class Monitor class Monitor { { public: public: explicit Monitor(const char* aName) explicit Monitor(const char* aName, : mMutex(aName) recordreplay::Behavior aRecorded = recordreplay::Behavior::Preserve) : mMutex(aName, aRecorded) , mCondVar(mMutex, "[Monitor.mCondVar]") , mCondVar(mMutex, "[Monitor.mCondVar]") { { } } Loading Loading
mozglue/misc/Mutex_posix.cpp +10 −3 Original line number Original line Diff line number Diff line Loading @@ -5,6 +5,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "mozilla/Assertions.h" #include "mozilla/Assertions.h" #include "mozilla/Maybe.h" #include <algorithm> #include <algorithm> #include <errno.h> #include <errno.h> Loading Loading @@ -35,7 +36,8 @@ // CPU count. Read concurrently from multiple threads. Written once during the // CPU count. Read concurrently from multiple threads. Written once during the // first mutex initialization; re-initialization is safe hence relaxed ordering // first mutex initialization; re-initialization is safe hence relaxed ordering // is OK. // is OK. static mozilla::Atomic<uint32_t, mozilla::MemoryOrdering::Relaxed> sCPUCount(0); static mozilla::Atomic<uint32_t, mozilla::MemoryOrdering::Relaxed, mozilla::recordreplay::Behavior::DontPreserve> sCPUCount(0); static void static void EnsureCPUCount() EnsureCPUCount() Loading @@ -59,13 +61,18 @@ EnsureCPUCount() #endif // XP_DARWIN #endif // XP_DARWIN mozilla::detail::MutexImpl::MutexImpl() mozilla::detail::MutexImpl::MutexImpl(recordreplay::Behavior aRecorded) #ifdef XP_DARWIN #ifdef XP_DARWIN : averageSpins(0) : averageSpins(0) #endif #endif { { pthread_mutexattr_t* attrp = nullptr; pthread_mutexattr_t* attrp = nullptr; mozilla::Maybe<mozilla::recordreplay::AutoEnsurePassThroughThreadEvents> pt; if (aRecorded == recordreplay::Behavior::DontPreserve) { pt.emplace(); } // Linux with glibc and FreeBSD support adaptive mutexes that spin // Linux with glibc and FreeBSD support adaptive mutexes that spin // for a short number of tries before sleeping. NSPR's locks did // for a short number of tries before sleeping. NSPR's locks did // this, too, and it seems like a reasonable thing to do. // this, too, and it seems like a reasonable thing to do. Loading Loading @@ -149,7 +156,7 @@ mozilla::detail::MutexImpl::lock() // feature. // feature. MOZ_ASSERT(sCPUCount); MOZ_ASSERT(sCPUCount); if (sCPUCount == 1) { if (sCPUCount == 1 || recordreplay::IsRecordingOrReplaying()) { mutexLock(); mutexLock(); return; return; } } Loading
mozglue/misc/Mutex_windows.cpp +1 −1 Original line number Original line Diff line number Diff line Loading @@ -12,7 +12,7 @@ #include "MutexPlatformData_windows.h" #include "MutexPlatformData_windows.h" mozilla::detail::MutexImpl::MutexImpl() mozilla::detail::MutexImpl::MutexImpl(recordreplay::Behavior aRecorded) { { InitializeSRWLock(&platformData()->lock); InitializeSRWLock(&platformData()->lock); } } Loading
mozglue/misc/PlatformMutex.h +4 −2 Original line number Original line Diff line number Diff line Loading @@ -10,6 +10,7 @@ #include "mozilla/Atomics.h" #include "mozilla/Atomics.h" #include "mozilla/Attributes.h" #include "mozilla/Attributes.h" #include "mozilla/Move.h" #include "mozilla/Move.h" #include "mozilla/RecordReplay.h" #if !defined(XP_WIN) #if !defined(XP_WIN) # include <pthread.h> # include <pthread.h> Loading @@ -26,7 +27,7 @@ class MutexImpl public: public: struct PlatformData; struct PlatformData; MFBT_API MutexImpl(); explicit MFBT_API MutexImpl(recordreplay::Behavior aRecorded = recordreplay::Behavior::Preserve); MFBT_API ~MutexImpl(); MFBT_API ~MutexImpl(); protected: protected: Loading Loading @@ -56,7 +57,8 @@ private: // Moving average of the number of spins it takes to acquire the mutex if we // Moving average of the number of spins it takes to acquire the mutex if we // have to wait. May be accessed by multiple threads concurrently. Getting the // have to wait. May be accessed by multiple threads concurrently. Getting the // latest value is not essential hence relaxed memory ordering is sufficient. // latest value is not essential hence relaxed memory ordering is sufficient. mozilla::Atomic<int32_t, mozilla::MemoryOrdering::Relaxed> averageSpins; mozilla::Atomic<int32_t, mozilla::MemoryOrdering::Relaxed, recordreplay::Behavior::DontPreserve> averageSpins; #endif #endif #else #else void* platformData_[6]; void* platformData_[6]; Loading
xpcom/threads/Monitor.h +3 −2 Original line number Original line Diff line number Diff line Loading @@ -24,8 +24,9 @@ namespace mozilla { class Monitor class Monitor { { public: public: explicit Monitor(const char* aName) explicit Monitor(const char* aName, : mMutex(aName) recordreplay::Behavior aRecorded = recordreplay::Behavior::Preserve) : mMutex(aName, aRecorded) , mCondVar(mMutex, "[Monitor.mCondVar]") , mCondVar(mMutex, "[Monitor.mCondVar]") { { } } Loading