diff --git a/docshell/base/timeline/ObservedDocShell.h b/docshell/base/timeline/ObservedDocShell.h index 9d0c39fcb20e..a58a98dd7ce9 100644 --- a/docshell/base/timeline/ObservedDocShell.h +++ b/docshell/base/timeline/ObservedDocShell.h @@ -37,7 +37,7 @@ class ObservedDocShell : public MarkersStorage { // Off the main thread only. Mutex mLock; nsTArray> mOffTheMainThreadTimelineMarkers - MOZ_GUARDED_BY(mLock); + GUARDED_BY(mLock); public: explicit ObservedDocShell(nsIDocShell* aDocShell); diff --git a/docshell/base/timeline/TimelineConsumers.h b/docshell/base/timeline/TimelineConsumers.h index a199560d8c30..ee67e233f8ac 100644 --- a/docshell/base/timeline/TimelineConsumers.h +++ b/docshell/base/timeline/TimelineConsumers.h @@ -101,11 +101,11 @@ class TimelineConsumers { private: static StaticMutex sMutex; - static LinkedList& MarkersStores() MOZ_REQUIRES(sMutex); + static LinkedList& MarkersStores() REQUIRES(sMutex); - static uint32_t sActiveConsumers MOZ_GUARDED_BY(sMutex); + static uint32_t sActiveConsumers GUARDED_BY(sMutex); static StaticAutoPtr> sMarkersStores - MOZ_GUARDED_BY(sMutex); + GUARDED_BY(sMutex); }; } // namespace mozilla diff --git a/dom/base/BodyStream.cpp b/dom/base/BodyStream.cpp index a3538bc27366..04413f984fc6 100644 --- a/dom/base/BodyStream.cpp +++ b/dom/base/BodyStream.cpp @@ -428,7 +428,7 @@ void BodyStream::EnqueueChunkWithSizeIntoStream(JSContext* aCx, // thread-safety doesn't handle emplace well NS_IMETHODIMP BodyStream::OnInputStreamReady(nsIAsyncInputStream* aStream) - MOZ_NO_THREAD_SAFETY_ANALYSIS { + NO_THREAD_SAFETY_ANALYSIS { AssertIsOnOwningThread(); MOZ_DIAGNOSTIC_ASSERT(aStream); mAsyncWaitWorkerRef = nullptr; diff --git a/dom/base/BodyStream.h b/dom/base/BodyStream.h index 6038eb9d0dad..152774088e23 100644 --- a/dom/base/BodyStream.h +++ b/dom/base/BodyStream.h @@ -141,18 +141,17 @@ class BodyStream final : public nsIInputStreamCallback, void ErrorPropagation(JSContext* aCx, const MutexSingleWriterAutoLock& aProofOfLock, - ReadableStream* aStream, nsresult aRv) - MOZ_REQUIRES(mMutex); + ReadableStream* aStream, nsresult aRv) REQUIRES(mMutex); // TODO: convert this to MOZ_CAN_RUN_SCRIPT (bug 1750605) MOZ_CAN_RUN_SCRIPT_BOUNDARY void CloseAndReleaseObjects( JSContext* aCx, const MutexSingleWriterAutoLock& aProofOfLock, - ReadableStream* aStream) MOZ_REQUIRES(mMutex); + ReadableStream* aStream) REQUIRES(mMutex); class WorkerShutdown; void ReleaseObjects(const MutexSingleWriterAutoLock& aProofOfLock) - MOZ_REQUIRES(mMutex); + REQUIRES(mMutex); void ReleaseObjects(); @@ -187,12 +186,12 @@ class BodyStream final : public nsIInputStreamCallback, MutexSingleWriter mMutex; // Protected by mutex. - State mState MOZ_GUARDED_BY(mMutex); // all writes are from the owning thread + State mState GUARDED_BY(mMutex); // all writes are from the owning thread // mGlobal is set on creation, and isn't modified off the owning thread. // It isn't set to nullptr until ReleaseObjects() runs. nsCOMPtr mGlobal; - RefPtr mStreamHolder MOZ_GUARDED_BY(mMutex); + RefPtr mStreamHolder GUARDED_BY(mMutex); nsCOMPtr mOwningEventTarget; // This is the original inputStream received during the CTOR. It will be diff --git a/dom/canvas/WebGLContext.h b/dom/canvas/WebGLContext.h index 31f672fa052f..011130010d3a 100644 --- a/dom/canvas/WebGLContext.h +++ b/dom/canvas/WebGLContext.h @@ -272,7 +272,7 @@ class WebGLContext : public VRefCounted, public SupportsWeakPtr { ~LruPosition() { Reset(); } }; - mutable LruPosition mLruPosition MOZ_GUARDED_BY(sLruMutex); + mutable LruPosition mLruPosition GUARDED_BY(sLruMutex); void BumpLruLocked(const StaticMutexAutoLock& aProofOfLock); @@ -740,7 +740,7 @@ class WebGLContext : public VRefCounted, public SupportsWeakPtr { private: static StaticMutex sLruMutex; - static std::list sLru MOZ_GUARDED_BY(sLruMutex); + static std::list sLru GUARDED_BY(sLruMutex); // State tracking slots bool mDitherEnabled = true; diff --git a/dom/console/ConsoleReportCollector.h b/dom/console/ConsoleReportCollector.h index 9d4e0b1aa01c..c87430341a45 100644 --- a/dom/console/ConsoleReportCollector.h +++ b/dom/console/ConsoleReportCollector.h @@ -81,7 +81,7 @@ class ConsoleReportCollector final : public nsIConsoleReportCollector { Mutex mMutex; // protected by mMutex - nsTArray mPendingReports MOZ_GUARDED_BY(mMutex); + nsTArray mPendingReports GUARDED_BY(mMutex); public: NS_DECL_THREADSAFE_ISUPPORTS diff --git a/dom/file/ipc/RemoteLazyInputStream.h b/dom/file/ipc/RemoteLazyInputStream.h index 08bb168e2757..32fad68af03a 100644 --- a/dom/file/ipc/RemoteLazyInputStream.h +++ b/dom/file/ipc/RemoteLazyInputStream.h @@ -66,12 +66,12 @@ class RemoteLazyInputStream final : public nsIAsyncInputStream, ~RemoteLazyInputStream(); - void StreamNeeded() MOZ_REQUIRES(mMutex); + void StreamNeeded() REQUIRES(mMutex); // Upon receiving the stream from our actor, we will not wrap it into an async // stream until needed. This allows callers to get access to the underlying // potentially-sync stream using `TakeInternalStream` before reading. - nsresult EnsureAsyncRemoteStream() MOZ_REQUIRES(mMutex); + nsresult EnsureAsyncRemoteStream() REQUIRES(mMutex); // Note that data has been read from our input stream, and disconnect from our // remote actor. @@ -82,7 +82,7 @@ class RemoteLazyInputStream final : public nsIAsyncInputStream, IPC::MessageReader* aReader); // Helper method to generate a description of a stream for use in loggging. - nsCString Describe() MOZ_REQUIRES(mMutex); + nsCString Describe() REQUIRES(mMutex); // Start and length of the slice to apply on this RemoteLazyInputStream when // fetching the underlying stream with `SendStreamNeeded`. @@ -112,7 +112,7 @@ class RemoteLazyInputStream final : public nsIAsyncInputStream, // mInnerStream is released and any method will return // NS_BASE_STREAM_CLOSED. eClosed, - } mState MOZ_GUARDED_BY(mMutex) = eClosed; + } mState GUARDED_BY(mMutex) = eClosed; // The actor which will be used to provide the underlying stream or length // information when needed, as well as to efficiently allow transferring the @@ -121,25 +121,22 @@ class RemoteLazyInputStream final : public nsIAsyncInputStream, // The connection to our actor will be cleared once the stream has been closed // or has started reading, at which point this stream will be serialized and // cloned as-if it was the underlying stream. - RefPtr mActor MOZ_GUARDED_BY(mMutex); + RefPtr mActor GUARDED_BY(mMutex); - nsCOMPtr mInnerStream MOZ_GUARDED_BY(mMutex); - nsCOMPtr mAsyncInnerStream MOZ_GUARDED_BY(mMutex); + nsCOMPtr mInnerStream GUARDED_BY(mMutex); + nsCOMPtr mAsyncInnerStream GUARDED_BY(mMutex); // These 2 values are set only if mState is ePending or eRunning. // RefPtr is used instead of nsCOMPtr to avoid invoking QueryInterface when // assigning in debug builds, as `mInputStreamCallback` may not be threadsafe. - RefPtr mInputStreamCallback MOZ_GUARDED_BY(mMutex); - nsCOMPtr mInputStreamCallbackEventTarget - MOZ_GUARDED_BY(mMutex); - uint32_t mInputStreamCallbackFlags MOZ_GUARDED_BY(mMutex) = 0; - uint32_t mInputStreamCallbackRequestedCount MOZ_GUARDED_BY(mMutex) = 0; + RefPtr mInputStreamCallback GUARDED_BY(mMutex); + nsCOMPtr mInputStreamCallbackEventTarget GUARDED_BY(mMutex); + uint32_t mInputStreamCallbackFlags GUARDED_BY(mMutex) = 0; + uint32_t mInputStreamCallbackRequestedCount GUARDED_BY(mMutex) = 0; // These 2 values are set only if mState is ePending. - nsCOMPtr mFileMetadataCallback - MOZ_GUARDED_BY(mMutex); - nsCOMPtr mFileMetadataCallbackEventTarget - MOZ_GUARDED_BY(mMutex); + nsCOMPtr mFileMetadataCallback GUARDED_BY(mMutex); + nsCOMPtr mFileMetadataCallbackEventTarget GUARDED_BY(mMutex); }; } // namespace mozilla diff --git a/dom/ipc/ProcessHangMonitor.cpp b/dom/ipc/ProcessHangMonitor.cpp index 105eb769e68b..a75201af54a1 100644 --- a/dom/ipc/ProcessHangMonitor.cpp +++ b/dom/ipc/ProcessHangMonitor.cpp @@ -156,22 +156,21 @@ class HangMonitorChild : public PProcessHangMonitorChild, bool mSentReport; // These fields must be accessed with mMonitor held. - bool mTerminateScript MOZ_GUARDED_BY(mMonitor); - bool mStartDebugger MOZ_GUARDED_BY(mMonitor); - bool mFinishedStartingDebugger MOZ_GUARDED_BY(mMonitor); - bool mPaintWhileInterruptingJS MOZ_GUARDED_BY(mMonitor); - TabId mPaintWhileInterruptingJSTab MOZ_GUARDED_BY(mMonitor); + bool mTerminateScript GUARDED_BY(mMonitor); + bool mStartDebugger GUARDED_BY(mMonitor); + bool mFinishedStartingDebugger GUARDED_BY(mMonitor); + bool mPaintWhileInterruptingJS GUARDED_BY(mMonitor); + TabId mPaintWhileInterruptingJSTab GUARDED_BY(mMonitor); MOZ_INIT_OUTSIDE_CTOR LayersObserverEpoch mPaintWhileInterruptingJSEpoch - MOZ_GUARDED_BY(mMonitor); - bool mCancelContentJS MOZ_GUARDED_BY(mMonitor); - TabId mCancelContentJSTab MOZ_GUARDED_BY(mMonitor); + GUARDED_BY(mMonitor); + bool mCancelContentJS GUARDED_BY(mMonitor); + TabId mCancelContentJSTab GUARDED_BY(mMonitor); nsIRemoteTab::NavigationType mCancelContentJSNavigationType - MOZ_GUARDED_BY(mMonitor); - int32_t mCancelContentJSNavigationIndex MOZ_GUARDED_BY(mMonitor); - mozilla::Maybe mCancelContentJSNavigationURI - MOZ_GUARDED_BY(mMonitor); - int32_t mCancelContentJSEpoch MOZ_GUARDED_BY(mMonitor); - bool mShutdownDone MOZ_GUARDED_BY(mMonitor); + GUARDED_BY(mMonitor); + int32_t mCancelContentJSNavigationIndex GUARDED_BY(mMonitor); + mozilla::Maybe mCancelContentJSNavigationURI GUARDED_BY(mMonitor); + int32_t mCancelContentJSEpoch GUARDED_BY(mMonitor); + bool mShutdownDone GUARDED_BY(mMonitor); JSContext* mContext; // const after constructor @@ -294,14 +293,14 @@ class HangMonitorParent : public PProcessHangMonitorParent, RefPtr mProcess; // Must be accessed with mMonitor held. - bool mShutdownDone MOZ_GUARDED_BY(mMonitor); + bool mShutdownDone GUARDED_BY(mMonitor); // Map from plugin ID to crash dump ID. Protected by // mBrowserCrashDumpHashLock. nsTHashMap mBrowserCrashDumpIds - MOZ_GUARDED_BY(mMonitor); - Mutex mBrowserCrashDumpHashLock MOZ_GUARDED_BY(mMonitor); + GUARDED_BY(mMonitor); + Mutex mBrowserCrashDumpHashLock GUARDED_BY(mMonitor); mozilla::ipc::TaskFactory mMainThreadTaskFactory - MOZ_GUARDED_BY(mMonitor); + GUARDED_BY(mMonitor); }; } // namespace diff --git a/dom/media/AudioStream.cpp b/dom/media/AudioStream.cpp index 371308d9ab83..e6c833281e93 100644 --- a/dom/media/AudioStream.cpp +++ b/dom/media/AudioStream.cpp @@ -228,7 +228,7 @@ int AudioStream::InvokeCubeb(Function aFunction, Args&&... aArgs) { } nsresult AudioStream::Init(AudioDeviceInfo* aSinkInfo) - MOZ_NO_THREAD_SAFETY_ANALYSIS { + NO_THREAD_SAFETY_ANALYSIS { auto startTime = TimeStamp::Now(); TRACE("AudioStream::Init"); diff --git a/dom/media/AudioStream.h b/dom/media/AudioStream.h index 99e82eb49948..86975c6a7124 100644 --- a/dom/media/AudioStream.h +++ b/dom/media/AudioStream.h @@ -112,7 +112,7 @@ class AudioClock { // protected by the AudioStream monitor on other platforms. const UniquePtr mFrameHistory # ifndef XP_MACOSX - MOZ_GUARDED_BY(mMutex) + GUARDED_BY(mMutex) # endif ; # ifdef XP_MACOSX @@ -335,10 +335,10 @@ class AudioStream final { // Return true if audio frames are valid (correct sampling rate and valid // channel count) otherwise false. - bool IsValidAudioFormat(Chunk* aChunk) MOZ_REQUIRES(mMonitor); + bool IsValidAudioFormat(Chunk* aChunk) REQUIRES(mMonitor); template - int InvokeCubeb(Function aFunction, Args&&... aArgs) MOZ_REQUIRES(mMonitor); + int InvokeCubeb(Function aFunction, Args&&... aArgs) REQUIRES(mMonitor); bool CheckThreadIdChanged(); void AssertIsOnAudioThread() const; @@ -382,8 +382,7 @@ class AudioStream final { std::atomic mAudioThreadId; const bool mSandboxed = false; - MozPromiseHolder mEndedPromise - MOZ_GUARDED_BY(mMonitor); + MozPromiseHolder mEndedPromise GUARDED_BY(mMonitor); std::atomic mPlaybackComplete; // Both written on the MDSM thread, read on the audio thread. std::atomic mPlaybackRate; diff --git a/dom/media/FileBlockCache.h b/dom/media/FileBlockCache.h index 3a1daf079494..34c1b3ffc356 100644 --- a/dom/media/FileBlockCache.h +++ b/dom/media/FileBlockCache.h @@ -151,9 +151,9 @@ class FileBlockCache : public MediaBlockCacheBase { nsresult WriteBlockToFile(int32_t aBlockIndex, const uint8_t* aBlockData); // File descriptor we're writing to. This is created externally, but // shutdown by us. - PRFileDesc* mFD MOZ_PT_GUARDED_BY(mFileMutex); + PRFileDesc* mFD PT_GUARDED_BY(mFileMutex); // The current file offset in the file. - int64_t mFDCurrentPos MOZ_GUARDED_BY(mFileMutex); + int64_t mFDCurrentPos GUARDED_BY(mFileMutex); // Mutex which controls access to all data in this class, except mFD // and mFDCurrentPos. Don't hold mDataMutex while holding mFileMutex! @@ -170,22 +170,22 @@ class FileBlockCache : public MediaBlockCacheBase { // mBlockChanges[offset/BLOCK_SIZE] != nullptr, then either there's a block // cached in memory waiting to be written, or this block is the target of a // block move. - nsTArray > mBlockChanges MOZ_GUARDED_BY(mDataMutex); + nsTArray > mBlockChanges GUARDED_BY(mDataMutex); // Event target upon which block writes and block moves are performed. This is // created upon open, and dropped on close. - nsCOMPtr mBackgroundET MOZ_GUARDED_BY(mDataMutex); + nsCOMPtr mBackgroundET GUARDED_BY(mDataMutex); // Queue of pending block indexes that need to be written or moved. - std::deque mChangeIndexList MOZ_GUARDED_BY(mDataMutex); + std::deque mChangeIndexList GUARDED_BY(mDataMutex); // True if we've dispatched an event to commit all pending block changes // to file on mBackgroundET. - bool mIsWriteScheduled MOZ_GUARDED_BY(mDataMutex); + bool mIsWriteScheduled GUARDED_BY(mDataMutex); // True when a read is happening. Pending writes may be postponed, to give // higher priority to reads (which may be blocking the caller). - bool mIsReading MOZ_GUARDED_BY(mDataMutex); + bool mIsReading GUARDED_BY(mDataMutex); // True if we've got a temporary file descriptor. Note: we don't use mFD // directly as that's synchronized via mFileMutex and we need to make // decisions about whether we can write while holding mDataMutex. - bool mInitialized MOZ_GUARDED_BY(mDataMutex) = false; + bool mInitialized GUARDED_BY(mDataMutex) = false; }; } // End namespace mozilla. diff --git a/dom/media/FileMediaResource.h b/dom/media/FileMediaResource.h index 7373a6fd37de..59fb0da630ec 100644 --- a/dom/media/FileMediaResource.h +++ b/dom/media/FileMediaResource.h @@ -91,21 +91,21 @@ class FileMediaResource : public BaseMediaResource { // calling. The implmentation of Read, Seek and ReadAt obtains the // lock before calling these Unsafe variants to read or seek. nsresult UnsafeRead(char* aBuffer, uint32_t aCount, uint32_t* aBytes) - MOZ_REQUIRES(mLock); - nsresult UnsafeSeek(int32_t aWhence, int64_t aOffset) MOZ_REQUIRES(mLock); + REQUIRES(mLock); + nsresult UnsafeSeek(int32_t aWhence, int64_t aOffset) REQUIRES(mLock); private: // Ensures mSize is initialized, if it can be. // mLock must be held when this is called, and mInput must be non-null. - void EnsureSizeInitialized() MOZ_REQUIRES(mLock); + void EnsureSizeInitialized() REQUIRES(mLock); already_AddRefed UnsafeMediaReadAt(int64_t aOffset, uint32_t aCount) - MOZ_REQUIRES(mLock); + REQUIRES(mLock); // The file size, or -1 if not known. Immutable after Open(). // Can be used from any thread. // XXX FIX? is this under mLock? comments are contradictory - int64_t mSize MOZ_GUARDED_BY(mLock); + int64_t mSize GUARDED_BY(mLock); // This lock handles synchronisation between calls to Close() and // the Read, Seek, etc calls. Close must not be called while a @@ -116,16 +116,16 @@ class FileMediaResource : public BaseMediaResource { // Seekable stream interface to file. This can be used from any // thread. - nsCOMPtr mSeekable MOZ_GUARDED_BY(mLock); + nsCOMPtr mSeekable GUARDED_BY(mLock); // Input stream for the media data. This can be used from any // thread. - nsCOMPtr mInput MOZ_GUARDED_BY(mLock); + nsCOMPtr mInput GUARDED_BY(mLock); // Whether we've attempted to initialize mSize. Note that mSize can be -1 // when mSizeInitialized is true if we tried and failed to get the size // of the file. - bool mSizeInitialized MOZ_GUARDED_BY(mLock); + bool mSizeInitialized GUARDED_BY(mLock); // Set to true if NotifyDataEnded callback has been processed (which only // occurs if resource size is known) bool mNotifyDataEndedProcessed = false; diff --git a/dom/media/GraphRunner.h b/dom/media/GraphRunner.h index 9d98ef07b223..6e2625a234ed 100644 --- a/dom/media/GraphRunner.h +++ b/dom/media/GraphRunner.h @@ -86,9 +86,9 @@ class GraphRunner final : public Runnable { MediaTrackGraphImpl* const mGraph; // State being handed over to the graph through OneIteration. Protected by // mMonitor. - Maybe mIterationState MOZ_GUARDED_BY(mMonitor); + Maybe mIterationState GUARDED_BY(mMonitor); // Result from mGraph's OneIteration. Protected by mMonitor. - IterationResult mIterationResult MOZ_GUARDED_BY(mMonitor); + IterationResult mIterationResult GUARDED_BY(mMonitor); enum class ThreadState { Wait, // Waiting for a message. This is the initial state. @@ -100,7 +100,7 @@ class GraphRunner final : public Runnable { }; // Protected by mMonitor until set to Shutdown, after which this is not // modified. - ThreadState mThreadState MOZ_GUARDED_BY(mMonitor); + ThreadState mThreadState GUARDED_BY(mMonitor); // The thread running mGraph. Set on construction, after other members are // initialized. Cleared at the end of Shutdown(). diff --git a/dom/media/MediaTrackGraph.cpp b/dom/media/MediaTrackGraph.cpp index ba1e4f8ff968..f6af3c886119 100644 --- a/dom/media/MediaTrackGraph.cpp +++ b/dom/media/MediaTrackGraph.cpp @@ -1533,9 +1533,9 @@ auto MediaTrackGraphImpl::OneIterationImpl(GraphTime aStateTime, // > LIFECYCLE_RUNNING) // Ignore mutex warning: static during execution of the graph - MOZ_PUSH_IGNORE_THREAD_SAFETY + PUSH_IGNORE_THREAD_SAFETY MOZ_DIAGNOSTIC_ASSERT(mLifecycleState <= LIFECYCLE_RUNNING); - MOZ_POP_THREAD_SAFETY + POP_THREAD_SAFETY MOZ_ASSERT(OnGraphThread()); @@ -2725,7 +2725,7 @@ bool SourceMediaTrack::PullNewData(GraphTime aDesiredUpToTime) { static void MoveToSegment(SourceMediaTrack* aTrack, MediaSegment* aIn, MediaSegment* aOut, TrackTime aCurrentTime, TrackTime aDesiredUpToTime) - MOZ_REQUIRES(aTrack->GetMutex()) { + REQUIRES(aTrack->GetMutex()) { MOZ_ASSERT(aIn->GetType() == aOut->GetType()); MOZ_ASSERT(aOut->GetDuration() >= aCurrentTime); MOZ_ASSERT(aDesiredUpToTime >= aCurrentTime); diff --git a/dom/media/MediaTrackGraph.h b/dom/media/MediaTrackGraph.h index 13c3d946f76c..d4c3e4611314 100644 --- a/dom/media/MediaTrackGraph.h +++ b/dom/media/MediaTrackGraph.h @@ -671,9 +671,9 @@ class SourceMediaTrack : public MediaTrack { // The value set here is applied in MoveToSegment so we can avoid the // buffering delay in applying the change. See Bug 1443511. void SetVolume(float aVolume); - float GetVolumeLocked() MOZ_REQUIRES(mMutex); + float GetVolumeLocked() REQUIRES(mMutex); - Mutex& GetMutex() MOZ_RETURN_CAPABILITY(mMutex) { return mMutex; } + Mutex& GetMutex() RETURN_CAPABILITY(mMutex) { return mMutex; } friend class MediaTrackGraphImpl; @@ -706,8 +706,7 @@ class SourceMediaTrack : public MediaTrack { bool NeedsMixing(); - void ResampleAudioToGraphSampleRate(MediaSegment* aSegment) - MOZ_REQUIRES(mMutex); + void ResampleAudioToGraphSampleRate(MediaSegment* aSegment) REQUIRES(mMutex); void AddDirectListenerImpl( already_AddRefed aListener) override; @@ -719,7 +718,7 @@ class SourceMediaTrack : public MediaTrack { * from AppendData on the thread providing the data, and will call * the Listeners on this thread. */ - void NotifyDirectConsumers(MediaSegment* aSegment) MOZ_REQUIRES(mMutex); + void NotifyDirectConsumers(MediaSegment* aSegment) REQUIRES(mMutex); void OnGraphThreadDone() override { MutexAutoLock lock(mMutex); @@ -740,10 +739,10 @@ class SourceMediaTrack : public MediaTrack { // held together. Mutex mMutex; // protected by mMutex - float mVolume MOZ_GUARDED_BY(mMutex) = 1.0; - UniquePtr mUpdateTrack MOZ_GUARDED_BY(mMutex); + float mVolume GUARDED_BY(mMutex) = 1.0; + UniquePtr mUpdateTrack GUARDED_BY(mMutex); nsTArray> mDirectTrackListeners - MOZ_GUARDED_BY(mMutex); + GUARDED_BY(mMutex); }; /** diff --git a/dom/media/MediaTrackGraphImpl.h b/dom/media/MediaTrackGraphImpl.h index 33a877c71688..6f82c413edb3 100644 --- a/dom/media/MediaTrackGraphImpl.h +++ b/dom/media/MediaTrackGraphImpl.h @@ -189,7 +189,7 @@ class MediaTrackGraphImpl : public MediaTrackGraph, /** * Called to apply a TrackUpdate to its track. */ - void ApplyTrackUpdate(TrackUpdate* aUpdate) MOZ_REQUIRES(mMonitor); + void ApplyTrackUpdate(TrackUpdate* aUpdate) REQUIRES(mMonitor); /** * Append a ControlMessage to the message queue. This queue is drained * during RunInStableState; the messages will run on the graph thread. @@ -280,13 +280,12 @@ class MediaTrackGraphImpl : public MediaTrackGraph, * mMonitor must be held. * See EnsureRunInStableState */ - void EnsureStableStateEventPosted() MOZ_REQUIRES(mMonitor); + void EnsureStableStateEventPosted() REQUIRES(mMonitor); /** * Generate messages to the main thread to update it for all state changes. * mMonitor must be held. */ - void PrepareUpdatesToMainThreadState(bool aFinalUpdate) - MOZ_REQUIRES(mMonitor); + void PrepareUpdatesToMainThreadState(bool aFinalUpdate) REQUIRES(mMonitor); /** * If we are rendering in non-realtime mode, we don't want to send messages to * the main thread at each iteration for performance reasons. We instead @@ -320,7 +319,7 @@ class MediaTrackGraphImpl : public MediaTrackGraph, */ void UpdateGraph(GraphTime aEndBlockingDecisions); - void SwapMessageQueues() MOZ_REQUIRES(mMonitor) { + void SwapMessageQueues() REQUIRES(mMonitor) { MOZ_ASSERT(OnGraphThreadOrNotRunning()); mMonitor.AssertCurrentThreadOwns(); MOZ_ASSERT(mFrontMessageQueue.IsEmpty()); @@ -554,7 +553,7 @@ class MediaTrackGraphImpl : public MediaTrackGraph, /** * Not safe to call off the MediaTrackGraph thread unless monitor is held! */ - GraphDriver* CurrentDriver() const MOZ_NO_THREAD_SAFETY_ANALYSIS { + GraphDriver* CurrentDriver() const NO_THREAD_SAFETY_ANALYSIS { #ifdef DEBUG if (!OnGraphThreadOrNotRunning()) { mMonitor.AssertCurrentThreadOwns(); @@ -788,11 +787,11 @@ class MediaTrackGraphImpl : public MediaTrackGraph, /** * State to copy to main thread */ - nsTArray mTrackUpdates MOZ_GUARDED_BY(mMonitor); + nsTArray mTrackUpdates GUARDED_BY(mMonitor); /** * Runnables to run after the next update to main thread state. */ - nsTArray> mUpdateRunnables MOZ_GUARDED_BY(mMonitor); + nsTArray> mUpdateRunnables GUARDED_BY(mMonitor); /** * A list of batches of messages to process. Each batch is processed * as an atomic unit. @@ -806,10 +805,10 @@ class MediaTrackGraphImpl : public MediaTrackGraph, * Message queue in which the main thread appends messages. * Access guarded by mMonitor. */ - nsTArray mBackMessageQueue MOZ_GUARDED_BY(mMonitor); + nsTArray mBackMessageQueue GUARDED_BY(mMonitor); /* True if there will messages to process if we swap the message queues. */ - bool MessagesQueued() const MOZ_REQUIRES(mMonitor) { + bool MessagesQueued() const REQUIRES(mMonitor) { mMonitor.AssertCurrentThreadOwns(); return !mBackMessageQueue.IsEmpty(); } @@ -863,8 +862,8 @@ class MediaTrackGraphImpl : public MediaTrackGraph, * LIFECYCLE_WAITING_FOR_MAIN_THREAD_CLEANUP occur on the graph thread at * the end of an iteration. All other transitions occur on the main thread. */ - LifecycleState mLifecycleState MOZ_GUARDED_BY(mMonitor); - LifecycleState& LifecycleStateRef() MOZ_NO_THREAD_SAFETY_ANALYSIS { + LifecycleState mLifecycleState GUARDED_BY(mMonitor); + LifecycleState& LifecycleStateRef() NO_THREAD_SAFETY_ANALYSIS { #if DEBUG if (mGraphDriverRunning) { mMonitor.AssertCurrentThreadOwns(); @@ -874,8 +873,7 @@ class MediaTrackGraphImpl : public MediaTrackGraph, #endif return mLifecycleState; } - const LifecycleState& LifecycleStateRef() const - MOZ_NO_THREAD_SAFETY_ANALYSIS { + const LifecycleState& LifecycleStateRef() const NO_THREAD_SAFETY_ANALYSIS { #if DEBUG if (mGraphDriverRunning) { mMonitor.AssertCurrentThreadOwns(); @@ -901,7 +899,7 @@ class MediaTrackGraphImpl : public MediaTrackGraph, * forced) has commenced. Set on the main thread under mMonitor and read on * the graph thread under mMonitor. **/ - bool mInterruptJSCalled MOZ_GUARDED_BY(mMonitor) = false; + bool mInterruptJSCalled GUARDED_BY(mMonitor) = false; /** * Remove this blocker to unblock shutdown. @@ -914,7 +912,7 @@ class MediaTrackGraphImpl : public MediaTrackGraph, * RunInStableState() and the event hasn't run yet. * Accessed on both main and MTG thread, mMonitor must be held. */ - bool mPostedRunInStableStateEvent MOZ_GUARDED_BY(mMonitor); + bool mPostedRunInStableStateEvent GUARDED_BY(mMonitor); /** * The JSContext of the graph thread. Set under mMonitor on only the graph @@ -922,7 +920,7 @@ class MediaTrackGraphImpl : public MediaTrackGraph, * the thread is about to exit. Read under mMonitor on the main thread to * interrupt running JS for forced shutdown. **/ - JSContext* mJSContext MOZ_GUARDED_BY(mMonitor) = nullptr; + JSContext* mJSContext GUARDED_BY(mMonitor) = nullptr; // Main thread only @@ -1017,7 +1015,7 @@ class MediaTrackGraphImpl : public MediaTrackGraph, * Set based on mProcessedTime at end of iteration. * Read by stable state runnable on main thread. Protected by mMonitor. */ - GraphTime mNextMainThreadGraphTime MOZ_GUARDED_BY(mMonitor) = 0; + GraphTime mNextMainThreadGraphTime GUARDED_BY(mMonitor) = 0; /** * Cached audio output latency, in seconds. Main thread only. This is reset diff --git a/dom/media/doctor/MultiWriterQueue.h b/dom/media/doctor/MultiWriterQueue.h index c7b84915b99c..cfc96930894d 100644 --- a/dom/media/doctor/MultiWriterQueue.h +++ b/dom/media/doctor/MultiWriterQueue.h @@ -20,12 +20,12 @@ namespace mozilla { // Default reader locking strategy, using a mutex to ensure that concurrent // PopAll calls won't overlap. -class MOZ_CAPABILITY MultiWriterQueueReaderLocking_Mutex { +class CAPABILITY MultiWriterQueueReaderLocking_Mutex { public: MultiWriterQueueReaderLocking_Mutex() : mMutex("MultiWriterQueueReaderLocking_Mutex") {} - void Lock() MOZ_CAPABILITY_ACQUIRE(mMutex) { mMutex.Lock(); }; - void Unlock() MOZ_CAPABILITY_RELEASE(mMutex) { mMutex.Unlock(); }; + void Lock() CAPABILITY_ACQUIRE(mMutex) { mMutex.Lock(); }; + void Unlock() CAPABILITY_RELEASE(mMutex) { mMutex.Unlock(); }; private: Mutex mMutex; @@ -33,17 +33,17 @@ class MOZ_CAPABILITY MultiWriterQueueReaderLocking_Mutex { // Reader non-locking strategy, trusting that PopAll will never be called // concurrently (e.g., by only calling it from a specific thread). -class MOZ_CAPABILITY MultiWriterQueueReaderLocking_None { +class CAPABILITY MultiWriterQueueReaderLocking_None { public: #ifndef DEBUG - void Lock() MOZ_CAPABILITY_ACQUIRE(){}; - void Unlock() MOZ_CAPABILITY_RELEASE(){}; + void Lock() CAPABILITY_ACQUIRE(){}; + void Unlock() CAPABILITY_RELEASE(){}; #else // DEBUG-mode checks to catch concurrent misuses. - void Lock() MOZ_CAPABILITY_ACQUIRE() { + void Lock() CAPABILITY_ACQUIRE() { MOZ_ASSERT(mLocked.compareExchange(false, true)); }; - void Unlock() MOZ_CAPABILITY_RELEASE() { + void Unlock() CAPABILITY_RELEASE() { MOZ_ASSERT(mLocked.compareExchange(true, false)); }; diff --git a/dom/media/gmp/GMPPlatform.cpp b/dom/media/gmp/GMPPlatform.cpp index 1a76015ed42f..6fb5ce2e255b 100644 --- a/dom/media/gmp/GMPPlatform.cpp +++ b/dom/media/gmp/GMPPlatform.cpp @@ -257,11 +257,11 @@ GMPMutexImpl::~GMPMutexImpl() { MOZ_COUNT_DTOR(GMPMutexImpl); } void GMPMutexImpl::Destroy() { delete this; } -MOZ_PUSH_IGNORE_THREAD_SAFETY +PUSH_IGNORE_THREAD_SAFETY void GMPMutexImpl::Acquire() { mMonitor.Enter(); } void GMPMutexImpl::Release() { mMonitor.Exit(); } -MOZ_POP_THREAD_SAFETY +POP_THREAD_SAFETY GMPTask* NewGMPTask(std::function&& aFunction) { class Task : public GMPTask { diff --git a/dom/media/ipc/RemoteDecoderManagerChild.cpp b/dom/media/ipc/RemoteDecoderManagerChild.cpp index 56a94cd0ff82..2640ca31765c 100644 --- a/dom/media/ipc/RemoteDecoderManagerChild.cpp +++ b/dom/media/ipc/RemoteDecoderManagerChild.cpp @@ -36,11 +36,11 @@ using namespace gfx; // launched serially. Protects sLaunchPromise StaticMutex sLaunchRDDMutex; static StaticRefPtr sLaunchRDDPromise - MOZ_GUARDED_BY(sLaunchRDDMutex); + GUARDED_BY(sLaunchRDDMutex); StaticMutex sLaunchUtilityMutex; static StaticRefPtr sLaunchUtilityPromise - MOZ_GUARDED_BY(sLaunchUtilityMutex); + GUARDED_BY(sLaunchUtilityMutex); // Only modified on the main-thread, read on any thread. While it could be read // on the main thread directly, for clarity we force access via the DataMutex diff --git a/dom/media/mediasource/TrackBuffersManager.h b/dom/media/mediasource/TrackBuffersManager.h index 0b3b64b8fe1e..138e1e731cad 100644 --- a/dom/media/mediasource/TrackBuffersManager.h +++ b/dom/media/mediasource/TrackBuffersManager.h @@ -154,7 +154,7 @@ class TrackBuffersManager final MediaResult& aResult); int32_t FindCurrentPosition(TrackInfo::TrackType aTrack, const media::TimeUnit& aFuzz) const - MOZ_REQUIRES(mTaskQueueCapability); + REQUIRES(mTaskQueueCapability); // Will set the next GetSample index if needed. This information is determined // through the value of mNextSampleTimecode. Return false if the index @@ -163,7 +163,7 @@ class TrackBuffersManager final // timecode or is empty. nsresult SetNextGetSampleIndexIfNeeded(TrackInfo::TrackType aTrack, const media::TimeUnit& aFuzz) - MOZ_REQUIRES(mTaskQueueCapability); + REQUIRES(mTaskQueueCapability); media::TimeUnit GetNextRandomAccessPoint(TrackInfo::TrackType aTrack, const media::TimeUnit& aFuzz); @@ -183,62 +183,62 @@ class TrackBuffersManager final // All following functions run on the taskqueue. RefPtr DoAppendData(already_AddRefed aData, const SourceBufferAttributes& aAttributes); - void ScheduleSegmentParserLoop() MOZ_REQUIRES(mTaskQueueCapability); - void SegmentParserLoop() MOZ_REQUIRES(mTaskQueueCapability); - void InitializationSegmentReceived() MOZ_REQUIRES(mTaskQueueCapability); - void ShutdownDemuxers() MOZ_REQUIRES(mTaskQueueCapability); - void CreateDemuxerforMIMEType() MOZ_REQUIRES(mTaskQueueCapability); - void ResetDemuxingState() MOZ_REQUIRES(mTaskQueueCapability); - void NeedMoreData() MOZ_REQUIRES(mTaskQueueCapability); + void ScheduleSegmentParserLoop() REQUIRES(mTaskQueueCapability); + void SegmentParserLoop() REQUIRES(mTaskQueueCapability); + void InitializationSegmentReceived() REQUIRES(mTaskQueueCapability); + void ShutdownDemuxers() REQUIRES(mTaskQueueCapability); + void CreateDemuxerforMIMEType() REQUIRES(mTaskQueueCapability); + void ResetDemuxingState() REQUIRES(mTaskQueueCapability); + void NeedMoreData() REQUIRES(mTaskQueueCapability); void RejectAppend(const MediaResult& aRejectValue, const char* aName) - MOZ_REQUIRES(mTaskQueueCapability); + REQUIRES(mTaskQueueCapability); // Will return a promise that will be resolved once all frames of the current // media segment have been processed. RefPtr CodedFrameProcessing() - MOZ_REQUIRES(mTaskQueueCapability); - void CompleteCodedFrameProcessing() MOZ_REQUIRES(mTaskQueueCapability); + REQUIRES(mTaskQueueCapability); + void CompleteCodedFrameProcessing() REQUIRES(mTaskQueueCapability); // Called by ResetParserState. - void CompleteResetParserState() MOZ_REQUIRES(mTaskQueueCapability); + void CompleteResetParserState() REQUIRES(mTaskQueueCapability); RefPtr CodedFrameRemovalWithPromise( - media::TimeInterval aInterval) MOZ_REQUIRES(mTaskQueueCapability); + media::TimeInterval aInterval) REQUIRES(mTaskQueueCapability); bool CodedFrameRemoval(media::TimeInterval aInterval) - MOZ_REQUIRES(mTaskQueueCapability); + REQUIRES(mTaskQueueCapability); // Removes all coded frames -- this is not to spec and should be used as a // last resort to clear buffers only if other methods cannot. - void RemoveAllCodedFrames() MOZ_REQUIRES(mTaskQueueCapability); + void RemoveAllCodedFrames() REQUIRES(mTaskQueueCapability); void SetAppendState(SourceBufferAttributes::AppendState aAppendState) - MOZ_REQUIRES(mTaskQueueCapability); + REQUIRES(mTaskQueueCapability); bool HasVideo() const { return mVideoTracks.mNumTracks > 0; } bool HasAudio() const { return mAudioTracks.mNumTracks > 0; } // The input buffer as per // http://w3c.github.io/media-source/index.html#sourcebuffer-input-buffer - Maybe mInputBuffer MOZ_GUARDED_BY(mTaskQueueCapability); + Maybe mInputBuffer GUARDED_BY(mTaskQueueCapability); // Buffer full flag as per // https://w3c.github.io/media-source/#sourcebuffer-buffer-full-flag. Accessed // on both the main thread and the task queue. Atomic mBufferFull; - bool mFirstInitializationSegmentReceived MOZ_GUARDED_BY(mTaskQueueCapability); - bool mChangeTypeReceived MOZ_GUARDED_BY(mTaskQueueCapability); + bool mFirstInitializationSegmentReceived GUARDED_BY(mTaskQueueCapability); + bool mChangeTypeReceived GUARDED_BY(mTaskQueueCapability); // Set to true once a new segment is started. - bool mNewMediaSegmentStarted MOZ_GUARDED_BY(mTaskQueueCapability); - bool mActiveTrack MOZ_GUARDED_BY(mTaskQueueCapability); - MediaContainerType mType MOZ_GUARDED_BY(mTaskQueueCapability); + bool mNewMediaSegmentStarted GUARDED_BY(mTaskQueueCapability); + bool mActiveTrack GUARDED_BY(mTaskQueueCapability); + MediaContainerType mType GUARDED_BY(mTaskQueueCapability); // ContainerParser objects and methods. // Those are used to parse the incoming input buffer. // Recreate the ContainerParser and if aReuseInitData is true then // feed it with the previous init segment found. - void RecreateParser(bool aReuseInitData) MOZ_REQUIRES(mTaskQueueCapability); + void RecreateParser(bool aReuseInitData) REQUIRES(mTaskQueueCapability); UniquePtr mParser; // Demuxer objects and methods. void AppendDataToCurrentInputBuffer(const MediaSpan& aData) - MOZ_REQUIRES(mTaskQueueCapability); + REQUIRES(mTaskQueueCapability); - RefPtr mInitData MOZ_GUARDED_BY(mTaskQueueCapability); + RefPtr mInitData GUARDED_BY(mTaskQueueCapability); // Checks if a new set of init data is a repeat of the last set of init data // received. Because streams may retransmit the same init data (or @@ -246,37 +246,36 @@ class TrackBuffersManager final // operations each time we receive init data, only when it's actually // different data. bool IsRepeatInitData(const MediaInfo& aNewMediaInfo) const - MOZ_REQUIRES(mTaskQueueCapability); + REQUIRES(mTaskQueueCapability); // Temporary input buffer to handle partial media segment header. // We store the current input buffer content into it should we need to // reinitialize the demuxer once we have some samples and a discontinuity is // detected. - Maybe mPendingInputBuffer MOZ_GUARDED_BY(mTaskQueueCapability); + Maybe mPendingInputBuffer GUARDED_BY(mTaskQueueCapability); RefPtr mCurrentInputBuffer - MOZ_GUARDED_BY(mTaskQueueCapability); - RefPtr mInputDemuxer MOZ_GUARDED_BY(mTaskQueueCapability); + GUARDED_BY(mTaskQueueCapability); + RefPtr mInputDemuxer GUARDED_BY(mTaskQueueCapability); // Length already processed in current media segment. - uint64_t mProcessedInput MOZ_GUARDED_BY(mTaskQueueCapability); - Maybe mLastParsedEndTime - MOZ_GUARDED_BY(mTaskQueueCapability); + uint64_t mProcessedInput GUARDED_BY(mTaskQueueCapability); + Maybe mLastParsedEndTime GUARDED_BY(mTaskQueueCapability); void OnDemuxerInitDone(const MediaResult& aResult); void OnDemuxerInitFailed(const MediaResult& aFailure); void OnDemuxerResetDone(const MediaResult& aResult) - MOZ_REQUIRES(mTaskQueueCapability); + REQUIRES(mTaskQueueCapability); MozPromiseRequestHolder mDemuxerInitRequest; void OnDemuxFailed(TrackType aTrack, const MediaResult& aError) - MOZ_REQUIRES(mTaskQueueCapability); - void DoDemuxVideo() MOZ_REQUIRES(mTaskQueueCapability); + REQUIRES(mTaskQueueCapability); + void DoDemuxVideo() REQUIRES(mTaskQueueCapability); void OnVideoDemuxCompleted(RefPtr aSamples); void OnVideoDemuxFailed(const MediaResult& aError) { mVideoTracks.mDemuxRequest.Complete(); mTaskQueueCapability->AssertOnCurrentThread(); OnDemuxFailed(TrackType::kVideoTrack, aError); } - void DoDemuxAudio() MOZ_REQUIRES(mTaskQueueCapability); + void DoDemuxAudio() REQUIRES(mTaskQueueCapability); void OnAudioDemuxCompleted(RefPtr aSamples); void OnAudioDemuxFailed(const MediaResult& aError) { mAudioTracks.mDemuxRequest.Complete(); @@ -290,10 +289,10 @@ class TrackBuffersManager final const nsTArray>& aSamples); void DoEvictData(const media::TimeUnit& aPlaybackTime, int64_t aSizeToEvict) - MOZ_REQUIRES(mTaskQueueCapability); + REQUIRES(mTaskQueueCapability); void GetDebugInfo(dom::TrackBuffersManagerDebugInfo& aInfo) const - MOZ_REQUIRES(mTaskQueueCapability); + REQUIRES(mTaskQueueCapability); struct TrackData { TrackData() : mNumTracks(0), mNeedRandomAccessPoint(true), mSizeBuffer(0) {} @@ -417,20 +416,20 @@ class TrackBuffersManager final }; void CheckSequenceDiscontinuity(const media::TimeUnit& aPresentationTime) - MOZ_REQUIRES(mTaskQueueCapability); + REQUIRES(mTaskQueueCapability); void ProcessFrames(TrackBuffer& aSamples, TrackData& aTrackData) - MOZ_REQUIRES(mTaskQueueCapability); + REQUIRES(mTaskQueueCapability); media::TimeInterval PresentationInterval(const TrackBuffer& aSamples) const - MOZ_REQUIRES(mTaskQueueCapability); + REQUIRES(mTaskQueueCapability); bool CheckNextInsertionIndex(TrackData& aTrackData, const media::TimeUnit& aSampleTime) - MOZ_REQUIRES(mTaskQueueCapability); + REQUIRES(mTaskQueueCapability); void InsertFrames(TrackBuffer& aSamples, const media::TimeIntervals& aIntervals, - TrackData& aTrackData) MOZ_REQUIRES(mTaskQueueCapability); + TrackData& aTrackData) REQUIRES(mTaskQueueCapability); void UpdateHighestTimestamp(TrackData& aTrackData, const media::TimeUnit& aHighestTime) - MOZ_REQUIRES(mTaskQueueCapability); + REQUIRES(mTaskQueueCapability); // Remove all frames and their dependencies contained in aIntervals. // Return the index at which frames were first removed or 0 if no frames // removed. @@ -508,15 +507,15 @@ class TrackBuffersManager final void ProcessTasks(); // Set if the TrackBuffersManager is currently processing a task. // At this stage, this task is always a AppendBufferTask. - RefPtr mCurrentTask MOZ_GUARDED_BY(mTaskQueueCapability); + RefPtr mCurrentTask GUARDED_BY(mTaskQueueCapability); // Current SourceBuffer state for ongoing task. // Its content is returned to the SourceBuffer once the AppendBufferTask has // completed. UniquePtr mSourceBufferAttributes - MOZ_GUARDED_BY(mTaskQueueCapability); + GUARDED_BY(mTaskQueueCapability); // The current sourcebuffer append window. It's content is equivalent to // mSourceBufferAttributes.mAppendWindowStart/End - media::TimeInterval mAppendWindow MOZ_GUARDED_BY(mTaskQueueCapability); + media::TimeInterval mAppendWindow GUARDED_BY(mTaskQueueCapability); // Strong references to external objects. nsMainThreadPtrHandle mParentDecoder; diff --git a/dom/media/platforms/ffmpeg/FFmpegAudioDecoder.h b/dom/media/platforms/ffmpeg/FFmpegAudioDecoder.h index 7bf98eb79f4a..ed37f3891f4f 100644 --- a/dom/media/platforms/ffmpeg/FFmpegAudioDecoder.h +++ b/dom/media/platforms/ffmpeg/FFmpegAudioDecoder.h @@ -29,7 +29,7 @@ class FFmpegAudioDecoder virtual ~FFmpegAudioDecoder(); RefPtr Init() override; - void InitCodecContext() MOZ_REQUIRES(sMutex) override; + void InitCodecContext() REQUIRES(sMutex) override; static AVCodecID GetCodecId(const nsACString& aMimeType); nsCString GetDescriptionName() const override { return "ffmpeg audio decoder"_ns; diff --git a/dom/media/platforms/ffmpeg/FFmpegDataDecoder.h b/dom/media/platforms/ffmpeg/FFmpegDataDecoder.h index fd1d4fd96f84..231b2fb4ddf8 100644 --- a/dom/media/platforms/ffmpeg/FFmpegDataDecoder.h +++ b/dom/media/platforms/ffmpeg/FFmpegDataDecoder.h @@ -48,7 +48,7 @@ class FFmpegDataDecoder // Flush and Drain operation, always run virtual RefPtr ProcessFlush(); virtual void ProcessShutdown(); - virtual void InitCodecContext() MOZ_REQUIRES(sMutex) {} + virtual void InitCodecContext() REQUIRES(sMutex) {} AVFrame* PrepareFrame(); MediaResult InitDecoder(); MediaResult AllocateExtraData(); diff --git a/dom/media/platforms/ffmpeg/FFmpegVideoDecoder.h b/dom/media/platforms/ffmpeg/FFmpegVideoDecoder.h index 367aa6bbe1d9..e2a74d8f1c53 100644 --- a/dom/media/platforms/ffmpeg/FFmpegVideoDecoder.h +++ b/dom/media/platforms/ffmpeg/FFmpegVideoDecoder.h @@ -53,7 +53,7 @@ class FFmpegVideoDecoder ~FFmpegVideoDecoder(); RefPtr Init() override; - void InitCodecContext() MOZ_REQUIRES(sMutex) override; + void InitCodecContext() REQUIRES(sMutex) override; nsCString GetDescriptionName() const override { #ifdef USING_MOZFFVPX return "ffvpx video decoder"_ns; diff --git a/dom/media/systemservices/MediaParent.cpp b/dom/media/systemservices/MediaParent.cpp index d2fb06b8ae7c..e47aaa9b5597 100644 --- a/dom/media/systemservices/MediaParent.cpp +++ b/dom/media/systemservices/MediaParent.cpp @@ -392,9 +392,9 @@ class OriginKeyStore { } // Only accessed on StreamTS threads - OriginKeysLoader mOriginKeys MOZ_GUARDED_BY(sOriginKeyStoreStsMutex); + OriginKeysLoader mOriginKeys GUARDED_BY(sOriginKeyStoreStsMutex); OriginKeysTable mPrivateBrowsingOriginKeys - MOZ_GUARDED_BY(sOriginKeyStoreStsMutex); + GUARDED_BY(sOriginKeyStoreStsMutex); }; OriginKeyStore* OriginKeyStore::sOriginKeyStore = nullptr; diff --git a/dom/media/systemservices/video_engine/platform_uithread.h b/dom/media/systemservices/video_engine/platform_uithread.h index 2c5fcb81da04..dfd5027ea8af 100644 --- a/dom/media/systemservices/video_engine/platform_uithread.h +++ b/dom/media/systemservices/video_engine/platform_uithread.h @@ -69,15 +69,15 @@ class PlatformUIThread : public PlatformThread { // Initialize the UI thread that is servicing the timer events bool InternalInit(); - HWND hwnd_ MOZ_GUARDED_BY(cs_) = nullptr; - UINT_PTR timerid_ MOZ_GUARDED_BY(cs_) = 0; - unsigned int timeout_ MOZ_GUARDED_BY(cs_) = 0; + HWND hwnd_ GUARDED_BY(cs_) = nullptr; + UINT_PTR timerid_ GUARDED_BY(cs_) = 0; + unsigned int timeout_ GUARDED_BY(cs_) = 0; enum class State { UNSTARTED, STARTED, STOPPED, }; - State state_ MOZ_GUARDED_BY(cs_) = State::UNSTARTED; + State state_ GUARDED_BY(cs_) = State::UNSTARTED; }; } // namespace rtc diff --git a/dom/media/webaudio/ScriptProcessorNode.cpp b/dom/media/webaudio/ScriptProcessorNode.cpp index c7abc8af4dda..5e23449f7085 100644 --- a/dom/media/webaudio/ScriptProcessorNode.cpp +++ b/dom/media/webaudio/ScriptProcessorNode.cpp @@ -32,7 +32,7 @@ class SharedBuffers final { explicit OutputQueue(const char* aName) : mMutex(aName) {} size_t SizeOfExcludingThis(MallocSizeOf aMallocSizeOf) const - MOZ_REQUIRES(mMutex) { + REQUIRES(mMutex) { mMutex.AssertCurrentThreadOwns(); size_t amount = 0; @@ -43,18 +43,18 @@ class SharedBuffers final { return amount; } - Mutex& Lock() const MOZ_RETURN_CAPABILITY(mMutex) { + Mutex& Lock() const RETURN_CAPABILITY(mMutex) { return const_cast(this)->mMutex; } - size_t ReadyToConsume() const MOZ_REQUIRES(mMutex) { + size_t ReadyToConsume() const REQUIRES(mMutex) { // Accessed on both main thread and media graph thread. mMutex.AssertCurrentThreadOwns(); return mBufferList.size(); } // Produce one buffer - AudioChunk& Produce() MOZ_REQUIRES(mMutex) { + AudioChunk& Produce() REQUIRES(mMutex) { mMutex.AssertCurrentThreadOwns(); MOZ_ASSERT(NS_IsMainThread()); mBufferList.push_back(AudioChunk()); @@ -62,7 +62,7 @@ class SharedBuffers final { } // Consumes one buffer. - AudioChunk Consume() MOZ_REQUIRES(mMutex) { + AudioChunk Consume() REQUIRES(mMutex) { mMutex.AssertCurrentThreadOwns(); MOZ_ASSERT(!NS_IsMainThread()); MOZ_ASSERT(ReadyToConsume() > 0); @@ -72,7 +72,7 @@ class SharedBuffers final { } // Empties the buffer queue. - void Clear() MOZ_REQUIRES(mMutex) { + void Clear() REQUIRES(mMutex) { mMutex.AssertCurrentThreadOwns(); mBufferList.clear(); } diff --git a/dom/media/webaudio/blink/HRTFDatabaseLoader.h b/dom/media/webaudio/blink/HRTFDatabaseLoader.h index 5d4548d24735..71dd073d8042 100644 --- a/dom/media/webaudio/blink/HRTFDatabaseLoader.h +++ b/dom/media/webaudio/blink/HRTFDatabaseLoader.h @@ -144,7 +144,7 @@ class HRTFDatabaseLoader { // Holding a m_threadLock is required when accessing m_databaseLoaderThread. mozilla::Mutex m_threadLock; - PRThread* m_databaseLoaderThread MOZ_GUARDED_BY(m_threadLock); + PRThread* m_databaseLoaderThread GUARDED_BY(m_threadLock); float m_databaseSampleRate; mozilla::Atomic m_databaseLoaded; diff --git a/dom/media/webm/WebMBufferedParser.h b/dom/media/webm/WebMBufferedParser.h index 8bc107bd7489..8bce578320ff 100644 --- a/dom/media/webm/WebMBufferedParser.h +++ b/dom/media/webm/WebMBufferedParser.h @@ -299,9 +299,9 @@ class WebMBufferedState final { // Sorted (by offset) map of data offsets to timecodes. Populated // on the main thread as data is received and parsed by WebMBufferedParsers. - nsTArray mTimeMapping MOZ_GUARDED_BY(mMutex); + nsTArray mTimeMapping GUARDED_BY(mMutex); // The last complete block parsed. -1 if not set. - int64_t mLastBlockOffset MOZ_GUARDED_BY(mMutex); + int64_t mLastBlockOffset GUARDED_BY(mMutex); // Sorted (by offset) live parser instances. Main thread only. nsTArray mRangeParsers; diff --git a/dom/performance/PerformanceStorageWorker.h b/dom/performance/PerformanceStorageWorker.h index e585069112a2..dd51eeb4b037 100644 --- a/dom/performance/PerformanceStorageWorker.h +++ b/dom/performance/PerformanceStorageWorker.h @@ -40,7 +40,7 @@ class PerformanceStorageWorker final : public PerformanceStorage { // Protected by mutex. // Created and released on worker-thread. Used also on main-thread. - RefPtr mWorkerRef MOZ_GUARDED_BY(mMutex); + RefPtr mWorkerRef GUARDED_BY(mMutex); }; } // namespace mozilla::dom diff --git a/dom/promise/PromiseWorkerProxy.h b/dom/promise/PromiseWorkerProxy.h index 92ebd5eaf298..4eba0348ed05 100644 --- a/dom/promise/PromiseWorkerProxy.h +++ b/dom/promise/PromiseWorkerProxy.h @@ -146,7 +146,7 @@ class PromiseWorkerProxy : public PromiseNativeHandler, // Main thread callers must hold Lock() and check CleanUp() before calling // this. Worker thread callers, this will assert that the proxy has not been // cleaned up. - WorkerPrivate* GetWorkerPrivate() const MOZ_NO_THREAD_SAFETY_ANALYSIS; + WorkerPrivate* GetWorkerPrivate() const NO_THREAD_SAFETY_ANALYSIS; // This should only be used within WorkerRunnable::WorkerRun() running on the // worker thread! Do not call this after calling CleanUp(). @@ -158,9 +158,9 @@ class PromiseWorkerProxy : public PromiseNativeHandler, // 2. WorkerPromise() will crash! void CleanUp(); - Mutex& Lock() MOZ_RETURN_CAPABILITY(mCleanUpLock) { return mCleanUpLock; } + Mutex& Lock() RETURN_CAPABILITY(mCleanUpLock) { return mCleanUpLock; } - bool CleanedUp() const MOZ_REQUIRES(mCleanUpLock) { + bool CleanedUp() const REQUIRES(mCleanUpLock) { mCleanUpLock.AssertCurrentThreadOwns(); return mCleanedUp; } @@ -204,8 +204,8 @@ class PromiseWorkerProxy : public PromiseNativeHandler, // Modified on the worker thread. // It is ok to *read* this without a lock on the worker. // Main thread must always acquire a lock. - bool mCleanedUp MOZ_GUARDED_BY( - mCleanUpLock); // To specify if the cleanUp() has been done. + bool mCleanedUp + GUARDED_BY(mCleanUpLock); // To specify if the cleanUp() has been done. const PromiseWorkerProxyStructuredCloneCallbacks* mCallbacks; diff --git a/dom/serviceworkers/ServiceWorkerRegistrar.cpp b/dom/serviceworkers/ServiceWorkerRegistrar.cpp index cc2b490c5c79..ed6dc1c31fcd 100644 --- a/dom/serviceworkers/ServiceWorkerRegistrar.cpp +++ b/dom/serviceworkers/ServiceWorkerRegistrar.cpp @@ -879,12 +879,12 @@ nsresult ServiceWorkerRegistrar::ReadData() { // XXX NOTE: if we could be accessed multi-threaded here, we would need to // find a way to lock around access to mData. Since we can't, suppress the // thread-safety warnings. - MOZ_PUSH_IGNORE_THREAD_SAFETY + PUSH_IGNORE_THREAD_SAFETY if (overwrite && NS_FAILED(WriteData(mData))) { NS_WARNING("Failed to write data for the ServiceWorker Registations."); DeleteData(); } - MOZ_POP_THREAD_SAFETY + POP_THREAD_SAFETY return NS_OK; } diff --git a/dom/serviceworkers/ServiceWorkerRegistrar.h b/dom/serviceworkers/ServiceWorkerRegistrar.h index 20c1cc530c5c..608b58786e8d 100644 --- a/dom/serviceworkers/ServiceWorkerRegistrar.h +++ b/dom/serviceworkers/ServiceWorkerRegistrar.h @@ -76,7 +76,7 @@ class ServiceWorkerRegistrar : public nsIObserver, void DeleteData(); void RegisterServiceWorkerInternal(const ServiceWorkerRegistrationData& aData) - MOZ_REQUIRES(mMonitor); + REQUIRES(mMonitor); ServiceWorkerRegistrar(); virtual ~ServiceWorkerRegistrar(); @@ -100,11 +100,11 @@ class ServiceWorkerRegistrar : public nsIObserver, mozilla::Monitor mMonitor; // protected by mMonitor. - nsCOMPtr mProfileDir MOZ_GUARDED_BY(mMonitor); + nsCOMPtr mProfileDir GUARDED_BY(mMonitor); // Read on mainthread, modified on background thread EXCEPT for // ReloadDataForTest() AND for gtest, which modifies this on MainThread. - nsTArray mData MOZ_GUARDED_BY(mMonitor); - bool mDataLoaded MOZ_GUARDED_BY(mMonitor); + nsTArray mData GUARDED_BY(mMonitor); + bool mDataLoaded GUARDED_BY(mMonitor); // PBackground thread only uint32_t mDataGeneration; diff --git a/dom/serviceworkers/test/gtest/TestReadWrite.cpp b/dom/serviceworkers/test/gtest/TestReadWrite.cpp index fbe71d710831..f6d08c1cd49e 100644 --- a/dom/serviceworkers/test/gtest/TestReadWrite.cpp +++ b/dom/serviceworkers/test/gtest/TestReadWrite.cpp @@ -37,7 +37,7 @@ class ServiceWorkerRegistrarTest : public ServiceWorkerRegistrar { } nsresult TestReadData() { return ReadData(); } - nsresult TestWriteData() MOZ_NO_THREAD_SAFETY_ANALYSIS { + nsresult TestWriteData() NO_THREAD_SAFETY_ANALYSIS { return WriteData(mData); } void TestDeleteData() { DeleteData(); } diff --git a/dom/websocket/WebSocket.cpp b/dom/websocket/WebSocket.cpp index 538ef44aaab7..c775c182f3f7 100644 --- a/dom/websocket/WebSocket.cpp +++ b/dom/websocket/WebSocket.cpp @@ -248,7 +248,7 @@ class WebSocketImpl final : public nsIInterfaceRequestor, // This mutex protects mWorkerShuttingDown. mozilla::Mutex mMutex; - bool mWorkerShuttingDown MOZ_GUARDED_BY(mMutex); + bool mWorkerShuttingDown GUARDED_BY(mMutex); RefPtr mService; nsCOMPtr mLoadingPrincipal; diff --git a/dom/websocket/WebSocket.h b/dom/websocket/WebSocket.h index c4a67a3e140a..6208fb50db4e 100644 --- a/dom/websocket/WebSocket.h +++ b/dom/websocket/WebSocket.h @@ -181,7 +181,7 @@ class WebSocket final : public DOMEventTargetHelper { mozilla::Mutex mMutex; // This value should not be used directly but use ReadyState() instead. - uint16_t mReadyState MOZ_GUARDED_BY(mMutex); + uint16_t mReadyState GUARDED_BY(mMutex); }; } // namespace dom diff --git a/dom/workers/JSExecutionManager.h b/dom/workers/JSExecutionManager.h index 132884bf53fd..120e42d1645b 100644 --- a/dom/workers/JSExecutionManager.h +++ b/dom/workers/JSExecutionManager.h @@ -104,17 +104,16 @@ class JSExecutionManager { // Workers waiting to be given permission for execution. // Guarded by mExecutionQueueMutex. - std::deque mExecutionQueue - MOZ_GUARDED_BY(mExecutionQueueMutex); + std::deque mExecutionQueue GUARDED_BY(mExecutionQueueMutex); // Number of threads currently executing concurrently for this manager. // Guarded by mExecutionQueueMutex. - int32_t mRunning MOZ_GUARDED_BY(mExecutionQueueMutex) = 0; + int32_t mRunning GUARDED_BY(mExecutionQueueMutex) = 0; // Number of threads allowed to run concurrently for environments managed // by this manager. // Guarded by mExecutionQueueMutex. - int32_t mMaxRunning MOZ_GUARDED_BY(mExecutionQueueMutex) = 1; + int32_t mMaxRunning GUARDED_BY(mExecutionQueueMutex) = 1; // Mutex that guards the execution queue and associated state. Mutex mExecutionQueueMutex = @@ -131,8 +130,7 @@ class JSExecutionManager { // Whether the main thread is currently awaiting permission to execute. Main // thread execution is always prioritized. // Guarded by mExecutionQueueMutex. - bool mMainThreadAwaitingExecution MOZ_GUARDED_BY(mExecutionQueueMutex) = - false; + bool mMainThreadAwaitingExecution GUARDED_BY(mExecutionQueueMutex) = false; }; // Helper for managing execution requests and allowing re-entrant permission diff --git a/dom/workers/Queue.h b/dom/workers/Queue.h index 143dd8ca76a0..a244e6ecd95a 100644 --- a/dom/workers/Queue.h +++ b/dom/workers/Queue.h @@ -51,26 +51,26 @@ struct StorageWithTArray { static void Compact(StorageType& aStorage) { aStorage.Compact(); } }; -class MOZ_CAPABILITY LockingWithMutex { +class CAPABILITY LockingWithMutex { mozilla::Mutex mMutex; protected: LockingWithMutex() : mMutex("LockingWithMutex::mMutex") {} - void Lock() MOZ_CAPABILITY_ACQUIRE() { mMutex.Lock(); } + void Lock() CAPABILITY_ACQUIRE() { mMutex.Lock(); } - void Unlock() MOZ_CAPABILITY_RELEASE() { mMutex.Unlock(); } + void Unlock() CAPABILITY_RELEASE() { mMutex.Unlock(); } - class MOZ_SCOPED_CAPABILITY AutoLock { + class SCOPED_CAPABILITY AutoLock { LockingWithMutex& mHost; public: - explicit AutoLock(LockingWithMutex& aHost) MOZ_CAPABILITY_ACQUIRE(aHost) + explicit AutoLock(LockingWithMutex& aHost) CAPABILITY_ACQUIRE(aHost) : mHost(aHost) { mHost.Lock(); } - ~AutoLock() MOZ_CAPABILITY_RELEASE() { mHost.Unlock(); } + ~AutoLock() CAPABILITY_RELEASE() { mHost.Unlock(); } }; friend class AutoLock; diff --git a/dom/workers/RuntimeService.h b/dom/workers/RuntimeService.h index d1a44a19e865..ef32cc847e8b 100644 --- a/dom/workers/RuntimeService.h +++ b/dom/workers/RuntimeService.h @@ -57,7 +57,7 @@ class RuntimeService final : public nsIObserver { // Protected by mMutex. nsClassHashtable mDomainMap - MOZ_GUARDED_BY(mMutex); + GUARDED_BY(mMutex); // *Not* protected by mMutex. nsClassHashtable, @@ -181,7 +181,7 @@ class RuntimeService final : public nsIObserver { void Cleanup(); void AddAllTopLevelWorkersToArray(nsTArray& aWorkers) - MOZ_REQUIRES(mMutex); + REQUIRES(mMutex); nsTArray GetWorkersForWindow( const nsPIDOMWindowInner& aWindow) const; diff --git a/dom/workers/WorkerCSPEventListener.h b/dom/workers/WorkerCSPEventListener.h index 1265f0ed1727..3cc1a05184fe 100644 --- a/dom/workers/WorkerCSPEventListener.h +++ b/dom/workers/WorkerCSPEventListener.h @@ -32,7 +32,7 @@ class WorkerCSPEventListener final : public nsICSPEventListener { Mutex mMutex; // Protected by mutex. - RefPtr mWorkerRef MOZ_GUARDED_BY(mMutex); + RefPtr mWorkerRef GUARDED_BY(mMutex); }; } // namespace mozilla::dom diff --git a/dom/workers/WorkerEventTarget.h b/dom/workers/WorkerEventTarget.h index dd9cb61748aa..39648bd7299c 100644 --- a/dom/workers/WorkerEventTarget.h +++ b/dom/workers/WorkerEventTarget.h @@ -28,8 +28,8 @@ class WorkerEventTarget final : public nsISerialEventTarget { private: mozilla::Mutex mMutex; - CheckedUnsafePtr mWorkerPrivate MOZ_GUARDED_BY(mMutex); - const Behavior mBehavior MOZ_GUARDED_BY(mMutex); + CheckedUnsafePtr mWorkerPrivate GUARDED_BY(mMutex); + const Behavior mBehavior GUARDED_BY(mMutex); ~WorkerEventTarget() = default; diff --git a/dom/workers/WorkerPrivate.cpp b/dom/workers/WorkerPrivate.cpp index 3c53d24cbf31..96357690e6f0 100644 --- a/dom/workers/WorkerPrivate.cpp +++ b/dom/workers/WorkerPrivate.cpp @@ -663,7 +663,7 @@ class DebuggerImmediateRunnable : public WorkerRunnable { // GetJSContext() is safe on the worker thread void PeriodicGCTimerCallback(nsITimer* aTimer, - void* aClosure) MOZ_NO_THREAD_SAFETY_ANALYSIS { + void* aClosure) NO_THREAD_SAFETY_ANALYSIS { auto* workerPrivate = static_cast(aClosure); MOZ_DIAGNOSTIC_ASSERT(workerPrivate); workerPrivate->AssertIsOnWorkerThread(); @@ -673,7 +673,7 @@ void PeriodicGCTimerCallback(nsITimer* aTimer, } void IdleGCTimerCallback(nsITimer* aTimer, - void* aClosure) MOZ_NO_THREAD_SAFETY_ANALYSIS { + void* aClosure) NO_THREAD_SAFETY_ANALYSIS { auto* workerPrivate = static_cast(aClosure); MOZ_DIAGNOSTIC_ASSERT(workerPrivate); workerPrivate->AssertIsOnWorkerThread(); @@ -943,7 +943,7 @@ class WorkerPrivate::EventTarget final : public nsISerialEventTarget { // This mutex protects mWorkerPrivate and must be acquired *before* the // WorkerPrivate's mutex whenever they must both be held. mozilla::Mutex mMutex; - WorkerPrivate* mWorkerPrivate MOZ_GUARDED_BY(mMutex); + WorkerPrivate* mWorkerPrivate GUARDED_BY(mMutex); nsIEventTarget* mWeakNestedEventTarget; nsCOMPtr mNestedEventTarget; @@ -3695,7 +3695,7 @@ void WorkerPrivate::ScheduleDeletion(WorkerRanOrNot aRanOrNot) { } bool WorkerPrivate::CollectRuntimeStats( - JS::RuntimeStats* aRtStats, bool aAnonymize) MOZ_NO_THREAD_SAFETY_ANALYSIS { + JS::RuntimeStats* aRtStats, bool aAnonymize) NO_THREAD_SAFETY_ANALYSIS { // We don't have a lock to access mJSContext, but it's safe to access on this // thread. AssertIsOnWorkerThread(); diff --git a/dom/workers/WorkerPrivate.h b/dom/workers/WorkerPrivate.h index ae304f38e867..1f31c4a6a944 100644 --- a/dom/workers/WorkerPrivate.h +++ b/dom/workers/WorkerPrivate.h @@ -85,10 +85,10 @@ class WorkerThread; // SharedMutex is a small wrapper around an (internal) reference-counted Mutex // object. It exists to avoid changing a lot of code to use Mutex* instead of // Mutex&. -class MOZ_CAPABILITY SharedMutex { +class CAPABILITY SharedMutex { using Mutex = mozilla::Mutex; - class MOZ_CAPABILITY RefCountedMutex final : public Mutex { + class CAPABILITY RefCountedMutex final : public Mutex { public: explicit RefCountedMutex(const char* aName) : Mutex(aName) {} @@ -106,17 +106,17 @@ class MOZ_CAPABILITY SharedMutex { SharedMutex(const SharedMutex& aOther) = default; - operator Mutex&() MOZ_RETURN_CAPABILITY(this) { return *mMutex; } + operator Mutex&() RETURN_CAPABILITY(this) { return *mMutex; } - operator const Mutex&() const MOZ_RETURN_CAPABILITY(this) { return *mMutex; } + operator const Mutex&() const RETURN_CAPABILITY(this) { return *mMutex; } // We need these to make thread-safety analysis work - void Lock() MOZ_CAPABILITY_ACQUIRE() { mMutex->Lock(); } - void Unlock() MOZ_CAPABILITY_RELEASE() { mMutex->Unlock(); } + void Lock() CAPABILITY_ACQUIRE() { mMutex->Lock(); } + void Unlock() CAPABILITY_RELEASE() { mMutex->Unlock(); } // We can assert we own 'this', but we can't assert we hold mMutex void AssertCurrentThreadOwns() const - MOZ_ASSERT_CAPABILITY(this) MOZ_NO_THREAD_SAFETY_ANALYSIS { + ASSERT_CAPABILITY(this) NO_THREAD_SAFETY_ANALYSIS { mMutex->AssertCurrentThreadOwns(); } }; @@ -173,14 +173,14 @@ class WorkerPrivate final bool Cancel() { return Notify(Canceling); } - bool Close() MOZ_REQUIRES(mMutex); + bool Close() REQUIRES(mMutex); // The passed principal must be the Worker principal in case of a // ServiceWorker and the loading principal for any other type. static void OverrideLoadInfoLoadGroup(WorkerLoadInfo& aLoadInfo, nsIPrincipal* aPrincipal); - bool IsDebuggerRegistered() MOZ_NO_THREAD_SAFETY_ANALYSIS { + bool IsDebuggerRegistered() NO_THREAD_SAFETY_ANALYSIS { AssertIsOnMainThread(); // No need to lock here since this is only ever modified by the same thread. @@ -369,7 +369,7 @@ class WorkerPrivate final return mFetchHandlerWasAdded; } - JSContext* GetJSContext() const MOZ_NO_THREAD_SAFETY_ANALYSIS { + JSContext* GetJSContext() const NO_THREAD_SAFETY_ANALYSIS { // mJSContext is only modified on the worker thread, so workerthread code // can safely read it without a lock AssertIsOnWorkerThread(); @@ -547,7 +547,7 @@ class WorkerPrivate final return mParentStatus; } - WorkerStatus ParentStatus() const MOZ_REQUIRES(mMutex) { + WorkerStatus ParentStatus() const REQUIRES(mMutex) { mMutex.AssertCurrentThreadOwns(); return mParentStatus; } @@ -1115,13 +1115,13 @@ class WorkerPrivate final } ProcessAllControlRunnablesResult ProcessAllControlRunnablesLocked() - MOZ_REQUIRES(mMutex); + REQUIRES(mMutex); void EnableMemoryReporter(); void DisableMemoryReporter(); - void WaitForWorkerEvents() MOZ_REQUIRES(mMutex); + void WaitForWorkerEvents() REQUIRES(mMutex); // If the worker shutdown status is equal or greater then aFailStatus, this // operation will fail and nullptr will be returned. See WorkerStatus.h for @@ -1158,8 +1158,7 @@ class WorkerPrivate final // to allow runnables to be atomically dispatched in bulk. nsresult DispatchLockHeld(already_AddRefed aRunnable, nsIEventTarget* aSyncLoopTarget, - const MutexAutoLock& aProofOfLock) - MOZ_REQUIRES(mMutex); + const MutexAutoLock& aProofOfLock) REQUIRES(mMutex); // This method dispatches a simple runnable that starts the shutdown procedure // after a self.close(). This method is called after a ClearMainEventQueue() @@ -1198,7 +1197,7 @@ class WorkerPrivate final friend class mozilla::dom::WorkerThread; SharedMutex mMutex; - mozilla::CondVar mCondVar MOZ_GUARDED_BY(mMutex); + mozilla::CondVar mCondVar GUARDED_BY(mMutex); // We cannot make this CheckedUnsafePtr as this would violate // our static assert @@ -1232,7 +1231,7 @@ class WorkerPrivate final LocationInfo mLocationInfo; // Protected by mMutex. - workerinternals::JSSettings mJSSettings MOZ_GUARDED_BY(mMutex); + workerinternals::JSSettings mJSSettings GUARDED_BY(mMutex); WorkerDebugger* mDebugger; @@ -1241,9 +1240,9 @@ class WorkerPrivate final // Touched on multiple threads, protected with mMutex. Only modified on the // worker thread - JSContext* mJSContext MOZ_GUARDED_BY(mMutex); + JSContext* mJSContext GUARDED_BY(mMutex); // mThread is only modified on the Worker thread, before calling DoRunLoop - RefPtr mThread MOZ_GUARDED_BY(mMutex); + RefPtr mThread GUARDED_BY(mMutex); // mPRThread is only modified on another thread in ScheduleWorker(), and is // constant for the duration of DoRunLoop. Static mutex analysis doesn't help // here @@ -1287,7 +1286,7 @@ class WorkerPrivate final RefPtr mCSPEventListener; // Protected by mMutex. - nsTArray> mPreStartRunnables MOZ_GUARDED_BY(mMutex); + nsTArray> mPreStartRunnables GUARDED_BY(mMutex); // Only touched on the parent thread. This is set only if IsSharedWorker(). RefPtr mRemoteWorkerController; @@ -1297,8 +1296,8 @@ class WorkerPrivate final JS::UniqueChars mDefaultLocale; // nulled during worker JSContext init TimeStamp mKillTime; - WorkerStatus mParentStatus MOZ_GUARDED_BY(mMutex); - WorkerStatus mStatus MOZ_GUARDED_BY(mMutex); + WorkerStatus mParentStatus GUARDED_BY(mMutex); + WorkerStatus mStatus GUARDED_BY(mMutex); // This is touched on parent thread only, but it can be read on a different // thread before crashing because hanging. @@ -1431,7 +1430,7 @@ class WorkerPrivate final // use our global object's secure state there. const bool mIsSecureContext; - bool mDebuggerRegistered MOZ_GUARDED_BY(mMutex); + bool mDebuggerRegistered GUARDED_BY(mMutex); // During registration, this worker may be marked as not being ready to // execute debuggee runnables or content. diff --git a/dom/xhr/XMLHttpRequestMainThread.h b/dom/xhr/XMLHttpRequestMainThread.h index 6147c2a044c1..7a70e6eb1e2b 100644 --- a/dom/xhr/XMLHttpRequestMainThread.h +++ b/dom/xhr/XMLHttpRequestMainThread.h @@ -117,7 +117,7 @@ class ArrayBufferBuilder { ArrayBufferBuilder& operator=(const ArrayBufferBuilder&&) = delete; bool SetCapacityInternal(uint32_t aNewCap, const MutexAutoLock& aProofOfLock) - MOZ_REQUIRES(mMutex); + REQUIRES(mMutex); static bool AreOverlappingRegions(const uint8_t* aStart1, uint32_t aLength1, const uint8_t* aStart2, uint32_t aLength2); @@ -125,10 +125,10 @@ class ArrayBufferBuilder { Mutex mMutex; // All of these are protected by mMutex. - uint8_t* mDataPtr MOZ_GUARDED_BY(mMutex); - uint32_t mCapacity MOZ_GUARDED_BY(mMutex); - uint32_t mLength MOZ_GUARDED_BY(mMutex); - void* mMapPtr MOZ_GUARDED_BY(mMutex); + uint8_t* mDataPtr GUARDED_BY(mMutex); + uint32_t mCapacity GUARDED_BY(mMutex); + uint32_t mLength GUARDED_BY(mMutex); + void* mMapPtr GUARDED_BY(mMutex); // This is used in assertions only. bool mNeutered; diff --git a/dom/xhr/XMLHttpRequestString.cpp b/dom/xhr/XMLHttpRequestString.cpp index d1fd2ccdc12a..facaed5443a9 100644 --- a/dom/xhr/XMLHttpRequestString.cpp +++ b/dom/xhr/XMLHttpRequestString.cpp @@ -25,12 +25,12 @@ class XMLHttpRequestStringBuffer final { return mData.Length(); } - uint32_t UnsafeLength() const MOZ_NO_THREAD_SAFETY_ANALYSIS { + uint32_t UnsafeLength() const NO_THREAD_SAFETY_ANALYSIS { return mData.Length(); } mozilla::Result, nsresult> UnsafeBulkWrite( - uint32_t aCapacity) MOZ_NO_THREAD_SAFETY_ANALYSIS { + uint32_t aCapacity) NO_THREAD_SAFETY_ANALYSIS { return mData.BulkWrite(aCapacity, UnsafeLength(), false); } @@ -86,7 +86,7 @@ class XMLHttpRequestStringBuffer final { Mutex mMutex; // The following member variable is protected by mutex. - nsString mData MOZ_GUARDED_BY(mMutex); + nsString mData GUARDED_BY(mMutex); }; // --------------------------------------------------------------------------- diff --git a/gfx/2d/2D.h b/gfx/2d/2D.h index ce5bed6f20c7..4acf5e4a9469 100644 --- a/gfx/2d/2D.h +++ b/gfx/2d/2D.h @@ -1092,11 +1092,11 @@ class SharedFTFace : public external::AtomicRefCounted { * If no owner is given, then the user should avoid modifying any state on * the face so as not to invalidate the prior owner's modification. */ - bool Lock(const void* aOwner = nullptr) MOZ_CAPABILITY_ACQUIRE(mLock) { + bool Lock(const void* aOwner = nullptr) CAPABILITY_ACQUIRE(mLock) { mLock.Lock(); return !aOwner || mLastLockOwner.exchange(aOwner) == aOwner; } - void Unlock() MOZ_CAPABILITY_RELEASE(mLock) { mLock.Unlock(); } + void Unlock() CAPABILITY_RELEASE(mLock) { mLock.Unlock(); } /** Should be called when a lock owner is destroyed so that we don't have * a dangling pointer to a destroyed owner. diff --git a/gfx/2d/Factory.cpp b/gfx/2d/Factory.cpp index 5eb375747df8..cfc94a345317 100644 --- a/gfx/2d/Factory.cpp +++ b/gfx/2d/Factory.cpp @@ -172,11 +172,11 @@ void mozilla_ForgetSharedFTFaceLockOwner(void* aContext, void* aOwner) { } int mozilla_LockSharedFTFace(void* aContext, - void* aOwner) MOZ_NO_THREAD_SAFETY_ANALYSIS { + void* aOwner) NO_THREAD_SAFETY_ANALYSIS { return int(static_cast(aContext)->Lock(aOwner)); } -void mozilla_UnlockSharedFTFace(void* aContext) MOZ_NO_THREAD_SAFETY_ANALYSIS { +void mozilla_UnlockSharedFTFace(void* aContext) NO_THREAD_SAFETY_ANALYSIS { static_cast(aContext)->Unlock(); } @@ -624,12 +624,12 @@ void Factory::ReleaseFTLibrary(FT_Library aFTLibrary) { } void Factory::LockFTLibrary(FT_Library aFTLibrary) - MOZ_CAPABILITY_ACQUIRE(mFTLock) MOZ_NO_THREAD_SAFETY_ANALYSIS { + CAPABILITY_ACQUIRE(mFTLock) NO_THREAD_SAFETY_ANALYSIS { mFTLock.Lock(); } void Factory::UnlockFTLibrary(FT_Library aFTLibrary) - MOZ_CAPABILITY_RELEASE(mFTLock) MOZ_NO_THREAD_SAFETY_ANALYSIS { + CAPABILITY_RELEASE(mFTLock) NO_THREAD_SAFETY_ANALYSIS { mFTLock.Unlock(); } diff --git a/gfx/2d/SourceSurfaceSkia.cpp b/gfx/2d/SourceSurfaceSkia.cpp index 73368752d4ca..3b96785d5a91 100644 --- a/gfx/2d/SourceSurfaceSkia.cpp +++ b/gfx/2d/SourceSurfaceSkia.cpp @@ -159,7 +159,7 @@ uint8_t* SourceSurfaceSkia::GetData() { } bool SourceSurfaceSkia::Map(MapType, MappedSurface* aMappedSurface) - MOZ_NO_THREAD_SAFETY_ANALYSIS { + NO_THREAD_SAFETY_ANALYSIS { mChangeMutex.Lock(); aMappedSurface->mData = GetData(); aMappedSurface->mStride = Stride(); @@ -169,12 +169,12 @@ bool SourceSurfaceSkia::Map(MapType, MappedSurface* aMappedSurface) mChangeMutex.Unlock(); } // Static analysis will warn due to a conditional Unlock - MOZ_PUSH_IGNORE_THREAD_SAFETY + PUSH_IGNORE_THREAD_SAFETY return isMapped; - MOZ_POP_THREAD_SAFETY + POP_THREAD_SAFETY } -void SourceSurfaceSkia::Unmap() MOZ_NO_THREAD_SAFETY_ANALYSIS { +void SourceSurfaceSkia::Unmap() NO_THREAD_SAFETY_ANALYSIS { mChangeMutex.AssertCurrentThreadOwns(); MOZ_ASSERT(mIsMapped); mIsMapped = false; diff --git a/gfx/gl/GLLibraryEGL.h b/gfx/gl/GLLibraryEGL.h index 53f9d0c18aca..768c26b6d527 100644 --- a/gfx/gl/GLLibraryEGL.h +++ b/gfx/gl/GLLibraryEGL.h @@ -140,7 +140,7 @@ class GLLibraryEGL final { ~GLLibraryEGL() = default; static StaticMutex sMutex; - static StaticRefPtr sInstance MOZ_GUARDED_BY(sMutex); + static StaticRefPtr sInstance GUARDED_BY(sMutex); bool Init(nsACString* const out_failureId); void InitLibExtensions(); diff --git a/gfx/layers/apz/src/APZCTreeManager.cpp b/gfx/layers/apz/src/APZCTreeManager.cpp index 4d16dd4a65b3..077b0029bdf9 100644 --- a/gfx/layers/apz/src/APZCTreeManager.cpp +++ b/gfx/layers/apz/src/APZCTreeManager.cpp @@ -3665,7 +3665,7 @@ void APZCTreeManager::AssertOnUpdaterThread() { GetUpdater()->AssertOnUpdaterThread(); } -MOZ_PUSH_IGNORE_THREAD_SAFETY +PUSH_IGNORE_THREAD_SAFETY void APZCTreeManager::LockTree() { AssertOnUpdaterThread(); mTreeLock.Lock(); @@ -3675,7 +3675,7 @@ void APZCTreeManager::UnlockTree() { AssertOnUpdaterThread(); mTreeLock.Unlock(); } -MOZ_POP_THREAD_SAFETY +POP_THREAD_SAFETY void APZCTreeManager::SetDPI(float aDpiValue) { if (!APZThreadUtils::IsControllerThread()) { diff --git a/gfx/layers/apz/src/APZCTreeManager.h b/gfx/layers/apz/src/APZCTreeManager.h index f7bf98f814fc..496a429a89fa 100644 --- a/gfx/layers/apz/src/APZCTreeManager.h +++ b/gfx/layers/apz/src/APZCTreeManager.h @@ -507,8 +507,8 @@ class APZCTreeManager : public IAPZCTreeManager, public APZInputBridge { // functions to the world. private: friend class APZUpdater; - void LockTree() MOZ_CAPABILITY_ACQUIRE(mTreeLock); - void UnlockTree() MOZ_CAPABILITY_RELEASE(mTreeLock); + void LockTree() CAPABILITY_ACQUIRE(mTreeLock); + void UnlockTree() CAPABILITY_RELEASE(mTreeLock); // Protected hooks for gtests subclass virtual AsyncPanZoomController* NewAPZCInstance( @@ -591,8 +591,7 @@ class APZCTreeManager : public IAPZCTreeManager, public APZInputBridge { /* Helpers */ void AttachNodeToTree(HitTestingTreeNode* aNode, HitTestingTreeNode* aParent, - HitTestingTreeNode* aNextSibling) - MOZ_REQUIRES(mTreeLock); + HitTestingTreeNode* aNextSibling) REQUIRES(mTreeLock); already_AddRefed GetTargetAPZC( const ScrollableLayerGuid& aGuid); already_AddRefed GetTargetNode( @@ -731,7 +730,7 @@ class APZCTreeManager : public IAPZCTreeManager, public APZInputBridge { // the coordinates of |aNode|'s parent in the hit-testing tree. // Requires the caller to hold mTreeLock. LayerToParentLayerMatrix4x4 ComputeTransformForNode( - const HitTestingTreeNode* aNode) const MOZ_REQUIRES(mTreeLock); + const HitTestingTreeNode* aNode) const REQUIRES(mTreeLock); // Look up the GeckoContentController for the given layers id. static already_AddRefed GetContentController( @@ -788,7 +787,7 @@ class APZCTreeManager : public IAPZCTreeManager, public APZInputBridge { * management state. * IMPORTANT: See the note about lock ordering at the top of this file. */ mutable mozilla::RecursiveMutex mTreeLock; - RefPtr mRootNode MOZ_GUARDED_BY(mTreeLock); + RefPtr mRootNode GUARDED_BY(mTreeLock); /* * A set of LayersIds for which APZCTM should only send empty @@ -800,7 +799,7 @@ class APZCTreeManager : public IAPZCTreeManager, public APZInputBridge { * Acquire mTreeLock before accessing this. */ std::unordered_set mDetachedLayersIds - MOZ_GUARDED_BY(mTreeLock); + GUARDED_BY(mTreeLock); /* If the current hit-testing tree contains an async zoom container * node, this is set to the layers id of subtree that has the node. diff --git a/gfx/layers/apz/src/APZUpdater.cpp b/gfx/layers/apz/src/APZUpdater.cpp index 2bbad6e1a77c..8f87ba0299c3 100644 --- a/gfx/layers/apz/src/APZUpdater.cpp +++ b/gfx/layers/apz/src/APZUpdater.cpp @@ -73,7 +73,7 @@ void APZUpdater::SetUpdaterThread(const wr::WrWindowId& aWindowId) { // Takes a conditional lock! /*static*/ void APZUpdater::PrepareForSceneSwap(const wr::WrWindowId& aWindowId) - MOZ_NO_THREAD_SAFETY_ANALYSIS { + NO_THREAD_SAFETY_ANALYSIS { if (RefPtr updater = GetUpdater(aWindowId)) { updater->mApz->LockTree(); } diff --git a/gfx/layers/ipc/CanvasTranslator.h b/gfx/layers/ipc/CanvasTranslator.h index d1c159ba390d..bec29bae10ce 100644 --- a/gfx/layers/ipc/CanvasTranslator.h +++ b/gfx/layers/ipc/CanvasTranslator.h @@ -272,7 +272,7 @@ class CanvasTranslator final : public gfx::InlineTranslator, UniquePtr mPreparedMap; typedef std::unordered_map> DescriptorMap; - DescriptorMap mSurfaceDescriptors MOZ_GUARDED_BY(mSurfaceDescriptorsMonitor); + DescriptorMap mSurfaceDescriptors GUARDED_BY(mSurfaceDescriptorsMonitor); Monitor mSurfaceDescriptorsMonitor{ "CanvasTranslator::mSurfaceDescriptorsMonitor"}; Atomic mDeactivated{false}; diff --git a/gfx/thebes/gfxDWriteFontList.h b/gfx/thebes/gfxDWriteFontList.h index ed7644b15f1c..2a1711c6913a 100644 --- a/gfx/thebes/gfxDWriteFontList.h +++ b/gfx/thebes/gfxDWriteFontList.h @@ -64,7 +64,7 @@ class gfxDWriteFontFamily final : public gfxFontFamily { virtual ~gfxDWriteFontFamily(); void FindStyleVariationsLocked(FontInfoData* aFontInfoData = nullptr) - MOZ_REQUIRES(mLock) final; + REQUIRES(mLock) final; void LocalizedName(nsACString& aLocalizedName) final; @@ -376,8 +376,8 @@ class gfxDWriteFontList final : public gfxPlatformFontList { } // initialize font lists - nsresult InitFontListForPlatform() MOZ_REQUIRES(mLock) override; - void InitSharedFontListForPlatform() MOZ_REQUIRES(mLock) override; + nsresult InitFontListForPlatform() REQUIRES(mLock) override; + void InitSharedFontListForPlatform() REQUIRES(mLock) override; FontVisibility GetVisibilityForFamily(const nsACString& aName) const; @@ -390,7 +390,7 @@ class gfxDWriteFontList final : public gfxPlatformFontList { void ReadFaceNamesForFamily(mozilla::fontlist::Family* aFamily, bool aNeedFullnamePostscriptNames) - MOZ_REQUIRES(mLock) override; + REQUIRES(mLock) override; bool ReadFaceNames(mozilla::fontlist::Family* aFamily, mozilla::fontlist::Face* aFace, nsCString& aPSName, @@ -422,7 +422,7 @@ class gfxDWriteFontList final : public gfxPlatformFontList { const nsACString& aFamily, nsTArray* aOutput, FindFamiliesFlags aFlags, gfxFontStyle* aStyle = nullptr, nsAtom* aLanguage = nullptr, gfxFloat aDevToCssSize = 1.0) - MOZ_REQUIRES(mLock) override; + REQUIRES(mLock) override; gfxFloat GetForceGDIClassicMaxFontSize() { return mForceGDIClassicMaxFontSize; @@ -437,7 +437,7 @@ class gfxDWriteFontList final : public gfxPlatformFontList { FontFamily GetDefaultFontForPlatform(nsPresContext* aPresContext, const gfxFontStyle* aStyle, nsAtom* aLanguage = nullptr) - MOZ_REQUIRES(mLock) override; + REQUIRES(mLock) override; // attempt to use platform-specific fallback for the given character, // return null if no usable result found @@ -446,25 +446,24 @@ class gfxDWriteFontList final : public gfxPlatformFontList { Script aRunScript, const gfxFontStyle* aMatchStyle, FontFamily& aMatchedFamily) - MOZ_REQUIRES(mLock) override; + REQUIRES(mLock) override; private: friend class gfxDWriteFontFamily; - nsresult GetFontSubstitutes() MOZ_REQUIRES(mLock); + nsresult GetFontSubstitutes() REQUIRES(mLock); - void GetDirectWriteSubstitutes() MOZ_REQUIRES(mLock); + void GetDirectWriteSubstitutes() REQUIRES(mLock); virtual bool UsesSystemFallback() { return true; } void GetFontsFromCollection(IDWriteFontCollection* aCollection) - MOZ_REQUIRES(mLock); + REQUIRES(mLock); void AppendFamiliesFromCollection( IDWriteFontCollection* aCollection, nsTArray& aFamilies, - const nsTArray* aForceClassicFams = nullptr) - MOZ_REQUIRES(mLock); + const nsTArray* aForceClassicFams = nullptr) REQUIRES(mLock); #ifdef MOZ_BUNDLED_FONTS already_AddRefed CreateBundledFontsCollection( diff --git a/gfx/thebes/gfxFT2FontBase.cpp b/gfx/thebes/gfxFT2FontBase.cpp index 82aa6f8f5109..b6eb2a76592f 100644 --- a/gfx/thebes/gfxFT2FontBase.cpp +++ b/gfx/thebes/gfxFT2FontBase.cpp @@ -43,7 +43,7 @@ gfxFT2FontBase::gfxFT2FontBase( gfxFT2FontBase::~gfxFT2FontBase() { mFTFace->ForgetLockOwner(this); } FT_Face gfxFT2FontBase::LockFTFace() const - MOZ_CAPABILITY_ACQUIRE(mFTFace) MOZ_NO_THREAD_SAFETY_ANALYSIS { + CAPABILITY_ACQUIRE(mFTFace) NO_THREAD_SAFETY_ANALYSIS { if (!mFTFace->Lock(this)) { FT_Set_Transform(mFTFace->GetFace(), nullptr, nullptr); @@ -54,7 +54,7 @@ FT_Face gfxFT2FontBase::LockFTFace() const } void gfxFT2FontBase::UnlockFTFace() const - MOZ_CAPABILITY_RELEASE(mFTFace) MOZ_NO_THREAD_SAFETY_ANALYSIS { + CAPABILITY_RELEASE(mFTFace) NO_THREAD_SAFETY_ANALYSIS { mFTFace->Unlock(); } diff --git a/gfx/thebes/gfxFT2FontBase.h b/gfx/thebes/gfxFT2FontBase.h index 7cef74b5d329..61c16b775085 100644 --- a/gfx/thebes/gfxFT2FontBase.h +++ b/gfx/thebes/gfxFT2FontBase.h @@ -36,7 +36,7 @@ class gfxFT2FontEntryBase : public gfxFontEntry { uint32_t mGlyphIndex; }; - mozilla::UniquePtr mCmapCache MOZ_GUARDED_BY(mLock); + mozilla::UniquePtr mCmapCache GUARDED_BY(mLock); }; class gfxFT2FontBase : public gfxFont { @@ -147,7 +147,7 @@ class gfxFT2FontBase : public gfxFont { uint16_t aGID, mozilla::gfx::IntRect* aBounds = nullptr) const; mutable mozilla::UniquePtr> - mGlyphMetrics MOZ_GUARDED_BY(mLock); + mGlyphMetrics GUARDED_BY(mLock); }; // Helper classes used for clearing out user font data when FT font diff --git a/gfx/thebes/gfxFT2FontList.h b/gfx/thebes/gfxFT2FontList.h index c99ad29057a7..66933edb6834 100644 --- a/gfx/thebes/gfxFT2FontList.h +++ b/gfx/thebes/gfxFT2FontList.h @@ -174,26 +174,26 @@ class gfxFT2FontList final : public gfxPlatformFontList { typedef enum { kUnknown, kStandard } StandardFile; // initialize font lists - nsresult InitFontListForPlatform() MOZ_REQUIRES(mLock) override; + nsresult InitFontListForPlatform() REQUIRES(mLock) override; void AppendFaceFromFontListEntry(const FontListEntry& aFLE, - StandardFile aStdFile) MOZ_REQUIRES(mLock); + StandardFile aStdFile) REQUIRES(mLock); void AppendFacesFromBlob(const nsCString& aFileName, StandardFile aStdFile, hb_blob_t* aBlob, FontNameCache* aCache, uint32_t aTimestamp, uint32_t aFilesize) - MOZ_REQUIRES(mLock); + REQUIRES(mLock); void AppendFacesFromFontFile(const nsCString& aFileName, FontNameCache* aCache, StandardFile aStdFile) - MOZ_REQUIRES(mLock); + REQUIRES(mLock); void AppendFacesFromOmnijarEntry(nsZipArchive* aReader, const nsCString& aEntryName, FontNameCache* aCache, bool aJarChanged) - MOZ_REQUIRES(mLock); + REQUIRES(mLock); - void InitSharedFontListForPlatform() MOZ_REQUIRES(mLock) override; + void InitSharedFontListForPlatform() REQUIRES(mLock) override; void CollectInitData(const FontListEntry& aFLE, const nsCString& aPSName, const nsCString& aFullName, StandardFile aStdFile); @@ -217,23 +217,23 @@ class gfxFT2FontList final : public gfxPlatformFontList { bool AppendFacesFromCachedFaceList(CollectFunc aCollectFace, const nsCString& aFileName, const nsCString& aFaceList, - StandardFile aStdFile) MOZ_REQUIRES(mLock); + StandardFile aStdFile) REQUIRES(mLock); void AddFaceToList(const nsCString& aEntryName, uint32_t aIndex, StandardFile aStdFile, hb_face_t* aFace, - nsCString& aFaceList) MOZ_REQUIRES(mLock); + nsCString& aFaceList) REQUIRES(mLock); - void FindFonts() MOZ_REQUIRES(mLock); + void FindFonts() REQUIRES(mLock); - void FindFontsInOmnijar(FontNameCache* aCache) MOZ_REQUIRES(mLock); + void FindFontsInOmnijar(FontNameCache* aCache) REQUIRES(mLock); void FindFontsInDir(const nsCString& aDir, FontNameCache* aFNC) - MOZ_REQUIRES(mLock); + REQUIRES(mLock); FontFamily GetDefaultFontForPlatform(nsPresContext* aPresContext, const gfxFontStyle* aStyle, nsAtom* aLanguage = nullptr) - MOZ_REQUIRES(mLock) override; + REQUIRES(mLock) override; nsTHashSet mSkipSpaceLookupCheckFamilies; diff --git a/gfx/thebes/gfxFcPlatformFontList.h b/gfx/thebes/gfxFcPlatformFontList.h index 447dada3210f..f1cb705d3998 100644 --- a/gfx/thebes/gfxFcPlatformFontList.h +++ b/gfx/thebes/gfxFcPlatformFontList.h @@ -176,7 +176,7 @@ class gfxFontconfigFontFamily final : public gfxFontFamily { void AddFacesToFontList(Func aAddPatternFunc); void FindStyleVariationsLocked(FontInfoData* aFontInfoData = nullptr) - MOZ_REQUIRES(mLock) override; + REQUIRES(mLock) override; // Families are constructed initially with just references to patterns. // When necessary, these are enumerated within FindStyleVariations. @@ -245,8 +245,8 @@ class gfxFcPlatformFontList final : public gfxPlatformFontList { } // initialize font lists - nsresult InitFontListForPlatform() MOZ_REQUIRES(mLock) override; - void InitSharedFontListForPlatform() MOZ_REQUIRES(mLock) override; + nsresult InitFontListForPlatform() REQUIRES(mLock) override; + void InitSharedFontListForPlatform() REQUIRES(mLock) override; void GetFontList(nsAtom* aLangGroup, const nsACString& aGenericFamily, nsTArray& aListOfFonts) override; @@ -275,7 +275,7 @@ class gfxFcPlatformFontList final : public gfxPlatformFontList { const nsACString& aFamily, nsTArray* aOutput, FindFamiliesFlags aFlags, gfxFontStyle* aStyle = nullptr, nsAtom* aLanguage = nullptr, gfxFloat aDevToCssSize = 1.0) - MOZ_REQUIRES(mLock) override; + REQUIRES(mLock) override; bool GetStandardFamilyName(const nsCString& aFontName, nsACString& aFamilyName) override; @@ -287,14 +287,14 @@ class gfxFcPlatformFontList final : public gfxPlatformFontList { mozilla::StyleGenericFontFamily, nsAtom* aLanguage, nsTArray& aFamilyList) override; - void ClearLangGroupPrefFontsLocked() MOZ_REQUIRES(mLock) override; + void ClearLangGroupPrefFontsLocked() REQUIRES(mLock) override; // clear out cached generic-lang ==> family-list mappings void ClearGenericMappings() { AutoLock lock(mLock); ClearGenericMappingsLocked(); } - void ClearGenericMappingsLocked() MOZ_REQUIRES(mLock) { + void ClearGenericMappingsLocked() REQUIRES(mLock) { mGenericMappings.Clear(); } @@ -318,29 +318,29 @@ class gfxFcPlatformFontList final : public gfxPlatformFontList { // Add all the font families found in a font set. // aAppFonts indicates whether this is the system or application fontset. void AddFontSetFamilies(FcFontSet* aFontSet, const SandboxPolicy* aPolicy, - bool aAppFonts) MOZ_REQUIRES(mLock); + bool aAppFonts) REQUIRES(mLock); // Helper for above, to add a single font pattern. void AddPatternToFontList(FcPattern* aFont, FcChar8*& aLastFamilyName, nsACString& aFamilyName, RefPtr& aFontFamily, - bool aAppFonts) MOZ_REQUIRES(mLock); + bool aAppFonts) REQUIRES(mLock); // figure out which families fontconfig maps a generic to // (aGeneric assumed already lowercase) PrefFontList* FindGenericFamilies(nsPresContext* aPresContext, const nsCString& aGeneric, - nsAtom* aLanguage) MOZ_REQUIRES(mLock); + nsAtom* aLanguage) REQUIRES(mLock); // are all pref font settings set to use fontconfig generics? - bool PrefFontListsUseOnlyGenerics() MOZ_REQUIRES(mLock); + bool PrefFontListsUseOnlyGenerics() REQUIRES(mLock); static void CheckFontUpdates(nsITimer* aTimer, void* aThis); FontFamily GetDefaultFontForPlatform(nsPresContext* aPresContext, const gfxFontStyle* aStyle, nsAtom* aLanguage = nullptr) - MOZ_REQUIRES(mLock) override; + REQUIRES(mLock) override; enum class DistroID : int8_t { Unknown = 0, diff --git a/gfx/thebes/gfxFont.h b/gfx/thebes/gfxFont.h index 9b020811818a..e3bef7710a43 100644 --- a/gfx/thebes/gfxFont.h +++ b/gfx/thebes/gfxFont.h @@ -392,7 +392,7 @@ class gfxFontCache final // This gets called when the timeout has expired on a single-refcount // font; we just delete it. void NotifyExpiredLocked(gfxFont* aFont, const AutoLock&) - MOZ_REQUIRES(mMutex) override; + REQUIRES(mMutex) override; void NotifyHandlerEnd() override; void DestroyDiscard(nsTArray>& aDiscard); @@ -440,13 +440,13 @@ class gfxFontCache final RefPtr mFont; }; - nsTHashtable mFonts MOZ_GUARDED_BY(mMutex); + nsTHashtable mFonts GUARDED_BY(mMutex); - nsTArray> mTrackerDiscard MOZ_GUARDED_BY(mMutex); + nsTArray> mTrackerDiscard GUARDED_BY(mMutex); static void WordCacheExpirationTimerCallback(nsITimer* aTimer, void* aCache); - nsCOMPtr mWordCacheExpirationTimer MOZ_GUARDED_BY(mMutex); + nsCOMPtr mWordCacheExpirationTimer GUARDED_BY(mMutex); std::atomic mTimerRunning = false; }; @@ -1826,7 +1826,7 @@ class gfxFont { ClearCachedWordsLocked(); } } - void ClearCachedWordsLocked() MOZ_REQUIRES(mLock) { + void ClearCachedWordsLocked() REQUIRES(mLock) { MOZ_ASSERT(mWordCache); mWordCache->Clear(); } @@ -2145,15 +2145,14 @@ class gfxFont { mozilla::UniquePtr mShapedWord; }; - mozilla::UniquePtr> mWordCache - MOZ_GUARDED_BY(mLock); + mozilla::UniquePtr> mWordCache GUARDED_BY(mLock); static const uint32_t kShapedWordCacheMaxAge = 3; nsTArray> mGlyphExtentsArray - MOZ_GUARDED_BY(mLock); + GUARDED_BY(mLock); mozilla::UniquePtr> mGlyphChangeObservers - MOZ_GUARDED_BY(mLock); + GUARDED_BY(mLock); // a copy of the font without antialiasing, if needed for separate // measurement by mathml code diff --git a/gfx/thebes/gfxFontEntry.cpp b/gfx/thebes/gfxFontEntry.cpp index 9c52c844b4ee..f51274bb27a2 100644 --- a/gfx/thebes/gfxFontEntry.cpp +++ b/gfx/thebes/gfxFontEntry.cpp @@ -520,7 +520,7 @@ hb_blob_t* gfxFontEntry::FontTableHashEntry::GetBlob() const { bool gfxFontEntry::GetExistingFontTable(uint32_t aTag, hb_blob_t** aBlob) { // Accessing the mFontTableCache pointer is atomic, so we don't need to take // a write lock even if we're initializing it here... - MOZ_PUSH_IGNORE_THREAD_SAFETY + PUSH_IGNORE_THREAD_SAFETY if (MOZ_UNLIKELY(!mFontTableCache)) { // We do this here rather than on fontEntry construction // because not all shapers will access the table cache at all. @@ -533,7 +533,7 @@ bool gfxFontEntry::GetExistingFontTable(uint32_t aTag, hb_blob_t** aBlob) { } } FontTableCache* cache = GetFontTableCache(); - MOZ_POP_THREAD_SAFETY + POP_THREAD_SAFETY // ...but we do need a lock to read the actual hashtable contents. AutoReadLock lock(mLock); @@ -548,7 +548,7 @@ bool gfxFontEntry::GetExistingFontTable(uint32_t aTag, hb_blob_t** aBlob) { hb_blob_t* gfxFontEntry::ShareFontTableAndGetBlob(uint32_t aTag, nsTArray* aBuffer) { - MOZ_PUSH_IGNORE_THREAD_SAFETY + PUSH_IGNORE_THREAD_SAFETY if (MOZ_UNLIKELY(!mFontTableCache)) { auto* newCache = new FontTableCache(8); if (MOZ_UNLIKELY(!mFontTableCache.compareExchange(nullptr, newCache))) { @@ -556,7 +556,7 @@ hb_blob_t* gfxFontEntry::ShareFontTableAndGetBlob(uint32_t aTag, } } FontTableCache* cache = GetFontTableCache(); - MOZ_POP_THREAD_SAFETY + POP_THREAD_SAFETY AutoWriteLock lock(mLock); FontTableHashEntry* entry = cache->PutEntry(aTag); diff --git a/gfx/thebes/gfxFontEntry.h b/gfx/thebes/gfxFontEntry.h index c1c19b265aba..346126ed45c9 100644 --- a/gfx/thebes/gfxFontEntry.h +++ b/gfx/thebes/gfxFontEntry.h @@ -492,14 +492,14 @@ class gfxFontEntry { gfxSVGGlyphs* GetSVGGlyphs() const { return mSVGGlyphs; } // list of gfxFonts that are using SVG glyphs - nsTArray mFontsUsingSVGGlyphs MOZ_GUARDED_BY(mLock); + nsTArray mFontsUsingSVGGlyphs GUARDED_BY(mLock); nsTArray mFeatureSettings; nsTArray mVariationSettings; mozilla::UniquePtr> mSupportedFeatures - MOZ_GUARDED_BY(mFeatureInfoLock); + GUARDED_BY(mFeatureInfoLock); mozilla::UniquePtr> mFeatureInputs - MOZ_GUARDED_BY(mFeatureInfoLock); + GUARDED_BY(mFeatureInfoLock); // Color Layer font support. These tables are inert once loaded, so we don't // need to hold a lock when reading them. @@ -615,7 +615,7 @@ class gfxFontEntry { // Helper for HasTrackingTable; check/parse the table and cache pointers // to the subtables we need. Returns false on failure, in which case the // table is unusable. - bool ParseTrakTable() MOZ_REQUIRES(mLock); + bool ParseTrakTable() REQUIRES(mLock); // lookup the cmap in cached font data virtual already_AddRefed GetCMAPFromFontInfo( @@ -862,12 +862,11 @@ class gfxFontFamily { bool CheckForLegacyFamilyNames(gfxPlatformFontList* aFontList); // Callers must hold a read-lock for as long as they're using the list. - const nsTArray>& GetFontList() - MOZ_REQUIRES_SHARED(mLock) { + const nsTArray>& GetFontList() REQUIRES_SHARED(mLock) { return mAvailableFonts; } - void ReadLock() MOZ_ACQUIRE_SHARED(mLock) { mLock.ReadLock(); } - void ReadUnlock() MOZ_RELEASE_SHARED(mLock) { mLock.ReadUnlock(); } + void ReadLock() ACQUIRE_SHARED(mLock) { mLock.ReadLock(); } + void ReadUnlock() RELEASE_SHARED(mLock) { mLock.ReadUnlock(); } uint32_t FontListLength() const { mozilla::AutoReadLock lock(mLock); @@ -879,7 +878,7 @@ class gfxFontFamily { AddFontEntryLocked(aFontEntry); } - void AddFontEntryLocked(RefPtr aFontEntry) MOZ_REQUIRES(mLock) { + void AddFontEntryLocked(RefPtr aFontEntry) REQUIRES(mLock) { // Avoid potentially duplicating entries. if (mAvailableFonts.Contains(aFontEntry)) { return; @@ -952,7 +951,7 @@ class gfxFontFamily { // This is a no-op in cases where the family is explicitly populated by other // means, rather than being asked to find its faces via system API. virtual void FindStyleVariationsLocked(FontInfoData* aFontInfoData = nullptr) - MOZ_REQUIRES(mLock){}; + REQUIRES(mLock){}; void FindStyleVariations(FontInfoData* aFontInfoData = nullptr) { if (mHasStyles) { return; @@ -978,7 +977,7 @@ class gfxFontFamily { return mFamilyCharacterMap.test(aCh); } - void ResetCharacterMap() MOZ_REQUIRES(mLock) { + void ResetCharacterMap() REQUIRES(mLock) { mFamilyCharacterMap.reset(); mFamilyCharacterMapInitialized = false; } @@ -998,12 +997,12 @@ class gfxFontFamily { bool CheckForFallbackFaces() const { return mCheckForFallbackFaces; } // sort available fonts to put preferred (standard) faces towards the end - void SortAvailableFonts() MOZ_REQUIRES(mLock); + void SortAvailableFonts() REQUIRES(mLock); // check whether the family fits into the simple 4-face model, // so we can use simplified style-matching; // if so set the mIsSimpleFamily flag (defaults to False before we've checked) - void CheckForSimpleFamily() MOZ_REQUIRES(mLock); + void CheckForSimpleFamily() REQUIRES(mLock); // For memory reporter virtual void AddSizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf, @@ -1046,7 +1045,7 @@ class gfxFontFamily { bool useFullName = false); // set whether this font family is in "bad" underline offset blocklist. - void SetBadUnderlineFonts() MOZ_REQUIRES(mLock) { + void SetBadUnderlineFonts() REQUIRES(mLock) { for (auto& f : mAvailableFonts) { if (f) { f->mIsBadUnderlineFont = true; @@ -1055,8 +1054,8 @@ class gfxFontFamily { } nsCString mName; - nsTArray> mAvailableFonts MOZ_GUARDED_BY(mLock); - gfxSparseBitSet mFamilyCharacterMap MOZ_GUARDED_BY(mLock); + nsTArray> mAvailableFonts GUARDED_BY(mLock); + gfxSparseBitSet mFamilyCharacterMap GUARDED_BY(mLock); mutable mozilla::RWLock mLock; @@ -1069,7 +1068,7 @@ class gfxFontFamily { mozilla::Atomic mCheckedForLegacyFamilyNames; mozilla::Atomic mHasOtherFamilyNames; - bool mIsSimpleFamily : 1 MOZ_GUARDED_BY(mLock); + bool mIsSimpleFamily : 1 GUARDED_BY(mLock); bool mIsBadUnderlineFamily : 1; bool mSkipDefaultFeatureSpaceCheck : 1; bool mCheckForFallbackFaces : 1; // check other faces for character diff --git a/gfx/thebes/gfxGDIFontList.cpp b/gfx/thebes/gfxGDIFontList.cpp index 3c4c7bce0725..73df88d83147 100644 --- a/gfx/thebes/gfxGDIFontList.cpp +++ b/gfx/thebes/gfxGDIFontList.cpp @@ -400,7 +400,7 @@ static bool ShouldIgnoreItalicStyle(const nsACString& aName) { int CALLBACK GDIFontFamily::FamilyAddStylesProc( const ENUMLOGFONTEXW* lpelfe, const NEWTEXTMETRICEXW* nmetrics, - DWORD fontType, LPARAM data) MOZ_NO_THREAD_SAFETY_ANALYSIS { + DWORD fontType, LPARAM data) NO_THREAD_SAFETY_ANALYSIS { const NEWTEXTMETRICW& metrics = nmetrics->ntmTm; LOGFONTW logFont = lpelfe->elfLogFont; GDIFontFamily* ff = reinterpret_cast(data); diff --git a/gfx/thebes/gfxGDIFontList.h b/gfx/thebes/gfxGDIFontList.h index 708f7fc1146c..46408f24ac2a 100644 --- a/gfx/thebes/gfxGDIFontList.h +++ b/gfx/thebes/gfxGDIFontList.h @@ -188,7 +188,7 @@ class GDIFontFamily final : public gfxFontFamily { mCharset() {} void FindStyleVariationsLocked(FontInfoData* aFontInfoData = nullptr) - MOZ_REQUIRES(mLock) override; + REQUIRES(mLock) override; bool FilterForFontList(nsAtom* aLangGroup, const nsACString& aGeneric) const final { @@ -296,7 +296,7 @@ class gfxGDIFontList final : public gfxPlatformFontList { virtual ~gfxGDIFontList() { AutoLock lock(mLock); } // initialize font lists - nsresult InitFontListForPlatform() MOZ_REQUIRES(mLock) override; + nsresult InitFontListForPlatform() REQUIRES(mLock) override; gfxFontFamily* CreateFontFamily(const nsACString& aName, FontVisibility aVisibility) const override; @@ -306,7 +306,7 @@ class gfxGDIFontList final : public gfxPlatformFontList { const nsACString& aFamily, nsTArray* aOutput, FindFamiliesFlags aFlags, gfxFontStyle* aStyle = nullptr, nsAtom* aLanguage = nullptr, gfxFloat aDevToCssSize = 1.0) - MOZ_REQUIRES(mLock) override; + REQUIRES(mLock) override; gfxFontEntry* LookupLocalFont(nsPresContext* aPresContext, const nsACString& aFontName, @@ -330,14 +330,14 @@ class gfxGDIFontList final : public gfxPlatformFontList { FontFamily GetDefaultFontForPlatform(nsPresContext* aPresContext, const gfxFontStyle* aStyle, nsAtom* aLanguage = nullptr) - MOZ_REQUIRES(mLock) override; + REQUIRES(mLock) override; private: friend class gfxWindowsPlatform; gfxGDIFontList(); - nsresult GetFontSubstitutes() MOZ_REQUIRES(mLock); + nsresult GetFontSubstitutes() REQUIRES(mLock); static int CALLBACK EnumFontFamExProc(ENUMLOGFONTEXW* lpelfe, NEWTEXTMETRICEXW* lpntme, diff --git a/gfx/thebes/gfxGlyphExtents.h b/gfx/thebes/gfxGlyphExtents.h index 2dfed8868c8b..580573409864 100644 --- a/gfx/thebes/gfxGlyphExtents.h +++ b/gfx/thebes/gfxGlyphExtents.h @@ -149,8 +149,8 @@ class gfxGlyphExtents { nsTArray mBlocks; }; - GlyphWidths mContainedGlyphWidths MOZ_GUARDED_BY(mLock); - nsTHashtable mTightGlyphExtents MOZ_GUARDED_BY(mLock); + GlyphWidths mContainedGlyphWidths GUARDED_BY(mLock); + nsTHashtable mTightGlyphExtents GUARDED_BY(mLock); const int32_t mAppUnitsPerDevUnit; mutable mozilla::RWLock mLock; diff --git a/gfx/thebes/gfxMacPlatformFontList.h b/gfx/thebes/gfxMacPlatformFontList.h index 518c58d3afcd..2b7136938dd5 100644 --- a/gfx/thebes/gfxMacPlatformFontList.h +++ b/gfx/thebes/gfxMacPlatformFontList.h @@ -145,7 +145,7 @@ class gfxMacPlatformFontList final : public gfxPlatformFontList { const nsACString& aFamily, nsTArray* aOutput, FindFamiliesFlags aFlags, gfxFontStyle* aStyle = nullptr, nsAtom* aLanguage = nullptr, gfxFloat aDevToCssSize = 1.0) - MOZ_REQUIRES(mLock) override; + REQUIRES(mLock) override; // lookup the system font for a particular system font type and set // the name and style characteristics @@ -165,7 +165,7 @@ class gfxMacPlatformFontList final : public gfxPlatformFontList { FontFamily GetDefaultFontForPlatform(nsPresContext* aPresContext, const gfxFontStyle* aStyle, nsAtom* aLanguage = nullptr) - MOZ_REQUIRES(mLock) override; + REQUIRES(mLock) override; private: friend class gfxPlatformMac; @@ -174,23 +174,23 @@ class gfxMacPlatformFontList final : public gfxPlatformFontList { virtual ~gfxMacPlatformFontList(); // initialize font lists - nsresult InitFontListForPlatform() MOZ_REQUIRES(mLock) override; - void InitSharedFontListForPlatform() MOZ_REQUIRES(mLock) override; + nsresult InitFontListForPlatform() REQUIRES(mLock) override; + void InitSharedFontListForPlatform() REQUIRES(mLock) override; // handle commonly used fonts for which the name table should be loaded at // startup - void PreloadNamesList() MOZ_REQUIRES(mLock); + void PreloadNamesList() REQUIRES(mLock); // special case font faces treated as font families (set via prefs) - void InitSingleFaceList() MOZ_REQUIRES(mLock); - void InitAliasesForSingleFaceList() MOZ_REQUIRES(mLock); + void InitSingleFaceList() REQUIRES(mLock); + void InitAliasesForSingleFaceList() REQUIRES(mLock); // initialize system fonts - void InitSystemFontNames() MOZ_REQUIRES(mLock); + void InitSystemFontNames() REQUIRES(mLock); // helper function to lookup in both hidden system fonts and normal fonts gfxFontFamily* FindSystemFontFamily(const nsACString& aFamily) - MOZ_REQUIRES(mLock); + REQUIRES(mLock); FontVisibility GetVisibilityForFamily(const nsACString& aName) const; @@ -205,7 +205,7 @@ class gfxMacPlatformFontList final : public gfxPlatformFontList { Script aRunScript, const gfxFontStyle* aMatchStyle, FontFamily& aMatchedFamily) - MOZ_REQUIRES(mLock) override; + REQUIRES(mLock) override; bool UsesSystemFallback() override { return true; } @@ -216,10 +216,10 @@ class gfxMacPlatformFontList final : public gfxPlatformFontList { // file is included in .cpp files, so we can't use objective C classes here. // But CFStringRef and NSString* are the same thing anyway (they're // toll-free bridged). - void AddFamily(CFStringRef aFamily) MOZ_REQUIRES(mLock); + void AddFamily(CFStringRef aFamily) REQUIRES(mLock); void AddFamily(const nsACString& aFamilyName, FontVisibility aVisibility) - MOZ_REQUIRES(mLock); + REQUIRES(mLock); static void ActivateFontsFromDir( const nsACString& aDir, @@ -236,7 +236,7 @@ class gfxMacPlatformFontList final : public gfxPlatformFontList { void ReadFaceNamesForFamily(mozilla::fontlist::Family* aFamily, bool aNeedFullnamePostscriptNames) - MOZ_REQUIRES(mLock) override; + REQUIRES(mLock) override; #ifdef MOZ_BUNDLED_FONTS void ActivateBundledFonts(); diff --git a/gfx/thebes/gfxMacPlatformFontList.mm b/gfx/thebes/gfxMacPlatformFontList.mm index d7c92b5a1d8b..13e4d29d29cb 100644 --- a/gfx/thebes/gfxMacPlatformFontList.mm +++ b/gfx/thebes/gfxMacPlatformFontList.mm @@ -759,8 +759,7 @@ class gfxMacFontFamily final : public gfxFontFamily { void LocalizedName(nsACString& aLocalizedName) override; - void FindStyleVariationsLocked(FontInfoData* aFontInfoData = nullptr) - MOZ_REQUIRES(mLock) override; + void FindStyleVariationsLocked(FontInfoData* aFontInfoData = nullptr) REQUIRES(mLock) override; protected: double mSizeHint; @@ -930,8 +929,7 @@ class gfxSingleFaceMacFontFamily final : public gfxFontFamily { virtual ~gfxSingleFaceMacFontFamily() = default; - void FindStyleVariationsLocked(FontInfoData* aFontInfoData = nullptr) - MOZ_REQUIRES(mLock) override{}; + void FindStyleVariationsLocked(FontInfoData* aFontInfoData = nullptr) REQUIRES(mLock) override{}; void LocalizedName(nsACString& aLocalizedName) override; @@ -1133,7 +1131,7 @@ void gfxMacPlatformFontList::ActivateFontsFromDir(const nsACString& aDir, } void gfxMacPlatformFontList::ReadSystemFontList(dom::SystemFontList* aList) - MOZ_NO_THREAD_SAFETY_ANALYSIS { + NO_THREAD_SAFETY_ANALYSIS { // Note: We rely on the records for mSystemTextFontFamilyName and // mSystemDisplayFontFamilyName (if present) being *before* the main // font list, so that those names are known in the content process diff --git a/gfx/thebes/gfxPlatformFontList.h b/gfx/thebes/gfxPlatformFontList.h index ff38d314d760..c8200673e0d5 100644 --- a/gfx/thebes/gfxPlatformFontList.h +++ b/gfx/thebes/gfxPlatformFontList.h @@ -271,7 +271,7 @@ class gfxPlatformFontList : public gfxFontInfoLoader { AutoLock lock(mLock); ClearLangGroupPrefFontsLocked(); } - virtual void ClearLangGroupPrefFontsLocked() MOZ_REQUIRES(mLock); + virtual void ClearLangGroupPrefFontsLocked() REQUIRES(mLock); void GetFontFamilyList(nsTArray>& aFamilyArray); @@ -326,7 +326,7 @@ class gfxPlatformFontList : public gfxFontInfoLoader { const nsACString& aFamily, nsTArray* aOutput, FindFamiliesFlags aFlags, gfxFontStyle* aStyle = nullptr, nsAtom* aLanguage = nullptr, gfxFloat aDevToCssSize = 1.0) - MOZ_REQUIRES(mLock); + REQUIRES(mLock); gfxFontEntry* FindFontForFamily(nsPresContext* aPresContext, const nsACString& aFamily, @@ -394,7 +394,7 @@ class gfxPlatformFontList : public gfxFontInfoLoader { AddFullnameLocked(aFontEntry, aFullname); } void AddFullnameLocked(gfxFontEntry* aFontEntry, const nsCString& aFullname) - MOZ_REQUIRES(mLock); + REQUIRES(mLock); void AddPostscriptName(gfxFontEntry* aFontEntry, const nsCString& aPostscriptName) { @@ -403,7 +403,7 @@ class gfxPlatformFontList : public gfxFontInfoLoader { } void AddPostscriptNameLocked(gfxFontEntry* aFontEntry, const nsCString& aPostscriptName) - MOZ_REQUIRES(mLock); + REQUIRES(mLock); bool NeedFullnamePostscriptNames() { return mExtraNames != nullptr; } @@ -427,8 +427,7 @@ class gfxPlatformFontList : public gfxFontInfoLoader { FontFamily GetDefaultFont(nsPresContext* aPresContext, const gfxFontStyle* aStyle); FontFamily GetDefaultFontLocked(nsPresContext* aPresContext, - const gfxFontStyle* aStyle) - MOZ_REQUIRES(mLock); + const gfxFontStyle* aStyle) REQUIRES(mLock); // get the "ultimate" default font, for use if the font list is otherwise // unusable (e.g. in the middle of being updated) @@ -493,7 +492,7 @@ class gfxPlatformFontList : public gfxFontInfoLoader { return GetShmemCharMapLocked(aCmap); } mozilla::fontlist::Pointer GetShmemCharMapLocked(const gfxSparseBitSet* aCmap) - MOZ_REQUIRES(mLock); + REQUIRES(mLock); // Search for existing cmap that matches the input; return the input if no // match is found. @@ -538,9 +537,9 @@ class gfxPlatformFontList : public gfxFontInfoLoader { } gfxFontEntry* GetOrCreateFontEntryLocked( mozilla::fontlist::Face* aFace, const mozilla::fontlist::Family* aFamily) - MOZ_REQUIRES(mLock); + REQUIRES(mLock); - const FontPrefs* GetFontPrefs() const MOZ_REQUIRES(mLock) { + const FontPrefs* GetFontPrefs() const REQUIRES(mLock) { return mFontPrefs.get(); } @@ -557,7 +556,7 @@ class gfxPlatformFontList : public gfxFontInfoLoader { } PrefFontList* GetPrefFontsLangGroupLocked( nsPresContext* aPresContext, mozilla::StyleGenericFontFamily aGenericType, - eFontPrefLang aPrefLang) MOZ_REQUIRES(mLock); + eFontPrefLang aPrefLang) REQUIRES(mLock); // in some situations, need to make decisions about ambiguous characters, may // need to look at multiple pref langs @@ -620,7 +619,7 @@ class gfxPlatformFontList : public gfxFontInfoLoader { FontVisibility aVisibility) const; // (Re-)initialize the set of codepoints that we know cannot be rendered. - void InitializeCodepointsWithNoFonts() MOZ_REQUIRES(mLock); + void InitializeCodepointsWithNoFonts() REQUIRES(mLock); // If using the shared font list, returns a generation count that is // incremented if/when the platform list is reinitialized (e.g. because @@ -635,8 +634,8 @@ class gfxPlatformFontList : public gfxFontInfoLoader { return PR_GetCurrentThread() == sInitFontListThread; } - void Lock() MOZ_CAPABILITY_ACQUIRE(mLock) { mLock.Lock(); } - void Unlock() MOZ_CAPABILITY_RELEASE(mLock) { mLock.Unlock(); } + void Lock() CAPABILITY_ACQUIRE(mLock) { mLock.Lock(); } + void Unlock() CAPABILITY_RELEASE(mLock) { mLock.Unlock(); } // This is only public because some external callers want to be able to // assert about the locked status. @@ -741,13 +740,13 @@ class gfxPlatformFontList : public gfxFontInfoLoader { nsPresContext* aPresContext, const nsACString& aFamily, FindFamiliesFlags aFlags = FindFamiliesFlags(0), gfxFontStyle* aStyle = nullptr, nsAtom* aLanguage = nullptr, - gfxFloat aDevToCssSize = 1.0) MOZ_REQUIRES(mLock); + gfxFloat aDevToCssSize = 1.0) REQUIRES(mLock); gfxFontFamily* FindUnsharedFamily( nsPresContext* aPresContext, const nsACString& aFamily, FindFamiliesFlags aFlags = FindFamiliesFlags(0), gfxFontStyle* aStyle = nullptr, nsAtom* aLanguage = nullptr, - gfxFloat aDevToCssSize = 1.0) MOZ_REQUIRES(mLock) { + gfxFloat aDevToCssSize = 1.0) REQUIRES(mLock) { if (SharedFontList()) { return nullptr; } @@ -764,7 +763,7 @@ class gfxPlatformFontList : public gfxFontInfoLoader { FindFamiliesFlags aFlags = FindFamiliesFlags(0), gfxFontStyle* aStyle = nullptr, nsAtom* aLanguage = nullptr, - gfxFloat aDevToCssSize = 1.0) MOZ_REQUIRES(mLock) { + gfxFloat aDevToCssSize = 1.0) REQUIRES(mLock) { if (SharedFontList()) { return FontFamily(FindSharedFamily(aPresContext, aFamily, aFlags, aStyle, aLanguage, aDevToCssSize)); @@ -776,7 +775,7 @@ class gfxPlatformFontList : public gfxFontInfoLoader { // Lookup family name in global family list without substitutions or // localized family name lookup. Used for common font fallback families. gfxFontFamily* FindFamilyByCanonicalName(const nsACString& aFamily) - MOZ_REQUIRES(mLock) { + REQUIRES(mLock) { nsAutoCString key; gfxFontFamily* familyEntry; GenerateFontListKey(aFamily, key); @@ -793,14 +792,14 @@ class gfxPlatformFontList : public gfxFontInfoLoader { eFontPresentation aPresentation, const gfxFontStyle* aMatchStyle, FontFamily& aMatchedFamily) - MOZ_REQUIRES(mLock); + REQUIRES(mLock); // Search fonts system-wide for a given character, null if not found. already_AddRefed GlobalFontFallback( nsPresContext* aPresContext, uint32_t aCh, uint32_t aNextCh, Script aRunScript, eFontPresentation aPresentation, const gfxFontStyle* aMatchStyle, uint32_t& aCmapCount, - FontFamily& aMatchedFamily) MOZ_REQUIRES(mLock); + FontFamily& aMatchedFamily) REQUIRES(mLock); // Platform-specific implementation of global font fallback, if any; // this may return nullptr in which case the default cmap-based fallback @@ -817,37 +816,37 @@ class gfxPlatformFontList : public gfxFontInfoLoader { void AppendCJKPrefLangs(eFontPrefLang aPrefLangs[], uint32_t& aLen, eFontPrefLang aCharLang, eFontPrefLang aPageLang) - MOZ_REQUIRES(mLock); + REQUIRES(mLock); // verifies that a family contains a non-zero font count - gfxFontFamily* CheckFamily(gfxFontFamily* aFamily) MOZ_REQUIRES(mLock); + gfxFontFamily* CheckFamily(gfxFontFamily* aFamily) REQUIRES(mLock); // initialize localized family names void InitOtherFamilyNamesInternal(bool aDeferOtherFamilyNamesLoading); void CancelInitOtherFamilyNamesTask(); - void AddToMissedNames(const nsCString& aKey) MOZ_REQUIRES(mLock); + void AddToMissedNames(const nsCString& aKey) REQUIRES(mLock); // search through font families, looking for a given name, initializing // facename lists along the way. first checks all families with names // close to face name, then searchs all families if not found. gfxFontEntry* SearchFamiliesForFaceName(const nsACString& aFaceName) - MOZ_REQUIRES(mLock); + REQUIRES(mLock); // helper method for finding fullname/postscript names in facename lists - gfxFontEntry* FindFaceName(const nsACString& aFaceName) MOZ_REQUIRES(mLock); + gfxFontEntry* FindFaceName(const nsACString& aFaceName) REQUIRES(mLock); // look up a font by name, for cases where platform font list // maintains explicit mappings of fullname/psname ==> font virtual gfxFontEntry* LookupInFaceNameLists(const nsACString& aFaceName) - MOZ_REQUIRES(mLock); + REQUIRES(mLock); gfxFontEntry* LookupInSharedFaceNameList(nsPresContext* aPresContext, const nsACString& aFaceName, WeightRange aWeightForEntry, StretchRange aStretchForEntry, SlantStyleRange aStyleForEntry) - MOZ_REQUIRES(mLock); + REQUIRES(mLock); // load the bad underline blocklist from pref. void LoadBadUnderlineList(); @@ -855,13 +854,13 @@ class gfxPlatformFontList : public gfxFontInfoLoader { void GenerateFontListKey(const nsACString& aKeyName, nsACString& aResult); virtual void GetFontFamilyNames(nsTArray& aFontFamilyNames) - MOZ_REQUIRES(mLock); + REQUIRES(mLock); // helper function to map lang to lang group nsAtom* GetLangGroup(nsAtom* aLanguage); // gfxFontInfoLoader overrides, used to load in font cmaps - void InitLoader() MOZ_REQUIRES(mLock) override; + void InitLoader() REQUIRES(mLock) override; bool LoadFontInfo() override; void CleanupLoader() override; @@ -871,25 +870,23 @@ class gfxPlatformFontList : public gfxFontInfoLoader { // If aForgetLocalFaces is true, all gfxFontEntries for src:local fonts must // be discarded (not potentially reused to satisfy the rebuilt rules), // because they may no longer be valid. - void RebuildLocalFonts(bool aForgetLocalFaces = false) MOZ_REQUIRES(mLock); + void RebuildLocalFonts(bool aForgetLocalFaces = false) REQUIRES(mLock); void ResolveGenericFontNames(nsPresContext* aPresContext, mozilla::StyleGenericFontFamily aGenericType, eFontPrefLang aPrefLang, - PrefFontList* aGenericFamilies) - MOZ_REQUIRES(mLock); + PrefFontList* aGenericFamilies) REQUIRES(mLock); void ResolveEmojiFontNames(nsPresContext* aPresContext, - PrefFontList* aGenericFamilies) - MOZ_REQUIRES(mLock); + PrefFontList* aGenericFamilies) REQUIRES(mLock); void GetFontFamiliesFromGenericFamilies( nsPresContext* aPresContext, mozilla::StyleGenericFontFamily aGenericType, nsTArray& aGenericNameFamilies, nsAtom* aLangGroup, - PrefFontList* aFontFamilies) MOZ_REQUIRES(mLock); + PrefFontList* aFontFamilies) REQUIRES(mLock); - virtual nsresult InitFontListForPlatform() MOZ_REQUIRES(mLock) = 0; - virtual void InitSharedFontListForPlatform() MOZ_REQUIRES(mLock) {} + virtual nsresult InitFontListForPlatform() REQUIRES(mLock) = 0; + virtual void InitSharedFontListForPlatform() REQUIRES(mLock) {} virtual gfxFontEntry* CreateFontEntry( mozilla::fontlist::Face* aFace, @@ -904,7 +901,7 @@ class gfxPlatformFontList : public gfxFontInfoLoader { * There are separate implementations of this for the per-process font list * and for the shared-memory font list. */ - void ApplyWhitelist() MOZ_REQUIRES(mLock); + void ApplyWhitelist() REQUIRES(mLock); void ApplyWhitelist(nsTArray& aFamilies); // Create a new gfxFontFamily of the appropriate subclass for the platform, @@ -924,7 +921,7 @@ class gfxPlatformFontList : public gfxFontInfoLoader { */ virtual void ReadFaceNamesForFamily(mozilla::fontlist::Family* aFamily, bool aNeedFullnamePostscriptNames) - MOZ_REQUIRES(mLock) {} + REQUIRES(mLock) {} typedef nsRefPtrHashtable FontFamilyTable; typedef nsRefPtrHashtable FontEntryTable; @@ -939,14 +936,14 @@ class gfxPlatformFontList : public gfxFontInfoLoader { virtual FontFamily GetDefaultFontForPlatform(nsPresContext* aPresContext, const gfxFontStyle* aStyle, nsAtom* aLanguage = nullptr) - MOZ_REQUIRES(mLock) = 0; + REQUIRES(mLock) = 0; // canonical family name ==> family entry (unique, one name per family entry) - FontFamilyTable mFontFamilies MOZ_GUARDED_BY(mLock); + FontFamilyTable mFontFamilies GUARDED_BY(mLock); // other family name ==> family entry (not unique, can have multiple names per // family entry, only names *other* than the canonical names are stored here) - FontFamilyTable mOtherFamilyNames MOZ_GUARDED_BY(mLock); + FontFamilyTable mOtherFamilyNames GUARDED_BY(mLock); // flag set after InitOtherFamilyNames is called upon first name lookup miss mozilla::Atomic mOtherFamilyNamesInitialized; @@ -968,15 +965,13 @@ class gfxPlatformFontList : public gfxFontInfoLoader { // The lock is needed to guard access to the actual name tables, but does not // need to be held to just test whether mExtraNames is non-null as it is set // during initialization before other threads have a chance to see it. - mozilla::UniquePtr mExtraNames MOZ_PT_GUARDED_BY(mLock); + mozilla::UniquePtr mExtraNames PT_GUARDED_BY(mLock); // face names missed when face name loading takes a long time - mozilla::UniquePtr> mFaceNamesMissed - MOZ_GUARDED_BY(mLock); + mozilla::UniquePtr> mFaceNamesMissed GUARDED_BY(mLock); // localized family names missed when face name loading takes a long time - mozilla::UniquePtr> mOtherNamesMissed - MOZ_GUARDED_BY(mLock); + mozilla::UniquePtr> mOtherNamesMissed GUARDED_BY(mLock); typedef mozilla::RangedArray, size_t(mozilla::StyleGenericFontFamily::None), @@ -985,28 +980,28 @@ class gfxPlatformFontList : public gfxFontInfoLoader { PrefFontsForLangGroup; mozilla::RangedArray - mLangGroupPrefFonts MOZ_GUARDED_BY(mLock); - mozilla::UniquePtr mEmojiPrefFont MOZ_GUARDED_BY(mLock); + mLangGroupPrefFonts GUARDED_BY(mLock); + mozilla::UniquePtr mEmojiPrefFont GUARDED_BY(mLock); // When system-wide font lookup fails for a character, cache it to skip future // searches. This is an array of bitsets, one for each FontVisibility level. mozilla::EnumeratedArray - mCodepointsWithNoFonts MOZ_GUARDED_BY(mLock); + mCodepointsWithNoFonts GUARDED_BY(mLock); // the family to use for U+FFFD fallback, to avoid expensive search every time // on pages with lots of problems mozilla::EnumeratedArray - mReplacementCharFallbackFamily MOZ_GUARDED_BY(mLock); + mReplacementCharFallbackFamily GUARDED_BY(mLock); // Sorted array of lowercased family names; use ContainsSorted to test nsTArray mBadUnderlineFamilyNames; // character map data shared across families // contains weak ptrs to cmaps shared by font entry objects - nsTHashtable mSharedCmaps MOZ_GUARDED_BY(mLock); + nsTHashtable mSharedCmaps GUARDED_BY(mLock); - nsTHashtable mShmemCharMaps MOZ_GUARDED_BY(mLock); + nsTHashtable mShmemCharMaps GUARDED_BY(mLock); // data used as part of the font cmap loading process nsTArray> mFontFamiliesToLoad; @@ -1017,13 +1012,13 @@ class gfxPlatformFontList : public gfxFontInfoLoader { // see bugs 636957, 1070983, 1189129 uint32_t mFontlistInitCount = 0; // num times InitFontList called - nsTHashSet mUserFontSetList MOZ_GUARDED_BY(mLock); + nsTHashSet mUserFontSetList GUARDED_BY(mLock); nsLanguageAtomService* mLangService = nullptr; - nsTArray mCJKPrefLangs MOZ_GUARDED_BY(mLock); + nsTArray mCJKPrefLangs GUARDED_BY(mLock); nsTArray mDefaultGenericsLangGroup - MOZ_GUARDED_BY(mLock); + GUARDED_BY(mLock); nsTArray mEnabledFontsList; @@ -1034,11 +1029,11 @@ class gfxPlatformFontList : public gfxFontInfoLoader { mLocalNameTable; nsRefPtrHashtable, gfxFontEntry> - mFontEntries MOZ_GUARDED_BY(mLock); + mFontEntries GUARDED_BY(mLock); mozilla::UniquePtr mFontPrefs; - RefPtr mDefaultFontEntry MOZ_GUARDED_BY(mLock); + RefPtr mDefaultFontEntry GUARDED_BY(mLock); RefPtr mLoadCmapsRunnable; uint32_t mStartedLoadingCmapsFrom = 0xffffffffu; diff --git a/image/DecodePool.h b/image/DecodePool.h index 5ae9785f8cb8..f324131d92c8 100644 --- a/image/DecodePool.h +++ b/image/DecodePool.h @@ -99,7 +99,7 @@ class DecodePool final : public nsIObserver { // mMutex protects mIOThread. Mutex mMutex; - nsCOMPtr mIOThread MOZ_GUARDED_BY(mMutex); + nsCOMPtr mIOThread GUARDED_BY(mMutex); }; } // namespace image diff --git a/image/SourceBuffer.h b/image/SourceBuffer.h index 79188fb88227..40063e18697d 100644 --- a/image/SourceBuffer.h +++ b/image/SourceBuffer.h @@ -438,19 +438,19 @@ class SourceBuffer final { char* mData; }; - nsresult AppendChunk(Maybe&& aChunk) MOZ_REQUIRES(mMutex); + nsresult AppendChunk(Maybe&& aChunk) REQUIRES(mMutex); Maybe CreateChunk(size_t aCapacity, size_t aExistingCapacity = 0, bool aRoundUp = true); - nsresult Compact() MOZ_REQUIRES(mMutex); + nsresult Compact() REQUIRES(mMutex); static size_t RoundedUpCapacity(size_t aCapacity); - size_t FibonacciCapacityWithMinimum(size_t aMinCapacity) MOZ_REQUIRES(mMutex); + size_t FibonacciCapacityWithMinimum(size_t aMinCapacity) REQUIRES(mMutex); ////////////////////////////////////////////////////////////////////////////// // Iterator / consumer methods. ////////////////////////////////////////////////////////////////////////////// - void AddWaitingConsumer(IResumable* aConsumer) MOZ_REQUIRES(mMutex); - void ResumeWaitingConsumers() MOZ_REQUIRES(mMutex); + void AddWaitingConsumer(IResumable* aConsumer) REQUIRES(mMutex); + void ResumeWaitingConsumers() REQUIRES(mMutex); typedef SourceBufferIterator::State State; @@ -466,9 +466,9 @@ class SourceBuffer final { // Helper methods. ////////////////////////////////////////////////////////////////////////////// - nsresult HandleError(nsresult aError) MOZ_REQUIRES(mMutex); - bool IsEmpty() MOZ_REQUIRES(mMutex); - bool IsLastChunk(uint32_t aChunk) MOZ_REQUIRES(mMutex); + nsresult HandleError(nsresult aError) REQUIRES(mMutex); + bool IsEmpty() REQUIRES(mMutex); + bool IsLastChunk(uint32_t aChunk) REQUIRES(mMutex); ////////////////////////////////////////////////////////////////////////////// // Member variables. @@ -478,19 +478,19 @@ class SourceBuffer final { mutable Mutex mMutex; /// The data in this SourceBuffer, stored as a series of Chunks. - AutoTArray mChunks MOZ_GUARDED_BY(mMutex); + AutoTArray mChunks GUARDED_BY(mMutex); /// Consumers which are waiting to be notified when new data is available. - nsTArray> mWaitingConsumers MOZ_GUARDED_BY(mMutex); + nsTArray> mWaitingConsumers GUARDED_BY(mMutex); /// If present, marks this SourceBuffer complete with the given final status. - Maybe mStatus MOZ_GUARDED_BY(mMutex); + Maybe mStatus GUARDED_BY(mMutex); /// Count of active consumers. - uint32_t mConsumerCount MOZ_GUARDED_BY(mMutex); + uint32_t mConsumerCount GUARDED_BY(mMutex); /// True if compacting has been performed. - bool mCompacted MOZ_GUARDED_BY(mMutex); + bool mCompacted GUARDED_BY(mMutex); }; } // namespace image diff --git a/image/imgFrame.h b/image/imgFrame.h index c0049c36ca55..267ad652150b 100644 --- a/image/imgFrame.h +++ b/image/imgFrame.h @@ -185,7 +185,7 @@ class imgFrame { private: // methods ~imgFrame(); - bool AreAllPixelsWritten() const MOZ_REQUIRES(mMonitor); + bool AreAllPixelsWritten() const REQUIRES(mMonitor); nsresult ImageUpdatedInternal(const nsIntRect& aUpdateRect); void GetImageDataInternal(uint8_t** aData, uint32_t* length) const; uint32_t GetImageBytesPerRow() const; @@ -229,20 +229,20 @@ class imgFrame { /** * Used for rasterized images, this contains the raw pixel data. */ - RefPtr mRawSurface MOZ_GUARDED_BY(mMonitor); - RefPtr mBlankRawSurface MOZ_GUARDED_BY(mMonitor); + RefPtr mRawSurface GUARDED_BY(mMonitor); + RefPtr mBlankRawSurface GUARDED_BY(mMonitor); /** * Used for vector images that were not rasterized directly. This might be a * blob recording or native surface. */ - RefPtr mOptSurface MOZ_GUARDED_BY(mMonitor); + RefPtr mOptSurface GUARDED_BY(mMonitor); - nsIntRect mDecoded MOZ_GUARDED_BY(mMonitor); + nsIntRect mDecoded GUARDED_BY(mMonitor); - bool mAborted MOZ_GUARDED_BY(mMonitor); - bool mFinished MOZ_GUARDED_BY(mMonitor); - bool mShouldRecycle MOZ_GUARDED_BY(mMonitor); + bool mAborted GUARDED_BY(mMonitor); + bool mFinished GUARDED_BY(mMonitor); + bool mShouldRecycle GUARDED_BY(mMonitor); ////////////////////////////////////////////////////////////////////////////// // Effectively const data, only mutated in the Init methods. diff --git a/image/imgLoader.h b/image/imgLoader.h index 6e761a4a14ed..e55442df6ce4 100644 --- a/image/imgLoader.h +++ b/image/imgLoader.h @@ -413,7 +413,7 @@ class imgLoader final : public imgILoader, // mChromeCache. The union over all imgLoader's of mCache, mChromeCache, and // mUncachedImages should be every imgRequest that is alive. These are weak // pointers so we rely on the imgRequest destructor to remove itself. - imgSet mUncachedImages MOZ_GUARDED_BY(mUncachedImagesMutex); + imgSet mUncachedImages GUARDED_BY(mUncachedImagesMutex); // The imgRequest can have refs to them held on non-main thread, so we need // a mutex because we modify the uncached images set from the imgRequest // destructor. diff --git a/image/imgRequest.cpp b/image/imgRequest.cpp index e866a52b8b00..fb80d42264f5 100644 --- a/image/imgRequest.cpp +++ b/image/imgRequest.cpp @@ -90,7 +90,7 @@ nsresult imgRequest::Init( nsIRequest* aRequest, nsIChannel* aChannel, imgCacheEntry* aCacheEntry, mozilla::dom::Document* aLoadingDocument, nsIPrincipal* aTriggeringPrincipal, mozilla::CORSMode aCORSMode, - nsIReferrerInfo* aReferrerInfo) MOZ_NO_THREAD_SAFETY_ANALYSIS { + nsIReferrerInfo* aReferrerInfo) NO_THREAD_SAFETY_ANALYSIS { MOZ_ASSERT(NS_IsMainThread(), "Cannot use nsIURI off main thread!"); // Init() can only be called once, and that's before it can be used off // mainthread diff --git a/image/imgRequest.h b/image/imgRequest.h index 2658d746a73d..38d17edad57d 100644 --- a/image/imgRequest.h +++ b/image/imgRequest.h @@ -285,15 +285,15 @@ class imgRequest final : public nsIStreamListener, // Member variables protected by mMutex. Note that *all* flags in our bitfield // are protected by mMutex; if you're adding a new flag that isn'protected, it // must not be a part of this bitfield. - RefPtr mProgressTracker MOZ_GUARDED_BY(mMutex); - RefPtr mImage MOZ_GUARDED_BY(mMutex); - bool mIsMultiPartChannel : 1 MOZ_GUARDED_BY(mMutex); - bool mIsInCache : 1 MOZ_GUARDED_BY(mMutex); - bool mDecodeRequested : 1 MOZ_GUARDED_BY(mMutex); - bool mNewPartPending : 1 MOZ_GUARDED_BY(mMutex); - bool mHadInsecureRedirect : 1 MOZ_GUARDED_BY(mMutex); + RefPtr mProgressTracker GUARDED_BY(mMutex); + RefPtr mImage GUARDED_BY(mMutex); + bool mIsMultiPartChannel : 1 GUARDED_BY(mMutex); + bool mIsInCache : 1 GUARDED_BY(mMutex); + bool mDecodeRequested : 1 GUARDED_BY(mMutex); + bool mNewPartPending : 1 GUARDED_BY(mMutex); + bool mHadInsecureRedirect : 1 GUARDED_BY(mMutex); // The ID of the inner window origin, used for error reporting. - uint64_t mInnerWindowId MOZ_GUARDED_BY(mMutex); + uint64_t mInnerWindowId GUARDED_BY(mMutex); }; #endif // mozilla_image_imgRequest_h diff --git a/ipc/chromium/src/base/at_exit.h b/ipc/chromium/src/base/at_exit.h index 268d9e0fbece..25a51c1cdfb1 100644 --- a/ipc/chromium/src/base/at_exit.h +++ b/ipc/chromium/src/base/at_exit.h @@ -65,7 +65,7 @@ class AtExitManager { }; mozilla::Mutex lock_; - std::stack stack_ MOZ_GUARDED_BY(lock_); + std::stack stack_ GUARDED_BY(lock_); AtExitManager* next_manager_; // Stack of managers to allow shadowing. DISALLOW_COPY_AND_ASSIGN(AtExitManager); diff --git a/ipc/chromium/src/base/message_loop.cc b/ipc/chromium/src/base/message_loop.cc index 1fe853c408f0..425d6c4ebcd1 100644 --- a/ipc/chromium/src/base/message_loop.cc +++ b/ipc/chromium/src/base/message_loop.cc @@ -137,10 +137,9 @@ class MessageLoop::EventTarget : public nsISerialEventTarget, } mozilla::Mutex mMutex; - bool mShutdownTasksRun MOZ_GUARDED_BY(mMutex) = false; - nsTArray> mShutdownTasks - MOZ_GUARDED_BY(mMutex); - MessageLoop* mLoop MOZ_GUARDED_BY(mMutex); + bool mShutdownTasksRun GUARDED_BY(mMutex) = false; + nsTArray> mShutdownTasks GUARDED_BY(mMutex); + MessageLoop* mLoop GUARDED_BY(mMutex); }; NS_IMPL_ISUPPORTS(MessageLoop::EventTarget, nsIEventTarget, diff --git a/ipc/chromium/src/base/message_loop.h b/ipc/chromium/src/base/message_loop.h index b6e4938ee01f..41c86ac54063 100644 --- a/ipc/chromium/src/base/message_loop.h +++ b/ipc/chromium/src/base/message_loop.h @@ -420,7 +420,7 @@ class MessageLoop : public base::MessagePump::Delegate { // aquired under a mutex for processing on this instance's thread. These tasks // have not yet been sorted out into items for our work_queue_ vs items that // will be handled by the TimerManager. - TaskQueue incoming_queue_ MOZ_GUARDED_BY(incoming_queue_lock_); + TaskQueue incoming_queue_ GUARDED_BY(incoming_queue_lock_); // Protect access to incoming_queue_. mozilla::Mutex incoming_queue_lock_; diff --git a/ipc/chromium/src/base/time_win.cc b/ipc/chromium/src/base/time_win.cc index d39416cd6dc2..36d3894bd04c 100644 --- a/ipc/chromium/src/base/time_win.cc +++ b/ipc/chromium/src/base/time_win.cc @@ -246,11 +246,11 @@ class NowSingleton { : rollover_(TimeDelta::FromMilliseconds(0)), last_seen_(0) {} ~NowSingleton() = default; - TimeDelta rollover_ MOZ_GUARDED_BY( + TimeDelta rollover_ GUARDED_BY( sNowSingletonLock); // Accumulation of time lost due to rollover. DWORD last_seen_ - MOZ_GUARDED_BY(sNowSingletonLock); // The last timeGetTime value we saw, - // to detect rollover. + GUARDED_BY(sNowSingletonLock); // The last timeGetTime value we saw, to + // detect rollover. DISALLOW_COPY_AND_ASSIGN(NowSingleton); }; diff --git a/ipc/chromium/src/mojo/core/ports/node.h b/ipc/chromium/src/mojo/core/ports/node.h index 67540081770d..e0491834ccd4 100644 --- a/ipc/chromium/src/mojo/core/ports/node.h +++ b/ipc/chromium/src/mojo/core/ports/node.h @@ -226,7 +226,7 @@ class Node { void ConvertToProxy(Port* port, const NodeName& to_node_name, PortName* port_name, Event::PortDescriptor* port_descriptor) - MOZ_REQUIRES(ports_lock_); + REQUIRES(ports_lock_); int AcceptPort(const PortName& port_name, const Event::PortDescriptor& port_descriptor); @@ -249,19 +249,19 @@ class Node { void UpdatePortPeerAddress(const PortName& local_port_name, Port* local_port, const NodeName& new_peer_node, const PortName& new_peer_port) - MOZ_REQUIRES(ports_lock_); + REQUIRES(ports_lock_); // Removes an entry from |peer_port_map_| corresponding to |local_port|'s peer // address, if valid. void RemoveFromPeerPortMap(const PortName& local_port_name, Port* local_port) - MOZ_REQUIRES(ports_lock_); + REQUIRES(ports_lock_); // Swaps the peer information for two local ports. Used during port merges. // Note that |ports_lock_| must be held along with each of the two port's own // locks, through the extent of this method. void SwapPortPeers(const PortName& port0_name, Port* port0, const PortName& port1_name, Port* port1) - MOZ_REQUIRES(ports_lock_); + REQUIRES(ports_lock_); // Sends an acknowledge request to the peer if the port has a non-zero // |sequence_num_acknowledge_interval|. This needs to be done when the port's @@ -296,7 +296,7 @@ class Node { // destroyed while this (or any individual Port) lock is held. mozilla::Mutex ports_lock_{"Ports Lock"}; std::unordered_map> ports_ - MOZ_GUARDED_BY(ports_lock_); + GUARDED_BY(ports_lock_); // Maps a peer port name to a list of PortRefs for all local ports which have // the port name key designated as their peer port. The set of local ports @@ -316,7 +316,7 @@ class Node { // port on a peer node. The key to this map is the corresponding peer node // name. std::unordered_map peer_port_maps_ - MOZ_GUARDED_BY(ports_lock_); + GUARDED_BY(ports_lock_); }; } // namespace ports diff --git a/ipc/chromium/src/mojo/core/ports/port.h b/ipc/chromium/src/mojo/core/ports/port.h index c55f062be5eb..6dfa45b2313b 100644 --- a/ipc/chromium/src/mojo/core/ports/port.h +++ b/ipc/chromium/src/mojo/core/ports/port.h @@ -28,9 +28,9 @@ namespace detail { // Ports cannot use mozilla::Mutex, as the acquires-before relationships handled // by PortLocker can overload the debug-only deadlock detector. -class MOZ_CAPABILITY PortMutex : private ::mozilla::detail::MutexImpl { +class CAPABILITY PortMutex : private ::mozilla::detail::MutexImpl { public: - void AssertCurrentThreadOwns() const MOZ_ASSERT_CAPABILITY(this) { + void AssertCurrentThreadOwns() const ASSERT_CAPABILITY(this) { #ifdef DEBUG MOZ_ASSERT(mOwningThread == PR_GetCurrentThread()); #endif @@ -40,13 +40,13 @@ class MOZ_CAPABILITY PortMutex : private ::mozilla::detail::MutexImpl { // PortMutex should only be locked/unlocked via PortLocker friend class ::mojo::core::ports::PortLocker; - void Lock() MOZ_CAPABILITY_ACQUIRE() { + void Lock() CAPABILITY_ACQUIRE() { ::mozilla::detail::MutexImpl::lock(); #ifdef DEBUG mOwningThread = PR_GetCurrentThread(); #endif } - void Unlock() MOZ_CAPABILITY_RELEASE() { + void Unlock() CAPABILITY_RELEASE() { #ifdef DEBUG MOZ_ASSERT(mOwningThread == PR_GetCurrentThread()); mOwningThread = nullptr; diff --git a/ipc/glue/AsyncBlockers.h b/ipc/glue/AsyncBlockers.h index 141398fa5093..26b643602912 100644 --- a/ipc/glue/AsyncBlockers.h +++ b/ipc/glue/AsyncBlockers.h @@ -78,7 +78,7 @@ class AsyncBlockers { } private: - void MaybeResolve() MOZ_REQUIRES(mLock) { + void MaybeResolve() REQUIRES(mLock) { mLock.AssertCurrentThreadOwns(); if (mResolved) { return; @@ -90,8 +90,8 @@ class AsyncBlockers { mResolved = true; } Mutex mLock; - nsTArray mBlockers MOZ_GUARDED_BY(mLock); - bool mResolved MOZ_GUARDED_BY(mLock) = false; + nsTArray mBlockers GUARDED_BY(mLock); + bool mResolved GUARDED_BY(mLock) = false; const RefPtr mPromise; }; diff --git a/ipc/glue/BrowserProcessSubThread.h b/ipc/glue/BrowserProcessSubThread.h index 9be8d1ec3d27..c3f5eb573cd1 100644 --- a/ipc/glue/BrowserProcessSubThread.h +++ b/ipc/glue/BrowserProcessSubThread.h @@ -51,8 +51,7 @@ class BrowserProcessSubThread : public base::Thread { // The threads are not owned by this array. Typically, the threads are owned // on the UI thread by the g_browser_process object. ChromeThreads remove // themselves from this array upon destruction. - static BrowserProcessSubThread* sBrowserThreads[ID_COUNT] MOZ_GUARDED_BY( - sLock); + static BrowserProcessSubThread* sBrowserThreads[ID_COUNT] GUARDED_BY(sLock); }; inline void AssertIOThread() { diff --git a/ipc/glue/CrashReporterClient.h b/ipc/glue/CrashReporterClient.h index 26ada18a0307..099a1e8e2e5f 100644 --- a/ipc/glue/CrashReporterClient.h +++ b/ipc/glue/CrashReporterClient.h @@ -41,8 +41,7 @@ class CrashReporterClient { private: static StaticMutex sLock; - static StaticRefPtr sClientSingleton - MOZ_GUARDED_BY(sLock); + static StaticRefPtr sClientSingleton GUARDED_BY(sLock); }; } // namespace ipc diff --git a/ipc/glue/DataPipe.cpp b/ipc/glue/DataPipe.cpp index b7b21643c76f..d6b4c6ee0812 100644 --- a/ipc/glue/DataPipe.cpp +++ b/ipc/glue/DataPipe.cpp @@ -25,9 +25,9 @@ namespace data_pipe_detail { // Helper for queueing up actions to be run once the mutex has been unlocked. // Actions will be run in-order. -class MOZ_SCOPED_CAPABILITY DataPipeAutoLock { +class SCOPED_CAPABILITY DataPipeAutoLock { public: - explicit DataPipeAutoLock(Mutex& aMutex) MOZ_CAPABILITY_ACQUIRE(aMutex) + explicit DataPipeAutoLock(Mutex& aMutex) CAPABILITY_ACQUIRE(aMutex) : mMutex(aMutex) { mMutex.Lock(); } @@ -39,7 +39,7 @@ class MOZ_SCOPED_CAPABILITY DataPipeAutoLock { mActions.AppendElement(std::move(aAction)); } - ~DataPipeAutoLock() MOZ_CAPABILITY_RELEASE() { + ~DataPipeAutoLock() CAPABILITY_RELEASE() { mMutex.Unlock(); for (auto& action : mActions) { action(); @@ -82,7 +82,7 @@ class DataPipeLink : public NodeController::PortObserver { mOffset(aOffset), mAvailable(aAvailable) {} - void Init() MOZ_EXCLUDES(*mMutex) { + void Init() EXCLUDES(*mMutex) { { DataPipeAutoLock lock(*mMutex); if (NS_FAILED(mPeerStatus)) { @@ -94,18 +94,18 @@ class DataPipeLink : public NodeController::PortObserver { OnPortStatusChanged(); } - void OnPortStatusChanged() final MOZ_EXCLUDES(*mMutex); + void OnPortStatusChanged() final EXCLUDES(*mMutex); // Add a task to notify the callback after `aLock` is unlocked. // // This method is safe to call multiple times, as after the first time it is // called, `mCallback` will be cleared. - void NotifyOnUnlock(DataPipeAutoLock& aLock) MOZ_REQUIRES(*mMutex) { + void NotifyOnUnlock(DataPipeAutoLock& aLock) REQUIRES(*mMutex) { DoNotifyOnUnlock(aLock, mCallback.forget(), mCallbackTarget.forget()); } void SendBytesConsumedOnUnlock(DataPipeAutoLock& aLock, uint32_t aBytes) - MOZ_REQUIRES(*mMutex) { + REQUIRES(*mMutex) { MOZ_LOG(gDataPipeLog, LogLevel::Verbose, ("SendOnUnlock CONSUMED(%u) %s", aBytes, Describe(aLock).get())); if (NS_FAILED(mPeerStatus)) { @@ -128,7 +128,7 @@ class DataPipeLink : public NodeController::PortObserver { } void SetPeerError(DataPipeAutoLock& aLock, nsresult aStatus, - bool aSendClosed = false) MOZ_REQUIRES(*mMutex) { + bool aSendClosed = false) REQUIRES(*mMutex) { MOZ_LOG(gDataPipeLog, LogLevel::Debug, ("SetPeerError(%s%s) %s", GetStaticErrorName(aStatus), aSendClosed ? ", send" : "", Describe(aLock).get())); @@ -150,7 +150,7 @@ class DataPipeLink : public NodeController::PortObserver { NotifyOnUnlock(aLock); } - nsCString Describe(DataPipeAutoLock& aLock) const MOZ_REQUIRES(*mMutex) { + nsCString Describe(DataPipeAutoLock& aLock) const REQUIRES(*mMutex) { return nsPrintfCString( "[%s(%p) c=%u e=%s o=%u a=%u, cb=%s]", mReceiverSide ? "Receiver" : "Sender", this, mCapacity, @@ -162,20 +162,20 @@ class DataPipeLink : public NodeController::PortObserver { // `DataPipeLink`. std::shared_ptr mMutex; - ScopedPort mPort MOZ_GUARDED_BY(*mMutex); + ScopedPort mPort GUARDED_BY(*mMutex); const RefPtr mShmem; const uint32_t mCapacity; const bool mReceiverSide; - bool mProcessingSegment MOZ_GUARDED_BY(*mMutex) = false; + bool mProcessingSegment GUARDED_BY(*mMutex) = false; - nsresult mPeerStatus MOZ_GUARDED_BY(*mMutex) = NS_OK; - uint32_t mOffset MOZ_GUARDED_BY(*mMutex) = 0; - uint32_t mAvailable MOZ_GUARDED_BY(*mMutex) = 0; + nsresult mPeerStatus GUARDED_BY(*mMutex) = NS_OK; + uint32_t mOffset GUARDED_BY(*mMutex) = 0; + uint32_t mAvailable GUARDED_BY(*mMutex) = 0; - bool mCallbackClosureOnly MOZ_GUARDED_BY(*mMutex) = false; - nsCOMPtr mCallback MOZ_GUARDED_BY(*mMutex); - nsCOMPtr mCallbackTarget MOZ_GUARDED_BY(*mMutex); + bool mCallbackClosureOnly GUARDED_BY(*mMutex) = false; + nsCOMPtr mCallback GUARDED_BY(*mMutex); + nsCOMPtr mCallbackTarget GUARDED_BY(*mMutex); }; void DataPipeLink::OnPortStatusChanged() { diff --git a/ipc/glue/DataPipe.h b/ipc/glue/DataPipe.h index d6439189ad90..c3903a3255fb 100644 --- a/ipc/glue/DataPipe.h +++ b/ipc/glue/DataPipe.h @@ -33,11 +33,11 @@ class DataPipeBase { uint32_t aCapacity, nsresult aPeerStatus, uint32_t aOffset, uint32_t aAvailable); - void CloseInternal(DataPipeAutoLock&, nsresult aStatus) MOZ_REQUIRES(*mMutex); + void CloseInternal(DataPipeAutoLock&, nsresult aStatus) REQUIRES(*mMutex); void AsyncWaitInternal(already_AddRefed aCallback, already_AddRefed aTarget, - bool aClosureOnly) MOZ_EXCLUDES(*mMutex); + bool aClosureOnly) EXCLUDES(*mMutex); // Like `nsWriteSegmentFun` or `nsReadSegmentFun`. using ProcessSegmentFun = @@ -45,25 +45,24 @@ class DataPipeBase { uint32_t* aProcessedCount)>; nsresult ProcessSegmentsInternal(uint32_t aCount, ProcessSegmentFun aProcessSegment, - uint32_t* aProcessedCount) - MOZ_EXCLUDES(*mMutex); + uint32_t* aProcessedCount) EXCLUDES(*mMutex); - nsresult CheckStatus(DataPipeAutoLock&) MOZ_REQUIRES(*mMutex); + nsresult CheckStatus(DataPipeAutoLock&) REQUIRES(*mMutex); - nsCString Describe(DataPipeAutoLock&) MOZ_REQUIRES(*mMutex); + nsCString Describe(DataPipeAutoLock&) REQUIRES(*mMutex); // Thread safety helper to tell the analysis that `mLink->mMutex` is held when // `mMutex` is held. - void AssertSameMutex(const std::shared_ptr& aMutex) - MOZ_REQUIRES(*mMutex) MOZ_ASSERT_CAPABILITY(*aMutex) { + void AssertSameMutex(const std::shared_ptr& aMutex) REQUIRES(*mMutex) + ASSERT_CAPABILITY(*aMutex) { MOZ_ASSERT(mMutex == aMutex); } virtual ~DataPipeBase(); const std::shared_ptr mMutex; - nsresult mStatus MOZ_GUARDED_BY(*mMutex) = NS_OK; - RefPtr mLink MOZ_GUARDED_BY(*mMutex); + nsresult mStatus GUARDED_BY(*mMutex) = NS_OK; + RefPtr mLink GUARDED_BY(*mMutex); }; template diff --git a/ipc/glue/GeckoChildProcessHost.cpp b/ipc/glue/GeckoChildProcessHost.cpp index 5bcae81feb73..6febbd83800b 100644 --- a/ipc/glue/GeckoChildProcessHost.cpp +++ b/ipc/glue/GeckoChildProcessHost.cpp @@ -898,7 +898,7 @@ void BaseProcessLauncher::GetChildLogName(const char* origLogName, static mozilla::StaticMutex gIPCLaunchThreadMutex; static mozilla::StaticRefPtr gIPCLaunchThread - MOZ_GUARDED_BY(gIPCLaunchThreadMutex); + GUARDED_BY(gIPCLaunchThreadMutex); class IPCLaunchThreadObserver final : public nsIObserver { public: diff --git a/ipc/glue/GeckoChildProcessHost.h b/ipc/glue/GeckoChildProcessHost.h index a41dfa2871d6..79d0c8777cc3 100644 --- a/ipc/glue/GeckoChildProcessHost.h +++ b/ipc/glue/GeckoChildProcessHost.h @@ -216,7 +216,7 @@ class GeckoChildProcessHost : public ChildProcessHost, // is well. PROCESS_CONNECTED, PROCESS_ERROR - } mProcessState MOZ_GUARDED_BY(mMonitor); + } mProcessState GUARDED_BY(mMonitor); void PrepareLaunch(); @@ -287,7 +287,7 @@ class GeckoChildProcessHost : public ChildProcessHost, static uint32_t sNextUniqueID; static StaticAutoPtr> - sGeckoChildProcessHosts MOZ_GUARDED_BY(sMutex); + sGeckoChildProcessHosts GUARDED_BY(sMutex); static StaticMutex sMutex; }; diff --git a/ipc/glue/MessageChannel.cpp b/ipc/glue/MessageChannel.cpp index 6ec6cac81304..71092fcc7b5f 100644 --- a/ipc/glue/MessageChannel.cpp +++ b/ipc/glue/MessageChannel.cpp @@ -140,7 +140,7 @@ class AutoEnterTransaction { public: explicit AutoEnterTransaction(MessageChannel* aChan, int32_t aMsgSeqno, int32_t aTransactionID, int aNestedLevel) - MOZ_REQUIRES(*aChan->mMonitor) + REQUIRES(*aChan->mMonitor) : mChan(aChan), mActive(true), mOutgoing(true), @@ -154,7 +154,7 @@ class AutoEnterTransaction { explicit AutoEnterTransaction(MessageChannel* aChan, const IPC::Message& aMessage) - MOZ_REQUIRES(*aChan->mMonitor) + REQUIRES(*aChan->mMonitor) : mChan(aChan), mActive(true), mOutgoing(false), @@ -356,7 +356,7 @@ class ChannelCountReporter final : public nsIMemoryReporter { using CountTable = nsTHashMap; static StaticMutex sChannelCountMutex; - static CountTable* sChannelCounts MOZ_GUARDED_BY(sChannelCountMutex); + static CountTable* sChannelCounts GUARDED_BY(sChannelCountMutex); public: NS_DECL_THREADSAFE_ISUPPORTS diff --git a/ipc/glue/MessageChannel.h b/ipc/glue/MessageChannel.h index 7a0882d04e0c..8962921a9d5b 100644 --- a/ipc/glue/MessageChannel.h +++ b/ipc/glue/MessageChannel.h @@ -48,8 +48,8 @@ class RefCountedMonitor : public Monitor { public: RefCountedMonitor() : Monitor("mozilla.ipc.MessageChannel.mMonitor") {} - void AssertSameMonitor(const RefCountedMonitor& aOther) const - MOZ_REQUIRES(*this) MOZ_ASSERT_CAPABILITY(aOther) { + void AssertSameMonitor(const RefCountedMonitor& aOther) const REQUIRES(*this) + ASSERT_CAPABILITY(aOther) { MOZ_ASSERT(this == &aOther); } @@ -196,18 +196,18 @@ class MessageChannel : HasResultCodes { * This sends a special message that is processed on the IO thread, so that * other actors can know that the process will soon shutdown. */ - void NotifyImpendingShutdown() MOZ_EXCLUDES(*mMonitor); + void NotifyImpendingShutdown() EXCLUDES(*mMonitor); // Close the underlying transport channel. - void Close() MOZ_EXCLUDES(*mMonitor); + void Close() EXCLUDES(*mMonitor); // Force the channel to behave as if a channel error occurred. Valid // for process links only, not thread links. - void CloseWithError() MOZ_EXCLUDES(*mMonitor); + void CloseWithError() EXCLUDES(*mMonitor); - void CloseWithTimeout() MOZ_EXCLUDES(*mMonitor); + void CloseWithTimeout() EXCLUDES(*mMonitor); - void SetAbortOnError(bool abort) MOZ_EXCLUDES(*mMonitor) { + void SetAbortOnError(bool abort) EXCLUDES(*mMonitor) { MonitorAutoLock lock(*mMonitor); mAbortOnError = abort; } @@ -216,7 +216,7 @@ class MessageChannel : HasResultCodes { // XXX: You must get permission from an IPC peer to use this function // since it requires custom deserialization and re-orders events. void PeekMessages(const std::function& aInvoke) - MOZ_EXCLUDES(*mMonitor); + EXCLUDES(*mMonitor); // Misc. behavioral traits consumers can request for this channel enum ChannelFlags { @@ -237,14 +237,14 @@ class MessageChannel : HasResultCodes { ChannelFlags GetChannelFlags() { return mFlags; } // Asynchronously send a message to the other side of the channel - bool Send(UniquePtr aMsg) MOZ_EXCLUDES(*mMonitor); + bool Send(UniquePtr aMsg) EXCLUDES(*mMonitor); // Asynchronously send a message to the other side of the channel // and wait for asynchronous reply. template void Send(UniquePtr aMsg, ActorIdType aActorId, ResolveCallback&& aResolve, RejectCallback&& aReject) - MOZ_EXCLUDES(*mMonitor) { + EXCLUDES(*mMonitor) { int32_t seqno = NextSeqno(); aMsg->set_seqno(seqno); if (!Send(std::move(aMsg))) { @@ -259,18 +259,17 @@ class MessageChannel : HasResultCodes { gUnresolvedResponses++; } - bool SendBuildIDsMatchMessage(const char* aParentBuildID) - MOZ_EXCLUDES(*mMonitor); - bool DoBuildIDsMatch() MOZ_EXCLUDES(*mMonitor) { + bool SendBuildIDsMatchMessage(const char* aParentBuildID) EXCLUDES(*mMonitor); + bool DoBuildIDsMatch() EXCLUDES(*mMonitor) { MonitorAutoLock lock(*mMonitor); return mBuildIDsConfirmedMatch; } // Synchronously send |aMsg| (i.e., wait for |aReply|) bool Send(UniquePtr aMsg, UniquePtr* aReply) - MOZ_EXCLUDES(*mMonitor); + EXCLUDES(*mMonitor); - bool CanSend() const MOZ_EXCLUDES(*mMonitor); + bool CanSend() const EXCLUDES(*mMonitor); // Remove and return a callback that needs reply UniquePtr PopCallback(const Message& aMsg); @@ -290,15 +289,15 @@ class MessageChannel : HasResultCodes { bool IsOnCxxStack() const { return mOnCxxStack; } - void CancelCurrentTransaction() MOZ_EXCLUDES(*mMonitor); + void CancelCurrentTransaction() EXCLUDES(*mMonitor); // IsClosed and NumQueuedMessages are safe to call from any thread, but // may provide an out-of-date value. - bool IsClosed() MOZ_EXCLUDES(*mMonitor) { + bool IsClosed() EXCLUDES(*mMonitor) { MonitorAutoLock lock(*mMonitor); return IsClosedLocked(); } - bool IsClosedLocked() const MOZ_REQUIRES(*mMonitor) { + bool IsClosedLocked() const REQUIRES(*mMonitor) { mMonitor->AssertCurrentThreadOwns(); return mLink ? mLink->IsClosed() : true; } @@ -311,8 +310,8 @@ class MessageChannel : HasResultCodes { /** * Does this MessageChannel currently cross process boundaries? */ - bool IsCrossProcess() const MOZ_REQUIRES(*mMonitor); - void SetIsCrossProcess(bool aIsCrossProcess) MOZ_REQUIRES(*mMonitor); + bool IsCrossProcess() const REQUIRES(*mMonitor); + void SetIsCrossProcess(bool aIsCrossProcess) REQUIRES(*mMonitor); #ifdef FUZZING_SNAPSHOT Maybe GetPortName() { @@ -366,39 +365,37 @@ class MessageChannel : HasResultCodes { #endif // defined(OS_WIN) private: - void PostErrorNotifyTask() MOZ_REQUIRES(*mMonitor); - void OnNotifyMaybeChannelError() MOZ_EXCLUDES(*mMonitor); + void PostErrorNotifyTask() REQUIRES(*mMonitor); + void OnNotifyMaybeChannelError() EXCLUDES(*mMonitor); void ReportConnectionError(const char* aFunctionName, - const uint32_t aMsgTyp) const - MOZ_REQUIRES(*mMonitor); + const uint32_t aMsgTyp) const REQUIRES(*mMonitor); void ReportMessageRouteError(const char* channelName) const - MOZ_EXCLUDES(*mMonitor); + EXCLUDES(*mMonitor); bool MaybeHandleError(Result code, const Message& aMsg, - const char* channelName) MOZ_EXCLUDES(*mMonitor); + const char* channelName) EXCLUDES(*mMonitor); - void Clear() MOZ_REQUIRES(*mMonitor); + void Clear() REQUIRES(*mMonitor); - bool HasPendingEvents() MOZ_REQUIRES(*mMonitor); + bool HasPendingEvents() REQUIRES(*mMonitor); void ProcessPendingRequests(ActorLifecycleProxy* aProxy, AutoEnterTransaction& aTransaction) - MOZ_REQUIRES(*mMonitor); + REQUIRES(*mMonitor); bool ProcessPendingRequest(ActorLifecycleProxy* aProxy, - UniquePtr aUrgent) - MOZ_REQUIRES(*mMonitor); + UniquePtr aUrgent) REQUIRES(*mMonitor); - void EnqueuePendingMessages() MOZ_REQUIRES(*mMonitor); + void EnqueuePendingMessages() REQUIRES(*mMonitor); // Dispatches an incoming message to its appropriate handler. void DispatchMessage(ActorLifecycleProxy* aProxy, UniquePtr aMsg) - MOZ_REQUIRES(*mMonitor); + REQUIRES(*mMonitor); // DispatchMessage will route to one of these functions depending on the // protocol type of the message. void DispatchSyncMessage(ActorLifecycleProxy* aProxy, const Message& aMsg, - UniquePtr& aReply) MOZ_EXCLUDES(*mMonitor); + UniquePtr& aReply) EXCLUDES(*mMonitor); void DispatchAsyncMessage(ActorLifecycleProxy* aProxy, const Message& aMsg) - MOZ_EXCLUDES(*mMonitor); + EXCLUDES(*mMonitor); // Return true if the wait ended because a notification was received. // @@ -410,16 +407,16 @@ class MessageChannel : HasResultCodes { // // So in sum: true is a meaningful return value; false isn't, // necessarily. - bool WaitForSyncNotify(bool aHandleWindowsMessages) MOZ_REQUIRES(*mMonitor); + bool WaitForSyncNotify(bool aHandleWindowsMessages) REQUIRES(*mMonitor); bool WaitResponse(bool aWaitTimedOut); - bool ShouldContinueFromTimeout() MOZ_REQUIRES(*mMonitor); + bool ShouldContinueFromTimeout() REQUIRES(*mMonitor); - void EndTimeout() MOZ_REQUIRES(*mMonitor); - void CancelTransaction(int transaction) MOZ_REQUIRES(*mMonitor); + void EndTimeout() REQUIRES(*mMonitor); + void CancelTransaction(int transaction) REQUIRES(*mMonitor); - void RepostAllMessages() MOZ_REQUIRES(*mMonitor); + void RepostAllMessages() REQUIRES(*mMonitor); int32_t NextSeqno() { AssertWorkerThread(); @@ -427,10 +424,10 @@ class MessageChannel : HasResultCodes { } void DebugAbort(const char* file, int line, const char* cond, const char* why, - bool reply = false) MOZ_REQUIRES(*mMonitor); + bool reply = false) REQUIRES(*mMonitor); void AddProfilerMarker(const IPC::Message& aMessage, - MessageDirection aDirection) MOZ_REQUIRES(*mMonitor); + MessageDirection aDirection) REQUIRES(*mMonitor); private: // Returns true if we're dispatching an async message's callback. @@ -444,19 +441,18 @@ class MessageChannel : HasResultCodes { return mDispatchingAsyncMessageNestedLevel; } - bool Connected() const MOZ_REQUIRES(*mMonitor); + bool Connected() const REQUIRES(*mMonitor); private: // Executed on the IO thread. - void NotifyWorkerThread() MOZ_REQUIRES(*mMonitor); + void NotifyWorkerThread() REQUIRES(*mMonitor); // Return true if |aMsg| is a special message targeted at the IO // thread, in which case it shouldn't be delivered to the worker. - bool MaybeInterceptSpecialIOMessage(const Message& aMsg) - MOZ_REQUIRES(*mMonitor); + bool MaybeInterceptSpecialIOMessage(const Message& aMsg) REQUIRES(*mMonitor); // Tell the IO thread to close the channel and wait for it to ACK. - void SynchronouslyClose() MOZ_REQUIRES(*mMonitor); + void SynchronouslyClose() REQUIRES(*mMonitor); // Returns true if ShouldDeferMessage(aMsg) is guaranteed to return true. // Otherwise, the result of ShouldDeferMessage(aMsg) may be true or false, @@ -465,13 +461,12 @@ class MessageChannel : HasResultCodes { // Helper for sending a message via the link. This should only be used for // non-special messages that might have to be postponed. - void SendMessageToLink(UniquePtr aMsg) MOZ_REQUIRES(*mMonitor); + void SendMessageToLink(UniquePtr aMsg) REQUIRES(*mMonitor); bool WasTransactionCanceled(int transaction); - bool ShouldDeferMessage(const Message& aMsg) MOZ_REQUIRES(*mMonitor); - void OnMessageReceivedFromLink(UniquePtr aMsg) - MOZ_REQUIRES(*mMonitor); - void OnChannelErrorFromLink() MOZ_REQUIRES(*mMonitor); + bool ShouldDeferMessage(const Message& aMsg) REQUIRES(*mMonitor); + void OnMessageReceivedFromLink(UniquePtr aMsg) REQUIRES(*mMonitor); + void OnChannelErrorFromLink() REQUIRES(*mMonitor); private: // Clear this channel, and notify the listener that the channel has either @@ -482,9 +477,9 @@ class MessageChannel : HasResultCodes { // listener is called, allowing for the monitor to be unlocked before the // MessageChannel is potentially destroyed. void NotifyChannelClosed(ReleasableMonitorAutoLock& aLock) - MOZ_REQUIRES(*mMonitor); + REQUIRES(*mMonitor); void NotifyMaybeChannelError(ReleasableMonitorAutoLock& aLock) - MOZ_REQUIRES(*mMonitor); + REQUIRES(*mMonitor); private: void AssertWorkerThread() const { @@ -509,31 +504,31 @@ class MessageChannel : HasResultCodes { nsresult Cancel() override; NS_IMETHOD GetPriority(uint32_t* aPriority) override; NS_DECL_NSIRUNNABLEIPCMESSAGETYPE - void Post() MOZ_REQUIRES(*mMonitor); + void Post() REQUIRES(*mMonitor); - bool IsScheduled() const MOZ_REQUIRES(*mMonitor) { + bool IsScheduled() const REQUIRES(*mMonitor) { mMonitor->AssertCurrentThreadOwns(); return mScheduled; } - UniquePtr& Msg() MOZ_REQUIRES(*mMonitor) { + UniquePtr& Msg() REQUIRES(*mMonitor) { MOZ_DIAGNOSTIC_ASSERT(mMessage, "message was moved"); return mMessage; } - const UniquePtr& Msg() const MOZ_REQUIRES(*mMonitor) { + const UniquePtr& Msg() const REQUIRES(*mMonitor) { MOZ_DIAGNOSTIC_ASSERT(mMessage, "message was moved"); return mMessage; } - void AssertMonitorHeld(const RefCountedMonitor& aMonitor) - MOZ_REQUIRES(aMonitor) MOZ_ASSERT_CAPABILITY(*mMonitor) { + void AssertMonitorHeld(const RefCountedMonitor& aMonitor) REQUIRES(aMonitor) + ASSERT_CAPABILITY(*mMonitor) { aMonitor.AssertSameMonitor(*mMonitor); } private: ~MessageTask(); - MessageChannel* Channel() MOZ_REQUIRES(*mMonitor) { + MessageChannel* Channel() REQUIRES(*mMonitor) { mMonitor->AssertCurrentThreadOwns(); MOZ_RELEASE_ASSERT(isInList()); return mChannel; @@ -545,18 +540,18 @@ class MessageChannel : HasResultCodes { // The channel which this MessageTask is associated with. Only valid while // `mMonitor` is held, and this MessageTask `isInList()`. MessageChannel* const mChannel; - UniquePtr mMessage MOZ_GUARDED_BY(*mMonitor); + UniquePtr mMessage GUARDED_BY(*mMonitor); uint32_t const mPriority; - bool mScheduled : 1 MOZ_GUARDED_BY(*mMonitor); + bool mScheduled : 1 GUARDED_BY(*mMonitor); #ifdef FUZZING_SNAPSHOT const bool mIsFuzzMsg; - bool mFuzzStopped MOZ_GUARDED_BY(*mMonitor); + bool mFuzzStopped GUARDED_BY(*mMonitor); #endif }; - bool ShouldRunMessage(const Message& aMsg) MOZ_REQUIRES(*mMonitor); + bool ShouldRunMessage(const Message& aMsg) REQUIRES(*mMonitor); void RunMessage(ActorLifecycleProxy* aProxy, MessageTask& aTask) - MOZ_REQUIRES(*mMonitor); + REQUIRES(*mMonitor); class WorkerTargetShutdownTask final : public nsITargetShutdownTask { public: @@ -594,13 +589,13 @@ class MessageChannel : HasResultCodes { // `MessageChannel`. RefPtr const mMonitor; - ChannelState mChannelState MOZ_GUARDED_BY(*mMonitor) = ChannelClosed; + ChannelState mChannelState GUARDED_BY(*mMonitor) = ChannelClosed; Side mSide = UnknownSide; - bool mIsCrossProcess MOZ_GUARDED_BY(*mMonitor) = false; - UniquePtr mLink MOZ_GUARDED_BY(*mMonitor); + bool mIsCrossProcess GUARDED_BY(*mMonitor) = false; + UniquePtr mLink GUARDED_BY(*mMonitor); // NotifyMaybeChannelError runnable - RefPtr mChannelErrorTask MOZ_GUARDED_BY(*mMonitor); + RefPtr mChannelErrorTask GUARDED_BY(*mMonitor); // Thread we are allowed to send and receive on. Set in Open(); never // changed, and we can only call Open() once. We shouldn't be accessing @@ -608,7 +603,7 @@ class MessageChannel : HasResultCodes { nsCOMPtr mWorkerThread; // Shutdown task to close the channel before mWorkerThread goes away. - RefPtr mShutdownTask MOZ_GUARDED_BY(*mMonitor); + RefPtr mShutdownTask GUARDED_BY(*mMonitor); // Timeout periods are broken up in two to prevent system suspension from // triggering an abort. This method (called by WaitForEvent with a 'did @@ -671,20 +666,20 @@ class MessageChannel : HasResultCodes { // which grow in opposite directions from child to parent. friend class AutoEnterTransaction; - AutoEnterTransaction* mTransactionStack MOZ_GUARDED_BY(*mMonitor) = nullptr; + AutoEnterTransaction* mTransactionStack GUARDED_BY(*mMonitor) = nullptr; - int32_t CurrentNestedInsideSyncTransaction() const MOZ_REQUIRES(*mMonitor); + int32_t CurrentNestedInsideSyncTransaction() const REQUIRES(*mMonitor); - bool AwaitingSyncReply() const MOZ_REQUIRES(*mMonitor); - int AwaitingSyncReplyNestedLevel() const MOZ_REQUIRES(*mMonitor); + bool AwaitingSyncReply() const REQUIRES(*mMonitor); + int AwaitingSyncReplyNestedLevel() const REQUIRES(*mMonitor); - bool DispatchingSyncMessage() const MOZ_REQUIRES(*mMonitor); - int DispatchingSyncMessageNestedLevel() const MOZ_REQUIRES(*mMonitor); + bool DispatchingSyncMessage() const REQUIRES(*mMonitor); + int DispatchingSyncMessageNestedLevel() const REQUIRES(*mMonitor); #ifdef DEBUG - void AssertMaybeDeferredCountCorrect() MOZ_REQUIRES(*mMonitor); + void AssertMaybeDeferredCountCorrect() REQUIRES(*mMonitor); #else - void AssertMaybeDeferredCountCorrect() MOZ_REQUIRES(*mMonitor) {} + void AssertMaybeDeferredCountCorrect() REQUIRES(*mMonitor) {} #endif // If a sync message times out, we store its sequence number here. Any @@ -700,8 +695,8 @@ class MessageChannel : HasResultCodes { // A message is only timed out if it initiated a transaction. This avoids // hitting a lot of corner cases with message nesting that we don't really // care about. - int32_t mTimedOutMessageSeqno MOZ_GUARDED_BY(*mMonitor) = 0; - int mTimedOutMessageNestedLevel MOZ_GUARDED_BY(*mMonitor) = 0; + int32_t mTimedOutMessageSeqno GUARDED_BY(*mMonitor) = 0; + int mTimedOutMessageNestedLevel GUARDED_BY(*mMonitor) = 0; // Queue of all incoming messages. // @@ -711,12 +706,12 @@ class MessageChannel : HasResultCodes { // blocked, and thus can't send us any more messages until we process the sync // in-msg. // - MessageQueue mPending MOZ_GUARDED_BY(*mMonitor); + MessageQueue mPending GUARDED_BY(*mMonitor); // The number of messages in mPending for which IsAlwaysDeferred is false // (i.e., the number of messages that might not be deferred, depending on // context). - size_t mMaybeDeferredPendingCount MOZ_GUARDED_BY(*mMonitor) = 0; + size_t mMaybeDeferredPendingCount GUARDED_BY(*mMonitor) = 0; // Is there currently MessageChannel logic for this channel on the C++ stack? // This member is only accessed on the worker thread, and so is not protected @@ -732,16 +727,16 @@ class MessageChannel : HasResultCodes { // Should the channel abort the process from the I/O thread when // a channel error occurs? - bool mAbortOnError MOZ_GUARDED_BY(*mMonitor) = false; + bool mAbortOnError GUARDED_BY(*mMonitor) = false; // True if the listener has already been notified of a channel close or // error. - bool mNotifiedChannelDone MOZ_GUARDED_BY(*mMonitor) = false; + bool mNotifiedChannelDone GUARDED_BY(*mMonitor) = false; // See SetChannelFlags ChannelFlags mFlags = REQUIRE_DEFAULT; - bool mBuildIDsConfirmedMatch MOZ_GUARDED_BY(*mMonitor) = false; + bool mBuildIDsConfirmedMatch GUARDED_BY(*mMonitor) = false; // If this is true, both ends of this message channel have event targets // on the same thread. diff --git a/ipc/glue/MessagePump.h b/ipc/glue/MessagePump.h index 831c3e3f06e7..78269b7bd42f 100644 --- a/ipc/glue/MessagePump.h +++ b/ipc/glue/MessagePump.h @@ -133,7 +133,7 @@ class MessagePumpForNonMainUIThreads final : public base::MessagePumpForUI, private: ~MessagePumpForNonMainUIThreads() {} - bool mInWait MOZ_GUARDED_BY(mWaitLock); + bool mInWait GUARDED_BY(mWaitLock); mozilla::Mutex mWaitLock; }; #endif // defined(XP_WIN) diff --git a/ipc/mscom/Interceptor.cpp b/ipc/mscom/Interceptor.cpp index 58843a710d0b..99b128913d14 100644 --- a/ipc/mscom/Interceptor.cpp +++ b/ipc/mscom/Interceptor.cpp @@ -38,13 +38,13 @@ namespace mozilla { namespace mscom { namespace detail { -class MOZ_CAPABILITY LiveSet final { +class CAPABILITY LiveSet final { public: LiveSet() : mMutex("mozilla::mscom::LiveSet::mMutex") {} - void Lock() MOZ_CAPABILITY_ACQUIRE(mMutex) { mMutex.Lock(); } + void Lock() CAPABILITY_ACQUIRE(mMutex) { mMutex.Lock(); } - void Unlock() MOZ_CAPABILITY_RELEASE(mMutex) { mMutex.Unlock(); } + void Unlock() CAPABILITY_RELEASE(mMutex) { mMutex.Unlock(); } void Put(IUnknown* aKey, already_AddRefed aValue) { mMutex.AssertCurrentThreadOwns(); @@ -72,20 +72,20 @@ class MOZ_CAPABILITY LiveSet final { * We don't use the normal XPCOM BaseAutoLock because we need the ability * to explicitly Unlock. */ -class MOZ_RAII MOZ_SCOPED_CAPABILITY LiveSetAutoLock final { +class MOZ_RAII SCOPED_CAPABILITY LiveSetAutoLock final { public: - explicit LiveSetAutoLock(LiveSet& aLiveSet) MOZ_CAPABILITY_ACQUIRE(aLiveSet) + explicit LiveSetAutoLock(LiveSet& aLiveSet) CAPABILITY_ACQUIRE(aLiveSet) : mLiveSet(&aLiveSet) { aLiveSet.Lock(); } - ~LiveSetAutoLock() MOZ_CAPABILITY_RELEASE() { + ~LiveSetAutoLock() CAPABILITY_RELEASE() { if (mLiveSet) { mLiveSet->Unlock(); } } - void Unlock() MOZ_CAPABILITY_RELEASE() { + void Unlock() CAPABILITY_RELEASE() { MOZ_ASSERT(mLiveSet); if (mLiveSet) { mLiveSet->Unlock(); @@ -466,7 +466,7 @@ HRESULT Interceptor::PublishTarget(detail::LiveSetAutoLock& aLiveSetLock, RefPtr aInterceptor, REFIID aTargetIid, STAUniquePtr aTarget) - MOZ_NO_THREAD_SAFETY_ANALYSIS { + NO_THREAD_SAFETY_ANALYSIS { // Suppress thread safety analysis as this conditionally releases locks. RefPtr weakRef; HRESULT hr = GetWeakReference(getter_AddRefs(weakRef)); @@ -494,7 +494,7 @@ HRESULT Interceptor::GetInitialInterceptorForIID( detail::LiveSetAutoLock& aLiveSetLock, REFIID aTargetIid, STAUniquePtr aTarget, - void** aOutInterceptor) MOZ_NO_THREAD_SAFETY_ANALYSIS { + void** aOutInterceptor) NO_THREAD_SAFETY_ANALYSIS { // Suppress thread safety analysis as this conditionally releases locks. MOZ_ASSERT(aOutInterceptor); MOZ_ASSERT(aTargetIid != IID_IMarshal); @@ -504,9 +504,9 @@ Interceptor::GetInitialInterceptorForIID( auto hasFailed = [&hr]() -> bool { return FAILED(hr); }; - MOZ_PUSH_IGNORE_THREAD_SAFETY // Avoid the lambda upsetting analysis. + PUSH_IGNORE_THREAD_SAFETY // Avoid the lambda upsetting analysis. auto cleanup = [&aLiveSetLock]() -> void { aLiveSetLock.Unlock(); }; - MOZ_POP_THREAD_SAFETY + POP_THREAD_SAFETY ExecuteWhen onFail(hasFailed, cleanup); diff --git a/js/xpconnect/loader/ScriptPreloader.h b/js/xpconnect/loader/ScriptPreloader.h index b0902ec3c35b..5f84c4bf65ea 100644 --- a/js/xpconnect/loader/ScriptPreloader.h +++ b/js/xpconnect/loader/ScriptPreloader.h @@ -423,7 +423,7 @@ class ScriptPreloader : public nsIObserver, Result OpenCache(); // Writes a new cache file to disk. Must not be called on the main thread. - Result WriteCache() MOZ_REQUIRES(mSaveMonitor); + Result WriteCache() REQUIRES(mSaveMonitor); void StartCacheWrite(); @@ -488,7 +488,7 @@ class ScriptPreloader : public nsIObserver, bool mSaveComplete = false; bool mDataPrepared = false; // May only be changed on the main thread, while `mSaveMonitor` is held. - bool mCacheInvalidated MOZ_GUARDED_BY(mSaveMonitor) = false; + bool mCacheInvalidated GUARDED_BY(mSaveMonitor) = false; // The list of scripts that we read from the initial startup cache file, // but have yet to initiate a decode task for. @@ -504,11 +504,11 @@ class ScriptPreloader : public nsIObserver, // True if a runnable has been dispatched to the main thread to finish an // off-thread decode operation. Access only while 'mMonitor' is held. - bool mFinishDecodeRunnablePending MOZ_GUARDED_BY(mMonitor) = false; + bool mFinishDecodeRunnablePending GUARDED_BY(mMonitor) = false; // True is main-thread is blocked and we should notify with Monitor. Access // only while `mMonitor` is held. - bool mWaitingForDecode MOZ_GUARDED_BY(mMonitor) = false; + bool mWaitingForDecode GUARDED_BY(mMonitor) = false; // The process type of the current process. static ProcessType sProcessType; @@ -534,7 +534,7 @@ class ScriptPreloader : public nsIObserver, AutoMemMap* mCacheData; Monitor mMonitor; - MonitorSingleWriter mSaveMonitor MOZ_ACQUIRED_BEFORE(mMonitor); + MonitorSingleWriter mSaveMonitor ACQUIRED_BEFORE(mMonitor); }; } // namespace mozilla diff --git a/layout/style/FontFaceSetImpl.h b/layout/style/FontFaceSetImpl.h index 71ff0a9d4f53..27ab8b05e538 100644 --- a/layout/style/FontFaceSetImpl.h +++ b/layout/style/FontFaceSetImpl.h @@ -241,7 +241,7 @@ class FontFaceSetImpl : public nsISupports, public gfxUserFontSet { mutable RecursiveMutex mMutex; - FontFaceSet* MOZ_NON_OWNING_REF mOwner MOZ_GUARDED_BY(mMutex); + FontFaceSet* MOZ_NON_OWNING_REF mOwner GUARDED_BY(mMutex); // The document's node principal, which is the principal font loads for // this FontFaceSet will generally use. (This principal is not used for @@ -255,19 +255,19 @@ class FontFaceSetImpl : public nsISupports, public gfxUserFontSet { // Because mDocument's principal can change over time, // its value must be updated by a call to ResetStandardFontLoadPrincipal. mutable RefPtr mStandardFontLoadPrincipal - MOZ_GUARDED_BY(mMutex); + GUARDED_BY(mMutex); // Set of all loaders pointing to us. These are not strong pointers, // but that's OK because nsFontFaceLoader always calls RemoveLoader on // us before it dies (unless we die first). - nsTHashtable> mLoaders MOZ_GUARDED_BY(mMutex); + nsTHashtable> mLoaders GUARDED_BY(mMutex); // The non rule backed FontFace objects that have been added to this // FontFaceSet. - nsTArray mNonRuleFaces MOZ_GUARDED_BY(mMutex); + nsTArray mNonRuleFaces GUARDED_BY(mMutex); // The overall status of the loading or loaded fonts in the FontFaceSet. - dom::FontFaceSetLoadStatus mStatus MOZ_GUARDED_BY(mMutex); + dom::FontFaceSetLoadStatus mStatus GUARDED_BY(mMutex); // A map from gfxFontFaceSrc pointer identity to whether the load is allowed // by CSP or other checks. We store this here because querying CSP off the @@ -276,22 +276,22 @@ class FontFaceSetImpl : public nsISupports, public gfxUserFontSet { // We could use just the pointer and use this as a hash set, but then we'd // have no way to verify that we've checked all the loads we should. nsTHashMap, bool> mAllowedFontLoads - MOZ_GUARDED_BY(mMutex); + GUARDED_BY(mMutex); // Whether mNonRuleFaces has changed since last time UpdateRules ran. - bool mNonRuleFacesDirty MOZ_GUARDED_BY(mMutex); + bool mNonRuleFacesDirty GUARDED_BY(mMutex); // Whether any FontFace objects in mRuleFaces or mNonRuleFaces are // loading. Only valid when mHasLoadingFontFacesIsDirty is false. Don't use // this variable directly; call the HasLoadingFontFaces method instead. - bool mHasLoadingFontFaces MOZ_GUARDED_BY(mMutex); + bool mHasLoadingFontFaces GUARDED_BY(mMutex); // This variable is only valid when mLoadingDirty is false. - bool mHasLoadingFontFacesIsDirty MOZ_GUARDED_BY(mMutex); + bool mHasLoadingFontFacesIsDirty GUARDED_BY(mMutex); // Whether CheckLoadingFinished calls should be ignored. See comment in // OnFontFaceStatusChanged. - bool mDelayedLoadCheck MOZ_GUARDED_BY(mMutex); + bool mDelayedLoadCheck GUARDED_BY(mMutex); // Whether the docshell for our document indicated that loads should // bypass the cache. diff --git a/layout/style/FontFaceSetWorkerImpl.h b/layout/style/FontFaceSetWorkerImpl.h index c32393a131c9..ebfc46fdb4eb 100644 --- a/layout/style/FontFaceSetWorkerImpl.h +++ b/layout/style/FontFaceSetWorkerImpl.h @@ -52,9 +52,9 @@ class FontFaceSetWorkerImpl final : public FontFaceSetImpl { TimeStamp GetNavigationStartTimeStamp() override; - RefPtr mWorkerRef MOZ_GUARDED_BY(mMutex); + RefPtr mWorkerRef GUARDED_BY(mMutex); - RefPtr mURLExtraData MOZ_GUARDED_BY(mMutex); + RefPtr mURLExtraData GUARDED_BY(mMutex); }; } // namespace mozilla::dom diff --git a/memory/build/Mutex.h b/memory/build/Mutex.h index 75f5eef03236..ee6317973495 100644 --- a/memory/build/Mutex.h +++ b/memory/build/Mutex.h @@ -44,7 +44,7 @@ static_assert(sizeof(os_unfair_lock) == sizeof(OSSpinLock), // 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 MOZ_CAPABILITY Mutex { +struct CAPABILITY Mutex { #if defined(XP_WIN) CRITICAL_SECTION mMutex; #elif defined(XP_DARWIN) @@ -86,7 +86,7 @@ struct MOZ_CAPABILITY Mutex { return true; } - inline void Lock() MOZ_CAPABILITY_ACQUIRE() { + inline void Lock() CAPABILITY_ACQUIRE() { #if defined(XP_WIN) EnterCriticalSection(&mMutex); #elif defined(XP_DARWIN) @@ -109,7 +109,7 @@ struct MOZ_CAPABILITY Mutex { #endif } - inline void Unlock() MOZ_CAPABILITY_RELEASE() { + inline void Unlock() CAPABILITY_RELEASE() { #if defined(XP_WIN) LeaveCriticalSection(&mMutex); #elif defined(XP_DARWIN) @@ -137,14 +137,12 @@ struct MOZ_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 MOZ_CAPABILITY StaticMutex { +struct CAPABILITY StaticMutex { SRWLOCK mMutex; - inline void Lock() MOZ_CAPABILITY_ACQUIRE() { - AcquireSRWLockExclusive(&mMutex); - } + inline void Lock() CAPABILITY_ACQUIRE() { AcquireSRWLockExclusive(&mMutex); } - inline void Unlock() MOZ_CAPABILITY_RELEASE() { + inline void Unlock() CAPABILITY_RELEASE() { ReleaseSRWLockExclusive(&mMutex); } }; @@ -170,12 +168,12 @@ typedef Mutex StaticMutex; #endif template -struct MOZ_SCOPED_CAPABILITY MOZ_RAII AutoLock { - explicit AutoLock(T& aMutex) MOZ_CAPABILITY_ACQUIRE(aMutex) : mMutex(aMutex) { +struct SCOPED_CAPABILITY MOZ_RAII AutoLock { + explicit AutoLock(T& aMutex) CAPABILITY_ACQUIRE(aMutex) : mMutex(aMutex) { mMutex.Lock(); } - ~AutoLock() MOZ_CAPABILITY_RELEASE() { mMutex.Unlock(); } + ~AutoLock() CAPABILITY_RELEASE() { mMutex.Unlock(); } AutoLock(const AutoLock&) = delete; AutoLock(AutoLock&&) = delete; diff --git a/memory/build/mozjemalloc.cpp b/memory/build/mozjemalloc.cpp index 5934e181cb92..0af1904bacda 100644 --- a/memory/build/mozjemalloc.cpp +++ b/memory/build/mozjemalloc.cpp @@ -4730,7 +4730,7 @@ inline void MozJemalloc::moz_dispose_arena(arena_id_t aArenaId) { // running in threaded mode, so there is no need to check whether the program // is threaded here. FORK_HOOK -void _malloc_prefork(void) MOZ_NO_THREAD_SAFETY_ANALYSIS { +void _malloc_prefork(void) NO_THREAD_SAFETY_ANALYSIS { // Acquire all mutexes in a safe order. gArenas.mLock.Lock(); @@ -4744,7 +4744,7 @@ void _malloc_prefork(void) MOZ_NO_THREAD_SAFETY_ANALYSIS { } FORK_HOOK -void _malloc_postfork_parent(void) MOZ_NO_THREAD_SAFETY_ANALYSIS { +void _malloc_postfork_parent(void) NO_THREAD_SAFETY_ANALYSIS { // Release all mutexes, now that fork() has completed. huge_mtx.Unlock(); diff --git a/memory/replace/logalloc/LogAlloc.cpp b/memory/replace/logalloc/LogAlloc.cpp index a976b0c6749a..0b95777066f4 100644 --- a/memory/replace/logalloc/LogAlloc.cpp +++ b/memory/replace/logalloc/LogAlloc.cpp @@ -27,8 +27,8 @@ static bool sStdoutOrStderr = false; static Mutex sMutex MOZ_UNANNOTATED; #ifndef _WIN32 -static void prefork() MOZ_NO_THREAD_SAFETY_ANALYSIS { sMutex.Lock(); } -static void postfork_parent() MOZ_NO_THREAD_SAFETY_ANALYSIS { sMutex.Unlock(); } +static void prefork() NO_THREAD_SAFETY_ANALYSIS { sMutex.Lock(); } +static void postfork_parent() NO_THREAD_SAFETY_ANALYSIS { sMutex.Unlock(); } static void postfork_child() { sMutex.Init(); } #endif diff --git a/memory/replace/phc/PHC.cpp b/memory/replace/phc/PHC.cpp index 37d10ce4864e..507a53eef4c5 100644 --- a/memory/replace/phc/PHC.cpp +++ b/memory/replace/phc/PHC.cpp @@ -800,9 +800,9 @@ class GMut { // 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. - MOZ_PUSH_IGNORE_THREAD_SAFETY + PUSH_IGNORE_THREAD_SAFETY sMutex.Unlock(); - MOZ_POP_THREAD_SAFETY + POP_THREAD_SAFETY *static_cast(aPtr) = 0; MOZ_CRASH("unreachable"); } @@ -880,10 +880,8 @@ class GMut { } #ifndef XP_WIN - static void prefork() MOZ_NO_THREAD_SAFETY_ANALYSIS { sMutex.Lock(); } - static void postfork_parent() MOZ_NO_THREAD_SAFETY_ANALYSIS { - sMutex.Unlock(); - } + static void prefork() NO_THREAD_SAFETY_ANALYSIS { sMutex.Lock(); } + static void postfork_parent() NO_THREAD_SAFETY_ANALYSIS { sMutex.Unlock(); } static void postfork_child() { sMutex.Init(); } #endif diff --git a/mfbt/Attributes.h b/mfbt/Attributes.h index dd7903aafdee..fee123ad5f0a 100644 --- a/mfbt/Attributes.h +++ b/mfbt/Attributes.h @@ -686,10 +686,10 @@ * MOZ_UNANNOTATED/MOZ_ANNOTATED: Applies to Mutexes/Monitors and variations on * them. MOZ_UNANNOTATED indicates that the Mutex/Monitor/etc hasn't been * examined and annotated using macros from mfbt/ThreadSafety -- - * MOZ_GUARDED_BY()/REQUIRES()/etc. MOZ_ANNOTATED is used in rare cases to + * GUARDED_BY()/REQUIRES()/etc. MOZ_ANNOTATED is used in rare cases to * indicate that is has been looked at, but it did not need any - * MOZ_GUARDED_BY()/REQUIRES()/etc (and thus static analysis knows it can - * ignore this Mutex/Monitor/etc) + * GUARDED_BY()/REQUIRES()/etc (and thus static analysis knows it can ignore + * this Mutex/Monitor/etc) */ // gcc emits a nuisance warning -Wignored-attributes because attributes do not diff --git a/mfbt/Maybe.h b/mfbt/Maybe.h index 3298370f49d4..c67ad22e8665 100644 --- a/mfbt/Maybe.h +++ b/mfbt/Maybe.h @@ -641,9 +641,9 @@ class MOZ_INHERIT_TYPE_ANNOTATIONS_FROM_TEMPLATE_ARGS Maybe * Static analyzer gets confused if we have Maybe, * so we suppress thread-safety warnings here */ - MOZ_PUSH_IGNORE_THREAD_SAFETY + PUSH_IGNORE_THREAD_SAFETY ref().T::~T(); - MOZ_POP_THREAD_SAFETY + POP_THREAD_SAFETY poisonData(); } mIsSome = false; diff --git a/mfbt/ThreadSafety.h b/mfbt/ThreadSafety.h index f1224a06b5f9..532dbf84edb6 100644 --- a/mfbt/ThreadSafety.h +++ b/mfbt/ThreadSafety.h @@ -23,118 +23,116 @@ #include "mozilla/Attributes.h" #if defined(__clang__) && (__clang_major__ >= 8) && !defined(SWIG) -# define MOZ_THREAD_ANNOTATION_ATTRIBUTE__(x) __attribute__((x)) +# define THREAD_ANNOTATION_ATTRIBUTE__(x) __attribute__((x)) // Allow for localized suppression of thread-safety warnings; finer-grained -// than MOZ_NO_THREAD_SAFETY_ANALYSIS -# define MOZ_PUSH_IGNORE_THREAD_SAFETY \ - _Pragma("GCC diagnostic push") \ +// than NO_THREAD_SAFETY_ANALYSIS +# define PUSH_IGNORE_THREAD_SAFETY \ + _Pragma("GCC diagnostic push") \ _Pragma("GCC diagnostic ignored \"-Wthread-safety\"") -# define MOZ_POP_THREAD_SAFETY _Pragma("GCC diagnostic pop") +# define POP_THREAD_SAFETY _Pragma("GCC diagnostic pop") #else -# define MOZ_THREAD_ANNOTATION_ATTRIBUTE__(x) // no-op -# define MOZ_PUSH_IGNORE_THREAD_SAFETY -# define MOZ_POP_THREAD_SAFETY +# define THREAD_ANNOTATION_ATTRIBUTE__(x) // no-op +# define PUSH_IGNORE_THREAD_SAFETY +# define POP_THREAD_SAFETY #endif // Document if a shared variable/field needs to be protected by a lock. -// MOZ_GUARDED_BY allows the user to specify a particular lock that should be -// held when accessing the annotated variable, while MOZ_GUARDED_VAR only -// indicates a shared variable should be guarded (by any lock). MOZ_GUARDED_VAR +// GUARDED_BY allows the user to specify a particular lock that should be +// held when accessing the annotated variable, while GUARDED_VAR only +// indicates a shared variable should be guarded (by any lock). GUARDED_VAR // is primarily used when the client cannot express the name of the lock. -#define MOZ_GUARDED_BY(x) MOZ_THREAD_ANNOTATION_ATTRIBUTE__(guarded_by(x)) -#define MOZ_GUARDED_VAR MOZ_THREAD_ANNOTATION_ATTRIBUTE__(guarded_var) +#define GUARDED_BY(x) THREAD_ANNOTATION_ATTRIBUTE__(guarded_by(x)) +#define GUARDED_VAR THREAD_ANNOTATION_ATTRIBUTE__(guarded_var) // Document if the memory location pointed to by a pointer should be guarded -// by a lock when dereferencing the pointer. Similar to MOZ_GUARDED_VAR, -// MOZ_PT_GUARDED_VAR is primarily used when the client cannot express the -// name of the lock. Note that a pointer variable to a shared memory location +// by a lock when dereferencing the pointer. Similar to GUARDED_VAR, +// PT_GUARDED_VAR is primarily used when the client cannot express the name +// of the lock. Note that a pointer variable to a shared memory location // could itself be a shared variable. For example, if a shared global pointer // q, which is guarded by mu1, points to a shared memory location that is // guarded by mu2, q should be annotated as follows: -// int *q MOZ_GUARDED_BY(mu1) MOZ_PT_GUARDED_BY(mu2); -#define MOZ_PT_GUARDED_BY(x) MOZ_THREAD_ANNOTATION_ATTRIBUTE__(pt_guarded_by(x)) -#define MOZ_PT_GUARDED_VAR MOZ_THREAD_ANNOTATION_ATTRIBUTE__(pt_guarded_var) +// int *q GUARDED_BY(mu1) PT_GUARDED_BY(mu2); +#define PT_GUARDED_BY(x) THREAD_ANNOTATION_ATTRIBUTE__(pt_guarded_by(x)) +#define PT_GUARDED_VAR THREAD_ANNOTATION_ATTRIBUTE__(pt_guarded_var) // Document the acquisition order between locks that can be held // simultaneously by a thread. For any two locks that need to be annotated // to establish an acquisition order, only one of them needs the annotation. -// (i.e. You don't have to annotate both locks with both MOZ_ACQUIRED_AFTER -// and MOZ_ACQUIRED_BEFORE.) -#define MOZ_ACQUIRED_AFTER(...) \ - MOZ_THREAD_ANNOTATION_ATTRIBUTE__(acquired_after(__VA_ARGS__)) -#define MOZ_ACQUIRED_BEFORE(...) \ - MOZ_THREAD_ANNOTATION_ATTRIBUTE__(acquired_before(__VA_ARGS__)) +// (i.e. You don't have to annotate both locks with both ACQUIRED_AFTER +// and ACQUIRED_BEFORE.) +#define ACQUIRED_AFTER(...) \ + THREAD_ANNOTATION_ATTRIBUTE__(acquired_after(__VA_ARGS__)) +#define ACQUIRED_BEFORE(...) \ + THREAD_ANNOTATION_ATTRIBUTE__(acquired_before(__VA_ARGS__)) // The following three annotations document the lock requirements for // functions/methods. // Document if a function expects certain locks to be held before it is called -#define MOZ_REQUIRES(...) \ - MOZ_THREAD_ANNOTATION_ATTRIBUTE__(exclusive_locks_required(__VA_ARGS__)) +#define REQUIRES(...) \ + THREAD_ANNOTATION_ATTRIBUTE__(exclusive_locks_required(__VA_ARGS__)) -#define MOZ_REQUIRES_SHARED(...) \ - MOZ_THREAD_ANNOTATION_ATTRIBUTE__(shared_locks_required(__VA_ARGS__)) +#define REQUIRES_SHARED(...) \ + THREAD_ANNOTATION_ATTRIBUTE__(shared_locks_required(__VA_ARGS__)) // Document the locks acquired in the body of the function. These locks // cannot be held when calling this function (as google3's Mutex locks are // non-reentrant). -#define MOZ_EXCLUDES(x) MOZ_THREAD_ANNOTATION_ATTRIBUTE__(locks_excluded(x)) +#define EXCLUDES(x) THREAD_ANNOTATION_ATTRIBUTE__(locks_excluded(x)) // Document the lock the annotated function returns without acquiring it. -#define MOZ_RETURN_CAPABILITY(x) \ - MOZ_THREAD_ANNOTATION_ATTRIBUTE__(lock_returned(x)) +#define RETURN_CAPABILITY(x) THREAD_ANNOTATION_ATTRIBUTE__(lock_returned(x)) // Document if a class/type is a lockable type (such as the Mutex class). -#define MOZ_CAPABILITY MOZ_THREAD_ANNOTATION_ATTRIBUTE__(lockable) +#define CAPABILITY THREAD_ANNOTATION_ATTRIBUTE__(lockable) // Document if a class is a scoped lockable type (such as the MutexLock class). -#define MOZ_SCOPED_CAPABILITY MOZ_THREAD_ANNOTATION_ATTRIBUTE__(scoped_lockable) +#define SCOPED_CAPABILITY THREAD_ANNOTATION_ATTRIBUTE__(scoped_lockable) // The following annotations specify lock and unlock primitives. -#define MOZ_CAPABILITY_ACQUIRE(...) \ - MOZ_THREAD_ANNOTATION_ATTRIBUTE__(exclusive_lock_function(__VA_ARGS__)) +#define CAPABILITY_ACQUIRE(...) \ + THREAD_ANNOTATION_ATTRIBUTE__(exclusive_lock_function(__VA_ARGS__)) -#define MOZ_EXCLUSIVE_RELEASE(...) \ - MOZ_THREAD_ANNOTATION_ATTRIBUTE__(release_capability(__VA_ARGS__)) +#define EXCLUSIVE_RELEASE(...) \ + THREAD_ANNOTATION_ATTRIBUTE__(release_capability(__VA_ARGS__)) -#define MOZ_ACQUIRE_SHARED(...) \ - MOZ_THREAD_ANNOTATION_ATTRIBUTE__(shared_lock_function(__VA_ARGS__)) +#define ACQUIRE_SHARED(...) \ + THREAD_ANNOTATION_ATTRIBUTE__(shared_lock_function(__VA_ARGS__)) -#define MOZ_TRY_ACQUIRE(...) \ - MOZ_THREAD_ANNOTATION_ATTRIBUTE__(exclusive_trylock_function(__VA_ARGS__)) +#define TRY_ACQUIRE(...) \ + THREAD_ANNOTATION_ATTRIBUTE__(exclusive_trylock_function(__VA_ARGS__)) -#define MOZ_SHARED_TRYLOCK_FUNCTION(...) \ - MOZ_THREAD_ANNOTATION_ATTRIBUTE__(shared_trylock_function(__VA_ARGS__)) +#define SHARED_TRYLOCK_FUNCTION(...) \ + THREAD_ANNOTATION_ATTRIBUTE__(shared_trylock_function(__VA_ARGS__)) -#define MOZ_CAPABILITY_RELEASE(...) \ - MOZ_THREAD_ANNOTATION_ATTRIBUTE__(unlock_function(__VA_ARGS__)) +#define CAPABILITY_RELEASE(...) \ + THREAD_ANNOTATION_ATTRIBUTE__(unlock_function(__VA_ARGS__)) // An escape hatch for thread safety analysis to ignore the annotated function. -#define MOZ_NO_THREAD_SAFETY_ANALYSIS \ - MOZ_THREAD_ANNOTATION_ATTRIBUTE__(no_thread_safety_analysis) +#define NO_THREAD_SAFETY_ANALYSIS \ + THREAD_ANNOTATION_ATTRIBUTE__(no_thread_safety_analysis) // Newer capabilities -#define MOZ_ASSERT_CAPABILITY(x) \ - MOZ_THREAD_ANNOTATION_ATTRIBUTE__(assert_capability(x)) +#define ASSERT_CAPABILITY(x) THREAD_ANNOTATION_ATTRIBUTE__(assert_capability(x)) -#define MOZ_ASSERT_SHARED_CAPABILITY(x) \ - MOZ_THREAD_ANNOTATION_ATTRIBUTE__(assert_shared_capability(x)) +#define ASSERT_SHARED_CAPABILITY(x) \ + THREAD_ANNOTATION_ATTRIBUTE__(assert_shared_capability(x)) // Additions from current clang assertions. // Note: new-style definitions, since these didn't exist in the old style -#define MOZ_RELEASE_SHARED(...) \ - MOZ_THREAD_ANNOTATION_ATTRIBUTE__(release_shared_capability(__VA_ARGS__)) +#define RELEASE_SHARED(...) \ + THREAD_ANNOTATION_ATTRIBUTE__(release_shared_capability(__VA_ARGS__)) -#define MOZ_RELEASE_GENERIC(...) \ - MOZ_THREAD_ANNOTATION_ATTRIBUTE__(release_generic_capability(__VA_ARGS__)) +#define RELEASE_GENERIC(...) \ + THREAD_ANNOTATION_ATTRIBUTE__(release_generic_capability(__VA_ARGS__)) // Mozilla additions: // AutoUnlock is supported by clang currently, but oddly you must use -// MOZ_EXCLUSIVE_RELEASE() for both the RAII constructor *and* the destructor. +// EXCLUSIVE_RELEASE() for both the RAII constructor *and* the destructor. // This hides the ugliness until they fix it upstream. -#define MOZ_SCOPED_UNLOCK_RELEASE(...) MOZ_EXCLUSIVE_RELEASE(__VA_ARGS__) -#define MOZ_SCOPED_UNLOCK_REACQUIRE(...) MOZ_EXCLUSIVE_RELEASE(__VA_ARGS__) +#define SCOPED_UNLOCK_RELEASE(...) EXCLUSIVE_RELEASE(__VA_ARGS__) +#define SCOPED_UNLOCK_REACQUIRE(...) EXCLUSIVE_RELEASE(__VA_ARGS__) #endif /* mozilla_ThreadSafety_h */ diff --git a/modules/libjar/nsJAR.h b/modules/libjar/nsJAR.h index b988c04f1c9b..65186495d216 100644 --- a/modules/libjar/nsJAR.h +++ b/modules/libjar/nsJAR.h @@ -83,13 +83,13 @@ class nsJAR final : public nsIZipReader { //-- Private data members, protected by mLock mozilla::RecursiveMutex mLock; // The entry in the zip this zip is reading from - nsCString mOuterZipEntry MOZ_GUARDED_BY(mLock); + nsCString mOuterZipEntry GUARDED_BY(mLock); // The zip/jar file on disk - nsCOMPtr mZipFile MOZ_GUARDED_BY(mLock); + nsCOMPtr mZipFile GUARDED_BY(mLock); // The underlying zip archive - RefPtr mZip MOZ_GUARDED_BY(mLock); + RefPtr mZip GUARDED_BY(mLock); // if cached, this points to the cache it's contained in - nsZipReaderCache* mCache MOZ_GUARDED_BY(mLock); + nsZipReaderCache* mCache GUARDED_BY(mLock); }; /** @@ -172,14 +172,14 @@ class nsZipReaderCache : public nsIZipReaderCache, virtual ~nsZipReaderCache(); mozilla::Mutex mLock; - uint32_t mCacheSize MOZ_GUARDED_BY(mLock); - ZipsHashtable mZips MOZ_GUARDED_BY(mLock); + uint32_t mCacheSize GUARDED_BY(mLock); + ZipsHashtable mZips GUARDED_BY(mLock); #ifdef ZIP_CACHE_HIT_RATE - uint32_t mZipCacheLookups MOZ_GUARDED_BY(mLock); - uint32_t mZipCacheHits MOZ_GUARDED_BY(mLock); - uint32_t mZipCacheFlushes MOZ_GUARDED_BY(mLock); - uint32_t mZipSyncMisses MOZ_GUARDED_BY(mLock); + uint32_t mZipCacheLookups GUARDED_BY(mLock); + uint32_t mZipCacheHits GUARDED_BY(mLock); + uint32_t mZipCacheFlushes GUARDED_BY(mLock); + uint32_t mZipSyncMisses GUARDED_BY(mLock); #endif private: diff --git a/modules/libjar/nsZipArchive.cpp b/modules/libjar/nsZipArchive.cpp index 66b41dab79d7..c2a23516e1cc 100644 --- a/modules/libjar/nsZipArchive.cpp +++ b/modules/libjar/nsZipArchive.cpp @@ -151,8 +151,8 @@ class ZipArchiveLogger { private: static StaticMutex sLock; - int mRefCnt MOZ_GUARDED_BY(sLock); - PRFileDesc* mFd MOZ_GUARDED_BY(sLock); + int mRefCnt GUARDED_BY(sLock); + PRFileDesc* mFd GUARDED_BY(sLock); }; StaticMutex ZipArchiveLogger::sLock; @@ -601,7 +601,7 @@ nsZipItem* nsZipArchive::CreateZipItem() { // nsZipArchive::BuildFileList //--------------------------------------------- nsresult nsZipArchive::BuildFileList(PRFileDesc* aFd) - MOZ_NO_THREAD_SAFETY_ANALYSIS { + NO_THREAD_SAFETY_ANALYSIS { // We're only called from the constructor, but need to call // CreateZipItem(), which touches locked data, and modify mFiles. Turn // off thread-safety, which normally doesn't apply for constructors diff --git a/modules/libjar/nsZipArchive.h b/modules/libjar/nsZipArchive.h index 12e4b7ea0024..8af9f9b69ba0 100644 --- a/modules/libjar/nsZipArchive.h +++ b/modules/libjar/nsZipArchive.h @@ -201,14 +201,14 @@ class nsZipArchive final { mozilla::Mutex mLock{"nsZipArchive"}; // all of the following members are guarded by mLock: - nsZipItem* mFiles[ZIP_TABSIZE] MOZ_GUARDED_BY(mLock); - mozilla::ArenaAllocator<1024, sizeof(void*)> mArena MOZ_GUARDED_BY(mLock); + nsZipItem* mFiles[ZIP_TABSIZE] GUARDED_BY(mLock); + mozilla::ArenaAllocator<1024, sizeof(void*)> mArena GUARDED_BY(mLock); // Whether we synthesized the directory entries - bool mBuiltSynthetics MOZ_GUARDED_BY(mLock); + bool mBuiltSynthetics GUARDED_BY(mLock); private: //--- private methods --- - nsZipItem* CreateZipItem() MOZ_REQUIRES(mLock); + nsZipItem* CreateZipItem() REQUIRES(mLock); nsresult BuildFileList(PRFileDesc* aFd = nullptr); nsresult BuildSynthetics(); diff --git a/mozglue/baseprofiler/public/BaseProfilerDetail.h b/mozglue/baseprofiler/public/BaseProfilerDetail.h index dc444ce2f373..340ccea21508 100644 --- a/mozglue/baseprofiler/public/BaseProfilerDetail.h +++ b/mozglue/baseprofiler/public/BaseProfilerDetail.h @@ -22,7 +22,7 @@ namespace baseprofiler { namespace detail { // Thin shell around mozglue PlatformMutex, for Base Profiler internal use. -class MOZ_CAPABILITY BaseProfilerMutex : private ::mozilla::detail::MutexImpl { +class CAPABILITY BaseProfilerMutex : private ::mozilla::detail::MutexImpl { public: BaseProfilerMutex() : ::mozilla::detail::MutexImpl() {} explicit BaseProfilerMutex(const char* aName) @@ -45,11 +45,11 @@ class MOZ_CAPABILITY BaseProfilerMutex : private ::mozilla::detail::MutexImpl { baseprofiler::profiler_current_thread_id(); } - void AssertCurrentThreadOwns() const MOZ_ASSERT_CAPABILITY(this) { + void AssertCurrentThreadOwns() const ASSERT_CAPABILITY(this) { MOZ_ASSERT(IsLockedOnCurrentThread()); } - void Lock() MOZ_CAPABILITY_ACQUIRE() { + void Lock() CAPABILITY_ACQUIRE() { const BaseProfilerThreadId tid = baseprofiler::profiler_current_thread_id(); MOZ_ASSERT(tid.IsSpecified()); MOZ_ASSERT(!IsLockedOnCurrentThread(), "Recursive locking"); @@ -59,7 +59,7 @@ class MOZ_CAPABILITY BaseProfilerMutex : private ::mozilla::detail::MutexImpl { mOwningThreadId = tid.ToNumber(); } - [[nodiscard]] bool TryLock() MOZ_TRY_ACQUIRE(true) { + [[nodiscard]] bool TryLock() TRY_ACQUIRE(true) { const BaseProfilerThreadId tid = baseprofiler::profiler_current_thread_id(); MOZ_ASSERT(tid.IsSpecified()); MOZ_ASSERT(!IsLockedOnCurrentThread(), "Recursive locking"); @@ -73,7 +73,7 @@ class MOZ_CAPABILITY BaseProfilerMutex : private ::mozilla::detail::MutexImpl { return true; } - void Unlock() MOZ_CAPABILITY_RELEASE() { + void Unlock() CAPABILITY_RELEASE() { MOZ_ASSERT(IsLockedOnCurrentThread(), "Unlocking when not locked here"); // We're still holding the mutex here, so it's safe to just reset // `mOwningThreadId`. @@ -149,7 +149,7 @@ class BaseProfilerMaybeMutex : private ::mozilla::detail::MutexImpl { #endif // DEBUG } - MOZ_PUSH_IGNORE_THREAD_SAFETY + PUSH_IGNORE_THREAD_SAFETY void Lock() { if (IsActivated()) { mMaybeMutex->Lock(); @@ -161,7 +161,7 @@ class BaseProfilerMaybeMutex : private ::mozilla::detail::MutexImpl { mMaybeMutex->Unlock(); } } - MOZ_POP_THREAD_SAFETY + POP_THREAD_SAFETY private: Maybe mMaybeMutex; diff --git a/mozglue/baseprofiler/public/ProfileBufferChunkManagerWithLocalLimit.h b/mozglue/baseprofiler/public/ProfileBufferChunkManagerWithLocalLimit.h index 034279809de8..6825add26d99 100644 --- a/mozglue/baseprofiler/public/ProfileBufferChunkManagerWithLocalLimit.h +++ b/mozglue/baseprofiler/public/ProfileBufferChunkManagerWithLocalLimit.h @@ -278,13 +278,12 @@ class ProfileBufferChunkManagerWithLocalLimit final protected: const ProfileBufferChunk* PeekExtantReleasedChunksAndLock() final - MOZ_CAPABILITY_ACQUIRE(mMutex) { + CAPABILITY_ACQUIRE(mMutex) { mMutex.Lock(); MOZ_ASSERT(mUser, "Not registered yet"); return mReleasedChunks.get(); } - void UnlockAfterPeekExtantReleasedChunks() final - MOZ_CAPABILITY_RELEASE(mMutex) { + void UnlockAfterPeekExtantReleasedChunks() final CAPABILITY_RELEASE(mMutex) { mMutex.Unlock(); } diff --git a/netwerk/base/BackgroundFileSaver.h b/netwerk/base/BackgroundFileSaver.h index 14a52de86369..270ac67f7151 100644 --- a/netwerk/base/BackgroundFileSaver.h +++ b/netwerk/base/BackgroundFileSaver.h @@ -122,17 +122,17 @@ class BackgroundFileSaver : public nsIBackgroundFileSaver { /** * True if the worker thread is already waiting to process a change in state. */ - bool mWorkerThreadAttentionRequested MOZ_GUARDED_BY(mLock){false}; + bool mWorkerThreadAttentionRequested GUARDED_BY(mLock){false}; /** * True if the operation should finish as soon as possibile. */ - bool mFinishRequested MOZ_GUARDED_BY(mLock){false}; + bool mFinishRequested GUARDED_BY(mLock){false}; /** * True if the operation completed, with either success or failure. */ - bool mComplete MOZ_GUARDED_BY(mLock){false}; + bool mComplete GUARDED_BY(mLock){false}; /** * Holds the current file saver status. This is a success status while the @@ -140,13 +140,13 @@ class BackgroundFileSaver : public nsIBackgroundFileSaver { * successfully. This becomes an error status when an error occurs on the * worker thread, or when the operation is canceled. */ - nsresult mStatus MOZ_GUARDED_BY(mLock){NS_OK}; + nsresult mStatus GUARDED_BY(mLock){NS_OK}; /** * True if we should append data to the initial target file, instead of * overwriting it. */ - bool mAppend MOZ_GUARDED_BY(mLock){false}; + bool mAppend GUARDED_BY(mLock){false}; /** * This is set by the first SetTarget call on the control thread, and contains @@ -154,14 +154,14 @@ class BackgroundFileSaver : public nsIBackgroundFileSaver { * is possible to update mActualTarget and open the file. This is null if no * target was ever assigned to this object. */ - nsCOMPtr mInitialTarget MOZ_GUARDED_BY(mLock); + nsCOMPtr mInitialTarget GUARDED_BY(mLock); /** * This is set by the first SetTarget call on the control thread, and * indicates whether mInitialTarget should be kept as partially completed, * rather than deleted, if the operation fails or is canceled. */ - bool mInitialTargetKeepPartial MOZ_GUARDED_BY(mLock){false}; + bool mInitialTargetKeepPartial GUARDED_BY(mLock){false}; /** * This is set by subsequent SetTarget calls on the control thread, and @@ -172,43 +172,43 @@ class BackgroundFileSaver : public nsIBackgroundFileSaver { * The target file can be renamed multiple times, though only the most recent * rename is guaranteed to be processed by the worker thread. */ - nsCOMPtr mRenamedTarget MOZ_GUARDED_BY(mLock); + nsCOMPtr mRenamedTarget GUARDED_BY(mLock); /** * This is set by subsequent SetTarget calls on the control thread, and * indicates whether mRenamedTarget should be kept as partially completed, * rather than deleted, if the operation fails or is canceled. */ - bool mRenamedTargetKeepPartial MOZ_GUARDED_BY(mLock){false}; + bool mRenamedTargetKeepPartial GUARDED_BY(mLock){false}; /** * While NS_AsyncCopy is in progress, allows canceling it. Null otherwise. * This is read by both threads but only written by the worker thread. */ - nsCOMPtr mAsyncCopyContext MOZ_GUARDED_BY(mLock); + nsCOMPtr mAsyncCopyContext GUARDED_BY(mLock); /** * The SHA 256 hash in raw bytes of the downloaded file. This is written * by the worker thread but can be read on the main thread. */ - nsCString mSha256 MOZ_GUARDED_BY(mLock); + nsCString mSha256 GUARDED_BY(mLock); /** * Whether or not to compute the hash. Must be set on the main thread before * setTarget is called. */ - bool mSha256Enabled MOZ_GUARDED_BY(mLock){false}; + bool mSha256Enabled GUARDED_BY(mLock){false}; /** * Store the signature info. */ - nsTArray>> mSignatureInfo MOZ_GUARDED_BY(mLock); + nsTArray>> mSignatureInfo GUARDED_BY(mLock); /** * Whether or not to extract the signature. Must be set on the main thread * before setTarget is called. */ - bool mSignatureInfoEnabled MOZ_GUARDED_BY(mLock){false}; + bool mSignatureInfoEnabled GUARDED_BY(mLock){false}; ////////////////////////////////////////////////////////////////////////////// //// State handled exclusively by the worker thread @@ -345,18 +345,18 @@ class BackgroundFileSaverStreamListener final : public BackgroundFileSaver, /** * Whether we should suspend the request because we received too much data. */ - bool mReceivedTooMuchData MOZ_GUARDED_BY(mSuspensionLock){false}; + bool mReceivedTooMuchData GUARDED_BY(mSuspensionLock){false}; /** * Request for which we received too much data. This is populated when * mReceivedTooMuchData becomes true for the first time. */ - nsCOMPtr mRequest MOZ_GUARDED_BY(mSuspensionLock); + nsCOMPtr mRequest GUARDED_BY(mSuspensionLock); /** * Whether mRequest is currently suspended. */ - bool mRequestSuspended MOZ_GUARDED_BY(mSuspensionLock){false}; + bool mRequestSuspended GUARDED_BY(mSuspensionLock){false}; /** * Called while NS_AsyncCopy is copying data. diff --git a/netwerk/base/TLSServerSocket.h b/netwerk/base/TLSServerSocket.h index d35f87fb9dc3..5b09bd94a26f 100644 --- a/netwerk/base/TLSServerSocket.h +++ b/netwerk/base/TLSServerSocket.h @@ -68,8 +68,7 @@ class TLSServerConnectionInfo : public nsITLSServerConnectionInfo, uint32_t mMacLength{0}; // lock protects access to mSecurityObserver mozilla::Mutex mLock{"TLSServerConnectionInfo.mLock"}; - nsCOMPtr mSecurityObserver - MOZ_GUARDED_BY(mLock); + nsCOMPtr mSecurityObserver GUARDED_BY(mLock); }; } // namespace net diff --git a/netwerk/base/nsAsyncStreamCopier.cpp b/netwerk/base/nsAsyncStreamCopier.cpp index 60c486a9d980..e67f694b9c08 100644 --- a/netwerk/base/nsAsyncStreamCopier.cpp +++ b/netwerk/base/nsAsyncStreamCopier.cpp @@ -220,7 +220,7 @@ nsAsyncStreamCopier::SetLoadGroup(nsILoadGroup* aLoadGroup) { return NS_OK; } nsresult nsAsyncStreamCopier::InitInternal( nsIInputStream* source, nsIOutputStream* sink, nsIEventTarget* target, uint32_t chunkSize, bool closeSource, - bool closeSink) MOZ_NO_THREAD_SAFETY_ANALYSIS { + bool closeSink) NO_THREAD_SAFETY_ANALYSIS { NS_ASSERTION(!mSource && !mSink, "Init() called more than once"); if (chunkSize == 0) { chunkSize = nsIOService::gDefaultSegmentSize; diff --git a/netwerk/base/nsAsyncStreamCopier.h b/netwerk/base/nsAsyncStreamCopier.h index 120218c3c760..47e92751a3bb 100644 --- a/netwerk/base/nsAsyncStreamCopier.h +++ b/netwerk/base/nsAsyncStreamCopier.h @@ -57,16 +57,16 @@ class nsAsyncStreamCopier final : public nsIAsyncStreamCopier, nsCOMPtr mTarget; - nsCOMPtr mCopierCtx MOZ_GUARDED_BY(mLock); + nsCOMPtr mCopierCtx GUARDED_BY(mLock); mozilla::Mutex mLock{"nsAsyncStreamCopier.mLock"}; nsAsyncCopyMode mMode{NS_ASYNCCOPY_VIA_READSEGMENTS}; uint32_t mChunkSize; // only modified in Init - nsresult mStatus MOZ_GUARDED_BY(mLock){NS_OK}; - bool mIsPending MOZ_GUARDED_BY(mLock){false}; - bool mCloseSource MOZ_GUARDED_BY(mLock){false}; - bool mCloseSink MOZ_GUARDED_BY(mLock){false}; + nsresult mStatus GUARDED_BY(mLock){NS_OK}; + bool mIsPending GUARDED_BY(mLock){false}; + bool mCloseSource GUARDED_BY(mLock){false}; + bool mCloseSink GUARDED_BY(mLock){false}; bool mShouldSniffBuffering{false}; // only modified in Init friend class ProceedWithAsyncCopy; diff --git a/netwerk/base/nsIOService.cpp b/netwerk/base/nsIOService.cpp index 1c6506cb83b1..5accdb671a65 100644 --- a/netwerk/base/nsIOService.cpp +++ b/netwerk/base/nsIOService.cpp @@ -269,9 +269,9 @@ nsresult nsIOService::Init() { // setup our bad port list stuff for (int i = 0; gBadPortList[i]; i++) { // We can't be accessed by another thread yet - MOZ_PUSH_IGNORE_THREAD_SAFETY + PUSH_IGNORE_THREAD_SAFETY mRestrictedPortList.AppendElement(gBadPortList[i]); - MOZ_POP_THREAD_SAFETY + POP_THREAD_SAFETY } // Further modifications to the port list come from prefs diff --git a/netwerk/base/nsIOService.h b/netwerk/base/nsIOService.h index 206370d969e7..33e4b15f709f 100644 --- a/netwerk/base/nsIOService.h +++ b/netwerk/base/nsIOService.h @@ -234,7 +234,7 @@ class nsIOService final : public nsIIOService, NS_CHANNEL_EVENT_SINK_CATEGORY}; Mutex mMutex{"nsIOService::mMutex"}; - nsTArray mRestrictedPortList MOZ_GUARDED_BY(mMutex); + nsTArray mRestrictedPortList GUARDED_BY(mMutex); uint32_t mTotalRequests{0}; uint32_t mCacheWon{0}; diff --git a/netwerk/base/nsInputStreamPump.cpp b/netwerk/base/nsInputStreamPump.cpp index 5b1195015920..ce6a4d6dcaa3 100644 --- a/netwerk/base/nsInputStreamPump.cpp +++ b/netwerk/base/nsInputStreamPump.cpp @@ -464,10 +464,10 @@ uint32_t nsInputStreamPump::OnStateStart() { // nsInputStreamPumps are needed (e.g. nsHttpChannel). RecursiveMutexAutoUnlock unlock(mMutex); // We're on the writing thread - MOZ_PUSH_IGNORE_THREAD_SAFETY + PUSH_IGNORE_THREAD_SAFETY AssertOnThread(); rv = mListener->OnStartRequest(this); - MOZ_POP_THREAD_SAFETY + POP_THREAD_SAFETY } // an error returned from OnStartRequest should cause us to abort; however, @@ -540,7 +540,7 @@ uint32_t nsInputStreamPump::OnStateTransfer() { // We may be called on non-MainThread even if mOffMainThread is // false, due to RetargetDeliveryTo(), so don't use AssertOnThread() - MOZ_PUSH_IGNORE_THREAD_SAFETY + PUSH_IGNORE_THREAD_SAFETY if (mTargetThread) { MOZ_ASSERT(mTargetThread->IsOnCurrentThread()); } else { @@ -548,7 +548,7 @@ uint32_t nsInputStreamPump::OnStateTransfer() { } rv = mListener->OnDataAvailable(this, mAsyncStream, mStreamOffset, odaAvail); - MOZ_POP_THREAD_SAFETY + POP_THREAD_SAFETY } // don't enter this code if ODA failed or called Cancel @@ -652,10 +652,10 @@ uint32_t nsInputStreamPump::OnStateStop() { RecursiveMutexAutoUnlock unlock(mMutex); // We're on the writing thread. // We believe that mStatus can't be changed on us here. - MOZ_PUSH_IGNORE_THREAD_SAFETY + PUSH_IGNORE_THREAD_SAFETY AssertOnThread(); mListener->OnStopRequest(this, mStatus); - MOZ_POP_THREAD_SAFETY + POP_THREAD_SAFETY } mTargetThread = nullptr; mListener = nullptr; diff --git a/netwerk/base/nsInputStreamPump.h b/netwerk/base/nsInputStreamPump.h index e9a3ae6b5981..ef815c7f9555 100644 --- a/netwerk/base/nsInputStreamPump.h +++ b/netwerk/base/nsInputStreamPump.h @@ -77,47 +77,47 @@ class nsInputStreamPump final : public nsIInputStreamPump, uint32_t OnStateStart(); uint32_t OnStateTransfer(); uint32_t OnStateStop(); - nsresult CreateBufferedStreamIfNeeded() MOZ_REQUIRES(mMutex); + nsresult CreateBufferedStreamIfNeeded() REQUIRES(mMutex); // This should optimize away in non-DEBUG builds MOZ_ALWAYS_INLINE void AssertOnThread() const { - MOZ_PUSH_IGNORE_THREAD_SAFETY + PUSH_IGNORE_THREAD_SAFETY if (mOffMainThread) { MOZ_ASSERT(mTargetThread->IsOnCurrentThread()); } else { MOZ_ASSERT(NS_IsMainThread()); } - MOZ_POP_THREAD_SAFETY + POP_THREAD_SAFETY } - uint32_t mState MOZ_GUARDED_BY(mMutex){STATE_IDLE}; - nsCOMPtr mLoadGroup MOZ_GUARDED_BY(mMutex); + uint32_t mState GUARDED_BY(mMutex){STATE_IDLE}; + nsCOMPtr mLoadGroup GUARDED_BY(mMutex); // mListener is written on a single thread (either MainThread or an // off-MainThread thread), read from that thread and perhaps others (in // RetargetDeliveryTo) - nsCOMPtr mListener MOZ_GUARDED_BY(mMutex); - nsCOMPtr mTargetThread MOZ_GUARDED_BY(mMutex); - nsCOMPtr mLabeledMainThreadTarget MOZ_GUARDED_BY(mMutex); - nsCOMPtr mStream MOZ_GUARDED_BY(mMutex); + nsCOMPtr mListener GUARDED_BY(mMutex); + nsCOMPtr mTargetThread GUARDED_BY(mMutex); + nsCOMPtr mLabeledMainThreadTarget GUARDED_BY(mMutex); + nsCOMPtr mStream GUARDED_BY(mMutex); // mAsyncStream is written on a single thread (either MainThread or an // off-MainThread thread), and lives from AsyncRead() to OnStateStop(). - nsCOMPtr mAsyncStream MOZ_GUARDED_BY(mMutex); - uint64_t mStreamOffset MOZ_GUARDED_BY(mMutex){0}; - uint64_t mStreamLength MOZ_GUARDED_BY(mMutex){0}; - uint32_t mSegSize MOZ_GUARDED_BY(mMutex){0}; - uint32_t mSegCount MOZ_GUARDED_BY(mMutex){0}; - nsresult mStatus MOZ_GUARDED_BY(mMutex){NS_OK}; - uint32_t mSuspendCount MOZ_GUARDED_BY(mMutex){0}; - uint32_t mLoadFlags MOZ_GUARDED_BY(mMutex){LOAD_NORMAL}; - bool mIsPending MOZ_GUARDED_BY(mMutex){false}; + nsCOMPtr mAsyncStream GUARDED_BY(mMutex); + uint64_t mStreamOffset GUARDED_BY(mMutex){0}; + uint64_t mStreamLength GUARDED_BY(mMutex){0}; + uint32_t mSegSize GUARDED_BY(mMutex){0}; + uint32_t mSegCount GUARDED_BY(mMutex){0}; + nsresult mStatus GUARDED_BY(mMutex){NS_OK}; + uint32_t mSuspendCount GUARDED_BY(mMutex){0}; + uint32_t mLoadFlags GUARDED_BY(mMutex){LOAD_NORMAL}; + bool mIsPending GUARDED_BY(mMutex){false}; // True while in OnInputStreamReady, calling OnStateStart, OnStateTransfer // and OnStateStop. Used to prevent calls to AsyncWait during callbacks. - bool mProcessingCallbacks MOZ_GUARDED_BY(mMutex){false}; + bool mProcessingCallbacks GUARDED_BY(mMutex){false}; // True if waiting on the "input stream ready" callback. - bool mWaitingForInputStreamReady MOZ_GUARDED_BY(mMutex){false}; - bool mCloseWhenDone MOZ_GUARDED_BY(mMutex){false}; - bool mRetargeting MOZ_GUARDED_BY(mMutex){false}; - bool mAsyncStreamIsBuffered MOZ_GUARDED_BY(mMutex){false}; + bool mWaitingForInputStreamReady GUARDED_BY(mMutex){false}; + bool mCloseWhenDone GUARDED_BY(mMutex){false}; + bool mRetargeting GUARDED_BY(mMutex){false}; + bool mAsyncStreamIsBuffered GUARDED_BY(mMutex){false}; // Indicate whether nsInputStreamPump is used completely off main thread. // If true, OnStateStop() is executed off main thread. Set at creation. const bool mOffMainThread; diff --git a/netwerk/base/nsProtocolProxyService.cpp b/netwerk/base/nsProtocolProxyService.cpp index 28b95c2219c0..d433dbaf47f9 100644 --- a/netwerk/base/nsProtocolProxyService.cpp +++ b/netwerk/base/nsProtocolProxyService.cpp @@ -1513,8 +1513,8 @@ class nsAsyncBridgeRequest final : public nsPACManCallback { mCondVar.Notify(); } - void Lock() MOZ_CAPABILITY_ACQUIRE(mMutex) { mMutex.Lock(); } - void Unlock() MOZ_CAPABILITY_RELEASE(mMutex) { mMutex.Unlock(); } + void Lock() CAPABILITY_ACQUIRE(mMutex) { mMutex.Lock(); } + void Unlock() CAPABILITY_RELEASE(mMutex) { mMutex.Unlock(); } void Wait() { mCondVar.Wait(TimeDuration::FromSeconds(3)); } private: @@ -1525,10 +1525,10 @@ class nsAsyncBridgeRequest final : public nsPACManCallback { Mutex mMutex; CondVar mCondVar; - nsresult mStatus MOZ_GUARDED_BY(mMutex){NS_OK}; - nsCString mPACString MOZ_GUARDED_BY(mMutex); - nsCString mPACURL MOZ_GUARDED_BY(mMutex); - bool mCompleted MOZ_GUARDED_BY(mMutex){false}; + nsresult mStatus GUARDED_BY(mMutex){NS_OK}; + nsCString mPACString GUARDED_BY(mMutex); + nsCString mPACURL GUARDED_BY(mMutex); + bool mCompleted GUARDED_BY(mMutex){false}; }; NS_IMPL_ISUPPORTS0(nsAsyncBridgeRequest) diff --git a/netwerk/base/nsStreamTransportService.cpp b/netwerk/base/nsStreamTransportService.cpp index d2e227dbbbc1..46cc7385cd1d 100644 --- a/netwerk/base/nsStreamTransportService.cpp +++ b/netwerk/base/nsStreamTransportService.cpp @@ -251,7 +251,7 @@ nsStreamTransportService::~nsStreamTransportService() { nsresult nsStreamTransportService::Init() { // Can't be used multithreaded before this - MOZ_PUSH_IGNORE_THREAD_SAFETY + PUSH_IGNORE_THREAD_SAFETY MOZ_ASSERT(!mPool); mPool = new nsThreadPool(); @@ -261,7 +261,7 @@ nsresult nsStreamTransportService::Init() { mPool->SetIdleThreadLimit(5); mPool->SetIdleThreadTimeoutRegressive(true); mPool->SetIdleThreadTimeout(PR_SecondsToInterval(30)); - MOZ_POP_THREAD_SAFETY + POP_THREAD_SAFETY nsCOMPtr obsSvc = mozilla::services::GetObserverService(); if (obsSvc) obsSvc->AddObserver(this, "xpcom-shutdown-threads", false); diff --git a/netwerk/base/nsStreamTransportService.h b/netwerk/base/nsStreamTransportService.h index 1229c0ca44b2..8e397277b3f5 100644 --- a/netwerk/base/nsStreamTransportService.h +++ b/netwerk/base/nsStreamTransportService.h @@ -36,10 +36,10 @@ class nsStreamTransportService final : public nsIStreamTransportService, private: ~nsStreamTransportService(); - nsCOMPtr mPool MOZ_GUARDED_BY(mShutdownLock); + nsCOMPtr mPool GUARDED_BY(mShutdownLock); mozilla::Mutex mShutdownLock{"nsStreamTransportService.mShutdownLock"}; - bool mIsShutdown MOZ_GUARDED_BY(mShutdownLock){false}; + bool mIsShutdown GUARDED_BY(mShutdownLock){false}; }; } // namespace net diff --git a/netwerk/cache2/CacheFile.h b/netwerk/cache2/CacheFile.h index 61debfcb1ab4..1369801efc00 100644 --- a/netwerk/cache2/CacheFile.h +++ b/netwerk/cache2/CacheFile.h @@ -140,7 +140,7 @@ class CacheFile final : public CacheFileChunkListener, virtual ~CacheFile(); - MOZ_PUSH_IGNORE_THREAD_SAFETY + PUSH_IGNORE_THREAD_SAFETY void Lock() { mLock->Lock().Lock(); } void Unlock() { // move the elements out of mObjsToRelease @@ -149,7 +149,7 @@ class CacheFile final : public CacheFileChunkListener, mLock->Lock().Unlock(); } - MOZ_POP_THREAD_SAFETY + POP_THREAD_SAFETY void AssertOwnsLock() const { mLock->Lock().AssertCurrentThreadOwns(); } void ReleaseOutsideLock(RefPtr aObject); diff --git a/netwerk/dns/ODoHService.h b/netwerk/dns/ODoHService.h index 4e09ebe3984c..52c39e32f7eb 100644 --- a/netwerk/dns/ODoHService.h +++ b/netwerk/dns/ODoHService.h @@ -60,16 +60,16 @@ class ODoHService : public nsIDNSListener, mozilla::Mutex mLock; Atomic mQueryODoHConfigInProgress; - nsCString mODoHProxyURI MOZ_GUARDED_BY(mLock); - nsCString mODoHTargetHost MOZ_GUARDED_BY(mLock); - nsCString mODoHTargetPath MOZ_GUARDED_BY(mLock); - nsCString mODoHRequestURI MOZ_GUARDED_BY(mLock); - nsCString mODoHConfigsUri MOZ_GUARDED_BY(mLock); - Maybe> mODoHConfigs MOZ_GUARDED_BY(mLock); - nsTArray> mPendingRequests MOZ_GUARDED_BY(mLock); + nsCString mODoHProxyURI GUARDED_BY(mLock); + nsCString mODoHTargetHost GUARDED_BY(mLock); + nsCString mODoHTargetPath GUARDED_BY(mLock); + nsCString mODoHRequestURI GUARDED_BY(mLock); + nsCString mODoHConfigsUri GUARDED_BY(mLock); + Maybe> mODoHConfigs GUARDED_BY(mLock); + nsTArray> mPendingRequests GUARDED_BY(mLock); // This timer is always touched on main thread to avoid race conditions. nsCOMPtr mTTLTimer; - nsCOMPtr mLoader MOZ_GUARDED_BY(mLock); + nsCOMPtr mLoader GUARDED_BY(mLock); }; extern ODoHService* gODoHService; diff --git a/netwerk/dns/TRRService.h b/netwerk/dns/TRRService.h index d7b438517695..12c86d2a63e9 100644 --- a/netwerk/dns/TRRService.h +++ b/netwerk/dns/TRRService.h @@ -125,8 +125,8 @@ class TRRService : public TRRServiceBase, MutexSingleWriter mLock; nsCString mPrivateCred; // main thread only - nsCString mConfirmationNS MOZ_GUARDED_BY(mLock){"example.com"_ns}; - nsCString mBootstrapAddr MOZ_GUARDED_BY(mLock); + nsCString mConfirmationNS GUARDED_BY(mLock){"example.com"_ns}; + nsCString mBootstrapAddr GUARDED_BY(mLock); Atomic mCaptiveIsPassed{ false}; // set when captive portal check is passed @@ -141,9 +141,9 @@ class TRRService : public TRRServiceBase, "DataMutex::TRRBlocklist"}; // A set of domains that we should not use TRR for. - nsTHashSet mExcludedDomains MOZ_GUARDED_BY(mLock); - nsTHashSet mDNSSuffixDomains MOZ_GUARDED_BY(mLock); - nsTHashSet mEtcHostsDomains MOZ_GUARDED_BY(mLock); + nsTHashSet mExcludedDomains GUARDED_BY(mLock); + nsTHashSet mDNSSuffixDomains GUARDED_BY(mLock); + nsTHashSet mEtcHostsDomains GUARDED_BY(mLock); enum class ConfirmationEvent { Init, diff --git a/netwerk/dns/nsHostResolver.cpp b/netwerk/dns/nsHostResolver.cpp index 8ec979a4751e..ebb91c27b7ec 100644 --- a/netwerk/dns/nsHostResolver.cpp +++ b/netwerk/dns/nsHostResolver.cpp @@ -175,7 +175,7 @@ nsHostResolver::nsHostResolver(uint32_t maxCacheEntries, nsHostResolver::~nsHostResolver() = default; -nsresult nsHostResolver::Init() MOZ_NO_THREAD_SAFETY_ANALYSIS { +nsresult nsHostResolver::Init() NO_THREAD_SAFETY_ANALYSIS { MOZ_ASSERT(NS_IsMainThread()); if (NS_FAILED(GetAddrInfoInit())) { return NS_ERROR_FAILURE; diff --git a/netwerk/dns/nsHostResolver.h b/netwerk/dns/nsHostResolver.h index 3467b3884a75..373bd63648ca 100644 --- a/netwerk/dns/nsHostResolver.h +++ b/netwerk/dns/nsHostResolver.h @@ -211,7 +211,7 @@ class nsHostResolver : public nsISupports, public AHostResolver { // Records true if the TRR service is enabled for the record's effective // TRR mode. Also records the TRRSkipReason when the TRR service is not // available/enabled. - bool TRRServiceEnabledForRecord(nsHostRecord* aRec) MOZ_REQUIRES(mLock); + bool TRRServiceEnabledForRecord(nsHostRecord* aRec) REQUIRES(mLock); private: explicit nsHostResolver(uint32_t maxCacheEntries, @@ -230,11 +230,11 @@ class nsHostResolver : public nsISupports, public AHostResolver { mozilla::net::TRRSkippedReason aReason, mozilla::net::TRR* aTRRRequest, const mozilla::MutexAutoLock& aLock) - MOZ_REQUIRES(mLock); + REQUIRES(mLock); LookupStatus CompleteLookupByTypeLocked( nsHostRecord*, nsresult, mozilla::net::TypeRecordResultType& aResult, uint32_t aTtl, bool pb, const mozilla::MutexAutoLock& aLock) - MOZ_REQUIRES(mLock); + REQUIRES(mLock); nsresult Init(); static void ComputeEffectiveTRRMode(nsHostRecord* aRec); nsresult NativeLookup(nsHostRecord* aRec, @@ -247,12 +247,12 @@ class nsHostResolver : public nsISupports, public AHostResolver { bool GetHostToLookup(AddrHostRecord** result); void MaybeRenewHostRecordLocked(nsHostRecord* aRec, const mozilla::MutexAutoLock& aLock) - MOZ_REQUIRES(mLock); + REQUIRES(mLock); // Cancels host records in the pending queue and also // calls CompleteLookup with the NS_ERROR_ABORT result code. void ClearPendingQueue(mozilla::LinkedList>& aPendingQ); - nsresult ConditionallyCreateThread(nsHostRecord* rec) MOZ_REQUIRES(mLock); + nsresult ConditionallyCreateThread(nsHostRecord* rec) REQUIRES(mLock); /** * Starts a new lookup in the background for entries that are in the grace @@ -260,10 +260,10 @@ class nsHostResolver : public nsISupports, public AHostResolver { */ nsresult ConditionallyRefreshRecord(nsHostRecord* rec, const nsACString& host, const mozilla::MutexAutoLock& aLock) - MOZ_REQUIRES(mLock); + REQUIRES(mLock); void AddToEvictionQ(nsHostRecord* rec, const mozilla::MutexAutoLock& aLock) - MOZ_REQUIRES(mLock); + REQUIRES(mLock); void ThreadFunc(); @@ -272,7 +272,7 @@ class nsHostResolver : public nsISupports, public AHostResolver { const nsACString& aHost, uint16_t aType, nsresult& aStatus, const mozilla::MutexAutoLock& aLock) - MOZ_REQUIRES(mLock); + REQUIRES(mLock); // Called when the host name is an IP address and has been passed. already_AddRefed FromCachedIPLiteral(nsHostRecord* aRec); // Like the above function, but the host name is not parsed to NetAddr yet. @@ -282,7 +282,7 @@ class nsHostResolver : public nsISupports, public AHostResolver { already_AddRefed FromUnspecEntry( nsHostRecord* aRec, const nsACString& aHost, const nsACString& aTrrServer, const nsACString& aOriginSuffix, uint16_t aType, uint16_t aFlags, - uint16_t af, bool aPb, nsresult& aStatus) MOZ_REQUIRES(mLock); + uint16_t af, bool aPb, nsresult& aStatus) REQUIRES(mLock); enum { METHOD_HIT = 1, @@ -301,7 +301,7 @@ class nsHostResolver : public nsISupports, public AHostResolver { mutable Mutex mLock{"nsHostResolver.mLock"}; CondVar mIdleTaskCV; nsRefPtrHashtable, nsHostRecord> mRecordDB - MOZ_GUARDED_BY(mLock); + GUARDED_BY(mLock); PRTime mCreationTime; mozilla::TimeDuration mLongIdleTimeout; mozilla::TimeDuration mShortIdleTimeout; @@ -309,11 +309,11 @@ class nsHostResolver : public nsISupports, public AHostResolver { RefPtr mResolverThreads; RefPtr mNCS; // reference to a singleton - mozilla::net::HostRecordQueue mQueue MOZ_GUARDED_BY(mLock); - mozilla::Atomic mShutdown MOZ_GUARDED_BY(mLock){true}; - mozilla::Atomic mNumIdleTasks MOZ_GUARDED_BY(mLock){0}; - mozilla::Atomic mActiveTaskCount MOZ_GUARDED_BY(mLock){0}; - mozilla::Atomic mActiveAnyThreadCount MOZ_GUARDED_BY(mLock){0}; + mozilla::net::HostRecordQueue mQueue GUARDED_BY(mLock); + mozilla::Atomic mShutdown GUARDED_BY(mLock){true}; + mozilla::Atomic mNumIdleTasks GUARDED_BY(mLock){0}; + mozilla::Atomic mActiveTaskCount GUARDED_BY(mLock){0}; + mozilla::Atomic mActiveAnyThreadCount GUARDED_BY(mLock){0}; // Set the expiration time stamps appropriately. void PrepareRecordExpirationAddrRecord(AddrHostRecord* rec) const; diff --git a/netwerk/dns/nsIDNService.cpp b/netwerk/dns/nsIDNService.cpp index c4e862f8e373..05dbb6893251 100644 --- a/netwerk/dns/nsIDNService.cpp +++ b/netwerk/dns/nsIDNService.cpp @@ -395,23 +395,23 @@ NS_IMETHODIMP nsIDNService::Normalize(const nsACString& input, namespace { template -class MOZ_CAPABILITY MOZ_STACK_CLASS MutexSettableAutoUnlock final { +class CAPABILITY MOZ_STACK_CLASS MutexSettableAutoUnlock final { private: T* mMutex = nullptr; public: MutexSettableAutoUnlock() = default; - void Acquire(T& aMutex) MOZ_CAPABILITY_ACQUIRE(aMutex) { + void Acquire(T& aMutex) CAPABILITY_ACQUIRE(aMutex) { MOZ_ASSERT(!mMutex); mMutex = &aMutex; aMutex.Lock(); } // Since this is commonly used in "if (!NS_IsMainThread())", if we make - // this MOZ_CAPABILITY_RELEASE(mMutex) we'll generate warnings on each return. + // this CAPABILITY_RELEASE(mMutex) we'll generate warnings on each return. // We may still get a warning at the end of a function using this - ~MutexSettableAutoUnlock() MOZ_CAPABILITY_ACQUIRE() { + ~MutexSettableAutoUnlock() CAPABILITY_ACQUIRE() { if (mMutex) { mMutex->Unlock(); } @@ -423,7 +423,7 @@ class MOZ_CAPABILITY MOZ_STACK_CLASS MutexSettableAutoUnlock final { // conditional locks blow threadsafety's mind NS_IMETHODIMP nsIDNService::ConvertToDisplayIDN( const nsACString& input, bool* _isASCII, - nsACString& _retval) MOZ_NO_THREAD_SAFETY_ANALYSIS { + nsACString& _retval) NO_THREAD_SAFETY_ANALYSIS { MutexSettableAutoUnlock lock; if (!NS_IsMainThread()) { lock.Acquire(mLock); diff --git a/netwerk/dns/nsIDNService.h b/netwerk/dns/nsIDNService.h index 72dad638f7e3..6dd8fb2d6326 100644 --- a/netwerk/dns/nsIDNService.h +++ b/netwerk/dns/nsIDNService.h @@ -176,7 +176,7 @@ class nsIDNService final : public nsIIDNService, mozilla::MutexSingleWriter mLock; // guarded by mLock - nsTArray mIDNBlocklist MOZ_GUARDED_BY(mLock); + nsTArray mIDNBlocklist GUARDED_BY(mLock); /** * Flag set by the pref network.IDN_show_punycode. When it is true, @@ -185,7 +185,7 @@ class nsIDNService final : public nsIIDNService, * * guarded by mLock */ - bool mShowPunycode MOZ_GUARDED_BY(mLock) = false; + bool mShowPunycode GUARDED_BY(mLock) = false; /** * Restriction-level Detection profiles defined in UTR 39 @@ -198,12 +198,11 @@ class nsIDNService final : public nsIIDNService, eModeratelyRestrictiveProfile }; // guarded by mLock; - restrictionProfile mRestrictionProfile MOZ_GUARDED_BY(mLock){ - eASCIIOnlyProfile}; + restrictionProfile mRestrictionProfile GUARDED_BY(mLock){eASCIIOnlyProfile}; // guarded by mLock; - nsCOMPtr mIDNWhitelistPrefBranch MOZ_GUARDED_BY(mLock); + nsCOMPtr mIDNWhitelistPrefBranch GUARDED_BY(mLock); // guarded by mLock - bool mIDNUseWhitelist MOZ_GUARDED_BY(mLock) = false; + bool mIDNUseWhitelist GUARDED_BY(mLock) = false; }; #endif // nsIDNService_h__ diff --git a/netwerk/ipc/ChannelEventQueue.h b/netwerk/ipc/ChannelEventQueue.h index 27b32795109e..33b0c64d304c 100644 --- a/netwerk/ipc/ChannelEventQueue.h +++ b/netwerk/ipc/ChannelEventQueue.h @@ -166,7 +166,7 @@ class ChannelEventQueue final { void SuspendInternal(); void ResumeInternal(); - bool MaybeSuspendIfEventsAreSuppressed() MOZ_REQUIRES(mMutex); + bool MaybeSuspendIfEventsAreSuppressed() REQUIRES(mMutex); inline void MaybeFlushQueue(); void FlushQueue(); @@ -174,13 +174,13 @@ class ChannelEventQueue final { ChannelEvent* TakeEvent(); - nsTArray> mEventQueue MOZ_GUARDED_BY(mMutex); + nsTArray> mEventQueue GUARDED_BY(mMutex); - uint32_t mSuspendCount MOZ_GUARDED_BY(mMutex); - bool mSuspended MOZ_GUARDED_BY(mMutex); + uint32_t mSuspendCount GUARDED_BY(mMutex); + bool mSuspended GUARDED_BY(mMutex); uint32_t mForcedCount // Support ForcedQueueing on multiple thread. - MOZ_GUARDED_BY(mMutex); - bool mFlushing MOZ_GUARDED_BY(mMutex); + GUARDED_BY(mMutex); + bool mFlushing GUARDED_BY(mMutex); // Whether the queue is associated with an XHR. This is lazily instantiated // the first time it is needed. These are MainThread-only. @@ -188,13 +188,13 @@ class ChannelEventQueue final { bool mForXMLHttpRequest; // Keep ptr to avoid refcount cycle: only grab ref during flushing. - nsISupports* mOwner MOZ_GUARDED_BY(mMutex); + nsISupports* mOwner GUARDED_BY(mMutex); // For atomic mEventQueue operation and state update Mutex mMutex; // To guarantee event execution order among threads - RecursiveMutex mRunningMutex MOZ_ACQUIRED_BEFORE(mMutex); + RecursiveMutex mRunningMutex ACQUIRED_BEFORE(mMutex); friend class AutoEventEnqueuer; }; diff --git a/netwerk/protocol/http/HttpChannelChild.h b/netwerk/protocol/http/HttpChannelChild.h index ddbf8d398196..fb336a99cb3d 100644 --- a/netwerk/protocol/http/HttpChannelChild.h +++ b/netwerk/protocol/http/HttpChannelChild.h @@ -274,17 +274,17 @@ class HttpChannelChild final : public PHttpChannelChild, Mutex mBgChildMutex{"HttpChannelChild::BgChildMutex"}; // Associated HTTP background channel - RefPtr mBgChild MOZ_GUARDED_BY(mBgChildMutex); + RefPtr mBgChild GUARDED_BY(mBgChildMutex); // Error handling procedure if failed to establish PBackground IPC - nsCOMPtr mBgInitFailCallback MOZ_GUARDED_BY(mBgChildMutex); + nsCOMPtr mBgInitFailCallback GUARDED_BY(mBgChildMutex); // Remove the association with background channel after OnStopRequest // or AsyncAbort. void CleanupBackgroundChannel(); // Target thread for delivering ODA. - nsCOMPtr mODATarget MOZ_GUARDED_BY(mEventTargetMutex); + nsCOMPtr mODATarget GUARDED_BY(mEventTargetMutex); // Used to ensure atomicity of mNeckoTarget / mODATarget; Mutex mEventTargetMutex{"HttpChannelChild::EventTargetMutex"}; diff --git a/netwerk/protocol/http/PHttpChannelParams.h b/netwerk/protocol/http/PHttpChannelParams.h index ce1297108e95..00d8f6ff8f02 100644 --- a/netwerk/protocol/http/PHttpChannelParams.h +++ b/netwerk/protocol/http/PHttpChannelParams.h @@ -182,7 +182,7 @@ struct ParamTraits { typedef mozilla::net::nsHttpRequestHead paramType; static void Write(MessageWriter* aWriter, - const paramType& aParam) MOZ_NO_THREAD_SAFETY_ANALYSIS { + const paramType& aParam) NO_THREAD_SAFETY_ANALYSIS { aParam.Enter(); WriteParam(aWriter, aParam.mHeaders); WriteParam(aWriter, aParam.mMethod); @@ -225,7 +225,7 @@ struct ParamTraits { typedef mozilla::net::nsHttpResponseHead paramType; static void Write(MessageWriter* aWriter, - const paramType& aParam) MOZ_NO_THREAD_SAFETY_ANALYSIS { + const paramType& aParam) NO_THREAD_SAFETY_ANALYSIS { aParam.Enter(); WriteParam(aWriter, aParam.mHeaders); WriteParam(aWriter, static_cast(aParam.mVersion)); diff --git a/netwerk/protocol/http/nsHttpConnectionMgr.h b/netwerk/protocol/http/nsHttpConnectionMgr.h index ddea5311f076..a72ed944f05d 100644 --- a/netwerk/protocol/http/nsHttpConnectionMgr.h +++ b/netwerk/protocol/http/nsHttpConnectionMgr.h @@ -209,8 +209,7 @@ class nsHttpConnectionMgr final : public HttpConnectionMgrShell, ReentrantMonitor mReentrantMonitor{"nsHttpConnectionMgr.mReentrantMonitor"}; // This is used as a flag that we're shut down, and no new events should be // dispatched. - nsCOMPtr mSocketThreadTarget - MOZ_GUARDED_BY(mReentrantMonitor); + nsCOMPtr mSocketThreadTarget GUARDED_BY(mReentrantMonitor); Atomic mIsShuttingDown{false}; diff --git a/netwerk/protocol/http/nsHttpRequestHead.h b/netwerk/protocol/http/nsHttpRequestHead.h index 7ddee4a87992..2e9a9c9d6a5f 100644 --- a/netwerk/protocol/http/nsHttpRequestHead.h +++ b/netwerk/protocol/http/nsHttpRequestHead.h @@ -41,10 +41,10 @@ class nsHttpRequestHead { // copying headers. If you use it be careful to do it only under // nsHttpRequestHead lock!!! const nsHttpHeaderArray& Headers() const; - void Enter() const MOZ_CAPABILITY_ACQUIRE(mRecursiveMutex) { + void Enter() const CAPABILITY_ACQUIRE(mRecursiveMutex) { mRecursiveMutex.Lock(); } - void Exit() const MOZ_CAPABILITY_RELEASE(mRecursiveMutex) { + void Exit() const CAPABILITY_RELEASE(mRecursiveMutex) { mRecursiveMutex.Unlock(); } @@ -124,19 +124,19 @@ class nsHttpRequestHead { private: // All members must be copy-constructable and assignable - nsHttpHeaderArray mHeaders MOZ_GUARDED_BY(mRecursiveMutex); - nsCString mMethod MOZ_GUARDED_BY(mRecursiveMutex){"GET"_ns}; - HttpVersion mVersion MOZ_GUARDED_BY(mRecursiveMutex){HttpVersion::v1_1}; + nsHttpHeaderArray mHeaders GUARDED_BY(mRecursiveMutex); + nsCString mMethod GUARDED_BY(mRecursiveMutex){"GET"_ns}; + HttpVersion mVersion GUARDED_BY(mRecursiveMutex){HttpVersion::v1_1}; // mRequestURI and mPath are strings instead of an nsIURI // because this is used off the main thread // TODO: nsIURI is thread-safe now, should be fixable. - nsCString mRequestURI MOZ_GUARDED_BY(mRecursiveMutex); - nsCString mPath MOZ_GUARDED_BY(mRecursiveMutex); + nsCString mRequestURI GUARDED_BY(mRecursiveMutex); + nsCString mPath GUARDED_BY(mRecursiveMutex); - nsCString mOrigin MOZ_GUARDED_BY(mRecursiveMutex); - ParsedMethodType mParsedMethod MOZ_GUARDED_BY(mRecursiveMutex){kMethod_Get}; - bool mHTTPS MOZ_GUARDED_BY(mRecursiveMutex){false}; + nsCString mOrigin GUARDED_BY(mRecursiveMutex); + ParsedMethodType mParsedMethod GUARDED_BY(mRecursiveMutex){kMethod_Get}; + bool mHTTPS GUARDED_BY(mRecursiveMutex){false}; // We are using RecursiveMutex instead of a Mutex because VisitHeader // function calls nsIHttpHeaderVisitor::VisitHeader while under lock. @@ -144,7 +144,7 @@ class nsHttpRequestHead { "nsHttpRequestHead.mRecursiveMutex"}; // During VisitHeader we sould not allow call to SetHeader. - bool mInVisitHeaders MOZ_GUARDED_BY(mRecursiveMutex){false}; + bool mInVisitHeaders GUARDED_BY(mRecursiveMutex){false}; friend struct IPC::ParamTraits; }; diff --git a/netwerk/protocol/http/nsHttpResponseHead.cpp b/netwerk/protocol/http/nsHttpResponseHead.cpp index 9758aaf9b01b..c1a8b6bd6b97 100644 --- a/netwerk/protocol/http/nsHttpResponseHead.cpp +++ b/netwerk/protocol/http/nsHttpResponseHead.cpp @@ -1046,7 +1046,7 @@ nsresult nsHttpResponseHead::GetLastModifiedValue(uint32_t* result) { } bool nsHttpResponseHead::operator==(const nsHttpResponseHead& aOther) const - MOZ_NO_THREAD_SAFETY_ANALYSIS { + NO_THREAD_SAFETY_ANALYSIS { nsHttpResponseHead& curr = const_cast(*this); nsHttpResponseHead& other = const_cast(aOther); RecursiveMutexAutoLock monitorOther(other.mRecursiveMutex); diff --git a/netwerk/protocol/http/nsHttpResponseHead.h b/netwerk/protocol/http/nsHttpResponseHead.h index e68a3340d659..2c1d6d5ddd80 100644 --- a/netwerk/protocol/http/nsHttpResponseHead.h +++ b/netwerk/protocol/http/nsHttpResponseHead.h @@ -43,10 +43,10 @@ class nsHttpResponseHead { nsHttpResponseHead(const nsHttpResponseHead& aOther); nsHttpResponseHead& operator=(const nsHttpResponseHead& aOther); - void Enter() const MOZ_CAPABILITY_ACQUIRE(mRecursiveMutex) { + void Enter() const CAPABILITY_ACQUIRE(mRecursiveMutex) { mRecursiveMutex.Lock(); } - void Exit() const MOZ_CAPABILITY_RELEASE(mRecursiveMutex) { + void Exit() const CAPABILITY_RELEASE(mRecursiveMutex) { mRecursiveMutex.Unlock(); } void AssertMutexOwned() const { mRecursiveMutex.AssertCurrentThreadIn(); } @@ -150,49 +150,48 @@ class nsHttpResponseHead { [[nodiscard]] nsresult SetHeader_locked(const nsHttpAtom& atom, const nsACString& h, const nsACString& v, bool m = false) - MOZ_REQUIRES(mRecursiveMutex); - void AssignDefaultStatusText() MOZ_REQUIRES(mRecursiveMutex); - void ParseVersion(const char*) MOZ_REQUIRES(mRecursiveMutex); - void ParseCacheControl(const char*) MOZ_REQUIRES(mRecursiveMutex); - void ParsePragma(const char*) MOZ_REQUIRES(mRecursiveMutex); + REQUIRES(mRecursiveMutex); + void AssignDefaultStatusText() REQUIRES(mRecursiveMutex); + void ParseVersion(const char*) REQUIRES(mRecursiveMutex); + void ParseCacheControl(const char*) REQUIRES(mRecursiveMutex); + void ParsePragma(const char*) REQUIRES(mRecursiveMutex); - void ParseStatusLine_locked(const nsACString& line) - MOZ_REQUIRES(mRecursiveMutex); + void ParseStatusLine_locked(const nsACString& line) REQUIRES(mRecursiveMutex); [[nodiscard]] nsresult ParseHeaderLine_locked(const nsACString& line, bool originalFromNetHeaders) - MOZ_REQUIRES(mRecursiveMutex); + REQUIRES(mRecursiveMutex); // these return failure if the header does not exist. [[nodiscard]] nsresult ParseDateHeader(const nsHttpAtom& header, uint32_t* result) const - MOZ_REQUIRES(mRecursiveMutex); + REQUIRES(mRecursiveMutex); [[nodiscard]] nsresult GetAgeValue(uint32_t* result); [[nodiscard]] nsresult GetMaxAgeValue(uint32_t* result); [[nodiscard]] nsresult GetStaleWhileRevalidateValue(uint32_t* result); [[nodiscard]] nsresult GetDateValue(uint32_t* result); [[nodiscard]] nsresult GetExpiresValue(uint32_t* result); - bool ExpiresInPast_locked() const MOZ_REQUIRES(mRecursiveMutex); + bool ExpiresInPast_locked() const REQUIRES(mRecursiveMutex); [[nodiscard]] nsresult GetAgeValue_locked(uint32_t* result) const - MOZ_REQUIRES(mRecursiveMutex); + REQUIRES(mRecursiveMutex); [[nodiscard]] nsresult GetExpiresValue_locked(uint32_t* result) const - MOZ_REQUIRES(mRecursiveMutex); + REQUIRES(mRecursiveMutex); [[nodiscard]] nsresult GetMaxAgeValue_locked(uint32_t* result) const - MOZ_REQUIRES(mRecursiveMutex); + REQUIRES(mRecursiveMutex); [[nodiscard]] nsresult GetStaleWhileRevalidateValue_locked( - uint32_t* result) const MOZ_REQUIRES(mRecursiveMutex); + uint32_t* result) const REQUIRES(mRecursiveMutex); [[nodiscard]] nsresult GetDateValue_locked(uint32_t* result) const - MOZ_REQUIRES(mRecursiveMutex) { + REQUIRES(mRecursiveMutex) { return ParseDateHeader(nsHttp::Date, result); } [[nodiscard]] nsresult GetLastModifiedValue_locked(uint32_t* result) const - MOZ_REQUIRES(mRecursiveMutex) { + REQUIRES(mRecursiveMutex) { return ParseDateHeader(nsHttp::Last_Modified, result); } - bool NoCache_locked() const MOZ_REQUIRES(mRecursiveMutex) { + bool NoCache_locked() const REQUIRES(mRecursiveMutex) { // We ignore Pragma: no-cache if Cache-Control is set. MOZ_ASSERT_IF(mCacheControlNoCache, mHasCacheControl); return mHasCacheControl ? mCacheControlNoCache : mPragmaNoCache; @@ -200,31 +199,30 @@ class nsHttpResponseHead { private: // All members must be copy-constructable and assignable - nsHttpHeaderArray mHeaders MOZ_GUARDED_BY(mRecursiveMutex); - HttpVersion mVersion MOZ_GUARDED_BY(mRecursiveMutex){HttpVersion::v1_1}; - uint16_t mStatus MOZ_GUARDED_BY(mRecursiveMutex){200}; - nsCString mStatusText MOZ_GUARDED_BY(mRecursiveMutex); - int64_t mContentLength MOZ_GUARDED_BY(mRecursiveMutex){-1}; - nsCString mContentType MOZ_GUARDED_BY(mRecursiveMutex); - nsCString mContentCharset MOZ_GUARDED_BY(mRecursiveMutex); - bool mHasCacheControl MOZ_GUARDED_BY(mRecursiveMutex){false}; - bool mCacheControlPublic MOZ_GUARDED_BY(mRecursiveMutex){false}; - bool mCacheControlPrivate MOZ_GUARDED_BY(mRecursiveMutex){false}; - bool mCacheControlNoStore MOZ_GUARDED_BY(mRecursiveMutex){false}; - bool mCacheControlNoCache MOZ_GUARDED_BY(mRecursiveMutex){false}; - bool mCacheControlImmutable MOZ_GUARDED_BY(mRecursiveMutex){false}; - bool mCacheControlStaleWhileRevalidateSet MOZ_GUARDED_BY(mRecursiveMutex){ - false}; - uint32_t mCacheControlStaleWhileRevalidate MOZ_GUARDED_BY(mRecursiveMutex){0}; - bool mCacheControlMaxAgeSet MOZ_GUARDED_BY(mRecursiveMutex){false}; - uint32_t mCacheControlMaxAge MOZ_GUARDED_BY(mRecursiveMutex){0}; - bool mPragmaNoCache MOZ_GUARDED_BY(mRecursiveMutex){false}; + nsHttpHeaderArray mHeaders GUARDED_BY(mRecursiveMutex); + HttpVersion mVersion GUARDED_BY(mRecursiveMutex){HttpVersion::v1_1}; + uint16_t mStatus GUARDED_BY(mRecursiveMutex){200}; + nsCString mStatusText GUARDED_BY(mRecursiveMutex); + int64_t mContentLength GUARDED_BY(mRecursiveMutex){-1}; + nsCString mContentType GUARDED_BY(mRecursiveMutex); + nsCString mContentCharset GUARDED_BY(mRecursiveMutex); + bool mHasCacheControl GUARDED_BY(mRecursiveMutex){false}; + bool mCacheControlPublic GUARDED_BY(mRecursiveMutex){false}; + bool mCacheControlPrivate GUARDED_BY(mRecursiveMutex){false}; + bool mCacheControlNoStore GUARDED_BY(mRecursiveMutex){false}; + bool mCacheControlNoCache GUARDED_BY(mRecursiveMutex){false}; + bool mCacheControlImmutable GUARDED_BY(mRecursiveMutex){false}; + bool mCacheControlStaleWhileRevalidateSet GUARDED_BY(mRecursiveMutex){false}; + uint32_t mCacheControlStaleWhileRevalidate GUARDED_BY(mRecursiveMutex){0}; + bool mCacheControlMaxAgeSet GUARDED_BY(mRecursiveMutex){false}; + uint32_t mCacheControlMaxAge GUARDED_BY(mRecursiveMutex){0}; + bool mPragmaNoCache GUARDED_BY(mRecursiveMutex){false}; // We are using RecursiveMutex instead of a Mutex because VisitHeader // function calls nsIHttpHeaderVisitor::VisitHeader while under lock. mutable RecursiveMutex mRecursiveMutex{"nsHttpResponseHead.mRecursiveMutex"}; // During VisitHeader we sould not allow call to SetHeader. - bool mInVisitHeaders MOZ_GUARDED_BY(mRecursiveMutex){false}; + bool mInVisitHeaders GUARDED_BY(mRecursiveMutex){false}; friend struct IPC::ParamTraits; }; diff --git a/netwerk/protocol/res/SubstitutingProtocolHandler.h b/netwerk/protocol/res/SubstitutingProtocolHandler.h index 8b8f065d63d5..86b3a00609ee 100644 --- a/netwerk/protocol/res/SubstitutingProtocolHandler.h +++ b/netwerk/protocol/res/SubstitutingProtocolHandler.h @@ -105,7 +105,7 @@ class SubstitutingProtocolHandler { RWLock mSubstitutionsLock; nsTHashMap mSubstitutions - MOZ_GUARDED_BY(mSubstitutionsLock); + GUARDED_BY(mSubstitutionsLock); nsCOMPtr mIOService; // Returns a SubstitutingJARURI if |aUrl| maps to a |jar:| URI, diff --git a/netwerk/protocol/websocket/WebSocketChannel.cpp b/netwerk/protocol/websocket/WebSocketChannel.cpp index 433762459776..5b312fb86ed9 100644 --- a/netwerk/protocol/websocket/WebSocketChannel.cpp +++ b/netwerk/protocol/websocket/WebSocketChannel.cpp @@ -553,7 +553,7 @@ class nsWSAdmissionManager { FailDelayManager mFailures; - static nsWSAdmissionManager* sManager MOZ_GUARDED_BY(sLock); + static nsWSAdmissionManager* sManager GUARDED_BY(sLock); static StaticMutex sLock; }; @@ -3264,12 +3264,12 @@ WebSocketChannel::Notify(nsITimer* timer) { } AbortSession(NS_ERROR_NET_TIMEOUT_EXTERNAL); - MOZ_PUSH_IGNORE_THREAD_SAFETY + PUSH_IGNORE_THREAD_SAFETY // mReconnectDelayTimer is only modified on MainThread, we can read it // without a lock, but ONLY if we're on MainThread! And if we're not // on MainThread, it can't be mReconnectDelayTimer } else if (NS_IsMainThread() && timer == mReconnectDelayTimer) { - MOZ_POP_THREAD_SAFETY + POP_THREAD_SAFETY MOZ_ASSERT(mConnecting == CONNECTING_DELAYED, "woke up from delay w/o being delayed?"); diff --git a/netwerk/protocol/websocket/WebSocketChannel.h b/netwerk/protocol/websocket/WebSocketChannel.h index aaf12e67fb04..1f6f00e0c983 100644 --- a/netwerk/protocol/websocket/WebSocketChannel.h +++ b/netwerk/protocol/websocket/WebSocketChannel.h @@ -214,7 +214,7 @@ class WebSocketChannel : public BaseWebSocketChannel, nsCOMPtr mChannel; nsCOMPtr mHttpChannel; - nsCOMPtr mCancelable MOZ_GUARDED_BY(mMutex); + nsCOMPtr mCancelable GUARDED_BY(mMutex); // Mainthread only nsCOMPtr mRedirectCallback; // Set on Mainthread during AsyncOpen, used on IO thread and Mainthread @@ -254,7 +254,7 @@ class WebSocketChannel : public BaseWebSocketChannel, wsConnectingState mConnecting; /* 0 if not connecting, MainThread only */ // Set on MainThread, deleted on MainThread, used on MainThread or // IO Thread (in DoStopSession). Mutex required to access off-main-thread. - nsCOMPtr mReconnectDelayTimer MOZ_GUARDED_BY(mMutex); + nsCOMPtr mReconnectDelayTimer GUARDED_BY(mMutex); // Only touched on IOThread (DoStopSession reads it on MainThread if // we haven't connected yet (mDataStarted==false), and it's always null @@ -310,8 +310,8 @@ class WebSocketChannel : public BaseWebSocketChannel, nsresult mStopOnClose; uint16_t mServerCloseCode; // only used on IO thread nsCString mServerCloseReason; // only used on IO thread - uint16_t mScriptCloseCode MOZ_GUARDED_BY(mMutex); - nsCString mScriptCloseReason MOZ_GUARDED_BY(mMutex); + uint16_t mScriptCloseCode GUARDED_BY(mMutex); + nsCString mScriptCloseReason GUARDED_BY(mMutex); // These are for the read buffers const static uint32_t kIncomingBufferInitialSize = 16 * 1024; diff --git a/netwerk/sctp/datachannel/DataChannel.cpp b/netwerk/sctp/datachannel/DataChannel.cpp index 49650234ba76..f49611f4a27b 100644 --- a/netwerk/sctp/datachannel/DataChannel.cpp +++ b/netwerk/sctp/datachannel/DataChannel.cpp @@ -2376,7 +2376,7 @@ void DataChannelConnection::HandleNotification( int DataChannelConnection::ReceiveCallback( struct socket* sock, void* data, size_t datalen, struct sctp_rcvinfo rcv, - int flags) MOZ_NO_THREAD_SAFETY_ANALYSIS { + int flags) NO_THREAD_SAFETY_ANALYSIS { ASSERT_WEBRTC(!NS_IsMainThread()); DC_DEBUG(("In ReceiveCallback")); diff --git a/netwerk/sctp/datachannel/DataChannel.h b/netwerk/sctp/datachannel/DataChannel.h index eefa48ad07cb..0b7daba9661c 100644 --- a/netwerk/sctp/datachannel/DataChannel.h +++ b/netwerk/sctp/datachannel/DataChannel.h @@ -186,7 +186,7 @@ class DataChannelConnection final : public net::NeckoTargetHolder void Stop(); void Close(DataChannel* aChannel); - void CloseLocked(DataChannel* aChannel) MOZ_REQUIRES(mLock); + void CloseLocked(DataChannel* aChannel) REQUIRES(mLock); void CloseAll(); // Returns a POSIX error code. @@ -216,7 +216,7 @@ class DataChannelConnection final : public net::NeckoTargetHolder void ReadBlob(already_AddRefed aThis, uint16_t aStream, nsIInputStream* aBlob); - bool SendDeferredMessages() MOZ_REQUIRES(mLock); + bool SendDeferredMessages() REQUIRES(mLock); #ifdef SCTP_DTLS_SUPPORTED int SctpDtlsOutput(void* addr, void* buffer, size_t length, uint8_t tos, @@ -245,14 +245,14 @@ class DataChannelConnection final : public net::NeckoTargetHolder const Maybe& aMaxMessageSize); // Caller must hold mLock - uint16_t GetReadyState() const MOZ_REQUIRES(mLock) { + uint16_t GetReadyState() const REQUIRES(mLock) { mLock.AssertCurrentThreadOwns(); return mState; } // Caller must hold mLock - void SetReadyState(const uint16_t aState) MOZ_REQUIRES(mLock); + void SetReadyState(const uint16_t aState) REQUIRES(mLock); #ifdef SCTP_DTLS_SUPPORTED static void DTLSConnectThread(void* data); @@ -260,75 +260,74 @@ class DataChannelConnection final : public net::NeckoTargetHolder void SctpDtlsInput(const std::string& aTransportId, const MediaPacket& packet); #endif - DataChannel* FindChannelByStream(uint16_t stream) MOZ_REQUIRES(mLock); - uint16_t FindFreeStream() MOZ_REQUIRES(mLock); - bool RequestMoreStreams(int32_t aNeeded = 16) MOZ_REQUIRES(mLock); - uint32_t UpdateCurrentStreamIndex() MOZ_REQUIRES(mLock); - uint32_t GetCurrentStreamIndex() MOZ_REQUIRES(mLock); + DataChannel* FindChannelByStream(uint16_t stream) REQUIRES(mLock); + uint16_t FindFreeStream() REQUIRES(mLock); + bool RequestMoreStreams(int32_t aNeeded = 16) REQUIRES(mLock); + uint32_t UpdateCurrentStreamIndex() REQUIRES(mLock); + uint32_t GetCurrentStreamIndex() REQUIRES(mLock); int SendControlMessage(const uint8_t* data, uint32_t len, uint16_t stream) - MOZ_REQUIRES(mLock); - int SendOpenAckMessage(uint16_t stream) MOZ_REQUIRES(mLock); + REQUIRES(mLock); + int SendOpenAckMessage(uint16_t stream) REQUIRES(mLock); int SendOpenRequestMessage(const nsACString& label, const nsACString& protocol, uint16_t stream, bool unordered, uint16_t prPolicy, - uint32_t prValue) MOZ_REQUIRES(mLock); + uint32_t prValue) REQUIRES(mLock); bool SendBufferedMessages(nsTArray>& buffer, size_t* aWritten); int SendMsgInternal(OutgoingMsg& msg, size_t* aWritten); int SendMsgInternalOrBuffer(nsTArray>& buffer, OutgoingMsg& msg, bool& buffered, - size_t* aWritten) MOZ_REQUIRES(mLock); + size_t* aWritten) REQUIRES(mLock); int SendDataMsgInternalOrBuffer(DataChannel& channel, const uint8_t* data, - size_t len, uint32_t ppid) - MOZ_REQUIRES(mLock); + size_t len, uint32_t ppid) REQUIRES(mLock); int SendDataMsg(DataChannel& channel, const uint8_t* data, size_t len, - uint32_t ppidPartial, uint32_t ppidFinal) MOZ_REQUIRES(mLock); + uint32_t ppidPartial, uint32_t ppidFinal) REQUIRES(mLock); int SendDataMsgCommon(uint16_t stream, const nsACString& aMsg, bool isBinary); - void DeliverQueuedData(uint16_t stream) MOZ_REQUIRES(mLock); + void DeliverQueuedData(uint16_t stream) REQUIRES(mLock); already_AddRefed OpenFinish( - already_AddRefed&& aChannel) MOZ_REQUIRES(mLock); + already_AddRefed&& aChannel) REQUIRES(mLock); - void ProcessQueuedOpens() MOZ_REQUIRES(mLock); - void ClearResets() MOZ_REQUIRES(mLock); - void SendOutgoingStreamReset() MOZ_REQUIRES(mLock); - void ResetOutgoingStream(uint16_t stream) MOZ_REQUIRES(mLock); + void ProcessQueuedOpens() REQUIRES(mLock); + void ClearResets() REQUIRES(mLock); + void SendOutgoingStreamReset() REQUIRES(mLock); + void ResetOutgoingStream(uint16_t stream) REQUIRES(mLock); void HandleOpenRequestMessage( const struct rtcweb_datachannel_open_request* req, uint32_t length, - uint16_t stream) MOZ_REQUIRES(mLock); + uint16_t stream) REQUIRES(mLock); void HandleOpenAckMessage(const struct rtcweb_datachannel_ack* ack, uint32_t length, uint16_t stream); void HandleUnknownMessage(uint32_t ppid, uint32_t length, uint16_t stream) - MOZ_REQUIRES(mLock); + REQUIRES(mLock); uint8_t BufferMessage(nsACString& recvBuffer, const void* data, uint32_t length, uint32_t ppid, int flags); void HandleDataMessage(const void* buffer, size_t length, uint32_t ppid, - uint16_t stream, int flags) MOZ_REQUIRES(mLock); + uint16_t stream, int flags) REQUIRES(mLock); void HandleDCEPMessage(const void* buffer, size_t length, uint32_t ppid, - uint16_t stream, int flags) MOZ_REQUIRES(mLock); + uint16_t stream, int flags) REQUIRES(mLock); void HandleMessage(const void* buffer, size_t length, uint32_t ppid, - uint16_t stream, int flags) MOZ_REQUIRES(mLock); + uint16_t stream, int flags) REQUIRES(mLock); void HandleAssociationChangeEvent(const struct sctp_assoc_change* sac) - MOZ_REQUIRES(mLock); + REQUIRES(mLock); void HandlePeerAddressChangeEvent(const struct sctp_paddr_change* spc) - MOZ_REQUIRES(mLock); + REQUIRES(mLock); void HandleRemoteErrorEvent(const struct sctp_remote_error* sre) - MOZ_REQUIRES(mLock); + REQUIRES(mLock); void HandleShutdownEvent(const struct sctp_shutdown_event* sse) - MOZ_REQUIRES(mLock); + REQUIRES(mLock); void HandleAdaptationIndication(const struct sctp_adaptation_event* sai) - MOZ_REQUIRES(mLock); + REQUIRES(mLock); void HandlePartialDeliveryEvent(const struct sctp_pdapi_event* spde) - MOZ_REQUIRES(mLock); + REQUIRES(mLock); void HandleSendFailedEvent(const struct sctp_send_failed_event* ssfe) - MOZ_REQUIRES(mLock); + REQUIRES(mLock); void HandleStreamResetEvent(const struct sctp_stream_reset_event* strrst) - MOZ_REQUIRES(mLock); + REQUIRES(mLock); void HandleStreamChangeEvent(const struct sctp_stream_change_event* strchg) - MOZ_REQUIRES(mLock); + REQUIRES(mLock); void HandleNotification(const union sctp_notification* notif, size_t n) - MOZ_REQUIRES(mLock); + REQUIRES(mLock); #ifdef SCTP_DTLS_SUPPORTED bool IsSTSThread() const { @@ -363,14 +362,14 @@ class DataChannelConnection final : public net::NeckoTargetHolder const RefPtr& a2) const; }; mutable Mutex mMutex; - ChannelArray mChannels MOZ_GUARDED_BY(mMutex); + ChannelArray mChannels GUARDED_BY(mMutex); }; - bool mSendInterleaved MOZ_GUARDED_BY(mLock) = false; + bool mSendInterleaved GUARDED_BY(mLock) = false; // MainThread only bool mMaxMessageSizeSet = false; // mMaxMessageSize is only set on MainThread, but read off-main-thread - uint64_t mMaxMessageSize MOZ_GUARDED_BY(mLock) = 0; + uint64_t mMaxMessageSize GUARDED_BY(mLock) = 0; // Main thread only Maybe mAllocateEven; // Data: @@ -382,21 +381,20 @@ class DataChannelConnection final : public net::NeckoTargetHolder uint32_t mCurrentStream = 0; nsRefPtrDeque mPending; // STS and main - size_t mNegotiatedIdLimit MOZ_GUARDED_BY(mLock) = 0; - uint8_t mPendingType MOZ_GUARDED_BY(mLock) = PENDING_NONE; + size_t mNegotiatedIdLimit GUARDED_BY(mLock) = 0; + uint8_t mPendingType GUARDED_BY(mLock) = PENDING_NONE; // holds data that's come in before a channel is open - nsTArray> mQueuedData MOZ_GUARDED_BY(mLock); + nsTArray> mQueuedData GUARDED_BY(mLock); // holds outgoing control messages - nsTArray> mBufferedControl - MOZ_GUARDED_BY(mLock); + nsTArray> mBufferedControl GUARDED_BY(mLock); // Streams pending reset. Accessed from main and STS. - AutoTArray mStreamsResetting MOZ_GUARDED_BY(mLock); + AutoTArray mStreamsResetting GUARDED_BY(mLock); // accessed from STS thread struct socket* mMasterSocket = nullptr; // cloned from mMasterSocket on successful Connect on STS thread struct socket* mSocket = nullptr; - uint16_t mState MOZ_GUARDED_BY(mLock) = CLOSED; // Protected with mLock + uint16_t mState GUARDED_BY(mLock) = CLOSED; // Protected with mLock #ifdef SCTP_DTLS_SUPPORTED std::string mTransportId; @@ -576,10 +574,10 @@ class DataChannel { size_t mBufferedAmount; nsCString mRecvBuffer; nsTArray> - mBufferedData; // MOZ_GUARDED_BY(mConnection->mLock) + mBufferedData; // GUARDED_BY(mConnection->mLock) nsCOMPtr mMainThreadEventTarget; mutable Mutex mStatsLock; // protects mTrafficCounters - TrafficCounters mTrafficCounters MOZ_GUARDED_BY(mStatsLock); + TrafficCounters mTrafficCounters GUARDED_BY(mStatsLock); }; // used to dispatch notifications of incoming data to the main thread diff --git a/netwerk/wifi/nsWifiMonitor.h b/netwerk/wifi/nsWifiMonitor.h index aa7176046745..f457e0be4e97 100644 --- a/netwerk/wifi/nsWifiMonitor.h +++ b/netwerk/wifi/nsWifiMonitor.h @@ -71,7 +71,7 @@ class nsWifiMonitor final : nsIRunnable, nsIWifiMonitor, nsIObserver { mozilla::Atomic mThreadComplete; nsCOMPtr mThread; // only accessed on MainThread - nsTArray mListeners MOZ_GUARDED_BY(mReentrantMonitor); + nsTArray mListeners GUARDED_BY(mReentrantMonitor); mozilla::ReentrantMonitor mReentrantMonitor; diff --git a/parser/html/nsHtml5StreamListener.h b/parser/html/nsHtml5StreamListener.h index 46056eacee23..e5f8ccdd4ff4 100644 --- a/parser/html/nsHtml5StreamListener.h +++ b/parser/html/nsHtml5StreamListener.h @@ -55,7 +55,7 @@ class nsHtml5StreamListener : public nsIStreamListener, // Owning pointer with manually-managed refcounting, protected by // mDelegateMonitor. Access to it is Atomic, which avoids getting a lock // to check if it's set or to return the pointer. Access to the data within - // it needs the monitor. MOZ_PT_GUARDED_BY() can't be used with Atomic<...*> + // it needs the monitor. PT_GUARDED_BY() can't be used with Atomic<...*> mozilla::Atomic mDelegate; }; diff --git a/parser/html/nsHtml5StreamParser.cpp b/parser/html/nsHtml5StreamParser.cpp index 93f0d62d8c15..7e9e9d1a7cee 100644 --- a/parser/html/nsHtml5StreamParser.cpp +++ b/parser/html/nsHtml5StreamParser.cpp @@ -1671,7 +1671,7 @@ nsresult nsHtml5StreamParser::OnDataAvailable(nsIRequest* aRequest, nsresult nsHtml5StreamParser::CopySegmentsToParser( nsIInputStream* aInStream, void* aClosure, const char* aFromSegment, uint32_t aToOffset, uint32_t aCount, - uint32_t* aWriteCount) MOZ_NO_THREAD_SAFETY_ANALYSIS { + uint32_t* aWriteCount) NO_THREAD_SAFETY_ANALYSIS { nsHtml5StreamParser* parser = static_cast(aClosure); parser->DoDataAvailable(AsBytes(Span(aFromSegment, aCount))); diff --git a/parser/html/nsHtml5StreamParser.h b/parser/html/nsHtml5StreamParser.h index 0dacf257bf34..6ba4f8bd645d 100644 --- a/parser/html/nsHtml5StreamParser.h +++ b/parser/html/nsHtml5StreamParser.h @@ -312,7 +312,7 @@ class nsHtml5StreamParser final : public nsISupports { mInterrupted = true; } - void Uninterrupt() MOZ_NO_THREAD_SAFETY_ANALYSIS { + void Uninterrupt() NO_THREAD_SAFETY_ANALYSIS { MOZ_ASSERT(IsParserThread(), "Wrong thread!"); mTokenizerMutex.AssertCurrentThreadOwns(); mInterrupted = false; @@ -325,30 +325,30 @@ class nsHtml5StreamParser final : public nsISupports { void FlushTreeOpsAndDisarmTimer(); void SwitchDecoderIfAsciiSoFar(NotNull aEncoding) - MOZ_REQUIRES(mTokenizerMutex); + REQUIRES(mTokenizerMutex); ; size_t CountGts(); void DiscardMetaSpeculation(); - bool ProcessLookingForMetaCharset(bool aEof) MOZ_REQUIRES(mTokenizerMutex); + bool ProcessLookingForMetaCharset(bool aEof) REQUIRES(mTokenizerMutex); void ParseAvailableData(); void DoStopRequest(); void DoDataAvailableBuffer(mozilla::Buffer&& aBuffer) - MOZ_REQUIRES(mTokenizerMutex); + REQUIRES(mTokenizerMutex); void DoDataAvailable(mozilla::Span aBuffer) - MOZ_REQUIRES(mTokenizerMutex); + REQUIRES(mTokenizerMutex); static nsresult CopySegmentsToParser(nsIInputStream* aInStream, void* aClosure, const char* aFromSegment, uint32_t aToOffset, uint32_t aCount, uint32_t* aWriteCount) - MOZ_REQUIRES(mTokenizerMutex); + REQUIRES(mTokenizerMutex); bool IsTerminatedOrInterrupted() { return mTerminated || mInterrupted; } @@ -372,13 +372,13 @@ class nsHtml5StreamParser final : public nsISupports { * Push bytes from network when there is no Unicode decoder yet */ nsresult SniffStreamBytes(mozilla::Span aFromSegment, - bool aEof) MOZ_REQUIRES(mTokenizerMutex); + bool aEof) REQUIRES(mTokenizerMutex); /** * Push bytes from network when there is a Unicode decoder already */ nsresult WriteStreamBytes(mozilla::Span aFromSegment) - MOZ_REQUIRES(mTokenizerMutex); + REQUIRES(mTokenizerMutex); /** * Set up the Unicode decoder and write the sniffing buffer into it @@ -393,7 +393,7 @@ class nsHtml5StreamParser final : public nsISupports { */ nsresult SetupDecodingAndWriteSniffingBufferAndCurrentSegment( mozilla::Span aPrefix, - mozilla::Span aFromSegment) MOZ_REQUIRES(mTokenizerMutex); + mozilla::Span aFromSegment) REQUIRES(mTokenizerMutex); /** * Initialize the Unicode decoder, mark the BOM as the source and @@ -418,7 +418,7 @@ class nsHtml5StreamParser final : public nsISupports { * When speculatively decoding from file: URL as UTF-8, redecode * using fallback and then continue normally with the fallback. */ - [[nodiscard]] nsresult ReDecodeLocalFile() MOZ_REQUIRES(mTokenizerMutex); + [[nodiscard]] nsresult ReDecodeLocalFile() REQUIRES(mTokenizerMutex); /** * Potentially guess the encoding using mozilla::EncodingDetector. diff --git a/security/certverifier/OCSPCache.h b/security/certverifier/OCSPCache.h index d2ff7dfc8950..7e5d0a0e90df 100644 --- a/security/certverifier/OCSPCache.h +++ b/security/certverifier/OCSPCache.h @@ -127,7 +127,7 @@ class OCSPCache { // implementation will give us. 1024 bytes is the maximum it allows, // which results in 256 Entry pointers or 128 Entry pointers, depending // on the size of a pointer. - Vector mEntries MOZ_GUARDED_BY(mMutex); + Vector mEntries GUARDED_BY(mMutex); }; } // namespace psm diff --git a/security/manager/ssl/DataStorage.h b/security/manager/ssl/DataStorage.h index f4d536f21ca4..8a37c2fc8aeb 100644 --- a/security/manager/ssl/DataStorage.h +++ b/security/manager/ssl/DataStorage.h @@ -195,14 +195,14 @@ class DataStorage : public nsIObserver { const MutexAutoLock& aProofOfLock); Mutex mMutex; // This mutex protects access to the following members: - DataStorageTable mPersistentDataTable MOZ_GUARDED_BY(mMutex); - DataStorageTable mTemporaryDataTable MOZ_GUARDED_BY(mMutex); - DataStorageTable mPrivateDataTable MOZ_GUARDED_BY(mMutex); - nsCOMPtr mBackingFile MOZ_GUARDED_BY(mMutex); - bool mPendingWrite MOZ_GUARDED_BY( + DataStorageTable mPersistentDataTable GUARDED_BY(mMutex); + DataStorageTable mTemporaryDataTable GUARDED_BY(mMutex); + DataStorageTable mPrivateDataTable GUARDED_BY(mMutex); + nsCOMPtr mBackingFile GUARDED_BY(mMutex); + bool mPendingWrite GUARDED_BY( mMutex); // true if a write is needed but hasn't been dispatched - bool mShuttingDown MOZ_GUARDED_BY(mMutex); - RefPtr mBackgroundTaskQueue MOZ_GUARDED_BY(mMutex); + bool mShuttingDown GUARDED_BY(mMutex); + RefPtr mBackgroundTaskQueue GUARDED_BY(mMutex); // (End list of members protected by mMutex) nsCOMPtr mTimer; // Must only be accessed on the main thread @@ -210,8 +210,8 @@ class DataStorage : public nsIObserver { mozilla::Atomic mInitCalled; // Indicates that Init() has been called. Monitor mReadyMonitor; // Do not acquire this at the same time as mMutex. - bool mReady MOZ_GUARDED_BY(mReadyMonitor); // Indicates that saved data has - // been read and Get can proceed. + bool mReady GUARDED_BY(mReadyMonitor); // Indicates that saved data has been + // read and Get can proceed. const nsString mFilename; diff --git a/security/manager/ssl/TransportSecurityInfo.h b/security/manager/ssl/TransportSecurityInfo.h index be7530a93a74..c8e89881c358 100644 --- a/security/manager/ssl/TransportSecurityInfo.h +++ b/security/manager/ssl/TransportSecurityInfo.h @@ -128,24 +128,24 @@ class TransportSecurityInfo : public nsITransportSecurityInfo, protected: mutable ::mozilla::Mutex mMutex; - uint16_t mCipherSuite MOZ_GUARDED_BY(mMutex); - uint16_t mProtocolVersion MOZ_GUARDED_BY(mMutex); - uint16_t mCertificateTransparencyStatus MOZ_GUARDED_BY(mMutex); - nsCString mKeaGroup MOZ_GUARDED_BY(mMutex); - nsCString mSignatureSchemeName MOZ_GUARDED_BY(mMutex); + uint16_t mCipherSuite GUARDED_BY(mMutex); + uint16_t mProtocolVersion GUARDED_BY(mMutex); + uint16_t mCertificateTransparencyStatus GUARDED_BY(mMutex); + nsCString mKeaGroup GUARDED_BY(mMutex); + nsCString mSignatureSchemeName GUARDED_BY(mMutex); - bool mIsAcceptedEch MOZ_GUARDED_BY(mMutex); - bool mIsDelegatedCredential MOZ_GUARDED_BY(mMutex); + bool mIsAcceptedEch GUARDED_BY(mMutex); + bool mIsDelegatedCredential GUARDED_BY(mMutex); - nsCOMPtr mCallbacks MOZ_GUARDED_BY(mMutex); - nsTArray> mSucceededCertChain MOZ_GUARDED_BY(mMutex); - bool mNPNCompleted MOZ_GUARDED_BY(mMutex); - nsCString mNegotiatedNPN MOZ_GUARDED_BY(mMutex); - bool mResumed MOZ_GUARDED_BY(mMutex); - bool mIsBuiltCertChainRootBuiltInRoot MOZ_GUARDED_BY(mMutex); - nsCString mPeerId MOZ_GUARDED_BY(mMutex); - nsCString mHostName MOZ_GUARDED_BY(mMutex); - OriginAttributes mOriginAttributes MOZ_GUARDED_BY(mMutex); + nsCOMPtr mCallbacks GUARDED_BY(mMutex); + nsTArray> mSucceededCertChain GUARDED_BY(mMutex); + bool mNPNCompleted GUARDED_BY(mMutex); + nsCString mNegotiatedNPN GUARDED_BY(mMutex); + bool mResumed GUARDED_BY(mMutex); + bool mIsBuiltCertChainRootBuiltInRoot GUARDED_BY(mMutex); + nsCString mPeerId GUARDED_BY(mMutex); + nsCString mHostName GUARDED_BY(mMutex); + OriginAttributes mOriginAttributes GUARDED_BY(mMutex); private: static nsresult ReadBoolAndSetAtomicFieldHelper(nsIObjectInputStream* stream, @@ -188,10 +188,10 @@ class TransportSecurityInfo : public nsITransportSecurityInfo, Atomic mPort; - nsCOMPtr mServerCert MOZ_GUARDED_BY(mMutex); + nsCOMPtr mServerCert GUARDED_BY(mMutex); /* Peer cert chain for failed connections (for error reporting) */ - nsTArray> mFailedCertChain MOZ_GUARDED_BY(mMutex); + nsTArray> mFailedCertChain GUARDED_BY(mMutex); nsresult ReadSSLStatus(nsIObjectInputStream* aStream, MutexAutoLock& aProofOfLock); @@ -216,8 +216,7 @@ class RememberCertErrorsTable { bool mIsNotValidAtThisTime; bool mIsUntrusted; }; - nsTHashMap mErrorHosts - MOZ_GUARDED_BY(mMutex); + nsTHashMap mErrorHosts GUARDED_BY(mMutex); public: void RememberCertHasError(TransportSecurityInfo* infoObject, diff --git a/security/manager/ssl/nsCertOverrideService.h b/security/manager/ssl/nsCertOverrideService.h index e22af55d6e94..e601df1b13d9 100644 --- a/security/manager/ssl/nsCertOverrideService.h +++ b/security/manager/ssl/nsCertOverrideService.h @@ -133,9 +133,9 @@ class nsCertOverrideService final : public nsICertOverrideService, ~nsCertOverrideService(); mozilla::Mutex mMutex; - bool mDisableAllSecurityCheck MOZ_GUARDED_BY(mMutex); - nsCOMPtr mSettingsFile MOZ_GUARDED_BY(mMutex); - nsTHashtable mSettingsTable MOZ_GUARDED_BY(mMutex); + bool mDisableAllSecurityCheck GUARDED_BY(mMutex); + nsCOMPtr mSettingsFile GUARDED_BY(mMutex); + nsTHashtable mSettingsTable GUARDED_BY(mMutex); void CountPermanentOverrideTelemetry( const mozilla::MutexAutoLock& aProofOfLock); diff --git a/security/manager/ssl/nsNSSComponent.h b/security/manager/ssl/nsNSSComponent.h index 54a6df3128b8..22fb51a01c95 100644 --- a/security/manager/ssl/nsNSSComponent.h +++ b/security/manager/ssl/nsNSSComponent.h @@ -116,9 +116,8 @@ class nsNSSComponent final : public nsINSSComponent, public nsIObserver { // mLoadableCertsLoadedMonitor protects mLoadableCertsLoaded. mozilla::Monitor mLoadableCertsLoadedMonitor; - bool mLoadableCertsLoaded MOZ_GUARDED_BY(mLoadableCertsLoadedMonitor); - nsresult mLoadableCertsLoadedResult - MOZ_GUARDED_BY(mLoadableCertsLoadedMonitor); + bool mLoadableCertsLoaded GUARDED_BY(mLoadableCertsLoadedMonitor); + nsresult mLoadableCertsLoadedResult GUARDED_BY(mLoadableCertsLoadedMonitor); // mMutex protects all members that are accessed from more than one thread. mozilla::Mutex mMutex; @@ -126,13 +125,13 @@ class nsNSSComponent final : public nsINSSComponent, public nsIObserver { // The following members are accessed from more than one thread: #ifdef DEBUG - nsCString mTestBuiltInRootHash MOZ_GUARDED_BY(mMutex); + nsCString mTestBuiltInRootHash GUARDED_BY(mMutex); #endif RefPtr mDefaultCertVerifier - MOZ_GUARDED_BY(mMutex); - nsString mMitmCanaryIssuer MOZ_GUARDED_BY(mMutex); - bool mMitmDetecionEnabled MOZ_GUARDED_BY(mMutex); - mozilla::Vector mEnterpriseCerts MOZ_GUARDED_BY(mMutex); + GUARDED_BY(mMutex); + nsString mMitmCanaryIssuer GUARDED_BY(mMutex); + bool mMitmDetecionEnabled GUARDED_BY(mMutex); + mozilla::Vector mEnterpriseCerts GUARDED_BY(mMutex); // The following members are accessed only on the main thread: static int mInstanceCount; diff --git a/security/manager/ssl/nsProtectedAuthThread.h b/security/manager/ssl/nsProtectedAuthThread.h index 8310c9089033..1adf1cbd0642 100644 --- a/security/manager/ssl/nsProtectedAuthThread.h +++ b/security/manager/ssl/nsProtectedAuthThread.h @@ -18,10 +18,10 @@ class nsProtectedAuthThread : public nsIProtectedAuthThread { private: mozilla::Mutex mMutex; - nsCOMPtr mNotifyObserver MOZ_GUARDED_BY(mMutex); + nsCOMPtr mNotifyObserver GUARDED_BY(mMutex); - bool mIAmRunning MOZ_GUARDED_BY(mMutex); - bool mLoginReady MOZ_GUARDED_BY(mMutex); + bool mIAmRunning GUARDED_BY(mMutex); + bool mLoginReady GUARDED_BY(mMutex); PRThread* mThreadHandle; // MainThread only diff --git a/startupcache/StartupCache.cpp b/startupcache/StartupCache.cpp index 2085be5f7ab3..250de03b6e95 100644 --- a/startupcache/StartupCache.cpp +++ b/startupcache/StartupCache.cpp @@ -366,8 +366,7 @@ bool StartupCache::HasEntry(const char* id) { } nsresult StartupCache::GetBuffer(const char* id, const char** outbuf, - uint32_t* length) - MOZ_NO_THREAD_SAFETY_ANALYSIS { + uint32_t* length) NO_THREAD_SAFETY_ANALYSIS { AUTO_PROFILER_LABEL("StartupCache::GetBuffer", OTHER); NS_ASSERTION(NS_IsMainThread(), @@ -454,7 +453,7 @@ nsresult StartupCache::GetBuffer(const char* id, const char** outbuf, // Makes a copy of the buffer, client retains ownership of inbuf. nsresult StartupCache::PutBuffer(const char* id, UniquePtr&& inbuf, - uint32_t len) MOZ_NO_THREAD_SAFETY_ANALYSIS { + uint32_t len) NO_THREAD_SAFETY_ANALYSIS { NS_ASSERTION(NS_IsMainThread(), "Startup cache only available on main thread"); if (StartupCache::gShutdownInitiated) { diff --git a/toolkit/components/url-classifier/nsUrlClassifierPrefixSet.h b/toolkit/components/url-classifier/nsUrlClassifierPrefixSet.h index 08703485e0fc..81421c1bfbb0 100644 --- a/toolkit/components/url-classifier/nsUrlClassifierPrefixSet.h +++ b/toolkit/components/url-classifier/nsUrlClassifierPrefixSet.h @@ -55,12 +55,12 @@ class nsUrlClassifierPrefixSet final : public nsIUrlClassifierPrefixSet { static const uint32_t MAX_INDEX_DIFF = (1 << 16); static const uint32_t PREFIXSET_VERSION_MAGIC = 1; - void Clear() MOZ_REQUIRES(mLock); + void Clear() REQUIRES(mLock); nsresult MakePrefixSet(const uint32_t* aArray, uint32_t aLength) - MOZ_REQUIRES(mLock); + REQUIRES(mLock); uint32_t BinSearch(uint32_t start, uint32_t end, uint32_t target) const - MOZ_REQUIRES(mLock); - bool IsEmptyInternal() const MOZ_REQUIRES(mLock); + REQUIRES(mLock); + bool IsEmptyInternal() const REQUIRES(mLock); // Lock to prevent races between the url-classifier thread (which does most // of the operations) and the main thread (which does memory reporting). @@ -69,17 +69,17 @@ class nsUrlClassifierPrefixSet final : public nsIUrlClassifierPrefixSet { mutable mozilla::Mutex mLock; // list of fully stored prefixes, that also form the // start of a run of deltas in mIndexDeltas. - nsTArray mIndexPrefixes MOZ_GUARDED_BY(mLock); + nsTArray mIndexPrefixes GUARDED_BY(mLock); // array containing arrays of deltas from indices. // Index to the place that matches the closest lower // prefix from mIndexPrefix. Then every "delta" corresponds // to a prefix in the PrefixSet. // This array could be empty when we decide to store all the prefixes // in mIndexPrefixes. - nsTArray > mIndexDeltas MOZ_GUARDED_BY(mLock); + nsTArray > mIndexDeltas GUARDED_BY(mLock); // how many prefixes we have. - uint32_t mTotalPrefixes MOZ_GUARDED_BY(mLock); + uint32_t mTotalPrefixes GUARDED_BY(mLock); nsCString mName; // Set in Init() only mozilla::CorruptionCanary mCanary; diff --git a/toolkit/crashreporter/nsExceptionHandler.cpp b/toolkit/crashreporter/nsExceptionHandler.cpp index 99c8aef8c82b..88ecbc529386 100644 --- a/toolkit/crashreporter/nsExceptionHandler.cpp +++ b/toolkit/crashreporter/nsExceptionHandler.cpp @@ -3223,7 +3223,7 @@ static void MaybeAnnotateDumperError(const ClientInfo& aClientInfo, static void OnChildProcessDumpRequested( void* aContext, const ClientInfo& aClientInfo, - const xpstring& aFilePath) MOZ_NO_THREAD_SAFETY_ANALYSIS { + const xpstring& aFilePath) NO_THREAD_SAFETY_ANALYSIS { nsCOMPtr minidump; // Hold the mutex until the current dump request is complete, to @@ -3268,9 +3268,8 @@ static void OnChildProcessDumpRequested( } } -static void OnChildProcessDumpWritten(void* aContext, - const ClientInfo& aClientInfo) - MOZ_NO_THREAD_SAFETY_ANALYSIS { +static void OnChildProcessDumpWritten( + void* aContext, const ClientInfo& aClientInfo) NO_THREAD_SAFETY_ANALYSIS { ProcessId pid = aClientInfo.pid(); ChildProcessData* pd = pidToMinidump->GetEntry(pid); MOZ_ASSERT(pd); diff --git a/widget/android/jni/Natives.h b/widget/android/jni/Natives.h index 72e02d9db096..4a349aacf895 100644 --- a/widget/android/jni/Natives.h +++ b/widget/android/jni/Natives.h @@ -599,11 +599,11 @@ class MOZ_HEAP_CLASS NativeWeakPtrControlBlock final { return nativeImpl; } - MOZ_PUSH_IGNORE_THREAD_SAFETY + PUSH_IGNORE_THREAD_SAFETY void Lock() const { mLock.ReadLock(); } void Unlock() const { mLock.ReadUnlock(); } - MOZ_POP_THREAD_SAFETY + POP_THREAD_SAFETY #if defined(DEBUG) // This is kind of expensive, so we only support it in debug builds. diff --git a/widget/cocoa/nsChildView.mm b/widget/cocoa/nsChildView.mm index 656bb6dd8093..a03913de80a9 100644 --- a/widget/cocoa/nsChildView.mm +++ b/widget/cocoa/nsChildView.mm @@ -1610,7 +1610,7 @@ void nsChildView::ConfigureAPZCTreeManager() { nsBaseWidget::ConfigureAPZCTreeMa void nsChildView::ConfigureAPZControllerThread() { nsBaseWidget::ConfigureAPZControllerThread(); } -bool nsChildView::PreRender(WidgetRenderingContext* aContext) MOZ_NO_THREAD_SAFETY_ANALYSIS { +bool nsChildView::PreRender(WidgetRenderingContext* aContext) NO_THREAD_SAFETY_ANALYSIS { // The lock makes sure that we don't attempt to tear down the view while // compositing. That would make us unable to call postRender on it when the // composition is done, thus keeping the GL context locked forever. @@ -1623,7 +1623,7 @@ bool nsChildView::PreRender(WidgetRenderingContext* aContext) MOZ_NO_THREAD_SAFE return true; } -void nsChildView::PostRender(WidgetRenderingContext* aContext) MOZ_NO_THREAD_SAFETY_ANALYSIS { +void nsChildView::PostRender(WidgetRenderingContext* aContext) NO_THREAD_SAFETY_ANALYSIS { mCompositingLock.Unlock(); } diff --git a/widget/gtk/MozContainerWayland.cpp b/widget/gtk/MozContainerWayland.cpp index 795bb88e608d..6306a40d3425 100644 --- a/widget/gtk/MozContainerWayland.cpp +++ b/widget/gtk/MozContainerWayland.cpp @@ -628,7 +628,7 @@ static bool moz_container_wayland_surface_create_locked( } struct wl_surface* moz_container_wayland_surface_lock(MozContainer* container) - MOZ_NO_THREAD_SAFETY_ANALYSIS { + NO_THREAD_SAFETY_ANALYSIS { // LOGWAYLAND("%s [%p] surface %p ready_to_draw %d\n", __FUNCTION__, // (void*)container, (void*)container->wl_container.surface, // container->wl_container.ready_to_draw); @@ -642,7 +642,7 @@ struct wl_surface* moz_container_wayland_surface_lock(MozContainer* container) void moz_container_wayland_surface_unlock(MozContainer* container, struct wl_surface** surface) - MOZ_NO_THREAD_SAFETY_ANALYSIS { + NO_THREAD_SAFETY_ANALYSIS { // Temporarily disabled to avoid log noise // LOGWAYLAND("%s [%p] surface %p\n", __FUNCTION__, (void*)container, // (void*)container->wl_container.surface); @@ -667,12 +667,12 @@ struct wl_surface* moz_container_wayland_get_surface_locked( } void moz_container_wayland_lock(MozContainer* container) - MOZ_NO_THREAD_SAFETY_ANALYSIS { + NO_THREAD_SAFETY_ANALYSIS { container->wl_container.container_lock->Lock(); } void moz_container_wayland_unlock(MozContainer* container) - MOZ_NO_THREAD_SAFETY_ANALYSIS { + NO_THREAD_SAFETY_ANALYSIS { container->wl_container.container_lock->Unlock(); } diff --git a/widget/windows/JumpListBuilder.h b/widget/windows/JumpListBuilder.h index 6c957c033ae8..2c3bafe05c52 100644 --- a/widget/windows/JumpListBuilder.h +++ b/widget/windows/JumpListBuilder.h @@ -46,8 +46,8 @@ class JumpListBuilder : public nsIJumpListBuilder, public nsIObserver { static Atomic sBuildingList; private: - mscom::AgileReference mJumpListMgr MOZ_GUARDED_BY(mMonitor); - uint32_t mMaxItems MOZ_GUARDED_BY(mMonitor); + mscom::AgileReference mJumpListMgr GUARDED_BY(mMonitor); + uint32_t mMaxItems GUARDED_BY(mMonitor); bool mHasCommit; nsCOMPtr mIOThread; ReentrantMonitor mMonitor; diff --git a/xpcom/base/AvailableMemoryWatcherLinux.cpp b/xpcom/base/AvailableMemoryWatcherLinux.cpp index c9641c18068e..f2af239a0892 100644 --- a/xpcom/base/AvailableMemoryWatcherLinux.cpp +++ b/xpcom/base/AvailableMemoryWatcherLinux.cpp @@ -43,11 +43,11 @@ class nsAvailableMemoryWatcher final : public nsITimerCallback, void UpdateCrashAnnotation(const MutexAutoLock&); static bool IsMemoryLow(); - nsCOMPtr mTimer MOZ_GUARDED_BY(mMutex); - nsCOMPtr mThread MOZ_GUARDED_BY(mMutex); + nsCOMPtr mTimer GUARDED_BY(mMutex); + nsCOMPtr mThread GUARDED_BY(mMutex); - bool mPolling MOZ_GUARDED_BY(mMutex); - bool mUnderMemoryPressure MOZ_GUARDED_BY(mMutex); + bool mPolling GUARDED_BY(mMutex); + bool mUnderMemoryPressure GUARDED_BY(mMutex); // We might tell polling to start/stop from our polling thread // or from the main thread during ::Observe(). @@ -113,7 +113,7 @@ NS_IMPL_ISUPPORTS_INHERITED(nsAvailableMemoryWatcher, nsIObserver); void nsAvailableMemoryWatcher::StopPolling(const MutexAutoLock&) - MOZ_REQUIRES(mMutex) { + REQUIRES(mMutex) { if (mPolling && mTimer) { // stop dispatching memory checks to the thread. mTimer->Cancel(); @@ -148,8 +148,7 @@ bool nsAvailableMemoryWatcher::IsMemoryLow() { return aResult; } -void nsAvailableMemoryWatcher::ShutDown(const MutexAutoLock&) - MOZ_REQUIRES(mMutex) { +void nsAvailableMemoryWatcher::ShutDown(const MutexAutoLock&) REQUIRES(mMutex) { if (mTimer) { mTimer->Cancel(); } @@ -202,7 +201,7 @@ void nsAvailableMemoryWatcher::HandleLowMemory() { } void nsAvailableMemoryWatcher::UpdateCrashAnnotation(const MutexAutoLock&) - MOZ_REQUIRES(mMutex) { + REQUIRES(mMutex) { CrashReporter::AnnotateCrashReport( CrashReporter::Annotation::LinuxUnderMemoryPressure, mUnderMemoryPressure); @@ -225,7 +224,7 @@ void nsAvailableMemoryWatcher::MaybeHandleHighMemory() { // When we change the polling interval, we will need to restart the timer // on the new interval. void nsAvailableMemoryWatcher::StartPolling(const MutexAutoLock& aLock) - MOZ_REQUIRES(mMutex) { + REQUIRES(mMutex) { uint32_t pollingInterval = mUnderMemoryPressure ? kLowMemoryPollingIntervalMS : kHighMemoryPollingIntervalMS; diff --git a/xpcom/base/AvailableMemoryWatcherWin.cpp b/xpcom/base/AvailableMemoryWatcherWin.cpp index 42e590e93af9..50e2c874c918 100644 --- a/xpcom/base/AvailableMemoryWatcherWin.cpp +++ b/xpcom/base/AvailableMemoryWatcherWin.cpp @@ -51,41 +51,40 @@ class nsAvailableMemoryWatcher final : public nsITimerCallback, ~nsAvailableMemoryWatcher(); bool RegisterMemoryResourceHandler(const MutexAutoLock& aLock) - MOZ_REQUIRES(mMutex); - void UnregisterMemoryResourceHandler(const MutexAutoLock&) - MOZ_REQUIRES(mMutex); - void MaybeSaveMemoryReport(const MutexAutoLock&) MOZ_REQUIRES(mMutex); - void Shutdown(const MutexAutoLock& aLock) MOZ_REQUIRES(mMutex); - bool ListenForLowMemory(const MutexAutoLock&) MOZ_REQUIRES(mMutex); - void OnLowMemory(const MutexAutoLock&) MOZ_REQUIRES(mMutex); - void OnHighMemory(const MutexAutoLock&) MOZ_REQUIRES(mMutex); + REQUIRES(mMutex); + void UnregisterMemoryResourceHandler(const MutexAutoLock&) REQUIRES(mMutex); + void MaybeSaveMemoryReport(const MutexAutoLock&) REQUIRES(mMutex); + void Shutdown(const MutexAutoLock& aLock) REQUIRES(mMutex); + bool ListenForLowMemory(const MutexAutoLock&) REQUIRES(mMutex); + void OnLowMemory(const MutexAutoLock&) REQUIRES(mMutex); + void OnHighMemory(const MutexAutoLock&) REQUIRES(mMutex); void StartPollingIfUserInteracting(const MutexAutoLock& aLock) - MOZ_REQUIRES(mMutex); - void StopPolling(const MutexAutoLock&) MOZ_REQUIRES(mMutex); - void StopPollingIfUserIdle(const MutexAutoLock&) MOZ_REQUIRES(mMutex); - void OnUserInteracting(const MutexAutoLock&) MOZ_REQUIRES(mMutex); + REQUIRES(mMutex); + void StopPolling(const MutexAutoLock&) REQUIRES(mMutex); + void StopPollingIfUserIdle(const MutexAutoLock&) REQUIRES(mMutex); + void OnUserInteracting(const MutexAutoLock&) REQUIRES(mMutex); // The publicly available methods (::Observe() and ::Notify()) are called on // the main thread while the ::LowMemoryCallback() method is called by an // external thread. All functions called from those must acquire a lock on // this mutex before accessing the object's fields to prevent races. Mutex mMutex; - nsCOMPtr mTimer MOZ_GUARDED_BY(mMutex); - nsAutoHandle mLowMemoryHandle MOZ_GUARDED_BY(mMutex); - HANDLE mWaitHandle MOZ_GUARDED_BY(mMutex); - bool mPolling MOZ_GUARDED_BY(mMutex); + nsCOMPtr mTimer GUARDED_BY(mMutex); + nsAutoHandle mLowMemoryHandle GUARDED_BY(mMutex); + HANDLE mWaitHandle GUARDED_BY(mMutex); + bool mPolling GUARDED_BY(mMutex); // Indicates whether to start a timer when user interaction is notified. // This flag is needed because the low-memory callback may be triggered when // the user is inactive and we want to delay-start the timer. - bool mNeedToRestartTimerOnUserInteracting MOZ_GUARDED_BY(mMutex); + bool mNeedToRestartTimerOnUserInteracting GUARDED_BY(mMutex); // Indicate that the available commit space is low. The timer handler needs // this flag because it is triggered by the low physical memory regardless // of the available commit space. - bool mUnderMemoryPressure MOZ_GUARDED_BY(mMutex); + bool mUnderMemoryPressure GUARDED_BY(mMutex); - bool mSavedReport MOZ_GUARDED_BY(mMutex); - bool mIsShutdown MOZ_GUARDED_BY(mMutex); + bool mSavedReport GUARDED_BY(mMutex); + bool mIsShutdown GUARDED_BY(mMutex); // Members below this line are used only in the main thread. // No lock is needed. diff --git a/xpcom/base/RLBoxSandboxPool.h b/xpcom/base/RLBoxSandboxPool.h index 47f389354896..03abef3c9f70 100644 --- a/xpcom/base/RLBoxSandboxPool.h +++ b/xpcom/base/RLBoxSandboxPool.h @@ -57,12 +57,12 @@ class RLBoxSandboxPool : public nsITimerCallback, public nsINamed { virtual ~RLBoxSandboxPool() = default; private: - void StartTimer() MOZ_REQUIRES(mMutex); - void CancelTimer() MOZ_REQUIRES(mMutex); + void StartTimer() REQUIRES(mMutex); + void CancelTimer() REQUIRES(mMutex); - nsTArray> mPool MOZ_GUARDED_BY(mMutex); - const size_t mDelaySeconds MOZ_GUARDED_BY(mMutex); - nsCOMPtr mTimer MOZ_GUARDED_BY(mMutex); + nsTArray> mPool GUARDED_BY(mMutex); + const size_t mDelaySeconds GUARDED_BY(mMutex); + nsCOMPtr mTimer GUARDED_BY(mMutex); mozilla::Mutex mMutex; }; diff --git a/xpcom/base/StaticMonitor.h b/xpcom/base/StaticMonitor.h index 68e1aad0640d..ea11d62e4a7f 100644 --- a/xpcom/base/StaticMonitor.h +++ b/xpcom/base/StaticMonitor.h @@ -13,7 +13,7 @@ namespace mozilla { -class MOZ_ONLY_USED_TO_AVOID_STATIC_CONSTRUCTORS MOZ_CAPABILITY StaticMonitor { +class MOZ_ONLY_USED_TO_AVOID_STATIC_CONSTRUCTORS CAPABILITY StaticMonitor { public: // In debug builds, check that mMutex is initialized for us as we expect by // the compiler. In non-debug builds, don't declare a constructor so that @@ -22,9 +22,9 @@ class MOZ_ONLY_USED_TO_AVOID_STATIC_CONSTRUCTORS MOZ_CAPABILITY StaticMonitor { StaticMonitor() { MOZ_ASSERT(!mMutex); } #endif - void Lock() MOZ_CAPABILITY_ACQUIRE() { Mutex()->Lock(); } + void Lock() CAPABILITY_ACQUIRE() { Mutex()->Lock(); } - void Unlock() MOZ_CAPABILITY_RELEASE() { Mutex()->Unlock(); } + void Unlock() CAPABILITY_RELEASE() { Mutex()->Unlock(); } void Wait() { CondVar()->Wait(); } CVStatus Wait(TimeDuration aDuration) { @@ -35,7 +35,7 @@ class MOZ_ONLY_USED_TO_AVOID_STATIC_CONSTRUCTORS MOZ_CAPABILITY StaticMonitor { void Notify() { CondVar()->Notify(); } void NotifyAll() { CondVar()->NotifyAll(); } - void AssertCurrentThreadOwns() MOZ_ASSERT_CAPABILITY(this) { + void AssertCurrentThreadOwns() ASSERT_CAPABILITY(this) { #ifdef DEBUG Mutex()->AssertCurrentThreadOwns(); #endif @@ -86,15 +86,15 @@ class MOZ_ONLY_USED_TO_AVOID_STATIC_CONSTRUCTORS MOZ_CAPABILITY StaticMonitor { static void operator delete(void*); }; -class MOZ_STACK_CLASS MOZ_SCOPED_CAPABILITY StaticMonitorAutoLock { +class MOZ_STACK_CLASS SCOPED_CAPABILITY StaticMonitorAutoLock { public: explicit StaticMonitorAutoLock(StaticMonitor& aMonitor) - MOZ_CAPABILITY_ACQUIRE(aMonitor) + CAPABILITY_ACQUIRE(aMonitor) : mMonitor(&aMonitor) { mMonitor->Lock(); } - ~StaticMonitorAutoLock() MOZ_CAPABILITY_RELEASE() { mMonitor->Unlock(); } + ~StaticMonitorAutoLock() CAPABILITY_RELEASE() { mMonitor->Unlock(); } void Wait() { mMonitor->Wait(); } CVStatus Wait(TimeDuration aDuration) { return mMonitor->Wait(aDuration); } diff --git a/xpcom/base/StaticMutex.h b/xpcom/base/StaticMutex.h index 3d1cdb4e0525..80e6caa6a2f5 100644 --- a/xpcom/base/StaticMutex.h +++ b/xpcom/base/StaticMutex.h @@ -26,7 +26,7 @@ namespace mozilla { * initialized to 0 in order to initialize mMutex. It is only safe to use * StaticMutex as a global or static variable. */ -class MOZ_ONLY_USED_TO_AVOID_STATIC_CONSTRUCTORS MOZ_CAPABILITY StaticMutex { +class MOZ_ONLY_USED_TO_AVOID_STATIC_CONSTRUCTORS CAPABILITY StaticMutex { public: // In debug builds, check that mMutex is initialized for us as we expect by // the compiler. In non-debug builds, don't declare a constructor so that @@ -35,11 +35,11 @@ class MOZ_ONLY_USED_TO_AVOID_STATIC_CONSTRUCTORS MOZ_CAPABILITY StaticMutex { StaticMutex() { MOZ_ASSERT(!mMutex); } #endif - void Lock() MOZ_CAPABILITY_ACQUIRE() { Mutex()->Lock(); } + void Lock() CAPABILITY_ACQUIRE() { Mutex()->Lock(); } - void Unlock() MOZ_CAPABILITY_RELEASE() { Mutex()->Unlock(); } + void Unlock() CAPABILITY_RELEASE() { Mutex()->Unlock(); } - void AssertCurrentThreadOwns() MOZ_ASSERT_CAPABILITY(this) { + void AssertCurrentThreadOwns() ASSERT_CAPABILITY(this) { #ifdef DEBUG Mutex()->AssertCurrentThreadOwns(); #endif diff --git a/xpcom/base/nsConsoleService.h b/xpcom/base/nsConsoleService.h index fe86f4c0fec0..f4c3dca6bd67 100644 --- a/xpcom/base/nsConsoleService.h +++ b/xpcom/base/nsConsoleService.h @@ -87,12 +87,12 @@ class nsConsoleService final : public nsIConsoleService, public nsIObserver { nsresult MaybeForwardScriptError(nsIConsoleMessage* aMessage, bool* sent); void ClearMessagesForWindowID(const uint64_t innerID); - void ClearMessages() MOZ_REQUIRES(mLock); + void ClearMessages() REQUIRES(mLock); - mozilla::LinkedList mMessages MOZ_GUARDED_BY(mLock); + mozilla::LinkedList mMessages GUARDED_BY(mLock); // The current size of mMessages. - uint32_t mCurrentSize MOZ_GUARDED_BY(mLock); + uint32_t mCurrentSize GUARDED_BY(mLock); // The maximum size of mMessages. const uint32_t mMaximumSize; @@ -104,7 +104,7 @@ class nsConsoleService final : public nsIConsoleService, public nsIObserver { bool mDeliveringMessage; // Listeners to notify whenever a new message is logged. - ListenerHash mListeners MOZ_GUARDED_BY(mLock); + ListenerHash mListeners GUARDED_BY(mLock); // To serialize interesting methods. mozilla::Mutex mLock; diff --git a/xpcom/base/nsDumpUtils.h b/xpcom/base/nsDumpUtils.h index 7aa9c6b735c8..5d6913955e02 100644 --- a/xpcom/base/nsDumpUtils.h +++ b/xpcom/base/nsDumpUtils.h @@ -126,7 +126,7 @@ class FifoWatcher : public FdWatcher { : mDirPath(aPath), mFifoInfoLock("FifoWatcher.mFifoInfoLock") {} mozilla::Mutex mFifoInfoLock; // protects mFifoInfo - FifoInfoArray mFifoInfo MOZ_GUARDED_BY(mFifoInfoLock); + FifoInfoArray mFifoInfo GUARDED_BY(mFifoInfoLock); }; typedef void (*PipeCallback)(const uint8_t aRecvSig); @@ -160,7 +160,7 @@ class SignalPipeWatcher : public FdWatcher { } mozilla::Mutex mSignalInfoLock; // protects mSignalInfo - SignalInfoArray mSignalInfo MOZ_GUARDED_BY(mSignalInfoLock); + SignalInfoArray mSignalInfo GUARDED_BY(mSignalInfoLock); }; #endif // XP_UNIX } diff --git a/xpcom/base/nsMacUtilsImpl.h b/xpcom/base/nsMacUtilsImpl.h index 237025e5258c..a78e39522ea0 100644 --- a/xpcom/base/nsMacUtilsImpl.h +++ b/xpcom/base/nsMacUtilsImpl.h @@ -69,7 +69,7 @@ class nsMacUtilsImpl final : public nsIMacUtils { #if defined(MOZ_SANDBOX) || defined(__aarch64__) // Cache the appDir returned from GetAppPath to avoid doing I/O static StaticAutoPtr sCachedAppPath - MOZ_GUARDED_BY(sCachedAppPathMutex); + GUARDED_BY(sCachedAppPathMutex); // For thread safe setting/checking of sCachedAppPath static StaticMutex sCachedAppPathMutex; // Utility method to call ClearOnShutdown() on the main thread diff --git a/xpcom/base/nsMemoryReporterManager.h b/xpcom/base/nsMemoryReporterManager.h index 9058d99aead3..64566bd35765 100644 --- a/xpcom/base/nsMemoryReporterManager.h +++ b/xpcom/base/nsMemoryReporterManager.h @@ -192,7 +192,7 @@ class nsMemoryReporterManager final : public nsIMemoryReporterManager, SizeOfTabFns mSizeOfTabFns; private: - bool IsRegistrationBlocked() MOZ_EXCLUDES(mMutex) { + bool IsRegistrationBlocked() EXCLUDES(mMutex) { mozilla::MutexAutoLock lock(mMutex); return mIsRegistrationBlocked; } @@ -215,14 +215,14 @@ class nsMemoryReporterManager final : public nsIMemoryReporterManager, static const uint32_t kTimeoutLengthMS = 180000; mozilla::Mutex mMutex; - bool mIsRegistrationBlocked MOZ_GUARDED_BY(mMutex); + bool mIsRegistrationBlocked GUARDED_BY(mMutex); - StrongReportersTable* mStrongReporters MOZ_GUARDED_BY(mMutex); - WeakReportersTable* mWeakReporters MOZ_GUARDED_BY(mMutex); + StrongReportersTable* mStrongReporters GUARDED_BY(mMutex); + WeakReportersTable* mWeakReporters GUARDED_BY(mMutex); // These two are only used for testing purposes. - StrongReportersTable* mSavedStrongReporters MOZ_GUARDED_BY(mMutex); - WeakReportersTable* mSavedWeakReporters MOZ_GUARDED_BY(mMutex); + StrongReportersTable* mSavedStrongReporters GUARDED_BY(mMutex); + WeakReportersTable* mSavedWeakReporters GUARDED_BY(mMutex); uint32_t mNextGeneration; // MainThread only @@ -284,7 +284,7 @@ class nsMemoryReporterManager final : public nsIMemoryReporterManager, PendingReportersState* mPendingReportersState; // MainThread only // Used in GetHeapAllocatedAsync() to run jemalloc_stats async. - nsCOMPtr mThreadPool MOZ_GUARDED_BY(mMutex); + nsCOMPtr mThreadPool GUARDED_BY(mMutex); PendingProcessesState* GetStateForGeneration(uint32_t aGeneration); [[nodiscard]] static bool StartChildReport( diff --git a/xpcom/build/IOInterposer.cpp b/xpcom/build/IOInterposer.cpp index 0420965b9118..1f88d4de8ba9 100644 --- a/xpcom/build/IOInterposer.cpp +++ b/xpcom/build/IOInterposer.cpp @@ -300,7 +300,7 @@ class SourceList { } private: - RefPtr mObserverLists MOZ_GUARDED_BY(mLock); + RefPtr mObserverLists GUARDED_BY(mLock); // Note, we cannot use mozilla::Mutex here as the ObserverLists may be leaked // (We want to monitor IO during shutdown). Furthermore, as we may have to // unregister observers during shutdown an OffTheBooksMutex is not an option diff --git a/xpcom/build/IOInterposerPrivate.h b/xpcom/build/IOInterposerPrivate.h index 2231307f887a..fc2f3fc5b6c6 100644 --- a/xpcom/build/IOInterposerPrivate.h +++ b/xpcom/build/IOInterposerPrivate.h @@ -28,7 +28,7 @@ namespace IOInterposer { * positives. */ -class MOZ_CAPABILITY Monitor { +class CAPABILITY Monitor { public: Monitor() : mLock(PR_NewLock()), mCondVar(PR_NewCondVar(mLock)) {} @@ -39,12 +39,11 @@ class MOZ_CAPABILITY Monitor { mLock = nullptr; } - void Lock() MOZ_CAPABILITY_ACQUIRE() { PR_Lock(mLock); } + void Lock() CAPABILITY_ACQUIRE() { PR_Lock(mLock); } - void Unlock() MOZ_CAPABILITY_RELEASE() { PR_Unlock(mLock); } + void Unlock() CAPABILITY_RELEASE() { PR_Unlock(mLock); } - bool Wait(PRIntervalTime aTimeout = PR_INTERVAL_NO_TIMEOUT) - MOZ_REQUIRES(this) { + bool Wait(PRIntervalTime aTimeout = PR_INTERVAL_NO_TIMEOUT) REQUIRES(this) { return PR_WaitCondVar(mCondVar, aTimeout) == PR_SUCCESS; } @@ -55,34 +54,33 @@ class MOZ_CAPABILITY Monitor { PRCondVar* mCondVar; }; -class MOZ_SCOPED_CAPABILITY MonitorAutoLock { +class SCOPED_CAPABILITY MonitorAutoLock { public: - explicit MonitorAutoLock(Monitor& aMonitor) MOZ_CAPABILITY_ACQUIRE(aMonitor) + explicit MonitorAutoLock(Monitor& aMonitor) CAPABILITY_ACQUIRE(aMonitor) : mMonitor(aMonitor) { mMonitor.Lock(); } - ~MonitorAutoLock() MOZ_CAPABILITY_RELEASE() { mMonitor.Unlock(); } + ~MonitorAutoLock() CAPABILITY_RELEASE() { mMonitor.Unlock(); } private: Monitor& mMonitor; }; -class MOZ_SCOPED_CAPABILITY MonitorAutoUnlock { +class SCOPED_CAPABILITY MonitorAutoUnlock { public: - explicit MonitorAutoUnlock(Monitor& aMonitor) - MOZ_SCOPED_UNLOCK_RELEASE(aMonitor) + explicit MonitorAutoUnlock(Monitor& aMonitor) SCOPED_UNLOCK_RELEASE(aMonitor) : mMonitor(aMonitor) { mMonitor.Unlock(); } - ~MonitorAutoUnlock() MOZ_SCOPED_UNLOCK_REACQUIRE() { mMonitor.Lock(); } + ~MonitorAutoUnlock() SCOPED_UNLOCK_REACQUIRE() { mMonitor.Lock(); } private: Monitor& mMonitor; }; -class MOZ_CAPABILITY Mutex { +class CAPABILITY Mutex { public: Mutex() : mPRLock(PR_NewLock()) {} @@ -91,21 +89,21 @@ class MOZ_CAPABILITY Mutex { mPRLock = nullptr; } - void Lock() MOZ_CAPABILITY_ACQUIRE() { PR_Lock(mPRLock); } + void Lock() CAPABILITY_ACQUIRE() { PR_Lock(mPRLock); } - void Unlock() MOZ_CAPABILITY_RELEASE() { PR_Unlock(mPRLock); } + void Unlock() CAPABILITY_RELEASE() { PR_Unlock(mPRLock); } private: PRLock* mPRLock; }; -class MOZ_SCOPED_CAPABILITY AutoLock { +class SCOPED_CAPABILITY AutoLock { public: - explicit AutoLock(Mutex& aLock) MOZ_CAPABILITY_ACQUIRE(aLock) : mLock(aLock) { + explicit AutoLock(Mutex& aLock) CAPABILITY_ACQUIRE(aLock) : mLock(aLock) { mLock.Lock(); } - ~AutoLock() MOZ_CAPABILITY_RELEASE() { mLock.Unlock(); } + ~AutoLock() CAPABILITY_RELEASE() { mLock.Unlock(); } private: Mutex& mLock; diff --git a/xpcom/build/MainThreadIOLogger.cpp b/xpcom/build/MainThreadIOLogger.cpp index 8fe2d9eba567..25480e591120 100644 --- a/xpcom/build/MainThreadIOLogger.cpp +++ b/xpcom/build/MainThreadIOLogger.cpp @@ -56,8 +56,8 @@ class MainThreadIOLoggerImpl final : public mozilla::IOInterposeObserver { const char* mFileName; PRThread* mIOThread; mozilla::IOInterposer::Monitor mMonitor; - bool mShutdownRequired MOZ_GUARDED_BY(mMonitor); - std::vector mObservations MOZ_GUARDED_BY(mMonitor); + bool mShutdownRequired GUARDED_BY(mMonitor); + std::vector mObservations GUARDED_BY(mMonitor); }; static mozilla::StaticAutoPtr sImpl; diff --git a/xpcom/build/SmallArrayLRUCache.h b/xpcom/build/SmallArrayLRUCache.h index e7ac72765296..d80819b4989c 100644 --- a/xpcom/build/SmallArrayLRUCache.h +++ b/xpcom/build/SmallArrayLRUCache.h @@ -166,7 +166,7 @@ class SmallArrayLRUCache { #endif // SMALLARRAYLRUCACHE_STATS private: - void Clear(const mozilla::OffTheBooksMutexAutoLock&) MOZ_REQUIRES(mMutex) { + void Clear(const mozilla::OffTheBooksMutexAutoLock&) REQUIRES(mMutex) { for (KeyAndValue* item = &mLRUArray[0]; item != &mLRUArray[mSize]; ++item) { item->mValue = Value{}; } @@ -186,11 +186,11 @@ class SmallArrayLRUCache { constexpr static unsigned ShutdownSize = unsigned(-1); mozilla::OffTheBooksMutex mMutex{"LRU cache"}; - unsigned mSize MOZ_GUARDED_BY(mMutex) = 0; - KeyAndValue mLRUArray[LRUCapacity] MOZ_GUARDED_BY(mMutex); + unsigned mSize GUARDED_BY(mMutex) = 0; + KeyAndValue mLRUArray[LRUCapacity] GUARDED_BY(mMutex); #ifdef SMALLARRAYLRUCACHE_STATS // Hit count for each position in the case. +1 for counting not-found cases. - unsigned mCacheFoundAt[LRUCapacity + 1] MOZ_GUARDED_BY(mMutex) = {0u}; + unsigned mCacheFoundAt[LRUCapacity + 1] GUARDED_BY(mMutex) = {0u}; #endif // SMALLARRAYLRUCACHE_STATS }; diff --git a/xpcom/docs/thread-safety.rst b/xpcom/docs/thread-safety.rst index be2f15680480..abdc696a01e2 100644 --- a/xpcom/docs/thread-safety.rst +++ b/xpcom/docs/thread-safety.rst @@ -15,11 +15,11 @@ they will be errors on checkin. This analysis depends on thread-safety attributions in the source. These have been added to Mozilla’s Mutex and Monitor classes and subclasses, but in practice the analysis is largely dependent on additions to the -code being checked, in particular adding MOZ_GUARDED_BY(mutex) attributions +code being checked, in particular adding GUARDED_BY(mutex) attributions on the definitions of member variables. Like this: :: mozilla::Mutex mLock; - bool mShutdown MOZ_GUARDED_BY(mLock); + bool mShutdown GUARDED_BY(mLock); For background on Clang’s thread-safety support, see `their documentation `__. @@ -29,7 +29,7 @@ and we are enabling static checks to verify this. Legacy uses of Mutexes and Monitors are marked with MOZ_UNANNOTATED. If you’re modifying code that has been annotated with -MOZ_GUARDED_BY()/MOZ_REQUIRES()/etc, you should **make sure that the annotations +GUARDED_BY()/REQUIRES()/etc, you should **make sure that the annotations are updated properly**; e.g. if you change the thread-usage of a member variable or method you should mark it accordingly, comment, and resolve any warnings. Since the warnings will be errors in autoland/m-c, you @@ -46,16 +46,16 @@ about the locking requirements and/or what threads it’s touched from: :: // thread. Protected by mMutex. nsTArray> mFrames - MOZ_GUARDED_BY(mMutex); + GUARDED_BY(mMutex); // Set on MainThread, deleted on either MainThread mainthread, used on // MainThread or IO Thread in DoStopSession - nsCOMPtr mReconnectDelayTimer MOZ_GUARDED_BY(mMutex); + nsCOMPtr mReconnectDelayTimer GUARDED_BY(mMutex); It’s strongly recommended to group values by access pattern, but it’s **critical** to make it clear what the requirements to access a value are. With values protected by Mutexes and Monitors, adding a -MOZ_GUARDED_BY(mutex/monitor) should be sufficient, though you may want to +GUARDED_BY(mutex/monitor) should be sufficient, though you may want to also document what threads access it, and if they read or write to it. Values which have more complex access requirements (see single-writer @@ -67,11 +67,11 @@ defined: :: // mResource should only be modified on the main thread with the lock. // So it can be read without lock on the main thread or on other threads // with the lock. - RefPtr mResource MOZ_GUARDED_BY(mMutex); + RefPtr mResource GUARDED_BY(mMutex); **WARNING:** thread-safety analysis is not magic; it depends on you telling it the requirements around access. If you don’t mark something as -MOZ_GUARDED_BY() it won’t figure it out for you, and you can end up with a data +GUARDED_BY() it won’t figure it out for you, and you can end up with a data race. When writing multithreaded code, you should always be thinking about which threads can access what and when, and document this. @@ -96,19 +96,19 @@ Gecko uses a number of different locking patterns. They include: The simplest and easiest to check with static analysis is **Always Lock**, and generally you should prefer this pattern. This is very -simple; you add MOZ_GUARDED_BY(mutex/monitor), and must own the lock to +simple; you add GUARDED_BY(mutex/monitor), and must own the lock to access the value. This can be implemented by some combination of direct Lock/AutoLock calls in the method; an assertion that the lock is already held by the current thread, or annotating the method as requiring the -lock (MOZ_REQUIRES(mutex)) in the method definition: :: +lock (REQUIRES(mutex)) in the method definition: :: // Ensures mSize is initialized, if it can be. // mLock must be held when this is called, and mInput must be non-null. - void EnsureSizeInitialized() MOZ_REQUIRES(mLock); + void EnsureSizeInitialized() REQUIRES(mLock); ... // This lock protects mSeekable, mInput, mSize, and mSizeInitialized. Mutex mLock; - int64_t mSize MOZ_GUARDED_BY(mLock); + int64_t mSize GUARDED_BY(mLock); **Single Writer** is tricky for static analysis normally, since it doesn’t know what thread an access will occur on. In general, you should @@ -130,9 +130,9 @@ There is one case this causes problems with: when a method needs to access the value (without the lock), and then decides to write to the value from the same method, taking the lock. To the static analyzer, this looks like a double-lock. Either you will need to add -MOZ_NO_THREAD_SAFETY_ANALYSIS to the method, move the write into another +NO_THREAD_SAFETY_ANALYSIS to the method, move the write into another method you call, or locally disable the warning with -MOZ_PUSH_IGNORE_THREAD_SAFETY and MOZ_POP_THREAD_SAFETY. We’re discussing with +PUSH_IGNORE_THREAD_SAFETY and POP_THREAD_SAFETY. We’re discussing with the clang static analysis developers how to better handle this. Note also that this provides no checking that the lock is taken to write @@ -142,7 +142,7 @@ to the value: :: // mResource should only be modified on the main thread with the lock. // So it can be read without lock on the main thread or on other threads // with the lock. - RefPtr mResource MOZ_GUARDED_BY(mMutex); + RefPtr mResource GUARDED_BY(mMutex); ... nsresult ChannelMediaResource::Listener::OnStartRequest(nsIRequest *aRequest) { mMutex.AssertOnWritingThread(); @@ -162,9 +162,9 @@ thread-safety analysis for the lock: :: mMutex.AssertOnWritingThread(); ... { - MOZ_PUSH_IGNORE_THREAD_SAFETY + PUSH_IGNORE_THREAD_SAFETY MutexSingleWriterAutoLock lock(mMutex); - MOZ_POP_THREAD_SAFETY + POP_THREAD_SAFETY **Out-of-band Invariants** is used in a number of places (and may be combined with either of the above patterns). It's using other knowledge @@ -194,8 +194,8 @@ might be called from elsewhere: :: } ... mMutex mMutex; - uint32_t mBar MOZ_GUARDED_BY(mMutex); - uint32_t mQuerty MOZ_GUARDED_BY(mMutex); + uint32_t mBar GUARDED_BY(mMutex); + uint32_t mQuerty GUARDED_BY(mMutex); } Another example might be a value that’s used from other threads, but only @@ -220,8 +220,8 @@ threads accessing the value. In all but a few cases where code is on a very lock is cheap. To quiet warnings where these patterns are in use, you'll need to either -add locks (preferred), or suppress the warnings with MOZ_NO_THREAD_SAFETY_ANALYSIS or -MOZ_PUSH_IGNORE_THREAD_SAFETY/MOZ_POP_THREAD_SAFETY. +add locks (preferred), or suppress the warnings with NO_THREAD_SAFETY_ANALYSIS or +PUSH_IGNORE_THREAD_SAFETY/POP_THREAD_SAFETY. **This pattern especially needs good documentation in the code as to what threads will access what members under what conditions!**:: @@ -233,15 +233,15 @@ threads will access what members under what conditions!**:: uint32_t chunkSize, bool closeSource, bool closeSink) - MOZ_NO_THREAD_SAFETY_ANALYSIS { + NO_THREAD_SAFETY_ANALYSIS { and:: // We can't be accessed by another thread because this hasn't been // added to the public list yet - MOZ_PUSH_IGNORE_THREAD_SAFETY + PUSH_IGNORE_THREAD_SAFETY mRestrictedPortList.AppendElement(gBadPortList[i]); - MOZ_POP_THREAD_SAFETY + POP_THREAD_SAFETY and:: @@ -259,8 +259,8 @@ per their documentation, it can’t handle conditional locks, like: :: mMutex.Lock(); } -You should resolve this either via MOZ_NO_THREAD_SAFETY_ANALYSIS on the -method, or MOZ_PUSH_IGNORE_THREAD_SAFETY/MOZ_POP_THREAD_SAFETY. +You should resolve this either via NO_THREAD_SAFETY_ANALYSIS on the +method, or PUSH_IGNORE_THREAD_SAFETY/POP_THREAD_SAFETY. **Sometimes the analyzer can’t figure out that two objects are both the same Mutex**, and it will warn you. You may be able to resolve this by @@ -282,14 +282,14 @@ is owned or freed; follow locking via the MayBe<> by mMonitor->AssertCurrentThreadOwns(); // for threadsafety analysis If you reset() the Maybe<>, you may need to surround it with -MOZ_PUSH_IGNORE_THREAD_SAFETY and MOZ_POP_THREAD_SAFETY macros: :: +PUSH_IGNORE_THREAD_SAFETY and POP_THREAD_SAFETY macros: :: - MOZ_PUSH_IGNORE_THREAD_SAFETY + PUSH_IGNORE_THREAD_SAFETY aLock.reset(); - MOZ_POP_THREAD_SAFETY + POP_THREAD_SAFETY **Passing a protected value by-reference** sometimes will confuse the -analyzer. Use MOZ_PUSH_IGNORE_THREAD_SAFETY and MOZ_POP_THREAD_SAFETY macros to +analyzer. Use PUSH_IGNORE_THREAD_SAFETY and POP_THREAD_SAFETY macros to resolve this. **Classes which need thread-safety annotations** @@ -321,19 +321,19 @@ Some code passes **Proof-of-Lock** AutoLock parameters, as a poor form of static analysis. While it’s hard to make mistakes if you pass an AutoLock reference, it is possible to pass a lock to the wrong Mutex/Monitor. -Proof-of-lock is basically redundant to MOZ_REQUIRES() and obsolete, and +Proof-of-lock is basically redundant to REQUIRES() and obsolete, and depends on the optimizer to remove it, and per above it can be misused, -with effort. With MOZ_REQUIRES(), any proof-of-lock parameters can be removed, +with effort. With REQUIRES(), any proof-of-lock parameters can be removed, though you don't have to do so immediately. -In any method taking an aProofOfLock parameter, add a MOZ_REQUIRES(mutex) to +In any method taking an aProofOfLock parameter, add a REQUIRES(mutex) to the definition (and optionally remove the proof-of-lock), or add a mMutex.AssertCurrentThreadOwns() to the method: :: nsresult DispatchLockHeld(already_AddRefed aRunnable, - nsIEventTarget* aSyncLoopTarget, - const MutexAutoLock& aProofOfLock); - + nsIEventTarget* aSyncLoopTarget) MOZ_REQUIRES(mMutex); + + nsIEventTarget* aSyncLoopTarget) REQUIRES(mMutex); or (if for some reason it's hard to specify the mutex in the header):: @@ -343,12 +343,12 @@ or (if for some reason it's hard to specify the mutex in the header):: + nsIEventTarget* aSyncLoopTarget) { + mMutex.AssertCurrentThreadOwns(); -In addition to MOZ_GUARDED_BY() there’s also MOZ_PT_GUARDED_BY(), which says +In addition to GUARDED_BY() there’s also PT_GUARDED_BY(), which says that the pointer isn’t guarded, but the data pointed to by the pointer is. Classes that expose a Mutex-like interface can be annotated like Mutex; -see some of the examples in the tree that use MOZ_CAPABILITY and -MOZ_ACQUIRE()/MOZ_RELEASE(). +see some of the examples in the tree that use CAPABILITY and +ACQUIRE()/RELEASE(). Shared locks are supported, though we don’t use them much. See RWLock. diff --git a/xpcom/ds/nsAtomTable.cpp b/xpcom/ds/nsAtomTable.cpp index 56618cd46c5a..090639c7b914 100644 --- a/xpcom/ds/nsAtomTable.cpp +++ b/xpcom/ds/nsAtomTable.cpp @@ -189,16 +189,16 @@ class nsAtomSubTable { Mutex mLock; PLDHashTable mTable; nsAtomSubTable(); - void GCLocked(GCKind aKind) MOZ_REQUIRES(mLock); + void GCLocked(GCKind aKind) REQUIRES(mLock); void AddSizeOfExcludingThisLocked(MallocSizeOf aMallocSizeOf, - AtomsSizes& aSizes) MOZ_REQUIRES(mLock); + AtomsSizes& aSizes) REQUIRES(mLock); - AtomTableEntry* Search(AtomTableKey& aKey) const MOZ_REQUIRES(mLock) { + AtomTableEntry* Search(AtomTableKey& aKey) const REQUIRES(mLock) { mLock.AssertCurrentThreadOwns(); return static_cast(mTable.Search(&aKey)); } - AtomTableEntry* Add(AtomTableKey& aKey) MOZ_REQUIRES(mLock) { + AtomTableEntry* Add(AtomTableKey& aKey) REQUIRES(mLock) { mLock.AssertCurrentThreadOwns(); return static_cast(mTable.Add(&aKey)); // Infallible } diff --git a/xpcom/io/FilePreferences.cpp b/xpcom/io/FilePreferences.cpp index 1d96c7281016..210c65a21695 100644 --- a/xpcom/io/FilePreferences.cpp +++ b/xpcom/io/FilePreferences.cpp @@ -26,10 +26,10 @@ static StaticMutex sMutex; static bool sBlockUNCPaths = false; typedef nsTArray WinPaths; -static WinPaths& PathAllowlist() MOZ_REQUIRES(sMutex) { +static WinPaths& PathAllowlist() REQUIRES(sMutex) { sMutex.AssertCurrentThreadOwns(); - static WinPaths sPaths MOZ_GUARDED_BY(sMutex); + static WinPaths sPaths GUARDED_BY(sMutex); return sPaths; } diff --git a/xpcom/io/InputStreamLengthWrapper.h b/xpcom/io/InputStreamLengthWrapper.h index a11a808fa711..201b61dcc783 100644 --- a/xpcom/io/InputStreamLengthWrapper.h +++ b/xpcom/io/InputStreamLengthWrapper.h @@ -76,7 +76,7 @@ class InputStreamLengthWrapper final : public nsIAsyncInputStream, mozilla::Mutex mMutex; // This is used for AsyncWait and it's protected by mutex. - nsCOMPtr mAsyncWaitCallback MOZ_GUARDED_BY(mMutex); + nsCOMPtr mAsyncWaitCallback GUARDED_BY(mMutex); }; } // namespace mozilla diff --git a/xpcom/io/NonBlockingAsyncInputStream.h b/xpcom/io/NonBlockingAsyncInputStream.h index 453ac2eafcae..6574e5df74fe 100644 --- a/xpcom/io/NonBlockingAsyncInputStream.h +++ b/xpcom/io/NonBlockingAsyncInputStream.h @@ -71,13 +71,13 @@ class NonBlockingAsyncInputStream final : public nsIAsyncInputStream, // This is set when AsyncWait is called with a callback and with // WAIT_CLOSURE_ONLY as flag. // This is protected by mLock. - Maybe mWaitClosureOnly MOZ_GUARDED_BY(mLock); + Maybe mWaitClosureOnly GUARDED_BY(mLock); // This is protected by mLock. - RefPtr mAsyncWaitCallback MOZ_GUARDED_BY(mLock); + RefPtr mAsyncWaitCallback GUARDED_BY(mLock); // This is protected by mLock. - bool mClosed MOZ_GUARDED_BY(mLock); + bool mClosed GUARDED_BY(mLock); }; } // namespace mozilla diff --git a/xpcom/io/SlicedInputStream.h b/xpcom/io/SlicedInputStream.h index 30b6c118ab54..d2c54ca556f2 100644 --- a/xpcom/io/SlicedInputStream.h +++ b/xpcom/io/SlicedInputStream.h @@ -84,15 +84,15 @@ class SlicedInputStream final : public nsIAsyncInputStream, // These four are used for AsyncWait. They are protected by mutex because // touched on multiple threads. - nsCOMPtr mAsyncWaitCallback MOZ_GUARDED_BY(mMutex); - nsCOMPtr mAsyncWaitEventTarget MOZ_GUARDED_BY(mMutex); - uint32_t mAsyncWaitFlags MOZ_GUARDED_BY(mMutex); - uint32_t mAsyncWaitRequestedCount MOZ_GUARDED_BY(mMutex); + nsCOMPtr mAsyncWaitCallback GUARDED_BY(mMutex); + nsCOMPtr mAsyncWaitEventTarget GUARDED_BY(mMutex); + uint32_t mAsyncWaitFlags GUARDED_BY(mMutex); + uint32_t mAsyncWaitRequestedCount GUARDED_BY(mMutex); // This is use for nsIAsyncInputStreamLength::AsyncWait. // This is protected by mutex. nsCOMPtr mAsyncWaitLengthCallback - MOZ_GUARDED_BY(mMutex); + GUARDED_BY(mMutex); Mutex mMutex; }; diff --git a/xpcom/io/nsMultiplexInputStream.cpp b/xpcom/io/nsMultiplexInputStream.cpp index 3c541d867a56..77869f3b6f28 100644 --- a/xpcom/io/nsMultiplexInputStream.cpp +++ b/xpcom/io/nsMultiplexInputStream.cpp @@ -64,7 +64,7 @@ class nsMultiplexInputStream final : public nsIMultiplexInputStream, // This is used for nsIAsyncInputStreamLength::AsyncLengthWait void AsyncWaitCompleted(int64_t aLength, const MutexAutoLock& aProofOfLock) - MOZ_REQUIRES(mLock); + REQUIRES(mLock); struct StreamData { nsresult Initialize(nsIInputStream* aOriginalStream) { @@ -101,12 +101,12 @@ class nsMultiplexInputStream final : public nsIMultiplexInputStream, uint64_t mCurrentPos; }; - Mutex& GetLock() MOZ_RETURN_CAPABILITY(mLock) { return mLock; } + Mutex& GetLock() RETURN_CAPABILITY(mLock) { return mLock; } private: ~nsMultiplexInputStream() = default; - void NextStream() MOZ_REQUIRES(mLock) { + void NextStream() REQUIRES(mLock) { ++mCurrentStream; mStartedReadingCurrent = false; } @@ -115,7 +115,7 @@ class nsMultiplexInputStream final : public nsIMultiplexInputStream, // This method updates mSeekableStreams, mTellableStreams, // mIPCSerializableStreams and mCloneableStreams values. - void UpdateQIMap(StreamData& aStream) MOZ_REQUIRES(mLock); + void UpdateQIMap(StreamData& aStream) REQUIRES(mLock); struct MOZ_STACK_CLASS ReadSegmentsState { nsCOMPtr mThisStream; @@ -142,24 +142,24 @@ class nsMultiplexInputStream final : public nsIMultiplexInputStream, Mutex mLock; // Protects access to all data members. - nsTArray mStreams MOZ_GUARDED_BY(mLock); + nsTArray mStreams GUARDED_BY(mLock); - uint32_t mCurrentStream MOZ_GUARDED_BY(mLock); - bool mStartedReadingCurrent MOZ_GUARDED_BY(mLock); - nsresult mStatus MOZ_GUARDED_BY(mLock); - nsCOMPtr mAsyncWaitCallback MOZ_GUARDED_BY(mLock); - uint32_t mAsyncWaitFlags MOZ_GUARDED_BY(mLock); - uint32_t mAsyncWaitRequestedCount MOZ_GUARDED_BY(mLock); - nsCOMPtr mAsyncWaitEventTarget MOZ_GUARDED_BY(mLock); + uint32_t mCurrentStream GUARDED_BY(mLock); + bool mStartedReadingCurrent GUARDED_BY(mLock); + nsresult mStatus GUARDED_BY(mLock); + nsCOMPtr mAsyncWaitCallback GUARDED_BY(mLock); + uint32_t mAsyncWaitFlags GUARDED_BY(mLock); + uint32_t mAsyncWaitRequestedCount GUARDED_BY(mLock); + nsCOMPtr mAsyncWaitEventTarget GUARDED_BY(mLock); nsCOMPtr mAsyncWaitLengthCallback - MOZ_GUARDED_BY(mLock); + GUARDED_BY(mLock); class AsyncWaitLengthHelper; - RefPtr mAsyncWaitLengthHelper MOZ_GUARDED_BY(mLock); + RefPtr mAsyncWaitLengthHelper GUARDED_BY(mLock); - uint32_t mSeekableStreams MOZ_GUARDED_BY(mLock); - uint32_t mIPCSerializableStreams MOZ_GUARDED_BY(mLock); - uint32_t mCloneableStreams MOZ_GUARDED_BY(mLock); + uint32_t mSeekableStreams GUARDED_BY(mLock); + uint32_t mIPCSerializableStreams GUARDED_BY(mLock); + uint32_t mCloneableStreams GUARDED_BY(mLock); // These are Atomics so that we can check them in QueryInterface without // taking a lock (to look at mStreams.Length() and the numbers above) diff --git a/xpcom/io/nsPipe3.cpp b/xpcom/io/nsPipe3.cpp index fab25ae38736..18f95ea7e281 100644 --- a/xpcom/io/nsPipe3.cpp +++ b/xpcom/io/nsPipe3.cpp @@ -160,21 +160,21 @@ struct nsPipeReadState { mNeedDrain(false) {} // All members of this type are guarded by the pipe monitor, however it cannot - // be named from this type, so the less-reliable MOZ_GUARDED_VAR is used - // instead. In the future it would be nice to avoid this, especially as - // MOZ_GUARDED_VAR is deprecated. - char* mReadCursor MOZ_GUARDED_VAR; - char* mReadLimit MOZ_GUARDED_VAR; - int32_t mSegment MOZ_GUARDED_VAR; - uint32_t mAvailable MOZ_GUARDED_VAR; + // be named from this type, so the less-reliable GUARDED_VAR is used instead. + // In the future it would be nice to avoid this, especially as GUARDED_VAR is + // deprecated. + char* mReadCursor GUARDED_VAR; + char* mReadLimit GUARDED_VAR; + int32_t mSegment GUARDED_VAR; + uint32_t mAvailable GUARDED_VAR; // This flag is managed using the AutoReadSegment RAII stack class. - bool mActiveRead MOZ_GUARDED_VAR; + bool mActiveRead GUARDED_VAR; // Set to indicate that the input stream has closed and should be drained, // but that drain has been delayed due to an active read. When the read // completes, this flag indicate the drain should then be performed. - bool mNeedDrain MOZ_GUARDED_VAR; + bool mNeedDrain GUARDED_VAR; }; //----------------------------------------------------------------------------- @@ -217,7 +217,7 @@ class nsPipeInputStream final : public nsIAsyncInputStream, void SetNonBlocking(bool aNonBlocking) { mBlocking = !aNonBlocking; } - uint32_t Available() MOZ_REQUIRES(Monitor()); + uint32_t Available() REQUIRES(Monitor()); // synchronously wait for the pipe to become readable. nsresult Wait(); @@ -227,10 +227,10 @@ class nsPipeInputStream final : public nsIAsyncInputStream, // evidence. MonitorAction OnInputReadable(uint32_t aBytesWritten, nsPipeEvents&, const ReentrantMonitorAutoEnter& ev) - MOZ_REQUIRES(Monitor()); + REQUIRES(Monitor()); MonitorAction OnInputException(nsresult, nsPipeEvents&, const ReentrantMonitorAutoEnter& ev) - MOZ_REQUIRES(Monitor()); + REQUIRES(Monitor()); nsPipeReadState& ReadState() { return mReadState; } @@ -240,13 +240,13 @@ class nsPipeInputStream final : public nsIAsyncInputStream, // A version of Status() that doesn't acquire the monitor. nsresult Status(const ReentrantMonitorAutoEnter& ev) const - MOZ_REQUIRES(Monitor()); + REQUIRES(Monitor()); // The status of this input stream, ignoring the status of the underlying // monitor. If this status is errored, the input stream has either already // been removed from the pipe, or will be removed from the pipe shortly. nsresult InputStatus(const ReentrantMonitorAutoEnter&) const - MOZ_REQUIRES(Monitor()) { + REQUIRES(Monitor()) { return mInputStatus; } @@ -261,12 +261,12 @@ class nsPipeInputStream final : public nsIAsyncInputStream, // Individual input streams can be closed without effecting the rest of the // pipe. So track individual input stream status separately. |mInputStatus| // is protected by |mPipe->mReentrantMonitor|. - nsresult mInputStatus MOZ_GUARDED_BY(Monitor()); + nsresult mInputStatus GUARDED_BY(Monitor()); bool mBlocking; // these variables can only be accessed while inside the pipe's monitor - bool mBlocked MOZ_GUARDED_BY(Monitor()); - CallbackHolder mCallback MOZ_GUARDED_BY(Monitor()); + bool mBlocked GUARDED_BY(Monitor()); + CallbackHolder mCallback GUARDED_BY(Monitor()); // requires pipe's monitor to access members; usually treat as an opaque token // to pass to nsPipe @@ -299,16 +299,15 @@ class nsPipeOutputStream : public nsIAsyncOutputStream, public nsIClassInfo { mWritable(true) {} void SetNonBlocking(bool aNonBlocking) { mBlocking = !aNonBlocking; } - void SetWritable(bool aWritable) MOZ_REQUIRES(Monitor()) { + void SetWritable(bool aWritable) REQUIRES(Monitor()) { mWritable = aWritable; } // synchronously wait for the pipe to become writable. nsresult Wait(); - MonitorAction OnOutputWritable(nsPipeEvents&) MOZ_REQUIRES(Monitor()); - MonitorAction OnOutputException(nsresult, nsPipeEvents&) - MOZ_REQUIRES(Monitor()); + MonitorAction OnOutputWritable(nsPipeEvents&) REQUIRES(Monitor()); + MonitorAction OnOutputException(nsresult, nsPipeEvents&) REQUIRES(Monitor()); ReentrantMonitor& Monitor() const; @@ -321,9 +320,9 @@ class nsPipeOutputStream : public nsIAsyncOutputStream, public nsIClassInfo { bool mBlocking; // these variables can only be accessed while inside the pipe's monitor - bool mBlocked MOZ_GUARDED_BY(Monitor()); - bool mWritable MOZ_GUARDED_BY(Monitor()); - CallbackHolder mCallback MOZ_GUARDED_BY(Monitor()); + bool mBlocked GUARDED_BY(Monitor()); + bool mWritable GUARDED_BY(Monitor()); + CallbackHolder mCallback GUARDED_BY(Monitor()); }; //----------------------------------------------------------------------------- @@ -351,26 +350,23 @@ class nsPipe final { // void PeekSegment(const nsPipeReadState& aReadState, uint32_t aIndex, - char*& aCursor, char*& aLimit) - MOZ_REQUIRES(mReentrantMonitor); + char*& aCursor, char*& aLimit) REQUIRES(mReentrantMonitor); SegmentChangeResult AdvanceReadSegment(nsPipeReadState& aReadState, const ReentrantMonitorAutoEnter& ev) - MOZ_REQUIRES(mReentrantMonitor); + REQUIRES(mReentrantMonitor); bool ReadSegmentBeingWritten(nsPipeReadState& aReadState) - MOZ_REQUIRES(mReentrantMonitor); - uint32_t CountSegmentReferences(int32_t aSegment) - MOZ_REQUIRES(mReentrantMonitor); - void SetAllNullReadCursors() MOZ_REQUIRES(mReentrantMonitor); - bool AllReadCursorsMatchWriteCursor() MOZ_REQUIRES(mReentrantMonitor); - void RollBackAllReadCursors(char* aWriteCursor) - MOZ_REQUIRES(mReentrantMonitor); - void UpdateAllReadCursors(char* aWriteCursor) MOZ_REQUIRES(mReentrantMonitor); - void ValidateAllReadCursors() MOZ_REQUIRES(mReentrantMonitor); + REQUIRES(mReentrantMonitor); + uint32_t CountSegmentReferences(int32_t aSegment) REQUIRES(mReentrantMonitor); + void SetAllNullReadCursors() REQUIRES(mReentrantMonitor); + bool AllReadCursorsMatchWriteCursor() REQUIRES(mReentrantMonitor); + void RollBackAllReadCursors(char* aWriteCursor) REQUIRES(mReentrantMonitor); + void UpdateAllReadCursors(char* aWriteCursor) REQUIRES(mReentrantMonitor); + void ValidateAllReadCursors() REQUIRES(mReentrantMonitor); uint32_t GetBufferSegmentCount(const nsPipeReadState& aReadState, const ReentrantMonitorAutoEnter& ev) const - MOZ_REQUIRES(mReentrantMonitor); + REQUIRES(mReentrantMonitor); bool IsAdvanceBufferFull(const ReentrantMonitorAutoEnter& ev) const - MOZ_REQUIRES(mReentrantMonitor); + REQUIRES(mReentrantMonitor); // // methods below may be called while outside the pipe's monitor @@ -401,39 +397,39 @@ class nsPipe final { // a weak reference as the streams will clear their entry here in their // destructor. Using a strong reference would create a reference cycle. // Only usable while mReentrantMonitor is locked. - nsTArray mInputList MOZ_GUARDED_BY(mReentrantMonitor); + nsTArray mInputList GUARDED_BY(mReentrantMonitor); ReentrantMonitor mReentrantMonitor; - nsSegmentedBuffer mBuffer MOZ_GUARDED_BY(mReentrantMonitor); + nsSegmentedBuffer mBuffer GUARDED_BY(mReentrantMonitor); // The maximum number of segments to allow to be buffered in advance // of the fastest reader. This is collection of segments is called // the "advance buffer". - uint32_t mMaxAdvanceBufferSegmentCount MOZ_GUARDED_BY(mReentrantMonitor); + uint32_t mMaxAdvanceBufferSegmentCount GUARDED_BY(mReentrantMonitor); - int32_t mWriteSegment MOZ_GUARDED_BY(mReentrantMonitor); - char* mWriteCursor MOZ_GUARDED_BY(mReentrantMonitor); - char* mWriteLimit MOZ_GUARDED_BY(mReentrantMonitor); + int32_t mWriteSegment GUARDED_BY(mReentrantMonitor); + char* mWriteCursor GUARDED_BY(mReentrantMonitor); + char* mWriteLimit GUARDED_BY(mReentrantMonitor); // |mStatus| is protected by |mReentrantMonitor|. - nsresult mStatus MOZ_GUARDED_BY(mReentrantMonitor); + nsresult mStatus GUARDED_BY(mReentrantMonitor); }; //----------------------------------------------------------------------------- // Declarations of Monitor() methods on the streams. // -// These must be placed early to provide MOZ_RETURN_CAPABILITY annotations for -// the thread-safety analysis. This couldn't be done at the declaration due to +// These must be placed early to provide RETURN_CAPABILITY annotations for the +// thread-safety analysis. This couldn't be done at the declaration due to // nsPipe not yet being defined. ReentrantMonitor& nsPipeOutputStream::Monitor() const - MOZ_RETURN_CAPABILITY(mPipe->mReentrantMonitor) { + RETURN_CAPABILITY(mPipe->mReentrantMonitor) { return mPipe->mReentrantMonitor; } ReentrantMonitor& nsPipeInputStream::Monitor() const - MOZ_RETURN_CAPABILITY(mPipe->mReentrantMonitor) { + RETURN_CAPABILITY(mPipe->mReentrantMonitor) { return mPipe->mReentrantMonitor; } @@ -1804,7 +1800,7 @@ nsresult NS_NewPipe(nsIInputStream** aPipeIn, nsIOutputStream** aPipeOut, nsresult NS_NewPipe2(nsIAsyncInputStream** aPipeIn, nsIAsyncOutputStream** aPipeOut, bool aNonBlockingInput, bool aNonBlockingOutput, uint32_t aSegmentSize, - uint32_t aSegmentCount) MOZ_NO_THREAD_SAFETY_ANALYSIS { + uint32_t aSegmentCount) NO_THREAD_SAFETY_ANALYSIS { RefPtr pipe = new nsPipe(aSegmentSize ? aSegmentSize : DEFAULT_SEGMENT_SIZE, aSegmentCount ? aSegmentCount : DEFAULT_SEGMENT_COUNT); diff --git a/xpcom/io/nsStorageStream.cpp b/xpcom/io/nsStorageStream.cpp index 2f0234288b7c..4cd542f0e4cc 100644 --- a/xpcom/io/nsStorageStream.cpp +++ b/xpcom/io/nsStorageStream.cpp @@ -358,7 +358,7 @@ class nsStorageInputStream final : public nsIInputStream, ~nsStorageInputStream() = default; protected: - nsresult Seek(uint32_t aPosition) MOZ_REQUIRES(mStorageStream->mMutex); + nsresult Seek(uint32_t aPosition) REQUIRES(mStorageStream->mMutex); friend class nsStorageStream; @@ -371,7 +371,7 @@ class nsStorageInputStream final : public nsIInputStream, uint32_t mLogicalCursor; // Logical offset into stream nsresult mStatus; - uint32_t SegNum(uint32_t aPosition) MOZ_REQUIRES(mStorageStream->mMutex) { + uint32_t SegNum(uint32_t aPosition) REQUIRES(mStorageStream->mMutex) { return aPosition >> mStorageStream->mSegmentSizeLog2; } uint32_t SegOffset(uint32_t aPosition) { diff --git a/xpcom/io/nsStorageStream.h b/xpcom/io/nsStorageStream.h index e5f5092a7497..adf6f425c25a 100644 --- a/xpcom/io/nsStorageStream.h +++ b/xpcom/io/nsStorageStream.h @@ -46,31 +46,31 @@ class nsStorageStream final : public nsIStorageStream, public nsIOutputStream { ~nsStorageStream(); mozilla::Mutex mMutex{"nsStorageStream"}; - nsSegmentedBuffer* mSegmentedBuffer MOZ_GUARDED_BY(mMutex) = nullptr; + nsSegmentedBuffer* mSegmentedBuffer GUARDED_BY(mMutex) = nullptr; // All segments, except possibly the last, are of this size. Must be // power-of-2 - uint32_t mSegmentSize MOZ_GUARDED_BY(mMutex) = 0; + uint32_t mSegmentSize GUARDED_BY(mMutex) = 0; // log2(mSegmentSize) - uint32_t mSegmentSizeLog2 MOZ_GUARDED_BY(mMutex) = 0; + uint32_t mSegmentSizeLog2 GUARDED_BY(mMutex) = 0; // true, if an un-Close'ed output stream exists - bool mWriteInProgress MOZ_GUARDED_BY(mMutex) = false; + bool mWriteInProgress GUARDED_BY(mMutex) = false; // Last segment # in use, -1 initially - int32_t mLastSegmentNum MOZ_GUARDED_BY(mMutex) = -1; + int32_t mLastSegmentNum GUARDED_BY(mMutex) = -1; // Pointer to next byte to be written - char* mWriteCursor MOZ_GUARDED_BY(mMutex) = nullptr; + char* mWriteCursor GUARDED_BY(mMutex) = nullptr; // Pointer to one byte after end of segment containing the write cursor - char* mSegmentEnd MOZ_GUARDED_BY(mMutex) = nullptr; + char* mSegmentEnd GUARDED_BY(mMutex) = nullptr; // Number of bytes written to stream - uint32_t mLogicalLength MOZ_GUARDED_BY(mMutex) = 0; + uint32_t mLogicalLength GUARDED_BY(mMutex) = 0; // number of input streams actively reading a segment. - uint32_t mActiveSegmentBorrows MOZ_GUARDED_BY(mMutex) = 0; + uint32_t mActiveSegmentBorrows GUARDED_BY(mMutex) = 0; - nsresult SetLengthLocked(uint32_t aLength) MOZ_REQUIRES(mMutex); - nsresult Seek(int32_t aPosition) MOZ_REQUIRES(mMutex); - uint32_t SegNum(uint32_t aPosition) MOZ_REQUIRES(mMutex) { + nsresult SetLengthLocked(uint32_t aLength) REQUIRES(mMutex); + nsresult Seek(int32_t aPosition) REQUIRES(mMutex); + uint32_t SegNum(uint32_t aPosition) REQUIRES(mMutex) { return aPosition >> mSegmentSizeLog2; } - uint32_t SegOffset(uint32_t aPosition) MOZ_REQUIRES(mMutex) { + uint32_t SegOffset(uint32_t aPosition) REQUIRES(mMutex) { return aPosition & (mSegmentSize - 1); } }; diff --git a/xpcom/io/nsStreamUtils.cpp b/xpcom/io/nsStreamUtils.cpp index d15901102d79..fb2754474e6e 100644 --- a/xpcom/io/nsStreamUtils.cpp +++ b/xpcom/io/nsStreamUtils.cpp @@ -455,7 +455,7 @@ class nsAStreamCopier : public nsIInputStreamCallback, return PostContinuationEvent_Locked(); } - nsresult PostContinuationEvent_Locked() MOZ_REQUIRES(mLock) { + nsresult PostContinuationEvent_Locked() REQUIRES(mLock) { nsresult rv = NS_OK; if (mEventInProcess) { mEventIsPending = true; @@ -481,12 +481,12 @@ class nsAStreamCopier : public nsIInputStreamCallback, nsAsyncCopyProgressFun mProgressCallback; void* mClosure; uint32_t mChunkSize; - bool mEventInProcess MOZ_GUARDED_BY(mLock); - bool mEventIsPending MOZ_GUARDED_BY(mLock); + bool mEventInProcess GUARDED_BY(mLock); + bool mEventIsPending GUARDED_BY(mLock); bool mCloseSource; bool mCloseSink; - bool mCanceled MOZ_GUARDED_BY(mLock); - nsresult mCancelStatus MOZ_GUARDED_BY(mLock); + bool mCanceled GUARDED_BY(mLock); + nsresult mCancelStatus GUARDED_BY(mLock); // virtual since subclasses call superclass Release() virtual ~nsAStreamCopier() = default; diff --git a/xpcom/io/nsStringStream.cpp b/xpcom/io/nsStringStream.cpp index cc035e214125..1fb2997a39bc 100644 --- a/xpcom/io/nsStringStream.cpp +++ b/xpcom/io/nsStringStream.cpp @@ -129,20 +129,18 @@ class nsStringInputStream final : public nsIStringInputStream, private: ~nsStringInputStream() = default; - size_t Length() const MOZ_REQUIRES(mMon) { + size_t Length() const REQUIRES(mMon) { return mSource ? mSource->Data().Length() : 0; } - size_t LengthRemaining() const MOZ_REQUIRES(mMon) { - return Length() - mOffset; - } + size_t LengthRemaining() const REQUIRES(mMon) { return Length() - mOffset; } - void Clear() MOZ_REQUIRES(mMon) { mSource = nullptr; } + void Clear() REQUIRES(mMon) { mSource = nullptr; } - bool Closed() MOZ_REQUIRES(mMon) { return !mSource; } + bool Closed() REQUIRES(mMon) { return !mSource; } - RefPtr mSource MOZ_GUARDED_BY(mMon); - size_t mOffset MOZ_GUARDED_BY(mMon) = 0; + RefPtr mSource GUARDED_BY(mMon); + size_t mOffset GUARDED_BY(mMon) = 0; mutable mozilla::ReentrantMonitor mMon{"nsStringInputStream"}; }; diff --git a/xpcom/tests/gtest/TestDeadlockDetector.cpp b/xpcom/tests/gtest/TestDeadlockDetector.cpp index 15e977a8f27e..65e54fb73348 100644 --- a/xpcom/tests/gtest/TestDeadlockDetector.cpp +++ b/xpcom/tests/gtest/TestDeadlockDetector.cpp @@ -71,7 +71,7 @@ static void DisableCrashReporter() { // Single-threaded sanity tests // Stupidest possible deadlock. -static int Sanity_Child() MOZ_NO_THREAD_SAFETY_ANALYSIS { +static int Sanity_Child() NO_THREAD_SAFETY_ANALYSIS { DisableCrashReporter(); MUTEX m1("dd.sanity.m1"); @@ -92,7 +92,7 @@ TEST_F(TESTNAME(DeadlockDetectorTest), TESTNAME(SanityDeathTest)) { } // Slightly less stupid deadlock. -static int Sanity2_Child() MOZ_NO_THREAD_SAFETY_ANALYSIS { +static int Sanity2_Child() NO_THREAD_SAFETY_ANALYSIS { DisableCrashReporter(); MUTEX m1("dd.sanity2.m1"); @@ -118,7 +118,7 @@ TEST_F(TESTNAME(DeadlockDetectorTest), TESTNAME(Sanity2DeathTest)) { #if 0 // Temporarily disabled, see bug 1370644. int -Sanity3_Child() MOZ_NO_THREAD_SAFETY_ANALYSIS +Sanity3_Child() NO_THREAD_SAFETY_ANALYSIS { DisableCrashReporter(); @@ -156,7 +156,7 @@ TEST_F(TESTNAME(DeadlockDetectorTest), TESTNAME(Sanity3DeathTest)) } #endif -static int Sanity4_Child() MOZ_NO_THREAD_SAFETY_ANALYSIS { +static int Sanity4_Child() NO_THREAD_SAFETY_ANALYSIS { DisableCrashReporter(); mozilla::ReentrantMonitor m1 MOZ_UNANNOTATED("dd.sanity4.m1"); @@ -179,7 +179,7 @@ TEST_F(TESTNAME(DeadlockDetectorTest), TESTNAME(Sanity4DeathTest)) { ASSERT_DEATH_IF_SUPPORTED(Sanity4_Child(), regex); } -static int Sanity5_Child() MOZ_NO_THREAD_SAFETY_ANALYSIS { +static int Sanity5_Child() NO_THREAD_SAFETY_ANALYSIS { DisableCrashReporter(); mozilla::RecursiveMutex m1 MOZ_UNANNOTATED("dd.sanity4.m1"); @@ -225,7 +225,7 @@ struct ThreadState { #if 0 // Temporarily disabled, see bug 1370644. static void -TwoThreads_thread(void* arg) MOZ_NO_THREAD_SAFETY_ANALYSIS +TwoThreads_thread(void* arg) NO_THREAD_SAFETY_ANALYSIS { ThreadState* state = static_cast(arg); @@ -247,7 +247,7 @@ TwoThreads_thread(void* arg) MOZ_NO_THREAD_SAFETY_ANALYSIS } int -TwoThreads_Child() MOZ_NO_THREAD_SAFETY_ANALYSIS +TwoThreads_Child() NO_THREAD_SAFETY_ANALYSIS { DisableCrashReporter(); @@ -284,8 +284,7 @@ TEST_F(TESTNAME(DeadlockDetectorTest), TESTNAME(TwoThreadsDeathTest)) } #endif -static void ContentionNoDeadlock_thread(void* arg) - MOZ_NO_THREAD_SAFETY_ANALYSIS { +static void ContentionNoDeadlock_thread(void* arg) NO_THREAD_SAFETY_ANALYSIS { const uint32_t K = 100000; ThreadState* state = static_cast(arg); @@ -301,7 +300,7 @@ static void ContentionNoDeadlock_thread(void* arg) } } -static int ContentionNoDeadlock_Child() MOZ_NO_THREAD_SAFETY_ANALYSIS { +static int ContentionNoDeadlock_Child() NO_THREAD_SAFETY_ANALYSIS { const size_t kMutexCount = 4; PRThread* threads[3]; diff --git a/xpcom/tests/gtest/TestRecursiveMutex.cpp b/xpcom/tests/gtest/TestRecursiveMutex.cpp index 57fb6fc0380d..8b20b905c027 100644 --- a/xpcom/tests/gtest/TestRecursiveMutex.cpp +++ b/xpcom/tests/gtest/TestRecursiveMutex.cpp @@ -15,7 +15,7 @@ using mozilla::RecursiveMutexAutoLock; // well, actually recursively acquirable. TEST(RecursiveMutex, SmokeTest) -MOZ_NO_THREAD_SAFETY_ANALYSIS { +NO_THREAD_SAFETY_ANALYSIS { RecursiveMutex mutex("testing mutex"); RecursiveMutexAutoLock lock1(mutex); diff --git a/xpcom/tests/gtest/TestSynchronization.cpp b/xpcom/tests/gtest/TestSynchronization.cpp index c4a1f5c99ed0..ec45c7f78535 100644 --- a/xpcom/tests/gtest/TestSynchronization.cpp +++ b/xpcom/tests/gtest/TestSynchronization.cpp @@ -21,7 +21,7 @@ static PRThread* spawn(void (*run)(void*), void* arg) { // Sanity check: tests that can be done on a single thread // TEST(Synchronization, Sanity) -MOZ_NO_THREAD_SAFETY_ANALYSIS { +NO_THREAD_SAFETY_ANALYSIS { Mutex lock("sanity::lock"); lock.Lock(); lock.AssertCurrentThreadOwns(); @@ -112,8 +112,7 @@ TEST(Synchronization, MonitorContention) static ReentrantMonitor* gMon2; -static void MonitorContention2_thread(void* /*arg*/) - MOZ_NO_THREAD_SAFETY_ANALYSIS { +static void MonitorContention2_thread(void* /*arg*/) NO_THREAD_SAFETY_ANALYSIS { for (int i = 0; i < 100000; ++i) { gMon2->Enter(); gMon2->AssertCurrentThreadIn(); @@ -145,8 +144,7 @@ TEST(Synchronization, MonitorContention2) static ReentrantMonitor* gMon3; static int32_t gMonFirst; -static void MonitorSyncSanity_thread(void* /*arg*/) - MOZ_NO_THREAD_SAFETY_ANALYSIS { +static void MonitorSyncSanity_thread(void* /*arg*/) NO_THREAD_SAFETY_ANALYSIS { gMon3->Enter(); gMon3->AssertCurrentThreadIn(); if (gMonFirst) { @@ -241,7 +239,7 @@ TEST(Synchronization, AutoLock) // // The thread owns assertions make mutex analysis throw spurious warnings TEST(Synchronization, AutoTryLock) -MOZ_NO_THREAD_SAFETY_ANALYSIS { +NO_THREAD_SAFETY_ANALYSIS { Mutex l1 MOZ_UNANNOTATED("autotrylock"); MutexAutoTryLock autol1(l1); @@ -297,7 +295,7 @@ TEST(Synchronization, AutoUnlock) // AutoMonitor tests // TEST(Synchronization, AutoMonitor) -MOZ_NO_THREAD_SAFETY_ANALYSIS { +NO_THREAD_SAFETY_ANALYSIS { ReentrantMonitor m1("automonitor"); ReentrantMonitor m2("automonitor2"); diff --git a/xpcom/threads/CondVar.h b/xpcom/threads/CondVar.h index e427fc2d9e0b..561356a23486 100644 --- a/xpcom/threads/CondVar.h +++ b/xpcom/threads/CondVar.h @@ -87,7 +87,7 @@ class OffTheBooksCondVar : BlockingResourceBase { * AssertCurrentThreadOwnsMutex * @see Mutex::AssertCurrentThreadOwns **/ - void AssertCurrentThreadOwnsMutex() const MOZ_ASSERT_CAPABILITY(mLock) { + void AssertCurrentThreadOwnsMutex() const ASSERT_CAPABILITY(mLock) { mLock->AssertCurrentThreadOwns(); } @@ -95,13 +95,13 @@ class OffTheBooksCondVar : BlockingResourceBase { * AssertNotCurrentThreadOwnsMutex * @see Mutex::AssertNotCurrentThreadOwns **/ - void AssertNotCurrentThreadOwnsMutex() const MOZ_ASSERT_CAPABILITY(!mLock) { + void AssertNotCurrentThreadOwnsMutex() const ASSERT_CAPABILITY(!mLock) { mLock->AssertNotCurrentThreadOwns(); } #else - void AssertCurrentThreadOwnsMutex() const MOZ_ASSERT_CAPABILITY(mLock) {} - void AssertNotCurrentThreadOwnsMutex() const MOZ_ASSERT_CAPABILITY(!mLock) {} + void AssertCurrentThreadOwnsMutex() const ASSERT_CAPABILITY(mLock) {} + void AssertNotCurrentThreadOwnsMutex() const ASSERT_CAPABILITY(!mLock) {} #endif // ifdef DEBUG diff --git a/xpcom/threads/EventTargetCapability.h b/xpcom/threads/EventTargetCapability.h index d839859dc21a..6f413e131c15 100644 --- a/xpcom/threads/EventTargetCapability.h +++ b/xpcom/threads/EventTargetCapability.h @@ -42,15 +42,14 @@ namespace mozilla { // } // // private: -// void IncreaseMediaCount() MOZ_REQUIRES(mTargetCapability) { mMediaCount += -// 1; } +// void IncreaseMediaCount() REQUIRES(mTargetCapability) { mMediaCount += 1; } // -// uint32_t mMediaCount MOZ_GUARDED_BY(mTargetCapability) = 0; +// uint32_t mMediaCount GUARDED_BY(mTargetCapability) = 0; // EventTargetCapability mTargetCapability; // }; template -class MOZ_CAPABILITY EventTargetCapability final { +class CAPABILITY EventTargetCapability final { static_assert(std::is_base_of_v, "T must derive from nsIEventTarget"); @@ -65,7 +64,7 @@ class MOZ_CAPABILITY EventTargetCapability final { EventTargetCapability& operator=(const EventTargetCapability&) = default; EventTargetCapability& operator=(EventTargetCapability&&) = default; - void AssertOnCurrentThread() const MOZ_ASSERT_CAPABILITY(this) { + void AssertOnCurrentThread() const ASSERT_CAPABILITY(this) { MOZ_ASSERT(mTarget->IsOnCurrentThread()); } diff --git a/xpcom/threads/LazyIdleThread.h b/xpcom/threads/LazyIdleThread.h index 11fa1c60f38a..e67c553b6dea 100644 --- a/xpcom/threads/LazyIdleThread.h +++ b/xpcom/threads/LazyIdleThread.h @@ -176,14 +176,14 @@ class LazyIdleThread final : public nsIThread, * The number of events that are pending on mThread. A nonzero value means * that the thread cannot be cleaned up. */ - uint32_t mPendingEventCount MOZ_GUARDED_BY(mMutex); + uint32_t mPendingEventCount GUARDED_BY(mMutex); /** * The number of times that mThread has dispatched an idle notification. Any * timer that fires while this count is nonzero can safely be ignored as * another timer will be on the way. */ - uint32_t mIdleNotificationCount MOZ_GUARDED_BY(mMutex); + uint32_t mIdleNotificationCount GUARDED_BY(mMutex); /** * Whether or not the thread should automatically shutdown. If the owner @@ -202,7 +202,7 @@ class LazyIdleThread final : public nsIThread, * Set from CleanupThread and lasting until the thread has shut down. Prevents * further idle notifications during the shutdown process. */ - bool mThreadIsShuttingDown MOZ_GUARDED_BY(mMutex); + bool mThreadIsShuttingDown GUARDED_BY(mMutex); /** * Whether or not the idle timeout is enabled. diff --git a/xpcom/threads/Monitor.h b/xpcom/threads/Monitor.h index 97cfa6fcd111..e0fa9bfd24ce 100644 --- a/xpcom/threads/Monitor.h +++ b/xpcom/threads/Monitor.h @@ -21,31 +21,29 @@ namespace mozilla { * to instead use the RAII wrappers MonitorAutoLock and * MonitorAutoUnlock. */ -class MOZ_CAPABILITY Monitor { +class CAPABILITY Monitor { public: explicit Monitor(const char* aName) : mMutex(aName), mCondVar(mMutex, "[Monitor.mCondVar]") {} ~Monitor() = default; - void Lock() MOZ_CAPABILITY_ACQUIRE() { mMutex.Lock(); } - [[nodiscard]] bool TryLock() MOZ_TRY_ACQUIRE(true) { - return mMutex.TryLock(); - } - void Unlock() MOZ_CAPABILITY_RELEASE() { mMutex.Unlock(); } + void Lock() CAPABILITY_ACQUIRE() { mMutex.Lock(); } + [[nodiscard]] bool TryLock() TRY_ACQUIRE(true) { return mMutex.TryLock(); } + void Unlock() CAPABILITY_RELEASE() { mMutex.Unlock(); } - void Wait() MOZ_REQUIRES(this) { mCondVar.Wait(); } - CVStatus Wait(TimeDuration aDuration) MOZ_REQUIRES(this) { + void Wait() REQUIRES(this) { mCondVar.Wait(); } + CVStatus Wait(TimeDuration aDuration) REQUIRES(this) { return mCondVar.Wait(aDuration); } void Notify() { mCondVar.Notify(); } void NotifyAll() { mCondVar.NotifyAll(); } - void AssertCurrentThreadOwns() const MOZ_ASSERT_CAPABILITY(this) { + void AssertCurrentThreadOwns() const ASSERT_CAPABILITY(this) { mMutex.AssertCurrentThreadOwns(); } - void AssertNotCurrentThreadOwns() const MOZ_ASSERT_CAPABILITY(!this) { + void AssertNotCurrentThreadOwns() const ASSERT_CAPABILITY(!this) { mMutex.AssertNotCurrentThreadOwns(); } @@ -90,10 +88,10 @@ class MonitorSingleWriter : public Monitor { MOZ_COUNTED_DTOR(MonitorSingleWriter) - void AssertOnWritingThread() const MOZ_ASSERT_CAPABILITY(this) { + void AssertOnWritingThread() const ASSERT_CAPABILITY(this) { MOZ_ASSERT(mOwner->OnWritingThread()); } - void AssertOnWritingThreadOrHeld() const MOZ_ASSERT_CAPABILITY(this) { + void AssertOnWritingThreadOrHeld() const ASSERT_CAPABILITY(this) { #ifdef DEBUG if (!mOwner->OnWritingThread()) { AssertCurrentThreadOwns(); @@ -122,14 +120,14 @@ class MonitorSingleWriter : public Monitor { */ namespace detail { template -class MOZ_SCOPED_CAPABILITY MOZ_STACK_CLASS BaseMonitorAutoLock { +class SCOPED_CAPABILITY MOZ_STACK_CLASS BaseMonitorAutoLock { public: - explicit BaseMonitorAutoLock(T& aMonitor) MOZ_CAPABILITY_ACQUIRE(aMonitor) + explicit BaseMonitorAutoLock(T& aMonitor) CAPABILITY_ACQUIRE(aMonitor) : mMonitor(&aMonitor) { mMonitor->Lock(); } - ~BaseMonitorAutoLock() MOZ_CAPABILITY_RELEASE() { mMonitor->Unlock(); } + ~BaseMonitorAutoLock() CAPABILITY_RELEASE() { mMonitor->Unlock(); } // It's very hard to mess up MonitorAutoLock lock(mMonitor); ... lock.Wait(). // The only way you can fail to hold the lock when you call lock.Wait() is to // use MonitorAutoUnlock. For now we'll ignore that case. @@ -170,7 +168,7 @@ class MOZ_SCOPED_CAPABILITY MOZ_STACK_CLASS BaseMonitorAutoLock { // should use this method in preference to using AssertCurrentThreadOwns on // the mutex you expected to be held, since this method provides stronger // guarantees. - void AssertOwns(const T& aMonitor) const MOZ_ASSERT_CAPABILITY(aMonitor) { + void AssertOwns(const T& aMonitor) const ASSERT_CAPABILITY(aMonitor) { MOZ_ASSERT(&aMonitor == mMonitor); mMonitor->AssertCurrentThreadOwns(); } @@ -199,9 +197,9 @@ typedef detail::BaseMonitorAutoLock // MutexSingleWriterAutoLockOnThread(lock, mutex) // clang-format on #define MonitorSingleWriterAutoLockOnThread(lock, monitor) \ - MOZ_PUSH_IGNORE_THREAD_SAFETY \ + PUSH_IGNORE_THREAD_SAFETY \ MonitorSingleWriterAutoLock lock(monitor); \ - MOZ_POP_THREAD_SAFETY + POP_THREAD_SAFETY /** * Unlock the monitor for the lexical scope instances of this class @@ -212,15 +210,14 @@ typedef detail::BaseMonitorAutoLock */ namespace detail { template -class MOZ_STACK_CLASS MOZ_SCOPED_CAPABILITY BaseMonitorAutoUnlock { +class MOZ_STACK_CLASS SCOPED_CAPABILITY BaseMonitorAutoUnlock { public: - explicit BaseMonitorAutoUnlock(T& aMonitor) - MOZ_SCOPED_UNLOCK_RELEASE(aMonitor) + explicit BaseMonitorAutoUnlock(T& aMonitor) SCOPED_UNLOCK_RELEASE(aMonitor) : mMonitor(&aMonitor) { mMonitor->Unlock(); } - ~BaseMonitorAutoUnlock() MOZ_SCOPED_UNLOCK_REACQUIRE() { mMonitor->Lock(); } + ~BaseMonitorAutoUnlock() SCOPED_UNLOCK_REACQUIRE() { mMonitor->Lock(); } private: BaseMonitorAutoUnlock() = delete; @@ -242,16 +239,16 @@ typedef detail::BaseMonitorAutoUnlock * The monitor must be unlocked when instances of this class are * created. */ -class MOZ_SCOPED_CAPABILITY MOZ_STACK_CLASS ReleasableMonitorAutoLock { +class SCOPED_CAPABILITY MOZ_STACK_CLASS ReleasableMonitorAutoLock { public: explicit ReleasableMonitorAutoLock(Monitor& aMonitor) - MOZ_CAPABILITY_ACQUIRE(aMonitor) + CAPABILITY_ACQUIRE(aMonitor) : mMonitor(&aMonitor) { mMonitor->Lock(); mLocked = true; } - ~ReleasableMonitorAutoLock() MOZ_CAPABILITY_RELEASE() { + ~ReleasableMonitorAutoLock() CAPABILITY_RELEASE() { if (mLocked) { mMonitor->Unlock(); } @@ -286,17 +283,17 @@ class MOZ_SCOPED_CAPABILITY MOZ_STACK_CLASS ReleasableMonitorAutoLock { // return; // } // clang-format on - void Unlock() MOZ_CAPABILITY_RELEASE() { + void Unlock() CAPABILITY_RELEASE() { MOZ_ASSERT(mLocked); mMonitor->Unlock(); mLocked = false; } - void Lock() MOZ_CAPABILITY_ACQUIRE() { + void Lock() CAPABILITY_ACQUIRE() { MOZ_ASSERT(!mLocked); mMonitor->Lock(); mLocked = true; } - void AssertCurrentThreadOwns() const MOZ_ASSERT_CAPABILITY() { + void AssertCurrentThreadOwns() const ASSERT_CAPABILITY() { mMonitor->AssertCurrentThreadOwns(); } diff --git a/xpcom/threads/Mutex.h b/xpcom/threads/Mutex.h index 7f3677c1d566..efa24e384056 100644 --- a/xpcom/threads/Mutex.h +++ b/xpcom/threads/Mutex.h @@ -34,8 +34,8 @@ namespace mozilla { * include leak checking. Sometimes you want to intentionally "leak" a mutex * until shutdown; in these cases, OffTheBooksMutex is for you. */ -class MOZ_CAPABILITY OffTheBooksMutex : public detail::MutexImpl, - BlockingResourceBase { +class CAPABILITY OffTheBooksMutex : public detail::MutexImpl, + BlockingResourceBase { public: /** * @param aName A name which can reference this lock @@ -62,24 +62,24 @@ class MOZ_CAPABILITY OffTheBooksMutex : public detail::MutexImpl, /** * Lock this mutex. **/ - void Lock() MOZ_CAPABILITY_ACQUIRE() { this->lock(); } + void Lock() CAPABILITY_ACQUIRE() { this->lock(); } /** * Try to lock this mutex, returning true if we were successful. **/ - [[nodiscard]] bool TryLock() MOZ_TRY_ACQUIRE(true) { return this->tryLock(); } + [[nodiscard]] bool TryLock() TRY_ACQUIRE(true) { return this->tryLock(); } /** * Unlock this mutex. **/ - void Unlock() MOZ_CAPABILITY_RELEASE() { this->unlock(); } + void Unlock() CAPABILITY_RELEASE() { this->unlock(); } /** * Assert that the current thread owns this mutex in debug builds. * * Does nothing in non-debug builds. **/ - void AssertCurrentThreadOwns() const MOZ_ASSERT_CAPABILITY(this) {} + void AssertCurrentThreadOwns() const ASSERT_CAPABILITY(this) {} /** * Assert that the current thread does not own this mutex. @@ -89,16 +89,16 @@ class MOZ_CAPABILITY OffTheBooksMutex : public detail::MutexImpl, * * It is therefore mostly useful as documentation. **/ - void AssertNotCurrentThreadOwns() const MOZ_ASSERT_CAPABILITY(!this) {} + void AssertNotCurrentThreadOwns() const ASSERT_CAPABILITY(!this) {} #else - void Lock() MOZ_CAPABILITY_ACQUIRE(); + void Lock() CAPABILITY_ACQUIRE(); - [[nodiscard]] bool TryLock() MOZ_TRY_ACQUIRE(true); - void Unlock() MOZ_CAPABILITY_RELEASE(); + [[nodiscard]] bool TryLock() TRY_ACQUIRE(true); + void Unlock() CAPABILITY_RELEASE(); - void AssertCurrentThreadOwns() const MOZ_ASSERT_CAPABILITY(this); - void AssertNotCurrentThreadOwns() const MOZ_ASSERT_CAPABILITY(!this) { + void AssertCurrentThreadOwns() const ASSERT_CAPABILITY(this); + void AssertNotCurrentThreadOwns() const ASSERT_CAPABILITY(!this) { // FIXME bug 476536 } #endif // ifndef DEBUG @@ -187,10 +187,10 @@ class MutexSingleWriter : public OffTheBooksMutex { * builds, but this doesn't. We could also use thread-safety/capability * system to provide direct thread assertions. **/ - void AssertOnWritingThread() const MOZ_ASSERT_CAPABILITY(this) { + void AssertOnWritingThread() const ASSERT_CAPABILITY(this) { MOZ_ASSERT(mOwner->OnWritingThread()); } - void AssertOnWritingThreadOrHeld() const MOZ_ASSERT_CAPABILITY(this) { + void AssertOnWritingThreadOrHeld() const ASSERT_CAPABILITY(this) { #ifdef DEBUG if (!mOwner->OnWritingThread()) { AssertCurrentThreadOwns(); @@ -222,7 +222,7 @@ class MOZ_RAII BaseAutoUnlock; * MUCH PREFERRED to bare calls to Mutex.Lock and Unlock. */ template -class MOZ_RAII MOZ_SCOPED_CAPABILITY BaseAutoLock { +class MOZ_RAII SCOPED_CAPABILITY BaseAutoLock { public: /** * Constructor @@ -232,11 +232,11 @@ class MOZ_RAII MOZ_SCOPED_CAPABILITY BaseAutoLock { * @param aLock A valid mozilla::Mutex* returned by * mozilla::Mutex::NewMutex. **/ - explicit BaseAutoLock(T aLock) MOZ_CAPABILITY_ACQUIRE(aLock) : mLock(aLock) { + explicit BaseAutoLock(T aLock) CAPABILITY_ACQUIRE(aLock) : mLock(aLock) { mLock.Lock(); } - ~BaseAutoLock(void) MOZ_CAPABILITY_RELEASE() { mLock.Unlock(); } + ~BaseAutoLock(void) CAPABILITY_RELEASE() { mLock.Unlock(); } // Assert that aLock is the mutex passed to the constructor and that the // current thread owns the mutex. In coding patterns such as: @@ -263,7 +263,7 @@ class MOZ_RAII MOZ_SCOPED_CAPABILITY BaseAutoLock { // should use this method in preference to using AssertCurrentThreadOwns on // the mutex you expected to be held, since this method provides stronger // guarantees. - void AssertOwns(const T& aMutex) const MOZ_ASSERT_CAPABILITY(aMutex) { + void AssertOwns(const T& aMutex) const ASSERT_CAPABILITY(aMutex) { MOZ_ASSERT(&aMutex == &mLock); mLock.AssertCurrentThreadOwns(); } @@ -293,9 +293,9 @@ typedef detail::BaseAutoLock OffTheBooksMutexAutoLock; // use // MutexSingleWriterAutoLockOnThread(lock, mutex) #define MutexSingleWriterAutoLockOnThread(lock, mutex) \ - MOZ_PUSH_IGNORE_THREAD_SAFETY \ + PUSH_IGNORE_THREAD_SAFETY \ MutexSingleWriterAutoLock lock(mutex); \ - MOZ_POP_THREAD_SAFETY + POP_THREAD_SAFETY namespace detail { /** @@ -306,7 +306,7 @@ namespace detail { * */ template -class MOZ_RAII MOZ_SCOPED_CAPABILITY ReleasableBaseAutoLock { +class MOZ_RAII SCOPED_CAPABILITY ReleasableBaseAutoLock { public: /** * Constructor @@ -316,19 +316,19 @@ class MOZ_RAII MOZ_SCOPED_CAPABILITY ReleasableBaseAutoLock { * @param aLock A valid mozilla::Mutex& returned by * mozilla::Mutex::NewMutex. **/ - explicit ReleasableBaseAutoLock(T aLock) MOZ_CAPABILITY_ACQUIRE(aLock) + explicit ReleasableBaseAutoLock(T aLock) CAPABILITY_ACQUIRE(aLock) : mLock(aLock) { mLock.Lock(); mLocked = true; } - ~ReleasableBaseAutoLock(void) MOZ_CAPABILITY_RELEASE() { + ~ReleasableBaseAutoLock(void) CAPABILITY_RELEASE() { if (mLocked) { Unlock(); } } - void AssertOwns(const T& aMutex) const MOZ_ASSERT_CAPABILITY(aMutex) { + void AssertOwns(const T& aMutex) const ASSERT_CAPABILITY(aMutex) { MOZ_ASSERT(&aMutex == &mLock); mLock.AssertCurrentThreadOwns(); } @@ -343,12 +343,12 @@ class MOZ_RAII MOZ_SCOPED_CAPABILITY ReleasableBaseAutoLock { // return; // } // clang-format on - void Unlock() MOZ_CAPABILITY_RELEASE() { + void Unlock() CAPABILITY_RELEASE() { MOZ_ASSERT(mLocked); mLock.Unlock(); mLocked = false; } - void Lock() MOZ_CAPABILITY_ACQUIRE() { + void Lock() CAPABILITY_ACQUIRE() { MOZ_ASSERT(!mLocked); mLock.Lock(); mLocked = true; @@ -379,21 +379,20 @@ namespace detail { * MUCH PREFERRED to bare calls to Mutex.Unlock and Lock. */ template -class MOZ_RAII MOZ_SCOPED_CAPABILITY BaseAutoUnlock { +class MOZ_RAII SCOPED_CAPABILITY BaseAutoUnlock { public: - explicit BaseAutoUnlock(T aLock) MOZ_SCOPED_UNLOCK_RELEASE(aLock) - : mLock(aLock) { + explicit BaseAutoUnlock(T aLock) SCOPED_UNLOCK_RELEASE(aLock) : mLock(aLock) { mLock.Unlock(); } explicit BaseAutoUnlock(BaseAutoLock& aAutoLock) - /* MOZ_CAPABILITY_RELEASE(aAutoLock.mLock) */ + /* CAPABILITY_RELEASE(aAutoLock.mLock) */ : mLock(aAutoLock.mLock) { NS_ASSERTION(mLock, "null lock"); mLock->Unlock(); } - ~BaseAutoUnlock() MOZ_SCOPED_UNLOCK_REACQUIRE() { mLock.Lock(); } + ~BaseAutoUnlock() SCOPED_UNLOCK_REACQUIRE() { mLock.Lock(); } private: BaseAutoUnlock() = delete; @@ -421,12 +420,12 @@ namespace detail { * MUCH PREFERRED to bare calls to Mutex.TryLock and Unlock. */ template -class MOZ_RAII MOZ_SCOPED_CAPABILITY BaseAutoTryLock { +class MOZ_RAII SCOPED_CAPABILITY BaseAutoTryLock { public: - explicit BaseAutoTryLock(T& aLock) MOZ_CAPABILITY_ACQUIRE(aLock) + explicit BaseAutoTryLock(T& aLock) CAPABILITY_ACQUIRE(aLock) : mLock(aLock.TryLock() ? &aLock : nullptr) {} - ~BaseAutoTryLock() MOZ_CAPABILITY_RELEASE() { + ~BaseAutoTryLock() CAPABILITY_RELEASE() { if (mLock) { mLock->Unlock(); mLock = nullptr; diff --git a/xpcom/threads/RWLock.h b/xpcom/threads/RWLock.h index 44b98bd20874..846eb90e16ef 100644 --- a/xpcom/threads/RWLock.h +++ b/xpcom/threads/RWLock.h @@ -39,32 +39,30 @@ namespace mozilla { // // It is unspecified whether RWLock gives priority to waiting readers or // a waiting writer when unlocking. -class MOZ_CAPABILITY RWLock : public detail::RWLockImpl, - public BlockingResourceBase { +class CAPABILITY RWLock : public detail::RWLockImpl, + public BlockingResourceBase { public: explicit RWLock(const char* aName); #ifdef DEBUG bool LockedForWritingByCurrentThread(); - [[nodiscard]] bool TryReadLock() MOZ_SHARED_TRYLOCK_FUNCTION(true); - void ReadLock() MOZ_ACQUIRE_SHARED(); - void ReadUnlock() MOZ_RELEASE_SHARED(); - [[nodiscard]] bool TryWriteLock() MOZ_TRY_ACQUIRE(true); - void WriteLock() MOZ_CAPABILITY_ACQUIRE(); - void WriteUnlock() MOZ_EXCLUSIVE_RELEASE(); + [[nodiscard]] bool TryReadLock() SHARED_TRYLOCK_FUNCTION(true); + void ReadLock() ACQUIRE_SHARED(); + void ReadUnlock() RELEASE_SHARED(); + [[nodiscard]] bool TryWriteLock() TRY_ACQUIRE(true); + void WriteLock() CAPABILITY_ACQUIRE(); + void WriteUnlock() EXCLUSIVE_RELEASE(); #else - [[nodiscard]] bool TryReadLock() MOZ_SHARED_TRYLOCK_FUNCTION(true) { + [[nodiscard]] bool TryReadLock() SHARED_TRYLOCK_FUNCTION(true) { return detail::RWLockImpl::tryReadLock(); } - void ReadLock() MOZ_ACQUIRE_SHARED() { detail::RWLockImpl::readLock(); } - void ReadUnlock() MOZ_RELEASE_SHARED() { detail::RWLockImpl::readUnlock(); } - [[nodiscard]] bool TryWriteLock() MOZ_TRY_ACQUIRE(true) { + void ReadLock() ACQUIRE_SHARED() { detail::RWLockImpl::readLock(); } + void ReadUnlock() RELEASE_SHARED() { detail::RWLockImpl::readUnlock(); } + [[nodiscard]] bool TryWriteLock() TRY_ACQUIRE(true) { return detail::RWLockImpl::tryWriteLock(); } - void WriteLock() MOZ_CAPABILITY_ACQUIRE() { detail::RWLockImpl::writeLock(); } - void WriteUnlock() MOZ_EXCLUSIVE_RELEASE() { - detail::RWLockImpl::writeUnlock(); - } + void WriteLock() CAPABILITY_ACQUIRE() { detail::RWLockImpl::writeLock(); } + void WriteUnlock() EXCLUSIVE_RELEASE() { detail::RWLockImpl::writeUnlock(); } #endif private: @@ -102,18 +100,17 @@ class MOZ_RAII BaseAutoTryReadLock { }; template -class MOZ_SCOPED_CAPABILITY MOZ_RAII BaseAutoReadLock { +class SCOPED_CAPABILITY MOZ_RAII BaseAutoReadLock { public: - explicit BaseAutoReadLock(T& aLock) MOZ_ACQUIRE_SHARED(aLock) - : mLock(&aLock) { + explicit BaseAutoReadLock(T& aLock) ACQUIRE_SHARED(aLock) : mLock(&aLock) { MOZ_ASSERT(mLock, "null lock"); mLock->ReadLock(); } - // Not MOZ_RELEASE_SHARED(), which would make sense - apparently this trips + // Not RELEASE_SHARED(), which would make sense - apparently this trips // over a bug in clang's static analyzer and it says it expected an // exclusive unlock. - ~BaseAutoReadLock() MOZ_RELEASE_GENERIC() { mLock->ReadUnlock(); } + ~BaseAutoReadLock() RELEASE_GENERIC() { mLock->ReadUnlock(); } private: BaseAutoReadLock() = delete; @@ -147,15 +144,15 @@ class MOZ_RAII BaseAutoTryWriteLock { }; template -class MOZ_SCOPED_CAPABILITY MOZ_RAII BaseAutoWriteLock final { +class SCOPED_CAPABILITY MOZ_RAII BaseAutoWriteLock final { public: - explicit BaseAutoWriteLock(T& aLock) MOZ_CAPABILITY_ACQUIRE(aLock) + explicit BaseAutoWriteLock(T& aLock) CAPABILITY_ACQUIRE(aLock) : mLock(&aLock) { MOZ_ASSERT(mLock, "null lock"); mLock->WriteLock(); } - ~BaseAutoWriteLock() MOZ_CAPABILITY_RELEASE() { mLock->WriteUnlock(); } + ~BaseAutoWriteLock() CAPABILITY_RELEASE() { mLock->WriteUnlock(); } private: BaseAutoWriteLock() = delete; @@ -190,7 +187,7 @@ typedef BaseAutoWriteLock AutoWriteLock; namespace detail { -class MOZ_CAPABILITY StaticRWLock { +class CAPABILITY StaticRWLock { public: // In debug builds, check that mLock is initialized for us as we expect by // the compiler. In non-debug builds, don't declare a constructor so that @@ -199,19 +196,19 @@ class MOZ_CAPABILITY StaticRWLock { StaticRWLock() { MOZ_ASSERT(!mLock); } #endif - [[nodiscard]] bool TryReadLock() MOZ_SHARED_TRYLOCK_FUNCTION(true) { + [[nodiscard]] bool TryReadLock() SHARED_TRYLOCK_FUNCTION(true) { return Lock()->TryReadLock(); } - void ReadLock() MOZ_ACQUIRE_SHARED() { Lock()->ReadLock(); } - void ReadUnlock() MOZ_RELEASE_SHARED() { Lock()->ReadUnlock(); } - [[nodiscard]] bool TryWriteLock() MOZ_TRY_ACQUIRE(true) { + void ReadLock() ACQUIRE_SHARED() { Lock()->ReadLock(); } + void ReadUnlock() RELEASE_SHARED() { Lock()->ReadUnlock(); } + [[nodiscard]] bool TryWriteLock() TRY_ACQUIRE(true) { return Lock()->TryWriteLock(); } - void WriteLock() MOZ_CAPABILITY_ACQUIRE() { Lock()->WriteLock(); } - void WriteUnlock() MOZ_EXCLUSIVE_RELEASE() { Lock()->WriteUnlock(); } + void WriteLock() CAPABILITY_ACQUIRE() { Lock()->WriteLock(); } + void WriteUnlock() EXCLUSIVE_RELEASE() { Lock()->WriteUnlock(); } private: - [[nodiscard]] RWLock* Lock() MOZ_RETURN_CAPABILITY(*mLock) { + [[nodiscard]] RWLock* Lock() RETURN_CAPABILITY(*mLock) { if (mLock) { return mLock; } diff --git a/xpcom/threads/RecursiveMutex.h b/xpcom/threads/RecursiveMutex.h index db645b289079..887f5b93f5be 100644 --- a/xpcom/threads/RecursiveMutex.h +++ b/xpcom/threads/RecursiveMutex.h @@ -18,33 +18,33 @@ namespace mozilla { -class MOZ_CAPABILITY RecursiveMutex : public BlockingResourceBase { +class CAPABILITY RecursiveMutex : public BlockingResourceBase { public: explicit RecursiveMutex(const char* aName); ~RecursiveMutex(); #ifdef DEBUG - void Lock() MOZ_CAPABILITY_ACQUIRE(); - void Unlock() MOZ_CAPABILITY_RELEASE(); + void Lock() CAPABILITY_ACQUIRE(); + void Unlock() CAPABILITY_RELEASE(); #else - void Lock() MOZ_CAPABILITY_ACQUIRE() { LockInternal(); } - void Unlock() MOZ_CAPABILITY_RELEASE() { UnlockInternal(); } + void Lock() CAPABILITY_ACQUIRE() { LockInternal(); } + void Unlock() CAPABILITY_RELEASE() { UnlockInternal(); } #endif #ifdef DEBUG /** * AssertCurrentThreadIn **/ - void AssertCurrentThreadIn() const MOZ_ASSERT_CAPABILITY(this); + void AssertCurrentThreadIn() const ASSERT_CAPABILITY(this); /** * AssertNotCurrentThreadIn **/ - void AssertNotCurrentThreadIn() const MOZ_EXCLUDES(this) { + void AssertNotCurrentThreadIn() const EXCLUDES(this) { // Not currently implemented. See bug 476536 for discussion. } #else - void AssertCurrentThreadIn() const MOZ_ASSERT_CAPABILITY(this) {} - void AssertNotCurrentThreadIn() const MOZ_EXCLUDES(this) {} + void AssertCurrentThreadIn() const ASSERT_CAPABILITY(this) {} + void AssertNotCurrentThreadIn() const EXCLUDES(this) {} #endif private: @@ -70,16 +70,16 @@ class MOZ_CAPABILITY RecursiveMutex : public BlockingResourceBase { #endif }; -class MOZ_RAII MOZ_SCOPED_CAPABILITY RecursiveMutexAutoLock { +class MOZ_RAII SCOPED_CAPABILITY RecursiveMutexAutoLock { public: explicit RecursiveMutexAutoLock(RecursiveMutex& aRecursiveMutex) - MOZ_CAPABILITY_ACQUIRE(aRecursiveMutex) + CAPABILITY_ACQUIRE(aRecursiveMutex) : mRecursiveMutex(&aRecursiveMutex) { NS_ASSERTION(mRecursiveMutex, "null mutex"); mRecursiveMutex->Lock(); } - ~RecursiveMutexAutoLock(void) MOZ_CAPABILITY_RELEASE() { + ~RecursiveMutexAutoLock(void) CAPABILITY_RELEASE() { mRecursiveMutex->Unlock(); } @@ -92,16 +92,16 @@ class MOZ_RAII MOZ_SCOPED_CAPABILITY RecursiveMutexAutoLock { mozilla::RecursiveMutex* mRecursiveMutex; }; -class MOZ_RAII MOZ_SCOPED_CAPABILITY RecursiveMutexAutoUnlock { +class MOZ_RAII SCOPED_CAPABILITY RecursiveMutexAutoUnlock { public: explicit RecursiveMutexAutoUnlock(RecursiveMutex& aRecursiveMutex) - MOZ_SCOPED_UNLOCK_RELEASE(aRecursiveMutex) + SCOPED_UNLOCK_RELEASE(aRecursiveMutex) : mRecursiveMutex(&aRecursiveMutex) { NS_ASSERTION(mRecursiveMutex, "null mutex"); mRecursiveMutex->Unlock(); } - ~RecursiveMutexAutoUnlock(void) MOZ_SCOPED_UNLOCK_REACQUIRE() { + ~RecursiveMutexAutoUnlock(void) SCOPED_UNLOCK_REACQUIRE() { mRecursiveMutex->Lock(); } diff --git a/xpcom/threads/ReentrantMonitor.h b/xpcom/threads/ReentrantMonitor.h index c778d5b13c0a..da09cc29dd88 100644 --- a/xpcom/threads/ReentrantMonitor.h +++ b/xpcom/threads/ReentrantMonitor.h @@ -34,7 +34,7 @@ namespace mozilla { * When possible, use ReentrantMonitorAutoEnter to hold this monitor within a * scope, instead of calling Enter/Exit directly. **/ -class MOZ_CAPABILITY ReentrantMonitor : BlockingResourceBase { +class CAPABILITY ReentrantMonitor : BlockingResourceBase { public: /** * ReentrantMonitor @@ -70,13 +70,13 @@ class MOZ_CAPABILITY ReentrantMonitor : BlockingResourceBase { * Enter * @see prmon.h **/ - void Enter() MOZ_CAPABILITY_ACQUIRE() { PR_EnterMonitor(mReentrantMonitor); } + void Enter() CAPABILITY_ACQUIRE() { PR_EnterMonitor(mReentrantMonitor); } /** * Exit * @see prmon.h **/ - void Exit() MOZ_CAPABILITY_RELEASE() { PR_ExitMonitor(mReentrantMonitor); } + void Exit() CAPABILITY_RELEASE() { PR_ExitMonitor(mReentrantMonitor); } /** * Wait @@ -93,8 +93,8 @@ class MOZ_CAPABILITY ReentrantMonitor : BlockingResourceBase { } #else // ifndef DEBUG - void Enter() MOZ_CAPABILITY_ACQUIRE(); - void Exit() MOZ_CAPABILITY_RELEASE(); + void Enter() CAPABILITY_ACQUIRE(); + void Exit() CAPABILITY_RELEASE(); nsresult Wait(PRIntervalTime aInterval = PR_INTERVAL_NO_TIMEOUT); #endif // ifndef DEBUG @@ -122,7 +122,7 @@ class MOZ_CAPABILITY ReentrantMonitor : BlockingResourceBase { * AssertCurrentThreadIn * @see prmon.h **/ - void AssertCurrentThreadIn() MOZ_ASSERT_CAPABILITY(this) { + void AssertCurrentThreadIn() ASSERT_CAPABILITY(this) { PR_ASSERT_CURRENT_THREAD_IN_MONITOR(mReentrantMonitor); } @@ -130,13 +130,13 @@ class MOZ_CAPABILITY ReentrantMonitor : BlockingResourceBase { * AssertNotCurrentThreadIn * @see prmon.h **/ - void AssertNotCurrentThreadIn() MOZ_ASSERT_CAPABILITY(!this) { + void AssertNotCurrentThreadIn() ASSERT_CAPABILITY(!this) { // FIXME bug 476536 } #else - void AssertCurrentThreadIn() MOZ_ASSERT_CAPABILITY(this) {} - void AssertNotCurrentThreadIn() MOZ_ASSERT_CAPABILITY(!this) {} + void AssertCurrentThreadIn() ASSERT_CAPABILITY(this) {} + void AssertNotCurrentThreadIn() ASSERT_CAPABILITY(!this) {} #endif // ifdef DEBUG @@ -158,7 +158,7 @@ class MOZ_CAPABILITY ReentrantMonitor : BlockingResourceBase { * * MUCH PREFERRED to bare calls to ReentrantMonitor.Enter and Exit. */ -class MOZ_SCOPED_CAPABILITY MOZ_STACK_CLASS ReentrantMonitorAutoEnter { +class SCOPED_CAPABILITY MOZ_STACK_CLASS ReentrantMonitorAutoEnter { public: /** * Constructor @@ -169,13 +169,13 @@ class MOZ_SCOPED_CAPABILITY MOZ_STACK_CLASS ReentrantMonitorAutoEnter { **/ explicit ReentrantMonitorAutoEnter( mozilla::ReentrantMonitor& aReentrantMonitor) - MOZ_CAPABILITY_ACQUIRE(aReentrantMonitor) + CAPABILITY_ACQUIRE(aReentrantMonitor) : mReentrantMonitor(&aReentrantMonitor) { NS_ASSERTION(mReentrantMonitor, "null monitor"); mReentrantMonitor->Enter(); } - ~ReentrantMonitorAutoEnter(void) MOZ_CAPABILITY_RELEASE() { + ~ReentrantMonitorAutoEnter(void) CAPABILITY_RELEASE() { mReentrantMonitor->Exit(); } @@ -204,7 +204,7 @@ class MOZ_SCOPED_CAPABILITY MOZ_STACK_CLASS ReentrantMonitorAutoEnter { * * MUCH PREFERRED to bare calls to ReentrantMonitor.Exit and Enter. */ -class MOZ_SCOPED_CAPABILITY MOZ_STACK_CLASS ReentrantMonitorAutoExit { +class SCOPED_CAPABILITY MOZ_STACK_CLASS ReentrantMonitorAutoExit { public: /** * Constructor @@ -216,7 +216,7 @@ class MOZ_SCOPED_CAPABILITY MOZ_STACK_CLASS ReentrantMonitorAutoExit { * must be already locked. **/ explicit ReentrantMonitorAutoExit(ReentrantMonitor& aReentrantMonitor) - MOZ_EXCLUSIVE_RELEASE(aReentrantMonitor) + EXCLUSIVE_RELEASE(aReentrantMonitor) : mReentrantMonitor(&aReentrantMonitor) { NS_ASSERTION(mReentrantMonitor, "null monitor"); mReentrantMonitor->AssertCurrentThreadIn(); @@ -225,14 +225,14 @@ class MOZ_SCOPED_CAPABILITY MOZ_STACK_CLASS ReentrantMonitorAutoExit { explicit ReentrantMonitorAutoExit( ReentrantMonitorAutoEnter& aReentrantMonitorAutoEnter) - MOZ_EXCLUSIVE_RELEASE(aReentrantMonitorAutoEnter.mReentrantMonitor) + EXCLUSIVE_RELEASE(aReentrantMonitorAutoEnter.mReentrantMonitor) : mReentrantMonitor(aReentrantMonitorAutoEnter.mReentrantMonitor) { NS_ASSERTION(mReentrantMonitor, "null monitor"); mReentrantMonitor->AssertCurrentThreadIn(); mReentrantMonitor->Exit(); } - ~ReentrantMonitorAutoExit(void) MOZ_EXCLUSIVE_RELEASE() { + ~ReentrantMonitorAutoExit(void) EXCLUSIVE_RELEASE() { mReentrantMonitor->Enter(); } diff --git a/xpcom/threads/SpinEventLoopUntil.h b/xpcom/threads/SpinEventLoopUntil.h index a28117726879..5cdfb85dd6c4 100644 --- a/xpcom/threads/SpinEventLoopUntil.h +++ b/xpcom/threads/SpinEventLoopUntil.h @@ -130,7 +130,7 @@ struct MOZ_STACK_CLASS AutoNestedEventLoopAnnotation { const AutoNestedEventLoopAnnotation&) = delete; // The declarations of these statics live in nsThreadManager.cpp. - static AutoNestedEventLoopAnnotation* sCurrent MOZ_GUARDED_BY(sStackMutex); + static AutoNestedEventLoopAnnotation* sCurrent GUARDED_BY(sStackMutex); static StaticMutex sStackMutex; // We need this to avoid the inclusion of nsExceptionHandler.h here @@ -138,8 +138,8 @@ struct MOZ_STACK_CLASS AutoNestedEventLoopAnnotation { // The implementation lives in nsThreadManager.cpp. static void AnnotateXPCOMSpinEventLoopStack(const nsACString& aStack); - AutoNestedEventLoopAnnotation* mPrev MOZ_GUARDED_BY(sStackMutex); - nsCString mStack MOZ_GUARDED_BY(sStackMutex); + AutoNestedEventLoopAnnotation* mPrev GUARDED_BY(sStackMutex); + nsCString mStack GUARDED_BY(sStackMutex); }; // Please see the above notes for the Behavior template parameter. diff --git a/xpcom/threads/SyncRunnable.h b/xpcom/threads/SyncRunnable.h index e24ac6f83a0b..cc7784f50541 100644 --- a/xpcom/threads/SyncRunnable.h +++ b/xpcom/threads/SyncRunnable.h @@ -125,7 +125,7 @@ class SyncRunnable : public Runnable { private: nsCOMPtr mRunnable; mozilla::Monitor mMonitor; - bool mDone MOZ_GUARDED_BY(mMonitor); + bool mDone GUARDED_BY(mMonitor); }; } // namespace mozilla diff --git a/xpcom/threads/TaskQueue.h b/xpcom/threads/TaskQueue.h index b9321866a979..9314d359a1d6 100644 --- a/xpcom/threads/TaskQueue.h +++ b/xpcom/threads/TaskQueue.h @@ -146,11 +146,11 @@ class TaskQueue final : public AbstractThread, void MaybeResolveShutdown(); - nsCOMPtr mTarget MOZ_GUARDED_BY(mQueueMonitor); + nsCOMPtr mTarget GUARDED_BY(mQueueMonitor); // Handle for this TaskQueue being registered with our target if it implements // TaskQueueTracker. - UniquePtr mTrackerEntry MOZ_GUARDED_BY(mQueueMonitor); + UniquePtr mTrackerEntry GUARDED_BY(mQueueMonitor); // Monitor that protects the queue, mIsRunning, mIsShutdown and // mShutdownTasks; @@ -162,11 +162,11 @@ class TaskQueue final : public AbstractThread, } TaskStruct; // Queue of tasks to run. - Queue mTasks MOZ_GUARDED_BY(mQueueMonitor); + Queue mTasks GUARDED_BY(mQueueMonitor); // List of tasks to run during shutdown. nsTArray> mShutdownTasks - MOZ_GUARDED_BY(mQueueMonitor); + GUARDED_BY(mQueueMonitor); // The thread currently running the task queue. We store a reference // to this so that IsCurrentThreadIn() can tell if the current thread @@ -218,12 +218,11 @@ class TaskQueue final : public AbstractThread, // True if we've dispatched an event to the target to execute events from // the queue. - bool mIsRunning MOZ_GUARDED_BY(mQueueMonitor); + bool mIsRunning GUARDED_BY(mQueueMonitor); // True if we've started our shutdown process. - bool mIsShutdown MOZ_GUARDED_BY(mQueueMonitor); - MozPromiseHolder mShutdownPromise - MOZ_GUARDED_BY(mQueueMonitor); + bool mIsShutdown GUARDED_BY(mQueueMonitor); + MozPromiseHolder mShutdownPromise GUARDED_BY(mQueueMonitor); // The name of this TaskQueue. Useful when debugging dispatch failures. const char* const mName; @@ -271,7 +270,7 @@ class TaskQueueTracker : public nsISupports { friend class TaskQueueTrackerEntry; Mutex mMutex{"TaskQueueTracker"}; - LinkedList mEntries MOZ_GUARDED_BY(mMutex); + LinkedList mEntries GUARDED_BY(mMutex); }; NS_DEFINE_STATIC_IID_ACCESSOR(TaskQueueTracker, MOZILLA_TASKQUEUETRACKER_IID) diff --git a/xpcom/threads/ThreadEventQueue.cpp b/xpcom/threads/ThreadEventQueue.cpp index 2499a433cad1..54c00b2fd25f 100644 --- a/xpcom/threads/ThreadEventQueue.cpp +++ b/xpcom/threads/ThreadEventQueue.cpp @@ -267,7 +267,7 @@ already_AddRefed ThreadEventQueue::GetObserver() { } already_AddRefed ThreadEventQueue::GetObserverOnThread() - MOZ_NO_THREAD_SAFETY_ANALYSIS { + NO_THREAD_SAFETY_ANALYSIS { // only written on this thread return do_AddRef(mObserver); } diff --git a/xpcom/threads/ThreadEventQueue.h b/xpcom/threads/ThreadEventQueue.h index 3a57f3e96fd5..7c27d348a895 100644 --- a/xpcom/threads/ThreadEventQueue.h +++ b/xpcom/threads/ThreadEventQueue.h @@ -76,16 +76,15 @@ class ThreadEventQueue final : public SynchronizedEventQueue { ThreadEventTarget* aEventTarget); }; - nsTArray mNestedQueues MOZ_GUARDED_BY(mLock); + nsTArray mNestedQueues GUARDED_BY(mLock); Mutex mLock; - CondVar mEventsAvailable MOZ_GUARDED_BY(mLock); + CondVar mEventsAvailable GUARDED_BY(mLock); - bool mEventsAreDoomed MOZ_GUARDED_BY(mLock) = false; - nsCOMPtr mObserver MOZ_GUARDED_BY(mLock); - nsTArray> mShutdownTasks - MOZ_GUARDED_BY(mLock); - bool mShutdownTasksRun MOZ_GUARDED_BY(mLock) = false; + bool mEventsAreDoomed GUARDED_BY(mLock) = false; + nsCOMPtr mObserver GUARDED_BY(mLock); + nsTArray> mShutdownTasks GUARDED_BY(mLock); + bool mShutdownTasksRun GUARDED_BY(mLock) = false; const bool mIsMainThread; }; diff --git a/xpcom/threads/ThrottledEventQueue.cpp b/xpcom/threads/ThrottledEventQueue.cpp index 9e4219b30593..fe5091d2074c 100644 --- a/xpcom/threads/ThrottledEventQueue.cpp +++ b/xpcom/threads/ThrottledEventQueue.cpp @@ -95,13 +95,13 @@ class ThrottledEventQueue::Inner final : public nsISupports { }; mutable Mutex mMutex; - mutable CondVar mIdleCondVar MOZ_GUARDED_BY(mMutex); + mutable CondVar mIdleCondVar GUARDED_BY(mMutex); // As-of-yet unexecuted runnables queued on this ThrottledEventQueue. // // Used from any thread; protected by mMutex. Signals mIdleCondVar when // emptied. - EventQueueSized<64> mEventQueue MOZ_GUARDED_BY(mMutex); + EventQueueSized<64> mEventQueue GUARDED_BY(mMutex); // The event target we dispatch our events (actually, just our Executor) to. // @@ -112,7 +112,7 @@ class ThrottledEventQueue::Inner final : public nsISupports { // queue. mExecutor->mInner points to this Inner, forming a reference loop. // // Used from any thread; protected by mMutex. - nsCOMPtr mExecutor MOZ_GUARDED_BY(mMutex); + nsCOMPtr mExecutor GUARDED_BY(mMutex); const char* const mName; @@ -120,7 +120,7 @@ class ThrottledEventQueue::Inner final : public nsISupports { // True if this queue is currently paused. // Used from any thread; protected by mMutex. - bool mIsPaused MOZ_GUARDED_BY(mMutex); + bool mIsPaused GUARDED_BY(mMutex); explicit Inner(nsISerialEventTarget* aBaseTarget, const char* aName, uint32_t aPriority) @@ -154,7 +154,7 @@ class ThrottledEventQueue::Inner final : public nsISupports { // Make sure an executor has been queued on our base target. If we already // have one, do nothing; otherwise, create and dispatch it. - nsresult EnsureExecutor(MutexAutoLock& lock) MOZ_REQUIRES(mMutex) { + nsresult EnsureExecutor(MutexAutoLock& lock) REQUIRES(mMutex) { if (mExecutor) return NS_OK; // Note, this creates a ref cycle keeping the inner alive @@ -308,7 +308,7 @@ class ThrottledEventQueue::Inner final : public nsISupports { return IsPaused(lock); } - bool IsPaused(const MutexAutoLock& aProofOfLock) const MOZ_REQUIRES(mMutex) { + bool IsPaused(const MutexAutoLock& aProofOfLock) const REQUIRES(mMutex) { return mIsPaused; } diff --git a/xpcom/threads/TimerThread.cpp b/xpcom/threads/TimerThread.cpp index 9a9d83b15828..4441f622042a 100644 --- a/xpcom/threads/TimerThread.cpp +++ b/xpcom/threads/TimerThread.cpp @@ -196,8 +196,8 @@ class TimerEventAllocator { FreeEntry* mNext; }; - ArenaAllocator<4096> mPool MOZ_GUARDED_BY(mMonitor); - FreeEntry* mFirstFree MOZ_GUARDED_BY(mMonitor); + ArenaAllocator<4096> mPool GUARDED_BY(mMonitor); + FreeEntry* mFirstFree GUARDED_BY(mMonitor); mozilla::Monitor mMonitor; public: diff --git a/xpcom/threads/TimerThread.h b/xpcom/threads/TimerThread.h index 1faa24d3181d..da7762b5e1c8 100644 --- a/xpcom/threads/TimerThread.h +++ b/xpcom/threads/TimerThread.h @@ -44,9 +44,9 @@ class TimerThread final : public mozilla::Runnable, public nsIObserver { nsresult Shutdown(); nsresult AddTimer(nsTimerImpl* aTimer, const MutexAutoLock& aProofOfLock) - MOZ_REQUIRES(aTimer->mMutex); + REQUIRES(aTimer->mMutex); nsresult RemoveTimer(nsTimerImpl* aTimer, const MutexAutoLock& aProofOfLock) - MOZ_REQUIRES(aTimer->mMutex); + REQUIRES(aTimer->mMutex); TimeStamp FindNextFireTimeForCurrentThread(TimeStamp aDefault, uint32_t aSearchBound); @@ -66,15 +66,15 @@ class TimerThread final : public mozilla::Runnable, public nsIObserver { // These internal helper methods must be called while mMonitor is held. // AddTimerInternal returns false if the insertion failed. - bool AddTimerInternal(nsTimerImpl* aTimer) MOZ_REQUIRES(mMonitor); + bool AddTimerInternal(nsTimerImpl* aTimer) REQUIRES(mMonitor); bool RemoveTimerInternal(nsTimerImpl* aTimer) - MOZ_REQUIRES(mMonitor, aTimer->mMutex); - void RemoveLeadingCanceledTimersInternal() MOZ_REQUIRES(mMonitor); - void RemoveFirstTimerInternal() MOZ_REQUIRES(mMonitor); - nsresult Init() MOZ_REQUIRES(mMonitor); + REQUIRES(mMonitor, aTimer->mMutex); + void RemoveLeadingCanceledTimersInternal() REQUIRES(mMonitor); + void RemoveFirstTimerInternal() REQUIRES(mMonitor); + nsresult Init() REQUIRES(mMonitor); void PostTimerEvent(already_AddRefed aTimerRef) - MOZ_REQUIRES(mMonitor); + REQUIRES(mMonitor); nsCOMPtr mThread; // Lock ordering requirements: @@ -83,10 +83,10 @@ class TimerThread final : public mozilla::Runnable, public nsIObserver { // TimerThread::mMonitor Monitor mMonitor; - bool mShutdown MOZ_GUARDED_BY(mMonitor); - bool mWaiting MOZ_GUARDED_BY(mMonitor); - bool mNotified MOZ_GUARDED_BY(mMonitor); - bool mSleeping MOZ_GUARDED_BY(mMonitor); + bool mShutdown GUARDED_BY(mMonitor); + bool mWaiting GUARDED_BY(mMonitor); + bool mNotified GUARDED_BY(mMonitor); + bool mSleeping GUARDED_BY(mMonitor); class Entry final : public nsTimerImplHolder { const TimeStamp mTimeout; @@ -120,10 +120,10 @@ class TimerThread final : public mozilla::Runnable, public nsIObserver { TimeStamp Timeout() const { return mTimeout; } }; - nsTArray> mTimers MOZ_GUARDED_BY(mMonitor); + nsTArray> mTimers GUARDED_BY(mMonitor); // Set only at the start of the thread's Run(): - uint32_t mAllowedEarlyFiringMicroseconds MOZ_GUARDED_BY(mMonitor); - ProfilerThreadId mProfilerThreadId MOZ_GUARDED_BY(mMonitor); + uint32_t mAllowedEarlyFiringMicroseconds GUARDED_BY(mMonitor); + ProfilerThreadId mProfilerThreadId GUARDED_BY(mMonitor); }; #endif /* TimerThread_h___ */ diff --git a/xpcom/threads/nsEnvironment.cpp b/xpcom/threads/nsEnvironment.cpp index 54efd9194a46..e7864f3e617c 100644 --- a/xpcom/threads/nsEnvironment.cpp +++ b/xpcom/threads/nsEnvironment.cpp @@ -91,9 +91,9 @@ typedef nsBaseHashtableET EnvEntryType; typedef nsTHashtable EnvHashType; static StaticMutex gEnvHashMutex; -static EnvHashType* gEnvHash MOZ_GUARDED_BY(gEnvHashMutex) = nullptr; +static EnvHashType* gEnvHash GUARDED_BY(gEnvHashMutex) = nullptr; -static EnvHashType* EnsureEnvHash() MOZ_REQUIRES(gEnvHashMutex) { +static EnvHashType* EnsureEnvHash() REQUIRES(gEnvHashMutex) { if (!gEnvHash) { gEnvHash = new EnvHashType; } diff --git a/xpcom/threads/nsProcess.h b/xpcom/threads/nsProcess.h index 95d6748640aa..1d625a5b43d2 100644 --- a/xpcom/threads/nsProcess.h +++ b/xpcom/threads/nsProcess.h @@ -59,7 +59,7 @@ class nsProcess final : public nsIProcess, public nsIObserver { PRThread* mThread; mozilla::Mutex mLock; - bool mShutdown MOZ_GUARDED_BY(mLock); + bool mShutdown GUARDED_BY(mLock); bool mBlocking; bool mStartHidden; bool mNoShell; @@ -71,11 +71,11 @@ class nsProcess final : public nsIProcess, public nsIObserver { // These members are modified by multiple threads, any accesses should be // protected with mLock. - int32_t mExitValue MOZ_GUARDED_BY(mLock); + int32_t mExitValue GUARDED_BY(mLock); #if defined(PROCESSMODEL_WINAPI) - HANDLE mProcess MOZ_GUARDED_BY(mLock); + HANDLE mProcess GUARDED_BY(mLock); #elif !defined(XP_UNIX) - PRProcess* mProcess MOZ_GUARDED_BY(mLock); + PRProcess* mProcess GUARDED_BY(mLock); #endif }; diff --git a/xpcom/threads/nsThread.h b/xpcom/threads/nsThread.h index 07ccd8ae5ef4..b4b0c3023cab 100644 --- a/xpcom/threads/nsThread.h +++ b/xpcom/threads/nsThread.h @@ -388,8 +388,8 @@ class nsThreadShutdownContext final : public nsIThreadShutdown { // the joining thread if `StopWaitingAndLeakThread` is called or by the // terminating thread upon exiting and notifying the joining thread. mozilla::Mutex mJoiningThreadMutex; - RefPtr mJoiningThread MOZ_GUARDED_BY(mJoiningThreadMutex); - bool mThreadLeaked MOZ_GUARDED_BY(mJoiningThreadMutex) = false; + RefPtr mJoiningThread GUARDED_BY(mJoiningThreadMutex); + bool mThreadLeaked GUARDED_BY(mJoiningThreadMutex) = false; }; // This RAII class controls the duration of the associated nsThread's local diff --git a/xpcom/threads/nsThreadPool.h b/xpcom/threads/nsThreadPool.h index 4905742345d2..006037c3eaad 100644 --- a/xpcom/threads/nsThreadPool.h +++ b/xpcom/threads/nsThreadPool.h @@ -37,20 +37,20 @@ class nsThreadPool final : public mozilla::Runnable, public nsIThreadPool { nsresult PutEvent(already_AddRefed aEvent, uint32_t aFlags); mozilla::Mutex mMutex; - nsCOMArray mThreads MOZ_GUARDED_BY(mMutex); - mozilla::CondVar mEventsAvailable MOZ_GUARDED_BY(mMutex); - mozilla::EventQueue mEvents MOZ_GUARDED_BY(mMutex); - uint32_t mThreadLimit MOZ_GUARDED_BY(mMutex); - uint32_t mIdleThreadLimit MOZ_GUARDED_BY(mMutex); - uint32_t mIdleThreadTimeout MOZ_GUARDED_BY(mMutex); - uint32_t mIdleCount MOZ_GUARDED_BY(mMutex); - uint32_t mStackSize MOZ_GUARDED_BY(mMutex); - nsCOMPtr mListener MOZ_GUARDED_BY(mMutex); + nsCOMArray mThreads GUARDED_BY(mMutex); + mozilla::CondVar mEventsAvailable GUARDED_BY(mMutex); + mozilla::EventQueue mEvents GUARDED_BY(mMutex); + uint32_t mThreadLimit GUARDED_BY(mMutex); + uint32_t mIdleThreadLimit GUARDED_BY(mMutex); + uint32_t mIdleThreadTimeout GUARDED_BY(mMutex); + uint32_t mIdleCount GUARDED_BY(mMutex); + uint32_t mStackSize GUARDED_BY(mMutex); + nsCOMPtr mListener GUARDED_BY(mMutex); mozilla::Atomic mShutdown; - bool mRegressiveMaxIdleTime MOZ_GUARDED_BY(mMutex); + bool mRegressiveMaxIdleTime GUARDED_BY(mMutex); mozilla::Atomic mIsAPoolThreadFree; // set once before we start threads - nsCString mName MOZ_GUARDED_BY(mMutex); + nsCString mName GUARDED_BY(mMutex); nsThreadPoolNaming mThreadNaming; // all data inside this is atomic }; diff --git a/xpcom/threads/nsTimerImpl.cpp b/xpcom/threads/nsTimerImpl.cpp index f068fb3d6cc8..7c22faabb103 100644 --- a/xpcom/threads/nsTimerImpl.cpp +++ b/xpcom/threads/nsTimerImpl.cpp @@ -50,16 +50,16 @@ class TimerThreadWrapper { void Shutdown(); nsresult AddTimer(nsTimerImpl* aTimer, const MutexAutoLock& aProofOfLock) - MOZ_REQUIRES(aTimer->mMutex); + REQUIRES(aTimer->mMutex); nsresult RemoveTimer(nsTimerImpl* aTimer, const MutexAutoLock& aProofOfLock) - MOZ_REQUIRES(aTimer->mMutex); + REQUIRES(aTimer->mMutex); TimeStamp FindNextFireTimeForCurrentThread(TimeStamp aDefault, uint32_t aSearchBound); uint32_t AllowedEarlyFiringMicroseconds(); private: static mozilla::StaticMutex sMutex; - TimerThread* mThread MOZ_GUARDED_BY(sMutex); + TimerThread* mThread GUARDED_BY(sMutex); }; mozilla::StaticMutex TimerThreadWrapper::sMutex; @@ -308,12 +308,11 @@ static mozilla::LogModule* GetTimerFiringsLog() { return sTimerFiringsLog; } /* static */ mozilla::StaticMutex nsTimerImpl::sDeltaMutex; /* static */ -double nsTimerImpl::sDeltaSumSquared MOZ_GUARDED_BY(nsTimerImpl::sDeltaMutex) = - 0; +double nsTimerImpl::sDeltaSumSquared GUARDED_BY(nsTimerImpl::sDeltaMutex) = 0; /* static */ -double nsTimerImpl::sDeltaSum MOZ_GUARDED_BY(nsTimerImpl::sDeltaMutex) = 0; +double nsTimerImpl::sDeltaSum GUARDED_BY(nsTimerImpl::sDeltaMutex) = 0; /* static */ -double nsTimerImpl::sDeltaNum MOZ_GUARDED_BY(nsTimerImpl::sDeltaMutex) = 0; +double nsTimerImpl::sDeltaNum GUARDED_BY(nsTimerImpl::sDeltaMutex) = 0; static void myNS_MeanAndStdDev(double n, double sumOfValues, double sumOfSquaredValues, double* meanResult, diff --git a/xpcom/threads/nsTimerImpl.h b/xpcom/threads/nsTimerImpl.h index 4065dc0100ca..d8165dff843d 100644 --- a/xpcom/threads/nsTimerImpl.h +++ b/xpcom/threads/nsTimerImpl.h @@ -102,9 +102,9 @@ class nsTimerImpl { nsresult InitCommon(const mozilla::TimeDuration& aDelay, uint32_t aType, Callback&& newCallback, const mozilla::MutexAutoLock& aProofOfLock) - MOZ_REQUIRES(mMutex); + REQUIRES(mMutex); - Callback& GetCallback() MOZ_REQUIRES(mMutex) { + Callback& GetCallback() REQUIRES(mMutex) { mMutex.AssertCurrentThreadOwns(); return mCallback; } @@ -133,7 +133,7 @@ class nsTimerImpl { } void GetName(nsACString& aName, const mozilla::MutexAutoLock& aProofOfLock) - MOZ_REQUIRES(mMutex); + REQUIRES(mMutex); void GetName(nsACString& aName); @@ -167,23 +167,23 @@ class nsTimerImpl { // Updated only after this timer has been removed from the timer thread. int32_t mGeneration; - mozilla::TimeDuration mDelay MOZ_GUARDED_BY(mMutex); + mozilla::TimeDuration mDelay GUARDED_BY(mMutex); // Never updated while in the TimerThread's timer list. Only updated // before adding to that list or during nsTimerImpl::Fire(), when it has // been removed from the TimerThread's list. TimerThread can access // mTimeout of any timer in the list safely mozilla::TimeStamp mTimeout; - RefPtr mITimer MOZ_GUARDED_BY(mMutex); + RefPtr mITimer GUARDED_BY(mMutex); mozilla::Mutex mMutex; - Callback mCallback MOZ_GUARDED_BY(mMutex); + Callback mCallback GUARDED_BY(mMutex); // Counter because in rare cases we can Fire reentrantly - unsigned int mFiring MOZ_GUARDED_BY(mMutex); + unsigned int mFiring GUARDED_BY(mMutex); static mozilla::StaticMutex sDeltaMutex; - static double sDeltaSum MOZ_GUARDED_BY(sDeltaMutex); - static double sDeltaSumSquared MOZ_GUARDED_BY(sDeltaMutex); - static double sDeltaNum MOZ_GUARDED_BY(sDeltaMutex); + static double sDeltaSum GUARDED_BY(sDeltaMutex); + static double sDeltaSumSquared GUARDED_BY(sDeltaMutex); + static double sDeltaNum GUARDED_BY(sDeltaMutex); }; class nsTimer final : public nsITimer { diff --git a/xpfe/appshell/AppWindow.h b/xpfe/appshell/AppWindow.h index d089f7156715..86bf853c1826 100644 --- a/xpfe/appshell/AppWindow.h +++ b/xpfe/appshell/AppWindow.h @@ -349,7 +349,7 @@ class AppWindow final : public nsIBaseWindow, nsCOMPtr mPrimaryBrowserParent; - nsCOMPtr mSPTimer MOZ_GUARDED_BY(mSPTimerLock); + nsCOMPtr mSPTimer GUARDED_BY(mSPTimerLock); mozilla::Mutex mSPTimerLock; WidgetListenerDelegate mWidgetListenerDelegate;