Commit 9b2613b1 authored by Nicholas Nethercote's avatar Nicholas Nethercote
Browse files

Bug 1329684 (part 1) - Remove GeckoMutex, ::Mutex and ::MutexAutoLock from the profiler. r=mstange.

Note that the comment on ::Mutex said that it should support recursive locking,
but GeckoMutex was implemented using mozilla::Mutex which does *not* support
recursive locking.

The patch also removes OS::CreateMutex(), because it's only used twice and
doesn't make the code more concise.
parent ccfef763
Loading
Loading
Loading
Loading
+7 −7
Original line number Diff line number Diff line
@@ -212,7 +212,7 @@ GeckoSampler::GeckoSampler(double aInterval, int aEntrySize,
  sStartTime = mozilla::TimeStamp::ProcessCreation(ignore);

  {
    ::MutexAutoLock lock(*sRegisteredThreadsMutex);
    MutexAutoLock lock(*sRegisteredThreadsMutex);

    // Create ThreadProfile for each registered thread
    for (uint32_t i = 0; i < sRegisteredThreads->size(); i++) {
@@ -242,7 +242,7 @@ GeckoSampler::~GeckoSampler()

  // Destroy ThreadProfile for all threads
  {
    ::MutexAutoLock lock(*sRegisteredThreadsMutex);
    MutexAutoLock lock(*sRegisteredThreadsMutex);

    for (uint32_t i = 0; i < sRegisteredThreads->size(); i++) {
      ThreadInfo* info = sRegisteredThreads->at(i);
@@ -295,7 +295,7 @@ void GeckoSampler::StreamTaskTracer(SpliceableJSONWriter& aWriter)
  aWriter.EndArray();

  aWriter.StartArrayProperty("threads");
    ::MutexAutoLock lock(*sRegisteredThreadsMutex);
    MutexAutoLock lock(*sRegisteredThreadsMutex);
    for (size_t i = 0; i < sRegisteredThreads->size(); i++) {
      // Thread meta data
      ThreadInfo* info = sRegisteredThreads->at(i);
@@ -527,7 +527,7 @@ void GeckoSampler::StreamJSON(SpliceableJSONWriter& aWriter, double aSinceTime)
      SetPaused(true);

      {
        ::MutexAutoLock lock(*sRegisteredThreadsMutex);
        MutexAutoLock lock(*sRegisteredThreadsMutex);

        for (size_t i = 0; i < sRegisteredThreads->size(); i++) {
          // Thread not being profiled, skip it
@@ -537,7 +537,7 @@ void GeckoSampler::StreamJSON(SpliceableJSONWriter& aWriter, double aSinceTime)
          // Note that we intentionally include ThreadProfile which
          // have been marked for pending delete.

          ::MutexAutoLock lock(sRegisteredThreads->at(i)->Profile()->GetMutex());
          MutexAutoLock lock(sRegisteredThreads->at(i)->Profile()->GetMutex());

          sRegisteredThreads->at(i)->Profile()->StreamJSON(aWriter, aSinceTime);
        }
@@ -580,7 +580,7 @@ void GeckoSampler::FlushOnJSShutdown(JSContext* aContext)
  SetPaused(true);

  {
    ::MutexAutoLock lock(*sRegisteredThreadsMutex);
    MutexAutoLock lock(*sRegisteredThreadsMutex);

    for (size_t i = 0; i < sRegisteredThreads->size(); i++) {
      // Thread not being profiled, skip it.
@@ -594,7 +594,7 @@ void GeckoSampler::FlushOnJSShutdown(JSContext* aContext)
        continue;
      }

      ::MutexAutoLock lock(sRegisteredThreads->at(i)->Profile()->GetMutex());
      MutexAutoLock lock(sRegisteredThreads->at(i)->Profile()->GetMutex());
      sRegisteredThreads->at(i)->Profile()->FlushSamplesAndMarkers();
    }
  }
+1 −1
Original line number Diff line number Diff line
@@ -28,6 +28,6 @@ void
ProfilerBacktrace::StreamJSON(SpliceableJSONWriter& aWriter,
                              UniqueStacks& aUniqueStacks)
{
  ::MutexAutoLock lock(mProfile->GetMutex());
  MutexAutoLock lock(mProfile->GetMutex());
  mProfile->StreamJSON(aWriter, aUniqueStacks);
}
+1 −1
Original line number Diff line number Diff line
@@ -25,7 +25,7 @@ SyncProfile::~SyncProfile()
bool
SyncProfile::ShouldDestroy()
{
  ::MutexAutoLock lock(GetMutex());
  MutexAutoLock lock(GetMutex());
  if (mOwnerState == OWNED) {
    mOwnerState = OWNER_DESTROYING;
    return true;
+1 −1
Original line number Diff line number Diff line
@@ -8,7 +8,7 @@ ThreadProfile::ThreadProfile(ThreadInfo* aInfo, ProfileBuffer* aBuffer)
  : mThreadInfo(aInfo)
  , mBuffer(aBuffer)
  , mPseudoStack(aInfo->Stack())
  , mMutex(OS::CreateMutex("ThreadProfile::mMutex"))
  , mMutex(MakeUnique<Mutex>("ThreadProfile::mMutex"))
  , mThreadId(int(aInfo->ThreadId()))
  , mIsMainThread(aInfo->IsMainThread())
  , mPlatformData(aInfo->GetPlatformData())
+2 −2
Original line number Diff line number Diff line
@@ -24,7 +24,7 @@ public:
   */
  void addStoredMarker(ProfilerMarker *aStoredMarker);
  PseudoStack* GetPseudoStack();
  ::Mutex& GetMutex();
  mozilla::Mutex& GetMutex();
  void StreamJSON(SpliceableJSONWriter& aWriter, double aSinceTime = 0);

  /**
@@ -83,7 +83,7 @@ private:
  mozilla::Maybe<UniqueStacks> mUniqueStacks;

  PseudoStack*   mPseudoStack;
  mozilla::UniquePtr<Mutex>  mMutex;
  mozilla::UniquePtr<mozilla::Mutex> mMutex;
  int            mThreadId;
  bool           mIsMainThread;
  PlatformData*  mPlatformData;  // Platform specific data.
Loading