Bug 1339327 (part 5) - Rename some profiler functions related to sleeping. r=mstange.
authorNicholas Nethercote <nnethercote@mozilla.com>
Wed, 15 Feb 2017 14:26:23 +1100
changeset 342970 1aa60b9dbadcc1352193a4b64367ed2135dd384d
parent 342969 c6933c5687aaee7f3c261364f077b4d1fa4d3d8a
child 342971 d6c8118d95f32d06261d69317e3d14f1b4fd9648
push id37410
push usercbook@mozilla.com
push dateWed, 15 Feb 2017 11:59:42 +0000
treeherderautoland@4702737fef39 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmstange
bugs1339327
milestone54.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1339327 (part 5) - Rename some profiler functions related to sleeping. r=mstange. The new names make it clearer that these actions apply to just one thread. - profiler_sleep_start() --> profiler_thread_sleep() - profiler_sleep_end() --> profiler_thread_wake() - profiler_is_sleeping() --> profiler_thread_is_sleeping() - GeckoProfilerSleepRAII --> GeckoProfilerThreadSleepRAII - GeckoProfilerWakeRAII --> GeckoProfilerThreadWakeRAII
ipc/chromium/src/base/message_pump_default.cc
ipc/mscom/MainThreadInvoker.cpp
tools/profiler/core/platform.cpp
tools/profiler/public/GeckoProfiler.h
widget/gtk/nsAppShell.cpp
widget/windows/nsAppShell.cpp
xpcom/threads/BlockingResourceBase.cpp
xpcom/threads/CondVar.h
xpcom/threads/ReentrantMonitor.h
--- a/ipc/chromium/src/base/message_pump_default.cc
+++ b/ipc/chromium/src/base/message_pump_default.cc
@@ -53,27 +53,27 @@ void MessagePumpDefault::Run(Delegate* d
     if (did_work)
       continue;
 
     if (delayed_work_time_.is_null()) {
       hangMonitor.NotifyWait();
       PROFILER_LABEL("MessagePump", "Wait",
         js::ProfileEntry::Category::OTHER);
       {
-        mozilla::GeckoProfilerSleepRAII profiler_sleep;
+        mozilla::GeckoProfilerThreadSleepRAII sleep;
         event_.Wait();
       }
     } else {
       TimeDelta delay = delayed_work_time_ - TimeTicks::Now();
       if (delay > TimeDelta()) {
         hangMonitor.NotifyWait();
         PROFILER_LABEL("MessagePump", "Wait",
           js::ProfileEntry::Category::OTHER);
         {
-          mozilla::GeckoProfilerSleepRAII profiler_sleep;
+          mozilla::GeckoProfilerThreadSleepRAII sleep;
           event_.TimedWait(delay);
         }
       } else {
         // It looks like delayed_work_time_ indicates a time in the past, so we
         // need to call DoDelayedWork now.
         delayed_work_time_ = TimeTicks();
       }
     }
--- a/ipc/mscom/MainThreadInvoker.cpp
+++ b/ipc/mscom/MainThreadInvoker.cpp
@@ -164,17 +164,17 @@ MainThreadInvoker::Invoke(already_AddRef
   widget::WinUtils::SetAPCPending();
 
   return syncRunnable.WaitUntilComplete();
 }
 
 /* static */ VOID CALLBACK
 MainThreadInvoker::MainThreadAPC(ULONG_PTR aParam)
 {
-  GeckoProfilerWakeRAII wakeProfiler;
+  GeckoProfilerThreadWakeRAII wake;
   mozilla::HangMonitor::NotifyActivity(mozilla::HangMonitor::kGeneralActivity);
   MOZ_ASSERT(NS_IsMainThread());
   auto runnable = reinterpret_cast<SyncRunnable*>(aParam);
   runnable->Run();
 }
 
 } // namespace mscom
 } // namespace mozilla
--- a/tools/profiler/core/platform.cpp
+++ b/tools/profiler/core/platform.cpp
@@ -2408,49 +2408,49 @@ profiler_unregister_thread()
   // We just cut the ThreadInfo's PseudoStack pointer (either nulling it via
   // SetPendingDelete() or by deleting the ThreadInfo altogether), so it is
   // safe to delete the PseudoStack.
   delete tlsPseudoStack.get();
   tlsPseudoStack.set(nullptr);
 }
 
 void
-profiler_sleep_start()
+profiler_thread_sleep()
 {
   // This function runs both on and off the main thread.
 
   if (gInitCount == 0) {
     return;
   }
 
   PseudoStack *stack = tlsPseudoStack.get();
   if (stack == nullptr) {
     return;
   }
   stack->setSleeping();
 }
 
 void
-profiler_sleep_end()
+profiler_thread_wake()
 {
   // This function runs both on and off the main thread.
 
   if (gInitCount == 0) {
     return;
   }
 
   PseudoStack *stack = tlsPseudoStack.get();
   if (stack == nullptr) {
     return;
   }
   stack->setAwake();
 }
 
 bool
-profiler_is_sleeping()
+profiler_thread_is_sleeping()
 {
   // This function currently only used on the main thread, but that restriction
   // (and this assertion) could be removed without too much difficulty.
   MOZ_RELEASE_ASSERT(NS_IsMainThread());
 
   if (gInitCount == 0) {
     return false;
   }
--- a/tools/profiler/public/GeckoProfiler.h
+++ b/tools/profiler/public/GeckoProfiler.h
@@ -263,22 +263,22 @@ PROFILER_FUNC_VOID(profiler_lock())
 // Unlock the profiler, leaving it stopped, and fire 'profiler-unlocked'.
 PROFILER_FUNC_VOID(profiler_unlock())
 
 // Register/unregister threads with the profiler.
 PROFILER_FUNC_VOID(profiler_register_thread(const char* name,
                                             void* guessStackTop))
 PROFILER_FUNC_VOID(profiler_unregister_thread())
 
-// These functions tell the profiler that a thread went to sleep so that we can avoid
-// sampling it while it's sleeping. Calling profiler_sleep_start() twice without
-// profiler_sleep_end() is an error.
-PROFILER_FUNC_VOID(profiler_sleep_start())
-PROFILER_FUNC_VOID(profiler_sleep_end())
-PROFILER_FUNC(bool profiler_is_sleeping(), false)
+// These functions tell the profiler that a thread went to sleep so that we can
+// avoid sampling it while it's sleeping. Calling profiler_thread_sleep()
+// twice without an intervening profiler_thread_wake() is an error.
+PROFILER_FUNC_VOID(profiler_thread_sleep())
+PROFILER_FUNC_VOID(profiler_thread_wake())
+PROFILER_FUNC(bool profiler_thread_is_sleeping(), false)
 
 // Call by the JSRuntime's operation callback. This is used to enable
 // profiling on auxilerary threads.
 PROFILER_FUNC_VOID(profiler_js_operation_callback())
 
 PROFILER_FUNC(double profiler_time(), 0)
 PROFILER_FUNC(double profiler_time(const mozilla::TimeStamp& aTime), 0)
 
@@ -553,43 +553,43 @@ public:
   explicit GeckoProfilerInitRAII(void* stackTop) {
     profiler_init(stackTop);
   }
   ~GeckoProfilerInitRAII() {
     profiler_shutdown();
   }
 };
 
-class MOZ_RAII GeckoProfilerSleepRAII {
+class MOZ_RAII GeckoProfilerThreadSleepRAII {
 public:
-  GeckoProfilerSleepRAII() {
-    profiler_sleep_start();
+  GeckoProfilerThreadSleepRAII() {
+    profiler_thread_sleep();
   }
-  ~GeckoProfilerSleepRAII() {
-    profiler_sleep_end();
+  ~GeckoProfilerThreadSleepRAII() {
+    profiler_thread_wake();
   }
 };
 
 /**
- * Temporarily wake up the profiler while servicing events such as
+ * Temporarily wake up the profiling of a thread while servicing events such as
  * Asynchronous Procedure Calls (APCs).
  */
-class MOZ_RAII GeckoProfilerWakeRAII {
+class MOZ_RAII GeckoProfilerThreadWakeRAII {
 public:
-  GeckoProfilerWakeRAII()
-    : mIssuedWake(profiler_is_sleeping())
+  GeckoProfilerThreadWakeRAII()
+    : mIssuedWake(profiler_thread_is_sleeping())
   {
     if (mIssuedWake) {
-      profiler_sleep_end();
+      profiler_thread_wake();
     }
   }
-  ~GeckoProfilerWakeRAII() {
+  ~GeckoProfilerThreadWakeRAII() {
     if (mIssuedWake) {
-      MOZ_ASSERT(!profiler_is_sleeping());
-      profiler_sleep_start();
+      MOZ_ASSERT(!profiler_thread_is_sleeping());
+      profiler_thread_sleep();
     }
   }
 private:
   bool mIssuedWake;
 };
 
 class MOZ_RAII GeckoProfilerTracingRAII {
 public:
--- a/widget/gtk/nsAppShell.cpp
+++ b/widget/gtk/nsAppShell.cpp
@@ -33,19 +33,19 @@ PRLogModuleInfo *gWidgetDrawLog = nullpt
 
 static GPollFunc sPollFunc;
 
 // Wrapper function to disable hang monitoring while waiting in poll().
 static gint
 PollWrapper(GPollFD *ufds, guint nfsd, gint timeout_)
 {
     mozilla::HangMonitor::Suspend();
-    profiler_sleep_start();
+    profiler_thread_sleep();
     gint result = (*sPollFunc)(ufds, nfsd, timeout_);
-    profiler_sleep_end();
+    profiler_thread_wake();
     mozilla::HangMonitor::NotifyActivity();
     return result;
 }
 
 #if MOZ_WIDGET_GTK == 3
 // For bug 726483.
 static decltype(GtkContainerClass::check_resize) sReal_gtk_window_check_resize;
 
--- a/widget/windows/nsAppShell.cpp
+++ b/widget/windows/nsAppShell.cpp
@@ -373,17 +373,17 @@ nsAppShell::ProcessNextNativeEvent(bool 
 
         ::TranslateMessage(&msg);
         ::DispatchMessageW(&msg);
       }
     } else if (mayWait) {
       // Block and wait for any posted application message
       mozilla::HangMonitor::Suspend();
       {
-        GeckoProfilerSleepRAII profiler_sleep;
+        GeckoProfilerThreadSleepRAII sleep;
         WinUtils::WaitForMessage();
       }
     }
   } while (!gotMessage && mayWait);
 
   // See DoProcessNextNativeEvent, mEventloopNestingLevel will be
   // one when a modal loop unwinds.
   if (mNativeCallbackPending && mEventloopNestingLevel == 1)
--- a/xpcom/threads/BlockingResourceBase.cpp
+++ b/xpcom/threads/BlockingResourceBase.cpp
@@ -456,17 +456,17 @@ ReentrantMonitor::Wait(PRIntervalTime aI
   BlockingResourceBase* savedChainPrev = mChainPrev;
   mEntryCount = 0;
   ClearAcquisitionState();
   mChainPrev = 0;
 
   nsresult rv;
 #if defined(MOZILLA_INTERNAL_API)
   {
-    GeckoProfilerSleepRAII profiler_sleep;
+    GeckoProfilerThreadSleepRAII sleep;
 #endif //MOZILLA_INTERNAL_API
 
     // give up the monitor until we're back from Wait()
     rv = PR_Wait(mReentrantMonitor, aInterval) == PR_SUCCESS ? NS_OK :
                                                                NS_ERROR_FAILURE;
 
 #if defined(MOZILLA_INTERNAL_API)
   }
--- a/xpcom/threads/CondVar.h
+++ b/xpcom/threads/CondVar.h
@@ -68,17 +68,17 @@ public:
   /**
    * Wait
    * @see prcvar.h
    **/
   nsresult Wait(PRIntervalTime aInterval = PR_INTERVAL_NO_TIMEOUT)
   {
 
 #ifdef MOZILLA_INTERNAL_API
-    GeckoProfilerSleepRAII profiler_sleep;
+    GeckoProfilerThreadSleepRAII sleep;
 #endif //MOZILLA_INTERNAL_API
     // NSPR checks for lock ownership
     return PR_WaitCondVar(mCvar, aInterval) == PR_SUCCESS ? NS_OK :
                                                             NS_ERROR_FAILURE;
   }
 #else
   nsresult Wait(PRIntervalTime aInterval = PR_INTERVAL_NO_TIMEOUT);
 #endif // ifndef DEBUG
--- a/xpcom/threads/ReentrantMonitor.h
+++ b/xpcom/threads/ReentrantMonitor.h
@@ -81,17 +81,17 @@ public:
 
   /**
    * Wait
    * @see prmon.h
    **/
   nsresult Wait(PRIntervalTime aInterval = PR_INTERVAL_NO_TIMEOUT)
   {
 #ifdef MOZILLA_INTERNAL_API
-    GeckoProfilerSleepRAII profiler_sleep;
+    GeckoProfilerThreadSleepRAII sleep;
 #endif //MOZILLA_INTERNAL_API
     return PR_Wait(mReentrantMonitor, aInterval) == PR_SUCCESS ?
       NS_OK : NS_ERROR_FAILURE;
   }
 
 #else // ifndef DEBUG
   void Enter();
   void Exit();