mozilla-bmo1807652.patch
branchfirefox112
changeset 1188 a2caa2a2494f
parent 1187 17bc5a064ab4
child 1189 ba0c97b018a6
equal deleted inserted replaced
1187:17bc5a064ab4 1188:a2caa2a2494f
     1 diff --git a/tools/profiler/core/platform.cpp b/tools/profiler/core/platform.cpp
       
     2 --- a/tools/profiler/core/platform.cpp
       
     3 +++ b/tools/profiler/core/platform.cpp
       
     4 @@ -1176,11 +1176,11 @@
       
     5        if (!profiledThreadData) {
       
     6          // This thread was not profiled, continue with the next one.
       
     7          continue;
       
     8        }
       
     9        ThreadRegistry::OffThreadRef::RWFromAnyThreadWithLock lockedThreadData =
       
    10 -          offThreadRef.LockedRWFromAnyThread();
       
    11 +          offThreadRef.GetLockedRWFromAnyThread();
       
    12        MOZ_RELEASE_ASSERT(array.append(ProfiledThreadListElement{
       
    13            profiledThreadData->Info().RegisterTime(),
       
    14            lockedThreadData->GetJSContext(), profiledThreadData}));
       
    15      }
       
    16  
       
    17 @@ -4208,11 +4208,11 @@
       
    18                    ProfileBufferEntry::Kind::RunningTimes, runningTimesDiff);
       
    19              }
       
    20  
       
    21              if (threadStackSampling) {
       
    22                ThreadRegistry::OffThreadRef::RWFromAnyThreadWithLock
       
    23 -                  lockedThreadData = offThreadRef.LockedRWFromAnyThread();
       
    24 +                  lockedThreadData = offThreadRef.GetLockedRWFromAnyThread();
       
    25                // Suspend the thread and collect its stack data in the local
       
    26                // buffer.
       
    27                mSampler.SuspendAndSampleAndResumeThread(
       
    28                    lock, lockedThreadData.DataCRef(), now,
       
    29                    [&](const Registers& aRegs, const TimeStamp& aNow) {
       
    30 @@ -4922,11 +4922,11 @@
       
    31      ThreadProfilingFeatures threadProfilingFeatures =
       
    32          ActivePS::ProfilingFeaturesForThread(
       
    33              aLock, aOffThreadRef.UnlockedConstReaderCRef().Info());
       
    34      if (threadProfilingFeatures != ThreadProfilingFeatures::NotProfiled) {
       
    35        ThreadRegistry::OffThreadRef::RWFromAnyThreadWithLock
       
    36 -          lockedRWFromAnyThread = aOffThreadRef.LockedRWFromAnyThread();
       
    37 +          lockedRWFromAnyThread = aOffThreadRef.GetLockedRWFromAnyThread();
       
    38  
       
    39        ProfiledThreadData* profiledThreadData = ActivePS::AddLiveProfiledThread(
       
    40            aLock, MakeUnique<ProfiledThreadData>(
       
    41                       aOffThreadRef.UnlockedConstReaderCRef().Info()));
       
    42        lockedRWFromAnyThread->SetProfilingFeaturesAndData(
       
    43 @@ -5788,11 +5788,11 @@
       
    44  
       
    45      ThreadProfilingFeatures threadProfilingFeatures =
       
    46          ActivePS::ProfilingFeaturesForThread(aLock, info);
       
    47      if (threadProfilingFeatures != ThreadProfilingFeatures::NotProfiled) {
       
    48        ThreadRegistry::OffThreadRef::RWFromAnyThreadWithLock lockedThreadData =
       
    49 -          offThreadRef.LockedRWFromAnyThread();
       
    50 +          offThreadRef.GetLockedRWFromAnyThread();
       
    51        ProfiledThreadData* profiledThreadData = ActivePS::AddLiveProfiledThread(
       
    52            aLock, MakeUnique<ProfiledThreadData>(info));
       
    53        lockedThreadData->SetProfilingFeaturesAndData(threadProfilingFeatures,
       
    54                                                      profiledThreadData, aLock);
       
    55        lockedThreadData->GetNewCpuTimeInNs();
       
    56 @@ -6012,11 +6012,11 @@
       
    57          ThreadProfilingFeatures::NotProfiled) {
       
    58        continue;
       
    59      }
       
    60  
       
    61      ThreadRegistry::OffThreadRef::RWFromAnyThreadWithLock lockedThreadData =
       
    62 -        offThreadRef.LockedRWFromAnyThread();
       
    63 +        offThreadRef.GetLockedRWFromAnyThread();
       
    64  
       
    65      lockedThreadData->ClearProfilingFeaturesAndData(aLock);
       
    66  
       
    67      if (ActivePS::FeatureJS(aLock)) {
       
    68        lockedThreadData->StopJSSampling();
       
    69 @@ -6355,11 +6355,11 @@
       
    70  
       
    71    // We don't call StopJSSampling() here; there's no point doing that for a JS
       
    72    // thread that is in the process of disappearing.
       
    73  
       
    74    ThreadRegistration::OnThreadRef::RWOnThreadWithLock lockedThreadData =
       
    75 -      aOnThreadRef.LockedRWOnThread();
       
    76 +      aOnThreadRef.GetLockedRWOnThread();
       
    77  
       
    78    ProfiledThreadData* profiledThreadData =
       
    79        lockedThreadData->GetProfiledThreadData(lock);
       
    80    lockedThreadData->ClearProfilingFeaturesAndData(lock);
       
    81  
       
    82 @@ -6876,11 +6876,11 @@
       
    83          }
       
    84  
       
    85          // The profiler mutex must be locked before the ThreadRegistration's.
       
    86          PSAutoLock lock;
       
    87          ThreadRegistration::OnThreadRef::RWOnThreadWithLock lockedThreadData =
       
    88 -            aOnThreadRef.LockedRWOnThread();
       
    89 +            aOnThreadRef.GetLockedRWOnThread();
       
    90  
       
    91          if (ProfiledThreadData* profiledThreadData =
       
    92                  lockedThreadData->GetProfiledThreadData(lock);
       
    93              profiledThreadData && ActivePS::Exists(lock) &&
       
    94              ActivePS::FeatureJS(lock)) {
       
    95 diff --git a/tools/profiler/public/ProfilerThreadRegistration.h b/tools/profiler/public/ProfilerThreadRegistration.h
       
    96 --- a/tools/profiler/public/ProfilerThreadRegistration.h
       
    97 +++ b/tools/profiler/public/ProfilerThreadRegistration.h
       
    98 @@ -212,18 +212,18 @@
       
    99  
       
   100        LockedRWOnThread& mLockedRWOnThread;
       
   101        DataLock mDataLock;
       
   102      };
       
   103  
       
   104 -    [[nodiscard]] RWOnThreadWithLock LockedRWOnThread() {
       
   105 +    [[nodiscard]] RWOnThreadWithLock GetLockedRWOnThread() {
       
   106        return RWOnThreadWithLock{mThreadRegistration->mData,
       
   107                                  mThreadRegistration->mDataMutex};
       
   108      }
       
   109  
       
   110      template <typename F>
       
   111      auto WithLockedRWOnThread(F&& aF) {
       
   112 -      RWOnThreadWithLock lockedData = LockedRWOnThread();
       
   113 +      RWOnThreadWithLock lockedData = GetLockedRWOnThread();
       
   114        return std::forward<F>(aF)(lockedData.DataRef());
       
   115      }
       
   116  
       
   117      // This is needed to allow OnThreadPtr::operator-> to return a temporary
       
   118      // OnThreadRef object, for which `->` must work; Here it provides a pointer
       
   119 diff --git a/tools/profiler/public/ProfilerThreadRegistry.h b/tools/profiler/public/ProfilerThreadRegistry.h
       
   120 --- a/tools/profiler/public/ProfilerThreadRegistry.h
       
   121 +++ b/tools/profiler/public/ProfilerThreadRegistry.h
       
   122 @@ -175,18 +175,18 @@
       
   123  
       
   124        LockedRWFromAnyThread& mLockedRWFromAnyThread;
       
   125        ThreadRegistration::DataLock mDataLock;
       
   126      };
       
   127  
       
   128 -    [[nodiscard]] RWFromAnyThreadWithLock LockedRWFromAnyThread() {
       
   129 +    [[nodiscard]] RWFromAnyThreadWithLock GetLockedRWFromAnyThread() {
       
   130        return RWFromAnyThreadWithLock{mThreadRegistration->mData,
       
   131                                       mThreadRegistration->mDataMutex};
       
   132      }
       
   133  
       
   134      template <typename F>
       
   135      auto WithLockedRWFromAnyThread(F&& aF) {
       
   136 -      RWFromAnyThreadWithLock lockedData = LockedRWFromAnyThread();
       
   137 +      RWFromAnyThreadWithLock lockedData = GetLockedRWFromAnyThread();
       
   138        return std::forward<F>(aF)(lockedData.DataRef());
       
   139      }
       
   140  
       
   141     private:
       
   142      // Only ThreadRegistry should construct an OnThreadRef.
       
   143 diff --git a/tools/profiler/tests/gtest/GeckoProfiler.cpp b/tools/profiler/tests/gtest/GeckoProfiler.cpp
       
   144 --- a/tools/profiler/tests/gtest/GeckoProfiler.cpp
       
   145 +++ b/tools/profiler/tests/gtest/GeckoProfiler.cpp
       
   146 @@ -620,11 +620,11 @@
       
   147        // non-const LockedRWOnThread
       
   148  
       
   149        EXPECT_FALSE(TR::IsDataMutexLockedOnCurrentThread());
       
   150        {
       
   151          TR::OnThreadRef::RWOnThreadWithLock rwOnThreadWithLock =
       
   152 -            aOnThreadRef.LockedRWOnThread();
       
   153 +            aOnThreadRef.GetLockedRWOnThread();
       
   154          EXPECT_TRUE(TR::IsDataMutexLockedOnCurrentThread());
       
   155          TestConstLockedRWOnThread(rwOnThreadWithLock.DataCRef(),
       
   156                                    beforeRegistration, afterRegistration,
       
   157                                    &onStackChar);
       
   158          TestLockedRWOnThread(rwOnThreadWithLock.DataRef(), beforeRegistration,
       
   159 @@ -1019,11 +1019,11 @@
       
   160          // non-const LockedRWFromAnyThread
       
   161  
       
   162          EXPECT_FALSE(TR::IsDataMutexLockedOnCurrentThread());
       
   163          {
       
   164            TRy::OffThreadRef::RWFromAnyThreadWithLock rwFromAnyThreadWithLock =
       
   165 -              aOffThreadRef.LockedRWFromAnyThread();
       
   166 +              aOffThreadRef.GetLockedRWFromAnyThread();
       
   167            if (profiler_current_thread_id() == testThreadId) {
       
   168              EXPECT_TRUE(TR::IsDataMutexLockedOnCurrentThread());
       
   169            }
       
   170            TestLockedRWFromAnyThread(rwFromAnyThreadWithLock.DataRef(),
       
   171                                      beforeRegistration, afterRegistration,
       
   172 @@ -1156,11 +1156,11 @@
       
   173                                                      aOffThreadRef) {
       
   174            if (otherThreadLoops % 1000 == 0) {
       
   175              PR_Sleep(PR_MillisecondsToInterval(1));
       
   176            }
       
   177            TRy::OffThreadRef::RWFromAnyThreadWithLock rwFromAnyThreadWithLock =
       
   178 -              aOffThreadRef.LockedRWFromAnyThread();
       
   179 +              aOffThreadRef.GetLockedRWFromAnyThread();
       
   180            ++otherThreadReads;
       
   181            if (otherThreadReads % 1000 == 0) {
       
   182              PR_Sleep(PR_MillisecondsToInterval(1));
       
   183            }
       
   184          });
       
   185