Skip to content

Commit

Permalink
Bug 1207753 - Add MOZ_UNANNOTATED to all Mutexes/Monitors r=nika,kershaw
Browse files Browse the repository at this point in the history
  • Loading branch information
Randell Jesup committed Mar 16, 2022
1 parent 2eed6a1 commit 7d4b5fa
Show file tree
Hide file tree
Showing 441 changed files with 573 additions and 549 deletions.
4 changes: 2 additions & 2 deletions accessible/ipc/win/HandlerProvider.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ class HandlerProvider final : public IGeckoBackChannel,
HRESULT* result);

Atomic<uint32_t> mRefCnt;
Mutex mMutex; // Protects mSerializer
Mutex mMutex MOZ_UNANNOTATED; // Protects mSerializer
const IID mTargetUnkIid;
mscom::InterceptorTargetPtr<IUnknown>
mTargetUnk; // Constant, main thread only
Expand All @@ -136,7 +136,7 @@ class HandlerProvider final : public IGeckoBackChannel,
// Used when the payload is built prior to marshaling the object by a bulk
// fetch operation. See prebuildPayload().
IA2PayloadPtr mPayload;
Mutex mPayloadMutex; // Protects mPayload
Mutex mPayloadMutex MOZ_UNANNOTATED; // Protects mPayload
};

} // namespace a11y
Expand Down
2 changes: 1 addition & 1 deletion docshell/base/timeline/MarkersStorage.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class MarkersStorage : public LinkedListElement<MarkersStorage> {
Mutex& GetLock();

private:
Mutex mLock;
Mutex mLock MOZ_UNANNOTATED;
};

} // namespace mozilla
Expand Down
2 changes: 1 addition & 1 deletion docshell/base/timeline/TimelineConsumers.h
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ class TimelineConsumers : public nsIObserver {
LinkedList<MarkersStorage> mMarkersStores;

// Protects this class's data structures.
static StaticMutex sMutex;
static StaticMutex sMutex MOZ_UNANNOTATED;
};

} // namespace mozilla
Expand Down
2 changes: 1 addition & 1 deletion dom/base/BodyStream.h
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ class BodyStream final : public nsIInputStreamCallback,
// We need a mutex because JS engine can release BodyStream on a non-owning
// thread. We must be sure that the releasing of resources doesn't trigger
// race conditions.
Mutex mMutex;
Mutex mMutex MOZ_UNANNOTATED;

// Protected by mutex.
State mState;
Expand Down
2 changes: 1 addition & 1 deletion dom/cache/Manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1101,7 +1101,7 @@ class Manager::CachePutAllAction final : public DBAction {
nsTArray<nsID> mDeletedBodyIdList;

// accessed from any thread while mMutex locked
Mutex mMutex;
Mutex mMutex MOZ_UNANNOTATED;
nsTArray<nsCOMPtr<nsISupports>> mCopyContextList;

Maybe<CacheDirectoryMetadata> mDirectoryMetadata;
Expand Down
2 changes: 1 addition & 1 deletion dom/cache/ReadStream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ class ReadStream::Inner final : public ReadStream::Controllable {
// to close a stream on our owning thread while an IO thread is simultaneously
// reading the same stream. Therefore, protect all access to these stream
// objects with a mutex.
Mutex mMutex;
Mutex mMutex MOZ_UNANNOTATED;
CondVar mCondVar;
nsCOMPtr<nsIInputStream> mStream;
nsCOMPtr<nsIInputStream> mSnappyStream;
Expand Down
2 changes: 1 addition & 1 deletion dom/canvas/HostWebGLContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ namespace mozilla {

// -

static StaticMutex sContextSetLock;
static StaticMutex sContextSetLock MOZ_UNANNOTATED;

static std::unordered_set<HostWebGLContext*>& DeferredStaticContextSet() {
static std::unordered_set<HostWebGLContext*> sContextSet;
Expand Down
2 changes: 1 addition & 1 deletion dom/canvas/ImageBitmap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1475,7 +1475,7 @@ class CreateImageBitmapFromBlob final : public DiscardableRunnable,
// This is called on the main-thread only.
nsresult GetMimeTypeAsync();

Mutex mMutex;
Mutex mMutex MOZ_UNANNOTATED;

// The access to this object is protected by mutex but is always nullified on
// the owning thread.
Expand Down
2 changes: 1 addition & 1 deletion dom/canvas/OffscreenCanvasDisplayHelper.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class OffscreenCanvasDisplayHelper final {
gfx::SurfaceFormat aFormat, const gfx::IntSize& aSize,
bool aNeedsPremult, gl::OriginPos aOriginPos) const;

mutable Mutex mMutex;
mutable Mutex mMutex MOZ_UNANNOTATED;
HTMLCanvasElement* MOZ_NON_OWNING_REF mCanvasElement;
RefPtr<layers::ImageContainer> mImageContainer;
RefPtr<gfx::SourceSurface> mFrontBufferSurface;
Expand Down
2 changes: 1 addition & 1 deletion dom/console/ConsoleReportCollector.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ class ConsoleReportCollector final : public nsIConsoleReportCollector {
const CopyableTArray<nsString> mStringParams;
};

Mutex mMutex;
Mutex mMutex MOZ_UNANNOTATED;

// protected by mMutex
nsTArray<PendingReport> mPendingReports;
Expand Down
2 changes: 1 addition & 1 deletion dom/file/FileBlobImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ class FileBlobImpl : public BlobImpl {

// FileBlobImpl has getter methods with lazy initialization. Because any
// BlobImpl must work thread-safe, we use a mutex.
Mutex mMutex;
Mutex mMutex MOZ_UNANNOTATED;

nsCOMPtr<nsIFile> mFile;

Expand Down
2 changes: 1 addition & 1 deletion dom/file/MemoryBlobImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ class MemoryBlobImpl final : public BaseBlobImpl {
// sDataOwners and sMemoryReporterRegistered may only be accessed while
// holding sDataOwnerMutex! You also must hold the mutex while touching
// elements of the linked list that DataOwner inherits from.
static mozilla::StaticMutex sDataOwnerMutex;
static mozilla::StaticMutex sDataOwnerMutex MOZ_UNANNOTATED;
static mozilla::StaticAutoPtr<mozilla::LinkedList<DataOwner> > sDataOwners;
static bool sMemoryReporterRegistered;

Expand Down
2 changes: 1 addition & 1 deletion dom/file/MutableBlobStorage.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ class MutableBlobStorage final {
[[nodiscard]] nsresult DispatchToIOThread(
already_AddRefed<nsIRunnable> aRunnable);

Mutex mMutex;
Mutex mMutex MOZ_UNANNOTATED;

// All these variables are touched on the main thread only or in the
// retargeted thread when used by Append(). They are protected by mMutex.
Expand Down
2 changes: 1 addition & 1 deletion dom/file/ipc/RemoteLazyInputStream.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ class RemoteLazyInputStream final : public nsIAsyncInputStream,

// Any member of this class is protected by mutex because touched on
// multiple threads.
Mutex mMutex;
Mutex mMutex MOZ_UNANNOTATED;
};

} // namespace mozilla
Expand Down
2 changes: 1 addition & 1 deletion dom/file/ipc/RemoteLazyInputStreamChild.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ class RemoteLazyInputStreamChild final : public PRemoteLazyInputStreamChild {
nsTArray<RemoteLazyInputStream*> mStreams;

// This mutex protects mStreams because that can be touched in any thread.
Mutex mMutex;
Mutex mMutex MOZ_UNANNOTATED;

const nsID mID;
const uint64_t mSize;
Expand Down
2 changes: 1 addition & 1 deletion dom/file/uri/BlobURLInputStream.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class BlobURLInputStream final : public nsIAsyncInputStream,

// Non-recursive mutex introduced in order to guard access to mState, mError
// and mAsyncInputStream
Mutex mStateMachineMutex;
Mutex mStateMachineMutex MOZ_UNANNOTATED;
State mState;
// Stores the error code if stream is in error state
nsresult mError;
Expand Down
2 changes: 1 addition & 1 deletion dom/file/uri/BlobURLProtocolHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ struct DataInfo {

// The mutex is locked whenever gDataTable is changed, or if gDataTable
// is accessed off-main-thread.
static StaticMutex sMutex;
static StaticMutex sMutex MOZ_UNANNOTATED;

// All changes to gDataTable must happen on the main thread, while locking
// sMutex. Reading from gDataTable on the main thread may happen without
Expand Down
2 changes: 1 addition & 1 deletion dom/filesystem/GetFilesHelper.h
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ class GetFilesHelper : public Runnable, public GetFilesHelperBase {
nsTArray<RefPtr<Promise>> mPromises;
nsTArray<RefPtr<GetFilesCallback>> mCallbacks;

Mutex mMutex;
Mutex mMutex MOZ_UNANNOTATED;

// This variable is protected by mutex.
bool mCanceled;
Expand Down
2 changes: 1 addition & 1 deletion dom/gamepad/GamepadPlatformService.h
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ class GamepadPlatformService final {

// This mutex protects mChannelParents from race condition
// between background and monitor thread
Mutex mMutex;
Mutex mMutex MOZ_UNANNOTATED;

std::map<GamepadHandle, GamepadAdded> mGamepadAdded;
};
Expand Down
8 changes: 4 additions & 4 deletions dom/indexedDB/ActorsParent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1497,7 +1497,7 @@ class ConnectionPool final {
};

// This mutex guards mDatabases, see below.
Mutex mDatabasesMutex;
Mutex mDatabasesMutex MOZ_UNANNOTATED;

nsTArray<IdleThreadInfo> mIdleThreads;
nsTArray<IdleDatabaseInfo> mIdleDatabases;
Expand Down Expand Up @@ -6592,7 +6592,7 @@ nsresult DispatchAndReturnFileReferences(
*aMemRefCnt = -1;
*aDBRefCnt = -1;

mozilla::Monitor monitor(__func__);
mozilla::Monitor monitor MOZ_ANNOTATED(__func__);
bool waiting = true;

auto lambda = [&] {
Expand Down Expand Up @@ -6758,7 +6758,7 @@ class DeserializeIndexValueHelper final : public Runnable {
lock.Notify();
}

Monitor mMonitor;
Monitor mMonitor MOZ_UNANNOTATED;

const int64_t mIndexID;
const KeyPath& mKeyPath;
Expand Down Expand Up @@ -21682,7 +21682,7 @@ class FileHelper::ReadCallback final : public nsIInputStreamCallback {
private:
~ReadCallback() = default;

mozilla::Mutex mMutex;
mozilla::Mutex mMutex MOZ_UNANNOTATED;
mozilla::CondVar mCondVar;
bool mInputAvailable;
};
Expand Down
2 changes: 1 addition & 1 deletion dom/indexedDB/SchemaUpgrades.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2842,7 +2842,7 @@ class DeserializeUpgradeValueHelper final : public Runnable {
lock.Notify();
}

Monitor mMonitor;
Monitor mMonitor MOZ_UNANNOTATED;
StructuredCloneReadInfoParent& mCloneReadInfo;
nsresult mStatus;
};
Expand Down
6 changes: 3 additions & 3 deletions dom/ipc/ProcessHangMonitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ class HangMonitorChild : public PProcessHangMonitorChild,
static Atomic<HangMonitorChild*, SequentiallyConsistent> sInstance;

const RefPtr<ProcessHangMonitor> mHangMonitor;
Monitor mMonitor;
Monitor mMonitor MOZ_UNANNOTATED;

// Main thread-only.
bool mSentReport;
Expand Down Expand Up @@ -282,15 +282,15 @@ class HangMonitorParent : public PProcessHangMonitorParent,
// This field is only accessed on the hang thread.
bool mIPCOpen;

Monitor mMonitor;
Monitor mMonitor MOZ_UNANNOTATED;

// Must be accessed with mMonitor held.
RefPtr<HangMonitoredProcess> mProcess;
bool mShutdownDone;
// Map from plugin ID to crash dump ID. Protected by
// mBrowserCrashDumpHashLock.
nsTHashMap<nsUint32HashKey, nsString> mBrowserCrashDumpIds;
Mutex mBrowserCrashDumpHashLock;
Mutex mBrowserCrashDumpHashLock MOZ_UNANNOTATED;
mozilla::ipc::TaskFactory<HangMonitorParent> mMainThreadTaskFactory;
};

Expand Down
2 changes: 1 addition & 1 deletion dom/ipc/RefMessageBodyService.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ class RefMessageBody final {
// In case the RefMessageBody is shared and refcounted (see mCount/mMaxCount),
// we must enforce that the reading does not happen simultaneously on
// different threads.
Mutex mMutex;
Mutex mMutex MOZ_UNANNOTATED;

UniquePtr<ipc::StructuredCloneData> mCloneData;

Expand Down
4 changes: 2 additions & 2 deletions dom/localstorage/ActorsParent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1368,7 +1368,7 @@ class Connection final : public CachingDatabaseConnection {
* origin, so we need to queue a runnable and wait our turn.)
*/
class Connection::InitTemporaryOriginHelper final : public Runnable {
mozilla::Monitor mMonitor;
mozilla::Monitor mMonitor MOZ_UNANNOTATED;
const OriginMetadata mOriginMetadata;
nsString mOriginDirectoryPath;
nsresult mIOThreadResultCode;
Expand Down Expand Up @@ -2614,7 +2614,7 @@ class QuotaClient final : public mozilla::dom::quota::Client {

static QuotaClient* sInstance;

Mutex mShadowDatabaseMutex;
Mutex mShadowDatabaseMutex MOZ_UNANNOTATED;
bool mShutdownRequested;

public:
Expand Down
2 changes: 1 addition & 1 deletion dom/media/AudioStream.h
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ class AudioStream final {
soundtouch::SoundTouch* mTimeStretcher;

// The monitor is held to protect all access to member variables below.
Monitor mMonitor;
Monitor mMonitor MOZ_UNANNOTATED;

const uint32_t mOutChannels;
const AudioConfig::ChannelLayout::ChannelMap mChannelMap;
Expand Down
2 changes: 1 addition & 1 deletion dom/media/Benchmark.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ bool VP9Benchmark::IsVP9DecodeFast(bool aDefault) {
if (!ShouldRun()) {
return false;
}
static StaticMutex sMutex;
static StaticMutex sMutex MOZ_UNANNOTATED;
uint32_t decodeFps = StaticPrefs::media_benchmark_vp9_fps();
uint32_t hadRecentUpdate = StaticPrefs::media_benchmark_vp9_versioncheck();
bool needBenchmark;
Expand Down
2 changes: 1 addition & 1 deletion dom/media/ChannelMediaResource.h
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ class ChannelMediaResource
void Revoke();

private:
Mutex mMutex;
Mutex mMutex MOZ_UNANNOTATED;
// 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.
Expand Down
2 changes: 1 addition & 1 deletion dom/media/CloneableWithRangeMediaResource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ class InputStreamReader final : public nsIInputStreamCallback {

nsCOMPtr<nsIInputStream> mStream;
nsCOMPtr<nsIAsyncInputStream> mAsyncStream;
Monitor mMonitor;
Monitor mMonitor MOZ_UNANNOTATED;
};

NS_IMPL_ADDREF(InputStreamReader);
Expand Down
4 changes: 2 additions & 2 deletions dom/media/FileBlockCache.h
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ class FileBlockCache : public MediaBlockCacheBase {
// Mutex which controls access to mFD and mFDCurrentPos. Don't hold
// mDataMutex while holding mFileMutex! mFileMutex must be owned
// while accessing any of the following data fields or methods.
Mutex mFileMutex;
Mutex mFileMutex MOZ_UNANNOTATED;
// Moves a block already committed to file.
nsresult MoveBlockInFile(int32_t aSourceBlockIndex, int32_t aDestBlockIndex);
// Seeks file pointer.
Expand All @@ -159,7 +159,7 @@ class FileBlockCache : public MediaBlockCacheBase {
// and mFDCurrentPos. Don't hold mDataMutex while holding mFileMutex!
// mDataMutex must be owned while accessing any of the following data
// fields or methods.
Mutex mDataMutex;
Mutex mDataMutex MOZ_UNANNOTATED;
// Ensures we either are running the event to preform IO, or an event
// has been dispatched to preform the IO.
// mDataMutex must be owned while calling this.
Expand Down
2 changes: 1 addition & 1 deletion dom/media/FileMediaResource.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ class FileMediaResource : public BaseMediaResource {
// Read or Seek is in progress since it resets various internal
// values to null.
// This lock protects mSeekable, mInput, mSize, and mSizeInitialized.
Mutex mLock;
Mutex mLock MOZ_UNANNOTATED;

// Seekable stream interface to file. This can be used from any
// thread.
Expand Down
2 changes: 1 addition & 1 deletion dom/media/FrameStatistics.h
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ class FrameStatistics {
~FrameStatistics() = default;

// ReentrantMonitor to protect access of playback statistics.
mutable ReentrantMonitor mReentrantMonitor;
mutable ReentrantMonitor mReentrantMonitor MOZ_UNANNOTATED;

FrameStatisticsData mFrameStatisticsData;
};
Expand Down
2 changes: 1 addition & 1 deletion dom/media/GraphDriver.h
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ class MediaTrackGraphInitThreadRunnable;
*/
class ThreadedDriver : public GraphDriver {
class IterationWaitHelper {
Monitor mMonitor;
Monitor mMonitor MOZ_UNANNOTATED;
// The below members are guarded by mMonitor.
bool mNeedAnotherIteration = false;
TimeStamp mWakeTime;
Expand Down
2 changes: 1 addition & 1 deletion dom/media/GraphRunner.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ class GraphRunner final : public Runnable {

// Monitor used for yielding mThread through Wait(), and scheduling mThread
// through Signal() from a GraphDriver.
Monitor mMonitor;
Monitor mMonitor MOZ_UNANNOTATED;
// The MediaTrackGraph we're running. Weakptr beecause this graph owns us and
// guarantees that our lifetime will not go beyond that of itself.
MediaTrackGraphImpl* const mGraph;
Expand Down
2 changes: 1 addition & 1 deletion dom/media/MediaCache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,7 @@ class MediaCache {
// The monitor protects all the data members here. Also, off-main-thread
// readers that need to block will Wait() on this monitor. When new
// data becomes available in the cache, we NotifyAll() on this monitor.
mozilla::Monitor mMonitor;
mozilla::Monitor mMonitor MOZ_UNANNOTATED;
// This must always be accessed when the monitor is held.
nsTArray<MediaCacheStream*> mStreams;
// The Blocks describing the cache entries.
Expand Down
2 changes: 1 addition & 1 deletion dom/media/MediaEventSource.h
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,7 @@ class MediaEventSourceImpl {
}

private:
Mutex mMutex;
Mutex mMutex MOZ_UNANNOTATED;
nsTArray<RefPtr<Listener>> mListeners;
};

Expand Down
2 changes: 1 addition & 1 deletion dom/media/MediaFormatReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -718,7 +718,7 @@ class MediaFormatReader::DemuxerProxy::Wrapper : public MediaTrackDemuxer {
void BreakCycles() override {}

private:
Mutex mMutex;
Mutex mMutex MOZ_UNANNOTATED;
const RefPtr<TaskQueue> mTaskQueue;
const bool mGetSamplesMayBlock;
const UniquePtr<TrackInfo> mInfo;
Expand Down
Loading

0 comments on commit 7d4b5fa

Please sign in to comment.