diff --git a/memory/build/Mutex.h b/memory/build/Mutex.h index 9d5116190100..67fd1cc107f6 100644 --- a/memory/build/Mutex.h +++ b/memory/build/Mutex.h @@ -15,13 +15,12 @@ # include #endif #include "mozilla/Attributes.h" -#include "mozilla/ThreadSafety.h" // Mutexes based on spinlocks. We can't use normal pthread spinlocks in all // places, because they require malloc()ed memory, which causes bootstrapping // issues in some cases. We also can't use constructors, because for statics, // they would fire after the first use of malloc, resetting the locks. -struct CAPABILITY Mutex { +struct Mutex { #if defined(XP_WIN) CRITICAL_SECTION mMutex; #elif defined(XP_DARWIN) @@ -57,7 +56,7 @@ struct CAPABILITY Mutex { return true; } - inline void Lock() CAPABILITY_ACQUIRE() { + inline void Lock() { #if defined(XP_WIN) EnterCriticalSection(&mMutex); #elif defined(XP_DARWIN) @@ -67,7 +66,7 @@ struct CAPABILITY Mutex { #endif } - inline void Unlock() CAPABILITY_RELEASE() { + inline void Unlock() { #if defined(XP_WIN) LeaveCriticalSection(&mMutex); #elif defined(XP_DARWIN) @@ -86,14 +85,12 @@ struct CAPABILITY Mutex { // Ideally, we'd use the same type of locks everywhere, but SRWLocks // everywhere incur a performance penalty. See bug 1418389. #if defined(XP_WIN) -struct CAPABILITY StaticMutex { +struct StaticMutex { SRWLOCK mMutex; - inline void Lock() CAPABILITY_ACQUIRE() { AcquireSRWLockExclusive(&mMutex); } + inline void Lock() { AcquireSRWLockExclusive(&mMutex); } - inline void Unlock() CAPABILITY_RELEASE() { - ReleaseSRWLockExclusive(&mMutex); - } + inline void Unlock() { ReleaseSRWLockExclusive(&mMutex); } }; // Normally, we'd use a constexpr constructor, but MSVC likes to create @@ -114,15 +111,10 @@ typedef Mutex StaticMutex; #endif template -struct SCOPED_CAPABILITY MOZ_RAII AutoLock { - explicit AutoLock(T& aMutex) CAPABILITY_ACQUIRE(aMutex) : mMutex(aMutex) { - mMutex.Lock(); - } +struct MOZ_RAII AutoLock { + explicit AutoLock(T& aMutex) : mMutex(aMutex) { mMutex.Lock(); } - ~AutoLock() CAPABILITY_RELEASE() { mMutex.Unlock(); } - - AutoLock(const AutoLock&) = delete; - AutoLock(AutoLock&&) = delete; + ~AutoLock() { mMutex.Unlock(); } private: T& mMutex; diff --git a/memory/replace/phc/PHC.cpp b/memory/replace/phc/PHC.cpp index ecbe11b18ede..2ed103770c03 100644 --- a/memory/replace/phc/PHC.cpp +++ b/memory/replace/phc/PHC.cpp @@ -793,16 +793,14 @@ class GMut { MOZ_RELEASE_ASSERT(page.mBaseAddr == aPtr); if (page.mState == AllocPageState::Freed) { - LOG("EnsureValidAndInUse(%p), use-after-free\n", aPtr); // An operation on a freed page? This is a particular kind of // use-after-free. Deliberately touch the page in question, in order to // cause a crash that triggers the usual PHC machinery. But unlock sMutex // first, because that self-same PHC machinery needs to re-lock it, and // the crash causes non-local control flow so sMutex won't be unlocked // the normal way in the caller. - PUSH_IGNORE_THREAD_SAFETY + LOG("EnsureValidAndInUse(%p), use-after-free\n", aPtr); sMutex.Unlock(); - POP_THREAD_SAFETY *static_cast(aPtr) = 0; MOZ_CRASH("unreachable"); } @@ -879,8 +877,8 @@ class GMut { *aInfo = {TagUnknown, nullptr, 0, 0}; } - static void prefork() CAPABILITY_ACQUIRE(sMutex) { sMutex.Lock(); } - static void postfork_parent() CAPABILITY_RELEASE(sMutex) { sMutex.Unlock(); } + static void prefork() { sMutex.Lock(); } + static void postfork_parent() { sMutex.Unlock(); } static void postfork_child() { sMutex.Init(); } void IncPageAllocHits(GMutLock) { mPageAllocHits++; }