Bug 1113429 - Optimize NUWA idle notifications on workers, r=froydnj.
authorBen Turner <bent.mozilla@gmail.com>
Fri, 19 Dec 2014 08:27:03 -0800
changeset 220550 3285d8bef13f9baa5883270b4391bcc63a6fa5fb
parent 220549 73dbbfed2b308b9ded17da84b68aacc44a8738a7
child 220551 8a89e46f8ff29b20632599a85d2a161409aa5d41
push id53134
push userbturner@mozilla.com
push dateFri, 19 Dec 2014 16:27:01 +0000
treeherdermozilla-inbound@3285d8bef13f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfroydnj
bugs1113429
milestone37.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 1113429 - Optimize NUWA idle notifications on workers, r=froydnj.
dom/workers/WorkerPrivate.cpp
--- a/dom/workers/WorkerPrivate.cpp
+++ b/dom/workers/WorkerPrivate.cpp
@@ -68,17 +68,16 @@
 #include "nsHostObjectProtocolHandler.h"
 #include "nsJSEnvironment.h"
 #include "nsJSUtils.h"
 #include "nsNetUtil.h"
 #include "nsPrintfCString.h"
 #include "nsProxyRelease.h"
 #include "nsSandboxFlags.h"
 #include "prthread.h"
-#include "nsThread.h"
 #include "xpcpublic.h"
 
 #ifdef ANDROID
 #include <android/log.h>
 #endif
 
 #ifdef DEBUG
 #include "nsThreadManager.h"
@@ -4328,27 +4327,16 @@ WorkerPrivate::DoRunLoop(JSContext* aCx)
     }
 
     Status currentStatus;
     bool normalRunnablesPending = false;
 
     {
       MutexAutoLock lock(mMutex);
 
-#ifdef MOZ_NUWA_PROCESS
-      {
-        nsThread *thr = static_cast<nsThread*>(NS_GetCurrentThread());
-        ReentrantMonitorAutoEnter mon(thr->ThreadStatusMonitor());
-        if (mControlQueue.IsEmpty() &&
-            !(normalRunnablesPending = NS_HasPendingEvents(mThread))) {
-          thr->SetIdle();
-        }
-      }
-#endif // MOZ_NUWA_PROCESS
-
       while (mControlQueue.IsEmpty() &&
              !(normalRunnablesPending = NS_HasPendingEvents(mThread))) {
         WaitForWorkerEvents();
       }
 
       ProcessAllControlRunnablesLocked();
 
       currentStatus = mStatus;
@@ -4848,16 +4836,25 @@ WorkerPrivate::WaitForWorkerEvents(PRInt
 
   // Let the main thread know that the worker is blocked and that memory
   // reporting may proceed.
   mBlockedForMemoryReporter = true;
 
   // The main thread may be waiting so we must notify.
   mMemoryReportCondVar.Notify();
 
+#ifdef MOZ_NUWA_PROCESS
+  {
+    MOZ_ASSERT(mThread);
+
+    ReentrantMonitorAutoEnter mon(mThread->ThreadStatusMonitor());
+    mThread->SetIdle();
+  }
+#endif // MOZ_NUWA_PROCESS
+
   // Now wait for an actual worker event.
   mCondVar.Wait(aInterval);
 
   // We've gotten some kind of signal but we can't continue until the memory
   // reporter has finished. Wait again.
   while (mMemoryReporterRunning) {
     mMemoryReportCondVar.Wait();
   }