Bug 1309031 - Remove support for prohibiting the background hang monitor; r=froydnj
authorEhsan Akhgari <ehsan@mozilla.com>
Mon, 10 Oct 2016 16:45:31 -0400
changeset 360384 79297e959908f1fba21e7d6384602f1e7772622a
parent 360383 7724e3dc67d8a5949aada7f831386c3744d3841f
child 360385 db30a41cbab583183b5e1b72b2c64cef84e92809
push id6795
push userjlund@mozilla.com
push dateMon, 23 Jan 2017 14:19:46 +0000
treeherdermozilla-beta@76101b503191 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfroydnj
bugs1309031, 1284674
milestone52.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 1309031 - Remove support for prohibiting the background hang monitor; r=froydnj The code that was using this was removed in bug 1284674.
xpcom/threads/BackgroundHangMonitor.cpp
xpcom/threads/BackgroundHangMonitor.h
--- a/xpcom/threads/BackgroundHangMonitor.cpp
+++ b/xpcom/threads/BackgroundHangMonitor.cpp
@@ -72,17 +72,16 @@ private:
   BackgroundHangManager(const BackgroundHangManager&);
   BackgroundHangManager& operator=(const BackgroundHangManager&);
   void RunMonitorThread();
 
 public:
   NS_DECL_THREADSAFE_ISUPPORTS
   NS_DECL_NSIOBSERVER
   static StaticRefPtr<BackgroundHangManager> sInstance;
-  static bool sProhibited;
   static bool sDisabled;
 
   // Lock for access to members of this class
   Monitor mLock;
   // Current time as seen by hang monitors
   PRIntervalTime mIntervalNow;
   // List of BackgroundHangThread instances associated with each thread
   LinkedList<BackgroundHangThread> mHangThreads;
@@ -190,17 +189,16 @@ public:
   {
     NotifyActivity();
     mWaiting = true;
   }
 };
 
 
 StaticRefPtr<BackgroundHangManager> BackgroundHangManager::sInstance;
-bool BackgroundHangManager::sProhibited = false;
 bool BackgroundHangManager::sDisabled = false;
 
 MOZ_THREAD_LOCAL(BackgroundHangThread*) BackgroundHangThread::sTlsKey;
 bool BackgroundHangThread::sTlsKeyInitialized;
 
 BackgroundHangManager::BackgroundHangManager()
   : mShutdown(false)
   , mLock("BackgroundHangManager")
@@ -474,25 +472,23 @@ BackgroundHangThread::NotifyActivity()
   }
 }
 
 BackgroundHangThread*
 BackgroundHangThread::FindThread()
 {
 #ifdef MOZ_ENABLE_BACKGROUND_HANG_MONITOR
   if (BackgroundHangManager::sInstance == nullptr) {
-    MOZ_ASSERT(BackgroundHangManager::sProhibited || BackgroundHangManager::sDisabled,
+    MOZ_ASSERT(BackgroundHangManager::sDisabled,
                "BackgroundHandleManager is not initialized");
     return nullptr;
   }
 
   if (sTlsKeyInitialized) {
     // Use TLS if available
-    MOZ_ASSERT(!BackgroundHangManager::sProhibited,
-               "BackgroundHandleManager is not initialized");
     return sTlsKey.get();
   }
   // If TLS is unavailable, we can search through the thread list
   RefPtr<BackgroundHangManager> manager(BackgroundHangManager::sInstance);
   MOZ_ASSERT(manager, "Creating BackgroundHangMonitor after shutdown");
 
   PRThread* threadID = PR_GetCurrentThread();
   // Lock thread list for traversal
@@ -540,17 +536,16 @@ BackgroundHangMonitor::DisableOnBeta() {
 
   return false;
 }
 
 void
 BackgroundHangMonitor::Startup()
 {
 #ifdef MOZ_ENABLE_BACKGROUND_HANG_MONITOR
-  MOZ_ASSERT(!BackgroundHangManager::sProhibited, "Prohibited");
   MOZ_ASSERT(!BackgroundHangManager::sInstance, "Already initialized");
 
   if (!strcmp(NS_STRINGIFY(MOZ_UPDATE_CHANNEL), "beta")) {
     if (XRE_IsParentProcess()) { // cached ClientID hasn't been read yet
       ThreadStackHelper::Startup();
       BackgroundHangThread::Startup();
       BackgroundHangManager::sInstance = new BackgroundHangManager();
 
@@ -574,17 +569,16 @@ void
 BackgroundHangMonitor::Shutdown()
 {
 #ifdef MOZ_ENABLE_BACKGROUND_HANG_MONITOR
   if (BackgroundHangManager::sDisabled) {
     MOZ_ASSERT(!BackgroundHangManager::sInstance, "Initialized");
     return;
   }
 
-  MOZ_ASSERT(!BackgroundHangManager::sProhibited, "Prohibited");
   MOZ_ASSERT(BackgroundHangManager::sInstance, "Not initialized");
   /* Scope our lock inside Shutdown() because the sInstance object can
      be destroyed as soon as we set sInstance to nullptr below, and
      we don't want to hold the lock when it's being destroyed. */
   BackgroundHangManager::sInstance->Shutdown();
   BackgroundHangManager::sInstance = nullptr;
   ThreadStackHelper::Shutdown();
   BackgroundHangManager::sDisabled = true;
@@ -592,94 +586,68 @@ BackgroundHangMonitor::Shutdown()
 }
 
 BackgroundHangMonitor::BackgroundHangMonitor(const char* aName,
                                              uint32_t aTimeoutMs,
                                              uint32_t aMaxTimeoutMs)
   : mThread(BackgroundHangThread::FindThread())
 {
 #ifdef MOZ_ENABLE_BACKGROUND_HANG_MONITOR
-  if (!BackgroundHangManager::sDisabled && !BackgroundHangManager::sProhibited && !mThread) {
-    // If sProhibit is true, mThread would be null, and no monitoring.
+  if (!BackgroundHangManager::sDisabled && !mThread) {
     mThread = new BackgroundHangThread(aName, aTimeoutMs, aMaxTimeoutMs);
   }
 #endif
 }
 
 BackgroundHangMonitor::BackgroundHangMonitor()
   : mThread(BackgroundHangThread::FindThread())
 {
 #ifdef MOZ_ENABLE_BACKGROUND_HANG_MONITOR
   if (BackgroundHangManager::sDisabled) {
     return;
   }
-
-  MOZ_ASSERT(!BackgroundHangManager::sProhibited || mThread,
-             "This thread is not initialized for hang monitoring");
 #endif
 }
 
 BackgroundHangMonitor::~BackgroundHangMonitor()
 {
 }
 
 void
 BackgroundHangMonitor::NotifyActivity()
 {
 #ifdef MOZ_ENABLE_BACKGROUND_HANG_MONITOR
   if (mThread == nullptr) {
-    MOZ_ASSERT(BackgroundHangManager::sProhibited ||
-               BackgroundHangManager::sDisabled,
+    MOZ_ASSERT(BackgroundHangManager::sDisabled,
                "This thread is not initialized for hang monitoring");
     return;
   }
 
   if (Telemetry::CanRecordExtended()) {
     mThread->NotifyActivity();
   }
 #endif
 }
 
 void
 BackgroundHangMonitor::NotifyWait()
 {
 #ifdef MOZ_ENABLE_BACKGROUND_HANG_MONITOR
   if (mThread == nullptr) {
-    MOZ_ASSERT(BackgroundHangManager::sProhibited ||
-               BackgroundHangManager::sDisabled,
+    MOZ_ASSERT(BackgroundHangManager::sDisabled,
                "This thread is not initialized for hang monitoring");
     return;
   }
 
   if (Telemetry::CanRecordExtended()) {
     mThread->NotifyWait();
   }
 #endif
 }
 
-void
-BackgroundHangMonitor::Prohibit()
-{
-#ifdef MOZ_ENABLE_BACKGROUND_HANG_MONITOR
-  MOZ_ASSERT(BackgroundHangManager::sInstance == nullptr,
-             "The background hang monitor is already initialized");
-  BackgroundHangManager::sProhibited = true;
-#endif
-}
-
-void
-BackgroundHangMonitor::Allow()
-{
-#ifdef MOZ_ENABLE_BACKGROUND_HANG_MONITOR
-  MOZ_ASSERT(BackgroundHangManager::sInstance == nullptr,
-             "The background hang monitor is already initialized");
-  BackgroundHangManager::sProhibited = false;
-#endif
-}
-
 bool
 BackgroundHangMonitor::RegisterAnnotator(HangMonitor::Annotator& aAnnotator)
 {
 #ifdef MOZ_ENABLE_BACKGROUND_HANG_MONITOR
   BackgroundHangThread* thisThread = BackgroundHangThread::FindThread();
   if (!thisThread) {
     return false;
   }
@@ -709,17 +677,16 @@ BackgroundHangMonitor::UnregisterAnnotat
 BackgroundHangMonitor::ThreadHangStatsIterator::ThreadHangStatsIterator()
   : MonitorAutoLock(BackgroundHangManager::sInstance->mLock)
   , mThread(BackgroundHangManager::sInstance ?
             BackgroundHangManager::sInstance->mHangThreads.getFirst() :
             nullptr)
 {
 #ifdef MOZ_ENABLE_BACKGROUND_HANG_MONITOR
   MOZ_ASSERT(BackgroundHangManager::sInstance ||
-             BackgroundHangManager::sProhibited ||
              BackgroundHangManager::sDisabled,
              "Inconsistent state");
 #endif
 }
 
 Telemetry::ThreadHangStats*
 BackgroundHangMonitor::ThreadHangStatsIterator::GetNext()
 {
--- a/xpcom/threads/BackgroundHangMonitor.h
+++ b/xpcom/threads/BackgroundHangMonitor.h
@@ -98,19 +98,16 @@ class BackgroundHangManager;
  *        process_next_event();
  *        hangMonitor.NotifyWait();
  *        wait_for_next_event();
  *      }
  *    } else {
  *      process_nonsync_event();
  *    }
  *  }
- *
- * Prohibit() and Allow() make the background hang monitor work safely
- * before Startup().
  */
 class BackgroundHangMonitor
 {
 private:
   friend BackgroundHangManager;
 
   RefPtr<BackgroundHangThread> mThread;
 
@@ -210,37 +207,16 @@ public:
   /**
    * Notify the hang monitor of current thread wait.
    * Call this method before entering a wait state; call
    * NotifyActivity when subsequently exiting the wait state.
    */
   void NotifyWait();
 
   /**
-   * Prohibit the hang monitor from activating.
-   *
-   * Startup() should not be called between Prohibit() and Allow().
-   * This function makes the background hang monitor stop monitoring
-   * threads.
-   *
-   * Prohibit() and Allow() can be called before XPCOM is ready.  If
-   * we don't stop monitoring threads it could case errors.
-   */
-  static void Prohibit();
-
-  /**
-   * Allow the hang monitor to run.
-   *
-   * Allow() and Prohibit() should be called in pair.
-   *
-   * \see Prohibit()
-   */
-  static void Allow();
-
-  /**
    * Register an annotator with BHR for the current thread.
    * @param aAnnotator annotator to register
    * @return true if the annotator was registered, otherwise false.
    */
   static bool RegisterAnnotator(HangMonitor::Annotator& aAnnotator);
 
   /**
    * Unregister an annotator that was previously registered via