Backout change 39e167bbd14c, a80140872ea5, adae9be2294d and b71ccef9c674 (bug 970307).
☠☠ backed out by 65d98d97db61 ☠ ☠
authorCervantes Yu <cyu@mozilla.com>
Tue, 19 May 2015 14:31:25 +0800
changeset 244428 4d2839eea957ebeb1599260a05a6d74854a53fb0
parent 244427 1b09d2b41795102dbe40e0a7330e72f6b5a6ceb0
child 244429 64f0e06852480e227387fa6554d23f4a2bd8e038
push id15654
push usercyu@mozilla.com
push dateTue, 19 May 2015 06:37:15 +0000
treeherderb2g-inbound@4d2839eea957 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs970307
milestone41.0a1
backs out39e167bbd14c29ba7597529c82847fbc82c788ef
Backout change 39e167bbd14c, a80140872ea5, adae9be2294d and b71ccef9c674 (bug 970307).
dom/apps/AppsServiceChild.jsm
dom/ipc/ContentChild.cpp
dom/ipc/ContentChild.h
dom/ipc/ContentParent.cpp
dom/ipc/ContentParent.h
dom/ipc/PContent.ipdl
dom/ipc/TabChild.cpp
dom/ipc/TabChild.h
dom/ipc/jar.mn
dom/ipc/post-fork-preload.js
dom/ipc/preload.js
dom/wifi/WifiProxyService.cpp
dom/workers/WorkerPrivate.cpp
netwerk/base/nsSocketTransportService2.cpp
widget/gonk/GonkMemoryPressureMonitoring.cpp
xpcom/glue/nsThreadUtils.cpp
xpcom/glue/nsThreadUtils.h
xpcom/threads/TimerThread.cpp
xpcom/threads/nsThread.cpp
xpcom/threads/nsThread.h
xpcom/threads/nsThreadManager.cpp
xpcom/threads/nsThreadManager.h
xpcom/threads/nsThreadPool.cpp
xpcom/threads/nsTimerImpl.cpp
--- a/dom/apps/AppsServiceChild.jsm
+++ b/dom/apps/AppsServiceChild.jsm
@@ -98,38 +98,33 @@ this.DOMApplicationRegistry = {
   init: function init() {
     this.cpmm = Cc["@mozilla.org/childprocessmessagemanager;1"]
                   .getService(Ci.nsISyncMessageSender);
 
     APPS_IPC_MSG_NAMES.forEach((function(aMsgName) {
       this.cpmm.addMessageListener(aMsgName, this);
     }).bind(this));
 
-    this.resetList();
-
-    Services.obs.addObserver(this, "xpcom-shutdown", false);
-  },
-
-  resetList: function() {
     this.cpmm.sendAsyncMessage("Webapps:RegisterForMessages", {
       messages: APPS_IPC_MSG_NAMES
     });
 
     // We need to prime the cache with the list of apps.
     let list = this.cpmm.sendSyncMessage("Webapps:GetList", { })[0];
     this.webapps = list.webapps;
-
     // We need a fast mapping from localId -> app, so we add an index.
     // We also add the manifest to the app object.
     this.localIdIndex = { };
     for (let id in this.webapps) {
       let app = this.webapps[id];
       this.localIdIndex[app.localId] = app;
       app.manifest = list.manifests[id];
     }
+
+    Services.obs.addObserver(this, "xpcom-shutdown", false);
   },
 
   observe: function(aSubject, aTopic, aData) {
     // cpmm.addMessageListener causes the DOMApplicationRegistry object to
     // live forever if we don't clean up properly.
     this.webapps = null;
     this.DOMApps = null;
 
--- a/dom/ipc/ContentChild.cpp
+++ b/dom/ipc/ContentChild.cpp
@@ -533,33 +533,26 @@ private:
         MOZ_CRASH("Failed to create a PBackgroundChild actor!");
     }
 };
 
 NS_IMPL_ISUPPORTS(BackgroundChildPrimer, nsIIPCBackgroundChildCreateCallback)
 
 ContentChild* ContentChild::sSingleton;
 
-static void
-PostForkPreload()
-{
-    TabChild::PostForkPreload();
-}
-
 // Performs initialization that is not fork-safe, i.e. that must be done after
 // forking from the Nuwa process.
 static void
 InitOnContentProcessCreated()
 {
 #ifdef MOZ_NUWA_PROCESS
     // Wait until we are forked from Nuwa
     if (IsNuwaProcess()) {
         return;
     }
-    PostForkPreload();
 
     nsCOMPtr<nsIPermissionManager> permManager =
         services::GetPermissionManager();
     MOZ_ASSERT(permManager, "Unable to get permission manager");
     nsresult rv = permManager->RefreshPermission();
     if (NS_FAILED(rv)) {
         MOZ_ASSERT(false, "Failed updating permission in child process");
     }
@@ -1351,16 +1344,17 @@ ContentChild::RecvPBrowserConstructor(PB
                                       const IPCTabContext& aContext,
                                       const uint32_t& aChromeFlags,
                                       const ContentParentId& aCpID,
                                       const bool& aIsForApp,
                                       const bool& aIsForBrowser)
 {
     // This runs after AllocPBrowserChild() returns and the IPC machinery for this
     // PBrowserChild has been set up.
+
     nsCOMPtr<nsIObserverService> os = services::GetObserverService();
     if (os) {
         nsITabChild* tc =
             static_cast<nsITabChild*>(static_cast<TabChild*>(aActor));
         os->NotifyObservers(tc, "tab-child-created", nullptr);
     }
 
     static bool hasRunOnce = false;
@@ -2196,21 +2190,18 @@ ContentChild::RecvScreenSizeChanged(cons
 #endif
     return true;
 }
 
 bool
 ContentChild::RecvFlushMemory(const nsString& reason)
 {
 #ifdef MOZ_NUWA_PROCESS
-    if (IsNuwaProcess() || ManagedPBrowserChild().Length() == 0) {
+    if (IsNuwaProcess()) {
         // Don't flush memory in the nuwa process: the GC thread could be frozen.
-        // If there's no PBrowser child, don't flush memory, either. GC writes
-        // to copy-on-write pages and makes preallocated process take more memory
-        // before it actually becomes an app.
         return true;
     }
 #endif
     nsCOMPtr<nsIObserverService> os =
         mozilla::services::GetObserverService();
     if (os)
         os->NotifyObservers(nullptr, "memory-pressure", reason.get());
     return true;
@@ -2294,45 +2285,30 @@ ContentChild::RecvAppInit()
 
     // If we're part of the mozbrowser machinery, go ahead and start
     // preloading things.  We can only do this for mozbrowser because
     // PreloadSlowThings() may set the docshell of the first TabChild
     // inactive, and we can only safely restore it to active from
     // BrowserElementChild.js.
     if ((mIsForApp || mIsForBrowser)
 #ifdef MOZ_NUWA_PROCESS
-        && IsNuwaProcess()
+        && !IsNuwaProcess()
 #endif
        ) {
         PreloadSlowThings();
-#ifndef MOZ_NUWA_PROCESS
-        PostForkPreload();
-#endif
     }
 
 #ifdef MOZ_NUWA_PROCESS
-    // Some modules are initialized in preloading. We need to wait until the
-    // tasks they dispatched to chrome process are done.
-    if (IsNuwaProcess()) {
-        SendNuwaWaitForFreeze();
-    }
-#endif
-    return true;
-}
-
-bool
-ContentChild::RecvNuwaFreeze()
-{
-#ifdef MOZ_NUWA_PROCESS
     if (IsNuwaProcess()) {
         ContentChild::GetSingleton()->RecvGarbageCollect();
         MessageLoop::current()->PostTask(
             FROM_HERE, NewRunnableFunction(OnFinishNuwaPreparation));
     }
 #endif
+
     return true;
 }
 
 bool
 ContentChild::RecvLastPrivateDocShellDestroyed()
 {
     nsCOMPtr<nsIObserverService> obs = mozilla::services::GetObserverService();
     obs->NotifyObservers(nullptr, "last-pb-context-exited", nullptr);
@@ -2599,60 +2575,43 @@ DoNuwaFork()
  */
 static void
 RunNuwaFork()
 {
     if (NuwaCheckpointCurrentThread()) {
       DoNuwaFork();
     }
 }
-
-class NuwaForkCaller: public nsRunnable
-{
-public:
-    NS_IMETHODIMP
-    Run() {
-        // We want to ensure that the PBackground actor gets cloned in the Nuwa
-        // process before we freeze. Also, we have to do this to avoid deadlock.
-        // Protocols that are "opened" (e.g. PBackground, PCompositor) block the
-        // main thread to wait for the IPC thread during the open operation.
-        // NuwaSpawnWait() blocks the IPC thread to wait for the main thread when
-        // the Nuwa process is forked. Unless we ensure that the two cannot happen
-        // at the same time then we risk deadlock. Spinning the event loop here
-        // guarantees the ordering is safe for PBackground.
-        if (!BackgroundChild::GetForCurrentThread()) {
-            // Dispatch ourself again.
-            NS_DispatchToMainThread(this, NS_DISPATCH_NORMAL);
-        } else {
-            MessageLoop* ioloop = XRE_GetIOMessageLoop();
-            ioloop->PostTask(FROM_HERE, NewRunnableFunction(RunNuwaFork));
-        }
-        return NS_OK;
-    }
-private:
-    virtual
-    ~NuwaForkCaller()
-    {
-    }
-};
-
 #endif
 
 bool
 ContentChild::RecvNuwaFork()
 {
 #ifdef MOZ_NUWA_PROCESS
     if (sNuwaForking) {           // No reentry.
         return true;
     }
     sNuwaForking = true;
 
-    nsRefPtr<NuwaForkCaller> runnable = new NuwaForkCaller();
-    NS_DispatchToMainThread(runnable, NS_DISPATCH_NORMAL);
-
+    // We want to ensure that the PBackground actor gets cloned in the Nuwa
+    // process before we freeze. Also, we have to do this to avoid deadlock.
+    // Protocols that are "opened" (e.g. PBackground, PCompositor) block the
+    // main thread to wait for the IPC thread during the open operation.
+    // NuwaSpawnWait() blocks the IPC thread to wait for the main thread when
+    // the Nuwa process is forked. Unless we ensure that the two cannot happen
+    // at the same time then we risk deadlock. Spinning the event loop here
+    // guarantees the ordering is safe for PBackground.
+    while (!BackgroundChild::GetForCurrentThread()) {
+        if (NS_WARN_IF(!NS_ProcessNextEvent())) {
+            return false;
+        }
+    }
+
+    MessageLoop* ioloop = XRE_GetIOMessageLoop();
+    ioloop->PostTask(FROM_HERE, NewRunnableFunction(RunNuwaFork));
     return true;
 #else
     return false; // Makes the underlying IPC channel abort.
 #endif
 }
 
 bool
 ContentChild::RecvOnAppThemeChanged()
--- a/dom/ipc/ContentChild.h
+++ b/dom/ipc/ContentChild.h
@@ -374,18 +374,16 @@ public:
     virtual bool RecvMinimizeMemoryUsage() override;
 
     virtual bool RecvLoadAndRegisterSheet(const URIParams& aURI,
                                           const uint32_t& aType) override;
     virtual bool RecvUnregisterSheet(const URIParams& aURI, const uint32_t& aType) override;
 
     virtual bool RecvNotifyPhoneStateChange(const nsString& state) override;
 
-    virtual bool RecvNuwaFreeze() override;
-
     void AddIdleObserver(nsIObserver* aObserver, uint32_t aIdleTimeInS);
     void RemoveIdleObserver(nsIObserver* aObserver, uint32_t aIdleTimeInS);
     virtual bool RecvNotifyIdleObserver(const uint64_t& aObserver,
                                         const nsCString& aTopic,
                                         const nsString& aData) override;
 
     virtual bool RecvOnAppThemeChanged() override;
 
--- a/dom/ipc/ContentParent.cpp
+++ b/dom/ipc/ContentParent.cpp
@@ -135,17 +135,16 @@
 #include "nsIXULRuntime.h"
 #include "gfxDrawable.h"
 #include "ImageOps.h"
 #include "nsMemoryInfoDumper.h"
 #include "nsMemoryReporterManager.h"
 #include "nsServiceManagerUtils.h"
 #include "nsStyleSheetService.h"
 #include "nsThreadUtils.h"
-#include "nsThreadManager.h"
 #include "nsToolkitCompsCID.h"
 #include "nsWidgetsCID.h"
 #include "PreallocatedProcessManager.h"
 #include "ProcessPriorityManager.h"
 #include "SandboxHal.h"
 #include "ScreenManagerParent.h"
 #include "SourceSurfaceRawData.h"
 #include "StructuredCloneUtils.h"
@@ -1558,38 +1557,16 @@ private:
 };
 
 StaticAutoPtr<LinkedList<SystemMessageHandledListener> >
     SystemMessageHandledListener::sListeners;
 
 NS_IMPL_ISUPPORTS(SystemMessageHandledListener,
                   nsITimerCallback)
 
-#ifdef MOZ_NUWA_PROCESS
-class NuwaFreezeListener : public nsThreadManager::AllThreadsWereIdleListener
-{
-public:
-    NuwaFreezeListener(ContentParent* parent)
-        : mParent(parent)
-    {
-    }
-
-    void OnAllThreadsWereIdle()
-    {
-        unused << mParent->SendNuwaFreeze();
-        nsThreadManager::get()->RemoveAllThreadsWereIdleListener(this);
-    }
-private:
-    nsRefPtr<ContentParent> mParent;
-    virtual ~NuwaFreezeListener()
-    {
-    }
-};
-#endif // MOZ_NUWA_PROCESS
-
 } // anonymous namespace
 
 void
 ContentParent::MaybeTakeCPUWakeLock(Element* aFrameElement)
 {
     // Take the CPU wake lock on behalf of this processs if it's expecting a
     // system message.  We'll release the CPU lock once the message is
     // delivered, or after some period of time, which ever comes first.
@@ -2357,18 +2334,16 @@ ContentParent::ContentParent(ContentPare
     // memory priority, which it has inherited from this process.
     ProcessPriority priority;
     if (IsPreallocated()) {
         priority = PROCESS_PRIORITY_PREALLOC;
     } else {
         priority = PROCESS_PRIORITY_FOREGROUND;
     }
 
-    mSendPermissionUpdates = aTemplate->mSendPermissionUpdates;
-
     InitInternal(priority,
                  false, /* Setup Off-main thread compositing */
                  false  /* Send registered chrome */);
 
     ContentProcessManager::GetSingleton()->AddContentProcess(this);
 }
 #endif  // MOZ_NUWA_PROCESS
 
@@ -2522,17 +2497,17 @@ ContentParent::IsAlive()
 bool
 ContentParent::IsForApp()
 {
     return !mAppManifestURL.IsEmpty();
 }
 
 #ifdef MOZ_NUWA_PROCESS
 bool
-ContentParent::IsNuwaProcess() const
+ContentParent::IsNuwaProcess()
 {
     return mIsNuwaProcess;
 }
 #endif
 
 int32_t
 ContentParent::Pid()
 {
@@ -2898,29 +2873,16 @@ ContentParent::RecvNuwaReady()
     return true;
 #else
     NS_ERROR("ContentParent::RecvNuwaReady() not implemented!");
     return false;
 #endif
 }
 
 bool
-ContentParent::RecvNuwaWaitForFreeze()
-{
-#ifdef MOZ_NUWA_PROCESS
-    nsRefPtr<NuwaFreezeListener> listener = new NuwaFreezeListener(this);
-    nsThreadManager::get()->AddAllThreadsWereIdleListener(listener);
-    return true;
-#else // MOZ_NUWA_PROCESS
-    NS_ERROR("ContentParent::RecvNuwaWaitForFreeze() not implemented!");
-    return false;
-#endif // MOZ_NUWA_PROCESS
-}
-
-bool
 ContentParent::RecvAddNewProcess(const uint32_t& aPid,
                                  InfallibleTArray<ProtocolFdMapping>&& aFds)
 {
 #ifdef MOZ_NUWA_PROCESS
     if (!IsNuwaProcess()) {
         NS_ERROR(
             nsPrintfCString(
                 "Terminating child process %d for unauthorized IPC message: "
--- a/dom/ipc/ContentParent.h
+++ b/dom/ipc/ContentParent.h
@@ -228,35 +228,31 @@ public:
 
     bool IsAlive();
     virtual bool IsForApp() override;
     virtual bool IsForBrowser() override
     {
       return mIsForBrowser;
     }
 #ifdef MOZ_NUWA_PROCESS
-    bool IsNuwaProcess() const;
+    bool IsNuwaProcess();
 #endif
 
     GeckoChildProcessHost* Process() {
         return mSubprocess;
     }
 
     int32_t Pid();
 
     ContentParent* Opener() {
         return mOpener;
     }
 
     bool NeedsPermissionsUpdate() const {
-#ifdef MOZ_NUWA_PROCESS
-        return !IsNuwaProcess() && mSendPermissionUpdates;
-#else
         return mSendPermissionUpdates;
-#endif
     }
 
     bool NeedsDataStoreInfos() const {
         return mSendDataStoreInfos;
     }
 
     /**
      * Kill our subprocess and make sure it dies.  Should only be used
@@ -778,18 +774,16 @@ private:
     virtual bool RecvSpeakerManagerGetSpeakerStatus(bool* aValue) override;
 
     virtual bool RecvSpeakerManagerForceSpeaker(const bool& aEnable) override;
 
     virtual bool RecvSystemMessageHandled() override;
 
     virtual bool RecvNuwaReady() override;
 
-    virtual bool RecvNuwaWaitForFreeze() override;
-
     virtual bool RecvAddNewProcess(const uint32_t& aPid,
                                    InfallibleTArray<ProtocolFdMapping>&& aFds) override;
 
     virtual bool RecvCreateFakeVolume(const nsString& fsName, const nsString& mountPoint) override;
 
     virtual bool RecvSetFakeVolumeState(const nsString& fsName, const int32_t& fsState) override;
 
     virtual bool RecvRemoveFakeVolume(const nsString& fsName) override;
--- a/dom/ipc/PContent.ipdl
+++ b/dom/ipc/PContent.ipdl
@@ -627,17 +627,16 @@ child:
                         nsCString[] aThreadNameFilters);
     async StopProfiler();
     prio(high) sync GetProfile()
       returns (nsCString aProfile);
 
     InvokeDragSession(IPCDataTransfer[] transfers, uint32_t action);
 
     EndDragSession(bool aDoneDrag, bool aUserCancelled);
-    NuwaFreeze();
 
     async DomainSetChanged(uint32_t aSetType, uint32_t aChangeType, OptionalURIParams aDomain);
 
     /**
      * Notify the child to shutdown. The child will in turn call FinishShutdown
      * and let the parent close the channel.
      */
     async Shutdown();
@@ -894,19 +893,16 @@ parent:
                                nsString aStorageName,
                                nsString aFilepath,
                                nsCString aReason);
 
     // Notify the parent that the child has finished handling a system message.
     async SystemMessageHandled();
 
     NuwaReady();
-    // Sent when nuwa finished its initialization process and is waiting for
-    // parent's signal to make it freeze.
-    NuwaWaitForFreeze();
 
     sync AddNewProcess(uint32_t pid, ProtocolFdMapping[] aFds);
 
     // called by the child (test code only) to propagate volume changes to the parent
     async CreateFakeVolume(nsString fsName, nsString mountPoint);
     async SetFakeVolumeState(nsString fsName, int32_t fsState);
     async RemoveFakeVolume(nsString fsName);
 
--- a/dom/ipc/TabChild.cpp
+++ b/dom/ipc/TabChild.cpp
@@ -770,31 +770,16 @@ TabChild::PreloadSlowThings()
         // work.
         presShell->MakeZombie();
     }
 
     sPreallocatedTab = tab;
     ClearOnShutdown(&sPreallocatedTab);
 }
 
-/*static*/ void
-TabChild::PostForkPreload()
-{
-    // Preallocated Tab can be null if we are forked directly from b2g. In such
-    // case we don't need to preload anything, just return.
-    if (!sPreallocatedTab) {
-        return;
-    }
-
-    // Rebuild connections to parent.
-    sPreallocatedTab->RecvLoadRemoteScript(
-      NS_LITERAL_STRING("chrome://global/content/post-fork-preload.js"),
-      true);
-}
-
 /*static*/ already_AddRefed<TabChild>
 TabChild::Create(nsIContentChild* aManager,
                  const TabId& aTabId,
                  const TabContext &aContext,
                  uint32_t aChromeFlags)
 {
     if (sPreallocatedTab &&
         sPreallocatedTab->mChromeFlags == aChromeFlags &&
--- a/dom/ipc/TabChild.h
+++ b/dom/ipc/TabChild.h
@@ -258,17 +258,16 @@ public:
 
 public:
     /** 
      * This is expected to be called off the critical path to content
      * startup.  This is an opportunity to load things that are slow
      * on the critical path.
      */
     static void PreloadSlowThings();
-    static void PostForkPreload();
 
     /** Return a TabChild with the given attributes. */
     static already_AddRefed<TabChild>
     Create(nsIContentChild* aManager, const TabId& aTabId, const TabContext& aContext, uint32_t aChromeFlags);
 
     bool IsRootContentDocument();
     // Let managees query if it is safe to send messages.
     bool IsDestroyed() { return mDestroyed; }
--- a/dom/ipc/jar.mn
+++ b/dom/ipc/jar.mn
@@ -7,9 +7,8 @@ toolkit.jar:
         content/global/remote-test-ipc.js (remote-test.js)
         content/global/BrowserElementChild.js (../browser-element/BrowserElementChild.js)
         content/global/BrowserElementChildPreload.js (../browser-element/BrowserElementChildPreload.js)
         content/global/BrowserElementPanning.js (../browser-element/BrowserElementPanning.js)
 *       content/global/BrowserElementPanningAPZDisabled.js (../browser-element/BrowserElementPanningAPZDisabled.js)
         content/global/manifestMessages.js (manifestMessages.js)
         content/global/PushServiceChildPreload.js (../push/PushServiceChildPreload.js)
         content/global/preload.js (preload.js)
-        content/global/post-fork-preload.js (post-fork-preload.js)
deleted file mode 100644
--- a/dom/ipc/post-fork-preload.js
+++ /dev/null
@@ -1,20 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this file,
- * You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-// Preload some things, in an attempt to make app startup faster.
-//
-// This script is run when the preallocated process starts.  It is injected as
-// a frame script.
-// If Nuwa process is enabled, this script will run in preallocated process
-// forked by Nuwa.
-
-(function (global) {
-  "use strict";
-
-  Components.utils.import("resource://gre/modules/AppsServiceChild.jsm");
-  Components.classes["@mozilla.org/network/protocol-proxy-service;1"].
-    getService(Ci["nsIProtocolProxyService"]);
-
-  DOMApplicationRegistry.resetList();
-})(this);
--- a/dom/ipc/preload.js
+++ b/dom/ipc/preload.js
@@ -1,17 +1,16 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this file,
  * You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 // Preload some things, in an attempt to make app startup faster.
 //
 // This script is run when the preallocated process starts.  It is injected as
 // a frame script.
-// If nuwa is enabled, this script will run in Nuwa process before frozen.
 
 const BrowserElementIsPreloaded = true;
 
 (function (global) {
   "use strict";
 
   let Cu = Components.utils;
   let Cc = Components.classes;
@@ -54,16 +53,17 @@ const BrowserElementIsPreloaded = true;
   Cc["@mozilla.org/message-loop;1"].getService(Ci["nsIMessageLoop"]);
   Cc["@mozilla.org/moz/jssubscript-loader;1"].getService(Ci["mozIJSSubScriptLoader"]);
   Cc["@mozilla.org/network/application-cache-service;1"].getService(Ci["nsIApplicationCacheService"]);
   Cc["@mozilla.org/network/dns-service;1"].getService(Ci["nsIDNSService"]);
   Cc["@mozilla.org/network/effective-tld-service;1"].getService(Ci["nsIEffectiveTLDService"]);
   Cc["@mozilla.org/network/idn-service;1"].getService(Ci["nsIIDNService"]);
   Cc["@mozilla.org/network/io-service;1"].getService(Ci["nsIIOService2"]);
   Cc["@mozilla.org/network/mime-hdrparam;1"].getService(Ci["nsIMIMEHeaderParam"]);
+  Cc["@mozilla.org/network/protocol-proxy-service;1"].getService(Ci["nsIProtocolProxyService"]);
   Cc["@mozilla.org/network/socket-transport-service;1"].getService(Ci["nsISocketTransportService"]);
   Cc["@mozilla.org/network/stream-transport-service;1"].getService(Ci["nsIStreamTransportService"]);
   Cc["@mozilla.org/network/url-parser;1?auth=maybe"].getService(Ci["nsIURLParser"]);
   Cc["@mozilla.org/network/url-parser;1?auth=no"].getService(Ci["nsIURLParser"]);
   Cc["@mozilla.org/network/url-parser;1?auth=yes"].getService(Ci["nsIURLParser"]);
   Cc["@mozilla.org/observer-service;1"].getService(Ci["nsIObserverService"]);
   Cc["@mozilla.org/permissionmanager;1"].getService(Ci["nsIPermissionManager"]);
   Cc["@mozilla.org/preferences-service;1"].getService(Ci["nsIPrefBranch"]);
--- a/dom/wifi/WifiProxyService.cpp
+++ b/dom/wifi/WifiProxyService.cpp
@@ -62,19 +62,16 @@ public:
     : mInterface(aInterface)
   {
     MOZ_ASSERT(NS_IsMainThread());
   }
 
   NS_IMETHOD Run()
   {
     MOZ_ASSERT(!NS_IsMainThread());
-#ifdef MOZ_NUWA_PROCESS
-    NS_SetIgnoreStatusOfCurrentThread();
-#endif
     nsAutoString event;
     gWpaSupplicant->WaitForEvent(event, mInterface);
     if (!event.IsEmpty()) {
 #ifdef MOZ_TASK_TRACER
       // Make wifi initialization events to be the source events of TaskTracer,
       // and originate the rest correlation tasks from here.
       AutoSourceEvent taskTracerEvent(SourceEventType::Wifi);
       AddLabel("%s %s", mInterface.get(), NS_ConvertUTF16toUTF8(event).get());
--- a/dom/workers/WorkerPrivate.cpp
+++ b/dom/workers/WorkerPrivate.cpp
@@ -80,17 +80,16 @@
 #include "nsJSEnvironment.h"
 #include "nsJSUtils.h"
 #include "nsNetUtil.h"
 #include "nsPrintfCString.h"
 #include "nsProxyRelease.h"
 #include "nsQueryObject.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"
@@ -5102,27 +5101,16 @@ WorkerPrivate::DoRunLoop(JSContext* aCx)
   for (;;) {
     Status currentStatus;
     bool debuggerRunnablesPending = false;
     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() &&
              !(debuggerRunnablesPending = !mDebuggerQueue.IsEmpty()) &&
              !(normalRunnablesPending = NS_HasPendingEvents(mThread))) {
         WaitForWorkerEvents();
       }
 
       ProcessAllControlRunnablesLocked();
 
--- a/netwerk/base/nsSocketTransportService2.cpp
+++ b/netwerk/base/nsSocketTransportService2.cpp
@@ -748,17 +748,16 @@ NS_IMETHODIMP
 nsSocketTransportService::Run()
 {
     PR_SetCurrentThreadName("Socket Thread");
 
 #ifdef MOZ_NUWA_PROCESS
     if (IsNuwaProcess()) {
         NuwaMarkCurrentThread(nullptr, nullptr);
     }
-    NS_SetIgnoreStatusOfCurrentThread();
 #endif
 
     SOCKET_LOG(("STS thread init\n"));
 
 #if !defined(MOZILLA_XPCOMRT_API)
     psm::InitializeSSLServerCertVerificationThreads();
 #endif // !defined(MOZILLA_XPCOMRT_API)
 
--- a/widget/gonk/GonkMemoryPressureMonitoring.cpp
+++ b/widget/gonk/GonkMemoryPressureMonitoring.cpp
@@ -122,18 +122,16 @@ public:
 #ifdef MOZ_NUWA_PROCESS
     if (IsNuwaProcess()) {
       NS_ASSERTION(NuwaMarkCurrentThread != nullptr,
                    "NuwaMarkCurrentThread is undefined!");
       NuwaMarkCurrentThread(nullptr, nullptr);
     }
 #endif
 
-    NS_SetIgnoreStatusOfCurrentThread();
-
     int lowMemFd = open("/sys/kernel/mm/lowmemkiller/notify_trigger_active",
                         O_RDONLY | O_CLOEXEC);
     NS_ENSURE_STATE(lowMemFd != -1);
     ScopedClose autoClose(lowMemFd);
 
     nsresult rv = CheckForMemoryPressure(lowMemFd, nullptr);
     NS_ENSURE_SUCCESS(rv, rv);
 
--- a/xpcom/glue/nsThreadUtils.cpp
+++ b/xpcom/glue/nsThreadUtils.cpp
@@ -370,16 +370,8 @@ nsAutoLowPriorityIO::~nsAutoLowPriorityI
   }
 #elif defined(XP_MACOSX)
   if (MOZ_LIKELY(lowIOPrioritySet)) {
     setiopolicy_np(IOPOL_TYPE_DISK, IOPOL_SCOPE_THREAD, oldPriority);
   }
 #endif
 }
 
-#ifdef MOZ_NUWA_PROCESS
-#ifdef MOZILLA_INTERNAL_API
-void
-NS_SetIgnoreStatusOfCurrentThread() {
-  nsThreadManager::get()->SetIgnoreThreadStatus();
-}
-#endif // MOZILLA_INTERNAL_API
-#endif // MOZ_NUWA_PROCESS
--- a/xpcom/glue/nsThreadUtils.h
+++ b/xpcom/glue/nsThreadUtils.h
@@ -1014,24 +1014,9 @@ private:
 #if defined(XP_MACOSX)
   int oldPriority;
 #endif
 };
 
 void
 NS_SetMainThread();
 
-/**
- * Helpers for thread to report their status when compiled with Nuwa.
- */
-#ifdef MOZILLA_INTERNAL_API
-#ifdef MOZ_NUWA_PROCESS
-extern void
-NS_SetIgnoreStatusOfCurrentThread();
-#else // MOZ_NUWA_PROCESS
-inline void
-NS_SetIgnoreStatusOfCurrentThread()
-{
-}
-#endif // MOZ_NUWA_PROCESS
-#endif // MOZILLA_INTERNAL_API
-
 #endif  // nsThreadUtils_h__
--- a/xpcom/threads/TimerThread.cpp
+++ b/xpcom/threads/TimerThread.cpp
@@ -200,17 +200,16 @@ TimerThread::Run()
   PR_SetCurrentThreadName("Timer");
 
 #ifdef MOZ_NUWA_PROCESS
   if (IsNuwaProcess()) {
     NuwaMarkCurrentThread(nullptr, nullptr);
   }
 #endif
 
-  NS_SetIgnoreStatusOfCurrentThread();
   MonitorAutoLock lock(mMonitor);
 
   // We need to know how many microseconds give a positive PRIntervalTime. This
   // is platform-dependent and we calculate it at runtime, finding a value |v|
   // such that |PR_MicrosecondsToInterval(v) > 0| and then binary-searching in
   // the range [0, v) to find the ms-to-interval scale.
   uint32_t usForPosInterval = 1;
   while (PR_MicrosecondsToInterval(usForPosInterval) == 0) {
--- a/xpcom/threads/nsThread.cpp
+++ b/xpcom/threads/nsThread.cpp
@@ -10,16 +10,17 @@
 #include "base/message_loop.h"
 #endif // !defined(MOZILLA_XPCOMRT_API)
 
 // Chromium's logging can sometimes leak through...
 #ifdef LOG
 #undef LOG
 #endif
 
+#include "mozilla/ReentrantMonitor.h"
 #include "nsMemoryPressure.h"
 #include "nsThreadManager.h"
 #include "nsIClassInfoImpl.h"
 #include "nsAutoPtr.h"
 #include "nsCOMPtr.h"
 #include "pratom.h"
 #include "prlog.h"
 #include "nsIObserverService.h"
@@ -325,20 +326,16 @@ nsThread::ThreadFunc(void* aArg)
 #endif // !defined(MOZILLA_XPCOMRT_API)
 
   nsThread* self = static_cast<nsThread*>(aArg);  // strong reference
   self->mThread = PR_GetCurrentThread();
   SetupCurrentThreadForChaosMode();
 
   // Inform the ThreadManager
   nsThreadManager::get()->RegisterCurrentThread(self);
-#ifdef MOZ_NUWA_PROCESS
-  self->mThreadStatusInfo =
-    static_cast<void*>(nsThreadManager::get()->GetCurrentThreadStatusInfo());
-#endif
 
 #if !defined(MOZILLA_XPCOMRT_API)
   mozilla::IOInterposer::RegisterCurrentThread();
 #endif // !defined(MOZILLA_XPCOMRT_API)
 
   // Wait for and process startup event
   nsCOMPtr<nsIRunnable> event;
   if (!self->GetEvent(true, getter_AddRefs(event))) {
@@ -446,20 +443,16 @@ nsThread::nsThread(MainThreadFlag aMainT
   , mPriority(PRIORITY_NORMAL)
   , mThread(nullptr)
   , mNestedEventLoopDepth(0)
   , mStackSize(aStackSize)
   , mShutdownContext(nullptr)
   , mShutdownRequired(false)
   , mEventsAreDoomed(false)
   , mIsMainThread(aMainThread)
-#ifdef MOZ_NUWA_PROCESS
-  , mThreadStatusMonitor("nsThread.mThreadStatusLock")
-  , mThreadStatusInfo(nullptr)
-#endif
 {
 }
 
 nsThread::~nsThread()
 {
 }
 
 nsresult
@@ -497,45 +490,32 @@ nsThread::Init()
 
 nsresult
 nsThread::InitCurrentThread()
 {
   mThread = PR_GetCurrentThread();
   SetupCurrentThreadForChaosMode();
 
   nsThreadManager::get()->RegisterCurrentThread(this);
-#ifdef MOZ_NUWA_PROCESS
-  mThreadStatusInfo =
-    static_cast<void*>(nsThreadManager::get()->GetCurrentThreadStatusInfo());
-#endif
-
   return NS_OK;
 }
 
 nsresult
 nsThread::PutEvent(nsIRunnable* aEvent, nsNestedEventTarget* aTarget)
 {
   nsCOMPtr<nsIThreadObserver> obs;
 
   {
     MutexAutoLock lock(mLock);
     nsChainedEventQueue* queue = aTarget ? aTarget->mQueue : &mEventsRoot;
     if (!queue || (queue == &mEventsRoot && mEventsAreDoomed)) {
       NS_WARNING("An event was posted to a thread that will never run it (rejected)");
       return NS_ERROR_UNEXPECTED;
     }
-#ifdef MOZ_NUWA_PROCESS
-    {
-      ReentrantMonitorAutoEnter mon(mThreadStatusMonitor);
-      SetWorking();
-#endif // MOZ_NUWA_PROCESS
-      queue->PutEvent(aEvent);
-#ifdef MOZ_NUWA_PROCESS
-    }
-#endif // MOZ_NUWA_PROCESS
+    queue->PutEvent(aEvent);
 
     // Make sure to grab the observer before dropping the lock, otherwise the
     // event that we just placed into the queue could run and eventually delete
     // this nsThread before the calling thread is scheduled again. We would then
     // crash while trying to access a dead nsThread.
     obs = mObserver;
   }
 
@@ -868,37 +848,16 @@ nsThread::ProcessNextEvent(bool aMayWait
       MOZ_ASSERT(ShuttingDown(),
                  "This should only happen when shutting down");
       rv = NS_ERROR_UNEXPECTED;
     }
   }
 
   --mNestedEventLoopDepth;
 
-#ifdef MOZ_NUWA_PROCESS
-  nsCOMPtr<nsIRunnable> notifyAllIdleRunnable;
-  {
-    ReentrantMonitorAutoEnter mon(mThreadStatusMonitor);
-    if ((!mEvents->GetEvent(false, nullptr)) && (mNestedEventLoopDepth == 0)) {
-      nsThreadManager::get()->SetThreadIsWorking(
-        static_cast<nsThreadManager::ThreadStatusInfo*>(mThreadStatusInfo),
-        false, getter_AddRefs(notifyAllIdleRunnable));
-    }
-  }
-  if (notifyAllIdleRunnable) {
-    // Dispatching a task leads us to acquire |mLock| of the thread. If we
-    // dispatch to main thread while holding main thread's
-    // |mThreadStatusMonitor|, deadlock could happen if other thread is
-    // blocked by main thread's |mThreadStatusMonitor| and is holding
-    // main thread's |mLock|.
-    Dispatch(notifyAllIdleRunnable, NS_DISPATCH_NORMAL);
-    nsThreadManager::get()->ResetIsDispatchingToMainThread();
-  }
-#endif // MOZ_NUWA_PROCESS
-
   NOTIFY_EVENT_OBSERVERS(AfterProcessNextEvent,
                          (this, mNestedEventLoopDepth, *aResult));
 
   if (obs) {
     obs->AfterProcessNextEvent(this, mNestedEventLoopDepth, *aResult);
   }
 
   if (notifyMainThreadObserver && sMainThreadObserver) {
@@ -1099,34 +1058,16 @@ nsThread::SetMainThreadObserver(nsIThrea
   if (!NS_IsMainThread()) {
     return NS_ERROR_UNEXPECTED;
   }
 
   nsThread::sMainThreadObserver = aObserver;
   return NS_OK;
 }
 
-#ifdef MOZ_NUWA_PROCESS
-void
-nsThread::SetWorking()
-{
-  nsThreadManager::get()->SetThreadIsWorking(
-    static_cast<nsThreadManager::ThreadStatusInfo*>(mThreadStatusInfo),
-    true, nullptr);
-}
-
-void
-nsThread::SetIdle()
-{
-  nsThreadManager::get()->SetThreadIsWorking(
-    static_cast<nsThreadManager::ThreadStatusInfo*>(mThreadStatusInfo),
-    false, nullptr);
-}
-#endif
-
 //-----------------------------------------------------------------------------
 
 NS_IMETHODIMP
 nsThreadSyncDispatch::Run()
 {
   if (mSyncTask) {
     mResult = mSyncTask->Run();
     mSyncTask = nullptr;
--- a/xpcom/threads/nsThread.h
+++ b/xpcom/threads/nsThread.h
@@ -11,17 +11,16 @@
 #include "nsIThreadInternal.h"
 #include "nsISupportsPriority.h"
 #include "nsEventQueue.h"
 #include "nsThreadUtils.h"
 #include "nsString.h"
 #include "nsTObserverArray.h"
 #include "mozilla/Attributes.h"
 #include "nsAutoPtr.h"
-#include "mozilla/ReentrantMonitor.h"
 
 // A native thread
 class nsThread
   : public nsIThreadInternal
   , public nsISupportsPriority
 {
 public:
   NS_DECL_THREADSAFE_ISUPPORTS
@@ -61,24 +60,16 @@ public:
   void ClearObservers()
   {
     mEventObservers.Clear();
   }
 
   static nsresult
   SetMainThreadObserver(nsIThreadObserver* aObserver);
 
-#ifdef MOZ_NUWA_PROCESS
-  void SetWorking();
-  void SetIdle();
-  mozilla::ReentrantMonitor& ThreadStatusMonitor() {
-    return mThreadStatusMonitor;
-  }
-#endif
-
 protected:
   static nsIThreadObserver* sMainThreadObserver;
 
   class nsChainedEventQueue;
 
   class nsNestedEventTarget;
   friend class nsNestedEventTarget;
 
@@ -186,22 +177,16 @@ protected:
   uint32_t  mStackSize;
 
   struct nsThreadShutdownContext* mShutdownContext;
 
   bool mShutdownRequired;
   // Set to true when events posted to this thread will never run.
   bool mEventsAreDoomed;
   MainThreadFlag mIsMainThread;
-#ifdef MOZ_NUWA_PROCESS
-  mozilla::ReentrantMonitor mThreadStatusMonitor;
-  // The actual type is defined in nsThreadManager.h which is not exposed to
-  // file out of thread module.
-  void* mThreadStatusInfo;
-#endif
 };
 
 //-----------------------------------------------------------------------------
 
 class nsThreadSyncDispatch : public nsRunnable
 {
 public:
   nsThreadSyncDispatch(nsIThread* aOrigin, nsIRunnable* aTask)
--- a/xpcom/threads/nsThreadManager.cpp
+++ b/xpcom/threads/nsThreadManager.cpp
@@ -6,17 +6,16 @@
 
 #include "nsThreadManager.h"
 #include "nsThread.h"
 #include "nsThreadUtils.h"
 #include "nsIClassInfoImpl.h"
 #include "nsTArray.h"
 #include "nsAutoPtr.h"
 #include "mozilla/ThreadLocal.h"
-#include "mozilla/ReentrantMonitor.h"
 #ifdef MOZ_CANARY
 #include <fcntl.h>
 #include <unistd.h>
 #endif
 
 using namespace mozilla;
 
 static mozilla::ThreadLocal<bool> sTLSIsMainThread;
@@ -36,81 +35,24 @@ NS_SetMainThread()
     }
     sTLSIsMainThread.set(true);
   }
   MOZ_ASSERT(NS_IsMainThread());
 }
 
 typedef nsTArray<nsRefPtr<nsThread>> nsThreadArray;
 
-#ifdef MOZ_NUWA_PROCESS
-class NotifyAllThreadsWereIdle: public nsRunnable
-{
-public:
-
-  NotifyAllThreadsWereIdle(
-    nsTArray<nsRefPtr<nsThreadManager::AllThreadsWereIdleListener>>* aListeners)
-    : mListeners(aListeners)
-  {
-  }
-
-  virtual NS_IMETHODIMP
-  Run() {
-    // Copy listener array, which may be modified during call back.
-    nsTArray<nsRefPtr<nsThreadManager::AllThreadsWereIdleListener>> arr(*mListeners);
-    for (size_t i = 0; i < arr.Length(); i++) {
-      arr[i]->OnAllThreadsWereIdle();
-    }
-    return NS_OK;
-  }
-
-private:
-  // Raw pointer, since it's pointing to a  member of thread manager.
-  nsTArray<nsRefPtr<nsThreadManager::AllThreadsWereIdleListener>>* mListeners;
-};
-
-struct nsThreadManager::ThreadStatusInfo {
-  Atomic<bool> mWorking;
-  Atomic<bool> mWillBeWorking;
-  bool mIgnored;
-  ThreadStatusInfo()
-    : mWorking(false)
-    , mWillBeWorking(false)
-    , mIgnored(false)
-  {
-  }
-};
-#endif // MOZ_NUWA_PROCESS
-
 //-----------------------------------------------------------------------------
 
 static void
 ReleaseObject(void* aData)
 {
   static_cast<nsISupports*>(aData)->Release();
 }
 
-#ifdef MOZ_NUWA_PROCESS
-void
-nsThreadManager::DeleteThreadStatusInfo(void* aData)
-{
-  nsThreadManager* mgr = nsThreadManager::get();
-  nsThreadManager::ThreadStatusInfo* thrInfo =
-    static_cast<nsThreadManager::ThreadStatusInfo*>(aData);
-  {
-    ReentrantMonitorAutoEnter mon(*(mgr->mMonitor));
-    mgr->mThreadStatusInfos.RemoveElement(thrInfo);
-    if (NS_IsMainThread()) {
-      mgr->mMainThreadStatusInfo = nullptr;
-    }
-  }
-  delete thrInfo;
-}
-#endif
-
 static PLDHashOperator
 AppendAndRemoveThread(PRThread* aKey, nsRefPtr<nsThread>& aThread, void* aArg)
 {
   nsThreadArray* threads = static_cast<nsThreadArray*>(aArg);
   threads->AppendElement(aThread);
   return PL_DHASH_REMOVE;
 }
 
@@ -142,27 +84,16 @@ nsThreadManager::Init()
   if (mInitialized) {
     return NS_OK;
   }
 
   if (PR_NewThreadPrivateIndex(&mCurThreadIndex, ReleaseObject) == PR_FAILURE) {
     return NS_ERROR_FAILURE;
   }
 
-#ifdef MOZ_NUWA_PROCESS
-  if (PR_NewThreadPrivateIndex(
-      &mThreadStatusInfoIndex,
-      nsThreadManager::DeleteThreadStatusInfo) == PR_FAILURE) {
-    return NS_ERROR_FAILURE;
-  }
-#endif // MOZ_NUWA_PROCESS
-
-#ifdef MOZ_NUWA_PROCESS
-  mMonitor = MakeUnique<ReentrantMonitor>("nsThreadManager.mMonitor");
-#endif // MOZ_NUWA_PROCESS
 
 #ifdef MOZ_CANARY
   const int flags = O_WRONLY | O_APPEND | O_CREAT | O_NONBLOCK;
   const mode_t mode = S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH;
   char* env_var_flag = getenv("MOZ_KILL_CANARIES");
   sCanaryOutputFD =
     env_var_flag ? (env_var_flag[0] ? open(env_var_flag, flags, mode) :
                                       STDERR_FILENO) :
@@ -245,19 +176,16 @@ nsThreadManager::Shutdown()
   mMainThread->SetObserver(nullptr);
   mMainThread->ClearObservers();
 
   // Release main thread object.
   mMainThread = nullptr;
 
   // Remove the TLS entry for the main thread.
   PR_SetThreadPrivate(mCurThreadIndex, nullptr);
-#ifdef MOZ_NUWA_PROCESS
-  PR_SetThreadPrivate(mThreadStatusInfoIndex, nullptr);
-#endif
 }
 
 void
 nsThreadManager::RegisterCurrentThread(nsThread* aThread)
 {
   MOZ_ASSERT(aThread->GetPRThread() == PR_GetCurrentThread(), "bad aThread");
 
   OffTheBooksMutexAutoLock lock(mLock);
@@ -280,19 +208,16 @@ nsThreadManager::UnregisterCurrentThread
 
   OffTheBooksMutexAutoLock lock(mLock);
 
   --mCurrentNumberOfThreads;
   mThreadsByPRThread.Remove(aThread->GetPRThread());
 
   PR_SetThreadPrivate(mCurThreadIndex, nullptr);
   // Ref-count balanced via ReleaseObject
-#ifdef MOZ_NUWA_PROCESS
-  PR_SetThreadPrivate(mThreadStatusInfoIndex, nullptr);
-#endif
 }
 
 nsThread*
 nsThreadManager::GetCurrentThread()
 {
   // read thread local storage
   void* data = PR_GetThreadPrivate(mCurThreadIndex);
   if (data) {
@@ -307,37 +232,16 @@ nsThreadManager::GetCurrentThread()
   nsRefPtr<nsThread> thread = new nsThread(nsThread::NOT_MAIN_THREAD, 0);
   if (!thread || NS_FAILED(thread->InitCurrentThread())) {
     return nullptr;
   }
 
   return thread.get();  // reference held in TLS
 }
 
-#ifdef MOZ_NUWA_PROCESS
-nsThreadManager::ThreadStatusInfo*
-nsThreadManager::GetCurrentThreadStatusInfo()
-{
-  void* data = PR_GetThreadPrivate(mThreadStatusInfoIndex);
-  if (!data) {
-    ThreadStatusInfo *thrInfo = new ThreadStatusInfo();
-    PR_SetThreadPrivate(mThreadStatusInfoIndex, thrInfo);
-    data = thrInfo;
-
-    ReentrantMonitorAutoEnter mon(*mMonitor);
-    mThreadStatusInfos.AppendElement(thrInfo);
-    if (NS_IsMainThread()) {
-      mMainThreadStatusInfo = thrInfo;
-    }
-  }
-
-  return static_cast<ThreadStatusInfo*>(data);
-}
-#endif
-
 NS_IMETHODIMP
 nsThreadManager::NewThread(uint32_t aCreationFlags,
                            uint32_t aStackSize,
                            nsIThread** aResult)
 {
   // Note: can be called from arbitrary threads
   
   // No new threads during Shutdown
@@ -424,162 +328,8 @@ nsThreadManager::GetIsMainThread(bool* a
 }
 
 uint32_t
 nsThreadManager::GetHighestNumberOfThreads()
 {
   OffTheBooksMutexAutoLock lock(mLock);
   return mHighestNumberOfThreads;
 }
-
-#ifdef MOZ_NUWA_PROCESS
-void
-nsThreadManager::SetIgnoreThreadStatus()
-{
-  GetCurrentThreadStatusInfo()->mIgnored = true;
-}
-
-void
-nsThreadManager::SetThreadIdle(nsIRunnable **aReturnRunnable)
-{
-  SetThreadIsWorking(GetCurrentThreadStatusInfo(), false, aReturnRunnable);
-}
-
-void
-nsThreadManager::SetThreadWorking()
-{
-  SetThreadIsWorking(GetCurrentThreadStatusInfo(), true, nullptr);
-}
-
-void
-nsThreadManager::SetThreadIsWorking(ThreadStatusInfo* aInfo,
-                                    bool aIsWorking,
-                                    nsIRunnable **aReturnRunnable)
-{
-  aInfo->mWillBeWorking = aIsWorking;
-  if (mThreadsIdledListeners.Length() > 0) {
-
-    // A race condition occurs since we don't want threads to try to enter the
-    // monitor (nsThreadManager::mMonitor) when no one cares about their status.
-    // And thus the race can happen when we put the first listener into
-    // |mThreadsIdledListeners|:
-    //
-    // (1) Thread A wants to dispatch a task to Thread B.
-    // (2) Thread A checks |mThreadsIdledListeners|, and nothing is in the
-    //     list. So Thread A decides not to enter |mMonitor| when updating B's
-    //     status.
-    // (3) Thread A is suspended just before it changed status of B.
-    // (4) A listener is added to |mThreadsIdledListeners|
-    // (5) Now is Thread C's turn to run. Thread C finds there's something in
-    //     |mThreadsIdledListeners|, so it enters |mMonitor| and check all
-    //     thread info structs in |mThreadStatusInfos| while A is in the middle
-    //     of changing B's status.
-    //
-    // Then C may find Thread B is an idle thread (which is not correct, because
-    // A attempted to change B's status prior to C starting to walk throught
-    // |mThreadStatusInfo|), but the fact that thread A is working (thread A
-    // hasn't finished dispatching a task to thread B) can prevent thread C from
-    // firing a bogus notification.
-    //
-    // If the state transition that happens outside the monitor is in the other
-    // direction, the race condition could be:
-    //
-    // (1) Thread D has just finished its jobs and wants to set its status to idle.
-    // (2) Thread D checks |mThreadsIdledListeners|, and nothing is in the list.
-    //     So Thread D decides not to enter |mMonitor|.
-    // (3) Thread D is is suspended before it updates its own status.
-    // (4) A listener is put into |mThreadsIdledListeners|.
-    // (5) Thread C wants to changes status of itself. It checks
-    //     |mThreadsIdledListeners| and finds something inside the list. Thread C
-    //     then enters |mMonitor|, updates its status and checks thread info in
-    //     |mThreadStatusInfos| while D is changing status of itself out of monitor.
-    //
-    // Thread C will find that thread D is working (D actually wants to change its
-    // status to idle before C starting to check), then C returns without firing
-    // any notification. Finding that thread D is working can make our checking
-    // mechanism miss a chance to fire a notification: because thread D thought
-    // there's nothing in |mThreadsIdledListeners| and thus won't check the
-    // |mThreadStatusInfos| after changing the status of itself.
-    //
-    // |mWillBeWorking| can be used to address this problem. We require each
-    // thread to put the value that is going to be set to |mWorking| to
-    // |mWillBeWorking| before the thread decide whether it should enter
-    // |mMonitor| to change status or not. Thus C finds that D is working while
-    // D's |mWillBeWorking| is false, and C realizes that D is just updating and
-    // can treat D as an idle thread.
-    //
-    // It doesn't matter whether D will check thread status after changing its
-    // own status or not. If D checks, which means D will enter the monitor
-    // before updating status, thus D must be blocked until C has finished
-    // dispatching the notification task to main thread, and D will find that main
-    // thread is working and will not fire an additional event. On the other hand,
-    // if D doesn't check |mThreadStatusInfos|, it's still ok, because C has
-    // treated D as an idle thread already.
-
-    bool hasWorkingThread = false;
-    nsRefPtr<NotifyAllThreadsWereIdle> runnable;
-    {
-      ReentrantMonitorAutoEnter mon(*mMonitor);
-      // Get data structure of thread info.
-      aInfo->mWorking = aIsWorking;
-      if (aIsWorking) {
-        // We are working, so there's no need to check futher.
-        return;
-      }
-
-      for (size_t i = 0; i < mThreadStatusInfos.Length(); i++) {
-        ThreadStatusInfo *info = mThreadStatusInfos[i];
-        if (!info->mIgnored) {
-          if (info->mWorking) {
-            if (info->mWillBeWorking) {
-              hasWorkingThread = true;
-              break;
-            }
-          }
-        }
-      }
-      if (!hasWorkingThread && !mDispatchingToMainThread) {
-        runnable = new NotifyAllThreadsWereIdle(&mThreadsIdledListeners);
-        mDispatchingToMainThread = true;
-      }
-    }
-
-    if (runnable) {
-      if (NS_IsMainThread()) {
-        // We are holding the main thread's |nsThread::mThreadStatusMonitor|.
-        // If we dispatch a task to ourself, then we are in danger of causing
-        // deadlock. Instead, return the task, and let the caller dispatch it
-        // for us.
-        MOZ_ASSERT(aReturnRunnable,
-                   "aReturnRunnable must be provided on main thread");
-        runnable.forget(aReturnRunnable);
-      } else {
-        NS_DispatchToMainThread(runnable);
-        ResetIsDispatchingToMainThread();
-      }
-    }
-  } else {
-    // Update thread info without holding any lock.
-    aInfo->mWorking = aIsWorking;
-  }
-}
-
-void
-nsThreadManager::ResetIsDispatchingToMainThread()
-{
-  ReentrantMonitorAutoEnter mon(*mMonitor);
-  mDispatchingToMainThread = false;
-}
-
-void
-nsThreadManager::AddAllThreadsWereIdleListener(AllThreadsWereIdleListener *listener)
-{
-  MOZ_ASSERT(GetCurrentThreadStatusInfo()->mWorking);
-  mThreadsIdledListeners.AppendElement(listener);
-}
-
-void
-nsThreadManager::RemoveAllThreadsWereIdleListener(AllThreadsWereIdleListener *listener)
-{
-  mThreadsIdledListeners.RemoveElement(listener);
-}
-
-#endif // MOZ_NUWA_PROCESS
--- a/xpcom/threads/nsThreadManager.h
+++ b/xpcom/threads/nsThreadManager.h
@@ -9,36 +9,19 @@
 
 #include "mozilla/Mutex.h"
 #include "nsIThreadManager.h"
 #include "nsRefPtrHashtable.h"
 #include "nsThread.h"
 
 class nsIRunnable;
 
-namespace mozilla {
-class ReentrantMonitor;
-}
-
 class nsThreadManager : public nsIThreadManager
 {
 public:
-#ifdef MOZ_NUWA_PROCESS
-  struct ThreadStatusInfo;
-  class AllThreadsWereIdleListener {
-  public:
-    NS_INLINE_DECL_REFCOUNTING(AllThreadsWereIdleListener);
-    virtual void OnAllThreadsWereIdle() = 0;
-  protected:
-    virtual ~AllThreadsWereIdleListener()
-    {
-    }
-  };
-#endif // MOZ_NUWA_PROCESS
-
   NS_DECL_ISUPPORTS
   NS_DECL_NSITHREADMANAGER
 
   static nsThreadManager* get()
   {
     static nsThreadManager sInstance;
     return &sInstance;
   }
@@ -66,81 +49,38 @@ public:
   uint32_t GetHighestNumberOfThreads();
 
   // This needs to be public in order to support static instantiation of this
   // class with older compilers (e.g., egcs-2.91.66).
   ~nsThreadManager()
   {
   }
 
-#ifdef MOZ_NUWA_PROCESS
-  void SetIgnoreThreadStatus();
-
-  // |SetThreadWorking| and |SetThreadIdle| set status of thread that is
-  // currently running. They get thread status information from TLS and pass
-  // the information to |SetThreadIsWorking|.
-  void SetThreadIdle(nsIRunnable** aReturnRunnable);
-  void SetThreadWorking();
-
-  // |SetThreadIsWorking| is where is status actually changed. Thread status
-  // information is passed as a argument so caller must obtain the structure
-  // by itself. If this method is invoked on main thread, |aReturnRunnable|
-  // should be provided to receive the runnable of notifying listeners.
-  // |ResetIsDispatchingToMainThread| should be invoked after caller on main
-  // thread dispatched the task to main thread's queue.
-  void SetThreadIsWorking(ThreadStatusInfo* aInfo,
-                          bool aIsWorking,
-                          nsIRunnable** aReturnRunnable);
-  void ResetIsDispatchingToMainThread();
-
-  void AddAllThreadsWereIdleListener(AllThreadsWereIdleListener *listener);
-  void RemoveAllThreadsWereIdleListener(AllThreadsWereIdleListener *listener);
-  ThreadStatusInfo* GetCurrentThreadStatusInfo();
-#endif // MOZ_NUWA_PROCESS
-
 private:
   nsThreadManager()
     : mCurThreadIndex(0)
     , mMainPRThread(nullptr)
     , mLock("nsThreadManager.mLock")
     , mInitialized(false)
     , mCurrentNumberOfThreads(1)
     , mHighestNumberOfThreads(1)
-#ifdef MOZ_NUWA_PROCESS
-    , mMonitor(nullptr)
-    , mMainThreadStatusInfo(nullptr)
-    , mDispatchingToMainThread(nullptr)
-#endif
   {
   }
 
   nsRefPtrHashtable<nsPtrHashKey<PRThread>, nsThread> mThreadsByPRThread;
   unsigned            mCurThreadIndex;  // thread-local-storage index
   nsRefPtr<nsThread>  mMainThread;
   PRThread*           mMainPRThread;
   mozilla::OffTheBooksMutex mLock;  // protects tables
   mozilla::Atomic<bool> mInitialized;
 
   // The current number of threads
   uint32_t            mCurrentNumberOfThreads;
   // The highest number of threads encountered so far during the session
   uint32_t            mHighestNumberOfThreads;
-
-#ifdef MOZ_NUWA_PROCESS
-  static void DeleteThreadStatusInfo(void *aData);
-  unsigned mThreadStatusInfoIndex;
-  nsTArray<nsRefPtr<AllThreadsWereIdleListener>> mThreadsIdledListeners;
-  nsTArray<ThreadStatusInfo*> mThreadStatusInfos;
-  mozilla::UniquePtr<mozilla::ReentrantMonitor> mMonitor;
-  ThreadStatusInfo* mMainThreadStatusInfo;
-  // |mDispatchingToMainThread| is set when all thread are found to be idle
-  // before task of notifying all listeners are dispatched to main thread.
-  // The flag is protected by |mMonitor|.
-  bool mDispatchingToMainThread;
-#endif // MOZ_NUWA_PROCESS
 };
 
 #define NS_THREADMANAGER_CID                       \
 { /* 7a4204c6-e45a-4c37-8ebb-6709a22c917c */       \
   0x7a4204c6,                                      \
   0xe45a,                                          \
   0x4c37,                                          \
   {0x8e, 0xbb, 0x67, 0x09, 0xa2, 0x2c, 0x91, 0x7c} \
--- a/xpcom/threads/nsThreadPool.cpp
+++ b/xpcom/threads/nsThreadPool.cpp
@@ -146,16 +146,17 @@ nsThreadPool::ShutdownThread(nsIThread* 
   nsCOMPtr<nsIRunnable> r = NS_NewRunnableMethod(aThread, &nsIThread::Shutdown);
   NS_DispatchToMainThread(r);
 }
 
 NS_IMETHODIMP
 nsThreadPool::Run()
 {
   LOG(("THRD-P(%p) enter\n", this));
+
   mThreadNaming.SetThreadPoolName(mName);
 
   nsCOMPtr<nsIThread> current;
   nsThreadManager::get()->GetCurrentThread(getter_AddRefs(current));
 
   bool shutdownThreadOnExit = false;
   bool exitThread = false;
   bool wasIdle = false;
@@ -203,31 +204,25 @@ nsThreadPool::Run()
         if (exitThread) {
           if (wasIdle) {
             --mIdleCount;
           }
           shutdownThreadOnExit = mThreads.RemoveObject(current);
         } else {
           PRIntervalTime delta = timeout - (now - idleSince);
           LOG(("THRD-P(%p) waiting [%d]\n", this, delta));
-#ifdef MOZ_NUWA_PROCESS
-          nsThreadManager::get()->SetThreadIdle(nullptr);
-#endif // MOZ_NUWA_PROCESS
           mon.Wait(delta);
         }
       } else if (wasIdle) {
         wasIdle = false;
         --mIdleCount;
       }
     }
     if (event) {
       LOG(("THRD-P(%p) running [%p]\n", this, event.get()));
-#ifdef MOZ_NUWA_PROCESS
-      nsThreadManager::get()->SetThreadWorking();
-#endif // MOZ_NUWA_PROCESS
       event->Run();
     }
   } while (!exitThread);
 
   if (listener) {
     listener->OnThreadShuttingDown();
   }
 
--- a/xpcom/threads/nsTimerImpl.cpp
+++ b/xpcom/threads/nsTimerImpl.cpp
@@ -544,23 +544,16 @@ nsTimerImpl::SetTarget(nsIEventTarget* a
 
 void
 nsTimerImpl::Fire()
 {
   if (mCanceled) {
     return;
   }
 
-#ifdef MOZ_NUWA_PROCESS
-  if (IsNuwaProcess() && IsNuwaReady()) {
-    // A timer event fired after Nuwa frozen can freeze main thread.
-    return;
-  }
-#endif
-
 #if !defined(MOZILLA_XPCOMRT_API)
   PROFILER_LABEL("Timer", "Fire",
                  js::ProfileEntry::Category::OTHER);
 #endif
 
 #ifdef MOZ_TASK_TRACER
   // mTracedTask is an instance of FakeTracedTask created by
   // DispatchTracedTask(). AutoRunFakeTracedTask logs the begin/end time of the