Bug 1591923 - Remove some dead code for cooperative contexts from XPConnect, XPCOM and JSAPI. r=mccr8
authorJan de Mooij <jdemooij@mozilla.com>
Mon, 28 Oct 2019 14:38:03 +0000
changeset 499468 bb62609416c8981592cd5a39d8b8654964b918ec
parent 499467 bbd49f460213524f5d956f7236a480a48b078c10
child 499469 c65ef27b6fc78ec5140068913209bad3b55f1139
push id114161
push userncsoregi@mozilla.com
push dateTue, 29 Oct 2019 21:34:24 +0000
treeherdermozilla-inbound@25bf8e097e60 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmccr8
bugs1591923
milestone72.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 1591923 - Remove some dead code for cooperative contexts from XPConnect, XPCOM and JSAPI. r=mccr8 Differential Revision: https://phabricator.services.mozilla.com/D50802
js/src/jsapi.cpp
js/src/jsapi.h
js/xpconnect/src/XPCJSContext.cpp
js/xpconnect/src/nsXPConnect.cpp
js/xpconnect/src/xpcprivate.h
js/xpconnect/src/xpcpublic.h
xpcom/base/CycleCollectedJSContext.cpp
xpcom/base/CycleCollectedJSContext.h
xpcom/base/nsCycleCollector.cpp
xpcom/base/nsCycleCollector.h
--- a/js/src/jsapi.cpp
+++ b/js/src/jsapi.cpp
@@ -364,28 +364,16 @@ JS_PUBLIC_API JSContext* JS_NewContext(u
   // Make sure that all parent runtimes are the topmost parent.
   while (parentRuntime && parentRuntime->parentRuntime) {
     parentRuntime = parentRuntime->parentRuntime;
   }
 
   return NewContext(maxbytes, parentRuntime);
 }
 
-JS_PUBLIC_API JSContext* JS_NewCooperativeContext(JSContext* siblingContext) {
-  MOZ_CRASH("Cooperative scheduling is unsupported");
-}
-
-JS_PUBLIC_API void JS_YieldCooperativeContext(JSContext* cx) {
-  MOZ_CRASH("Cooperative scheduling is unsupported");
-}
-
-JS_PUBLIC_API void JS_ResumeCooperativeContext(JSContext* cx) {
-  MOZ_CRASH("Cooperative scheduling is unsupported");
-}
-
 JS_PUBLIC_API void JS_DestroyContext(JSContext* cx) { DestroyContext(cx); }
 
 JS_PUBLIC_API void* JS_GetContextPrivate(JSContext* cx) { return cx->data; }
 
 JS_PUBLIC_API void JS_SetContextPrivate(JSContext* cx, void* data) {
   cx->data = data;
 }
 
--- a/js/src/jsapi.h
+++ b/js/src/jsapi.h
@@ -324,38 +324,18 @@ extern JS_PUBLIC_API bool JS_IsBuiltinFu
  * See:
  * https://developer.mozilla.org/en-US/docs/Mozilla/Projects/SpiderMonkey/JSAPI_reference
  */
 
 // Create a new context (and runtime) for this thread.
 extern JS_PUBLIC_API JSContext* JS_NewContext(
     uint32_t maxbytes, JSRuntime* parentRuntime = nullptr);
 
-// The methods below for controlling the active context in a cooperatively
-// multithreaded runtime are not threadsafe, and the caller must ensure they
-// are called serially if there is a chance for contention between threads.
-
-// Called from the active context for a runtime, yield execution so that
-// this context is no longer active and can no longer use the API.
-extern JS_PUBLIC_API void JS_YieldCooperativeContext(JSContext* cx);
-
-// Called from a context whose runtime has no active context, this thread
-// becomes the active context for that runtime and may use the API.
-extern JS_PUBLIC_API void JS_ResumeCooperativeContext(JSContext* cx);
-
-// Create a new context on this thread for cooperative multithreading in the
-// same runtime as siblingContext. Called on a runtime (as indicated by
-// siblingContet) which has no active context, on success the new context will
-// become the runtime's active context.
-extern JS_PUBLIC_API JSContext* JS_NewCooperativeContext(
-    JSContext* siblingContext);
-
-// Destroy a context allocated with JS_NewContext or JS_NewCooperativeContext.
-// The context must be the current active context in the runtime, and after
-// this call the runtime will have no active context.
+// Destroy a context allocated with JS_NewContext. Must be called on the thread
+// that called JS_NewContext.
 extern JS_PUBLIC_API void JS_DestroyContext(JSContext* cx);
 
 JS_PUBLIC_API void* JS_GetContextPrivate(JSContext* cx);
 
 JS_PUBLIC_API void JS_SetContextPrivate(JSContext* cx, void* data);
 
 extern JS_PUBLIC_API JSRuntime* JS_GetParentRuntime(JSContext* cx);
 
--- a/js/xpconnect/src/XPCJSContext.cpp
+++ b/js/xpconnect/src/XPCJSContext.cpp
@@ -1092,24 +1092,19 @@ static size_t GetWindowsStackSize() {
 XPCJSRuntime* XPCJSContext::Runtime() const {
   return static_cast<XPCJSRuntime*>(CycleCollectedJSContext::Runtime());
 }
 
 CycleCollectedJSRuntime* XPCJSContext::CreateRuntime(JSContext* aCx) {
   return new XPCJSRuntime(aCx);
 }
 
-nsresult XPCJSContext::Initialize(XPCJSContext* aPrimaryContext) {
-  nsresult rv;
-  if (aPrimaryContext) {
-    rv = CycleCollectedJSContext::InitializeNonPrimary(aPrimaryContext);
-  } else {
-    rv = CycleCollectedJSContext::Initialize(nullptr, JS::DefaultHeapMaxBytes,
-                                             JS::DefaultNurseryMaxBytes);
-  }
+nsresult XPCJSContext::Initialize() {
+  nsresult rv = CycleCollectedJSContext::Initialize(
+      nullptr, JS::DefaultHeapMaxBytes, JS::DefaultNurseryMaxBytes);
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
   }
 
   MOZ_ASSERT(Context());
   JSContext* cx = Context();
 
   // The JS engine permits us to set different stack limits for system code,
@@ -1246,19 +1241,17 @@ nsresult XPCJSContext::Initialize(XPCJSC
   JS_SetNativeStackQuota(
       cx, kStackQuota, kStackQuota - kSystemCodeBuffer,
       kStackQuota - kSystemCodeBuffer - kTrustedScriptBuffer);
 
   PROFILER_SET_JS_CONTEXT(cx);
 
   JS_AddInterruptCallback(cx, InterruptCallback);
 
-  if (!aPrimaryContext) {
-    Runtime()->Initialize(cx);
-  }
+  Runtime()->Initialize(cx);
 
   LoadStartupJSPrefs(this);
 
   // Watch for the JS boolean options.
   ReloadPrefsCallback(nullptr, this);
   Preferences::RegisterPrefixCallback(ReloadPrefsCallback, JS_OPTIONS_DOT_STR,
                                       this);
 
@@ -1285,19 +1278,19 @@ WatchdogManager* XPCJSContext::GetWatchd
   sWatchdogInstance = new WatchdogManager();
   return sWatchdogInstance;
 }
 
 // static
 void XPCJSContext::InitTLS() { MOZ_RELEASE_ASSERT(gTlsContext.init()); }
 
 // static
-XPCJSContext* XPCJSContext::NewXPCJSContext(XPCJSContext* aPrimaryContext) {
+XPCJSContext* XPCJSContext::NewXPCJSContext() {
   XPCJSContext* self = new XPCJSContext();
-  nsresult rv = self->Initialize(aPrimaryContext);
+  nsresult rv = self->Initialize();
   if (NS_FAILED(rv)) {
     MOZ_CRASH("new XPCJSContext failed to initialize.");
   }
 
   if (self->Context()) {
     return self;
   }
 
--- a/js/xpconnect/src/nsXPConnect.cpp
+++ b/js/xpconnect/src/nsXPConnect.cpp
@@ -56,37 +56,37 @@ nsIPrincipal* nsXPConnect::gSystemPrinci
 
 const char XPC_EXCEPTION_CONTRACTID[] = "@mozilla.org/js/xpc/Exception;1";
 const char XPC_CONSOLE_CONTRACTID[] = "@mozilla.org/consoleservice;1";
 const char XPC_SCRIPT_ERROR_CONTRACTID[] = "@mozilla.org/scripterror;1";
 
 /***************************************************************************/
 
 // This global should be used very sparingly: only to create and destroy
-// nsXPConnect and when creating a new cooperative (non-primary) XPCJSContext.
-static XPCJSContext* gPrimaryContext;
+// nsXPConnect.
+static XPCJSContext* gContext;
 
 nsXPConnect::nsXPConnect() : mShuttingDown(false) {
   XPCJSContext::InitTLS();
 
 #ifdef MOZ_GECKO_PROFILER
   JS::SetProfilingThreadCallbacks(profiler_register_thread,
                                   profiler_unregister_thread);
 #endif
 
-  XPCJSContext* xpccx = XPCJSContext::NewXPCJSContext(nullptr);
+  XPCJSContext* xpccx = XPCJSContext::NewXPCJSContext();
   if (!xpccx) {
     MOZ_CRASH("Couldn't create XPCJSContext.");
   }
-  gPrimaryContext = xpccx;
+  gContext = xpccx;
   mRuntime = xpccx->Runtime();
 }
 
 nsXPConnect::~nsXPConnect() {
-  MOZ_ASSERT(XPCJSContext::Get() == gPrimaryContext);
+  MOZ_ASSERT(XPCJSContext::Get() == gContext);
 
   mRuntime->DeleteSingletonScopes();
 
   // In order to clean up everything properly, we need to GC twice: once now,
   // to clean anything that can go away on its own (like the Junk Scope, which
   // we unrooted above), and once after forcing a bunch of shutdown in
   // XPConnect, to clean the stuff we forcibly disconnected. The forced
   // shutdown code defaults to leaking in a number of situations, so we can't
@@ -104,17 +104,17 @@ nsXPConnect::~nsXPConnect() {
   mRuntime->GarbageCollect(JS::GCReason::XPCONNECT_SHUTDOWN);
 
   NS_RELEASE(gSystemPrincipal);
   gScriptSecurityManager = nullptr;
 
   // shutdown the logging system
   XPC_LOG_FINISH();
 
-  delete gPrimaryContext;
+  delete gContext;
 
   MOZ_ASSERT(gSelf == this);
   gSelf = nullptr;
   gOnceAliveNowDead = true;
 }
 
 // static
 void nsXPConnect::InitStatics() {
@@ -1191,34 +1191,16 @@ bool ThreadSafeIsChromeOrXBLOrUAWidget(J
     return IsChromeOrXBLOrUAWidget(cx, obj);
   }
   return IsCurrentThreadRunningChromeWorker();
 }
 
 }  // namespace dom
 }  // namespace mozilla
 
-void xpc::CreateCooperativeContext() {
-  MOZ_ASSERT(gPrimaryContext);
-  XPCJSContext::NewXPCJSContext(gPrimaryContext);
-}
-
-void xpc::DestroyCooperativeContext() {
-  MOZ_ASSERT(XPCJSContext::Get() != gPrimaryContext);
-  delete XPCJSContext::Get();
-}
-
-void xpc::YieldCooperativeContext() {
-  JS_YieldCooperativeContext(XPCJSContext::Get()->Context());
-}
-
-void xpc::ResumeCooperativeContext() {
-  JS_ResumeCooperativeContext(XPCJSContext::Get()->Context());
-}
-
 void xpc::CacheAutomationPref(bool* aMirror) {
   // The obvious thing is to make this pref a static pref. But then it would
   // always be defined and always show up in about:config, and users could flip
   // it, which we don't want. Instead we roll our own callback so that if the
   // pref is undefined (the normal case) then sAutomationPrefIsSet is false and
   // nothing shows up in about:config.
   nsresult rv = mozilla::Preferences::RegisterCallbackAndCall(
       [](const char* aPrefName, void* aData) {
--- a/js/xpconnect/src/xpcprivate.h
+++ b/js/xpconnect/src/xpcprivate.h
@@ -308,17 +308,17 @@ class AsyncFreeSnowWhite;
 class XPCWrappedNativeScope;
 
 using XPCWrappedNativeScopeList = mozilla::LinkedList<XPCWrappedNativeScope>;
 
 class XPCJSContext final : public mozilla::CycleCollectedJSContext,
                            public mozilla::LinkedListElement<XPCJSContext> {
  public:
   static void InitTLS();
-  static XPCJSContext* NewXPCJSContext(XPCJSContext* aPrimaryContext);
+  static XPCJSContext* NewXPCJSContext();
   static XPCJSContext* Get();
 
   XPCJSRuntime* Runtime() const;
 
   virtual mozilla::CycleCollectedJSRuntime* CreateRuntime(
       JSContext* aCx) override;
 
   XPCCallContext* GetCallContext() const { return mCallContext; }
@@ -420,17 +420,17 @@ class XPCJSContext final : public mozill
 
   inline JS::HandleId GetStringID(unsigned index) const;
   inline const char* GetStringName(unsigned index) const;
 
  private:
   XPCJSContext();
 
   MOZ_IS_CLASS_INIT
-  nsresult Initialize(XPCJSContext* aPrimaryContext);
+  nsresult Initialize();
 
   XPCCallContext* mCallContext;
   AutoMarkingPtr* mAutoRoots;
   jsid mResolveName;
   XPCWrappedNative* mResolvingWrapper;
   WatchdogManager* mWatchdogManager;
 
   // Number of XPCJSContexts currently alive.
--- a/js/xpconnect/src/xpcpublic.h
+++ b/js/xpconnect/src/xpcpublic.h
@@ -695,26 +695,16 @@ inline bool IsInAutomation() {
   static bool sPrefCacheAdded = false;
   if (!sPrefCacheAdded) {
     CacheAutomationPref(&sAutomationPrefIsSet);
     sPrefCacheAdded = true;
   }
   return sAutomationPrefIsSet && AreNonLocalConnectionsDisabled();
 }
 
-void CreateCooperativeContext();
-
-void DestroyCooperativeContext();
-
-// Please see JS_YieldCooperativeContext in jsapi.h.
-void YieldCooperativeContext();
-
-// Please see JS_ResumeCooperativeContext in jsapi.h.
-void ResumeCooperativeContext();
-
 /**
  * Extract the native nsID object from a JS ID, IfaceID, ClassID, or ContractID
  * value.
  *
  * Returns 'Nothing()' if 'aVal' does is not one of the supported ID types.
  */
 mozilla::Maybe<nsID> JSValue2ID(JSContext* aCx, JS::HandleValue aVal);
 
--- a/xpcom/base/CycleCollectedJSContext.cpp
+++ b/xpcom/base/CycleCollectedJSContext.cpp
@@ -48,18 +48,17 @@
 #include "xpcpublic.h"
 
 using namespace mozilla;
 using namespace mozilla::dom;
 
 namespace mozilla {
 
 CycleCollectedJSContext::CycleCollectedJSContext()
-    : mIsPrimaryContext(true),
-      mRuntime(nullptr),
+    : mRuntime(nullptr),
       mJSContext(nullptr),
       mDoingStableStates(false),
       mTargetedMicroTaskRecursionDepth(0),
       mMicroTaskLevel(0),
       mDebuggerRecursionDepth(0),
       mMicroTaskRecursionDepth(0) {
   MOZ_COUNT_CTOR(CycleCollectedJSContext);
 
@@ -77,20 +76,17 @@ CycleCollectedJSContext::~CycleCollected
   // If the allocation failed, here we are.
   if (!mJSContext) {
     return;
   }
 
   JS_SetContextPrivate(mJSContext, nullptr);
 
   mRuntime->RemoveContext(this);
-
-  if (mIsPrimaryContext) {
-    mRuntime->Shutdown(mJSContext);
-  }
+  mRuntime->Shutdown(mJSContext);
 
   // Last chance to process any events.
   CleanupIDBTransactions(mBaseRecursionDepth);
   MOZ_ASSERT(mPendingIDBTransactions.IsEmpty());
 
   ProcessStableStateQueue();
   MOZ_ASSERT(mStableStateEvents.IsEmpty());
 
@@ -104,34 +100,41 @@ CycleCollectedJSContext::~CycleCollected
   mConsumedRejections.reset();
 
   mAboutToBeNotifiedRejectedPromises.Clear();
   mPendingUnhandledRejections.Clear();
 
   JS_DestroyContext(mJSContext);
   mJSContext = nullptr;
 
-  if (mIsPrimaryContext) {
-    nsCycleCollector_forgetJSContext();
-  } else {
-    nsCycleCollector_forgetNonPrimaryContext();
-  }
+  nsCycleCollector_forgetJSContext();
 
   mozilla::dom::DestroyScriptSettings();
 
   mOwningThread->SetScriptObserver(nullptr);
   NS_RELEASE(mOwningThread);
 
-  if (mIsPrimaryContext) {
-    delete mRuntime;
-  }
+  delete mRuntime;
   mRuntime = nullptr;
 }
 
-void CycleCollectedJSContext::InitializeCommon() {
+nsresult CycleCollectedJSContext::Initialize(JSRuntime* aParentRuntime,
+                                             uint32_t aMaxBytes,
+                                             uint32_t aMaxNurseryBytes) {
+  MOZ_ASSERT(!mJSContext);
+
+  mozilla::dom::InitScriptSettings();
+  mJSContext = JS_NewContext(aMaxBytes, aParentRuntime);
+  if (!mJSContext) {
+    return NS_ERROR_OUT_OF_MEMORY;
+  }
+
+  JS_SetGCParameter(mJSContext, JSGC_MAX_NURSERY_BYTES, aMaxNurseryBytes);
+
+  mRuntime = CreateRuntime(mJSContext);
   mRuntime->AddContext(this);
 
   mOwningThread->SetScriptObserver(this);
   // The main thread has a base recursion depth of 0, workers of 1.
   mBaseRecursionDepth = RecursionDepth();
 
   NS_GetCurrentThread()->SetCanInvokeJS(true);
 
@@ -142,61 +145,22 @@ void CycleCollectedJSContext::Initialize
                            JS::GCVector<JSObject*, 0, js::SystemAllocPolicy>(
                                js::SystemAllocPolicy()));
   mConsumedRejections.init(mJSContext,
                            JS::GCVector<JSObject*, 0, js::SystemAllocPolicy>(
                                js::SystemAllocPolicy()));
 
   // Cast to PerThreadAtomCache for dom::GetAtomCache(JSContext*).
   JS_SetContextPrivate(mJSContext, static_cast<PerThreadAtomCache*>(this));
-}
-
-nsresult CycleCollectedJSContext::Initialize(JSRuntime* aParentRuntime,
-                                             uint32_t aMaxBytes,
-                                             uint32_t aMaxNurseryBytes) {
-  MOZ_ASSERT(!mJSContext);
-
-  mozilla::dom::InitScriptSettings();
-  mJSContext = JS_NewContext(aMaxBytes, aParentRuntime);
-  if (!mJSContext) {
-    return NS_ERROR_OUT_OF_MEMORY;
-  }
-
-  JS_SetGCParameter(mJSContext, JSGC_MAX_NURSERY_BYTES, aMaxNurseryBytes);
-
-  mRuntime = CreateRuntime(mJSContext);
-
-  InitializeCommon();
 
   nsCycleCollector_registerJSContext(this);
 
   return NS_OK;
 }
 
-nsresult CycleCollectedJSContext::InitializeNonPrimary(
-    CycleCollectedJSContext* aPrimaryContext) {
-  MOZ_ASSERT(!mJSContext);
-
-  mIsPrimaryContext = false;
-
-  mozilla::dom::InitScriptSettings();
-  mJSContext = JS_NewCooperativeContext(aPrimaryContext->mJSContext);
-  if (!mJSContext) {
-    return NS_ERROR_OUT_OF_MEMORY;
-  }
-
-  mRuntime = aPrimaryContext->mRuntime;
-
-  InitializeCommon();
-
-  nsCycleCollector_registerNonPrimaryContext(this);
-
-  return NS_OK;
-}
-
 /* static */
 CycleCollectedJSContext* CycleCollectedJSContext::GetFor(JSContext* aCx) {
   // Cast from void* matching JS_SetContextPrivate.
   auto atomCache = static_cast<PerThreadAtomCache*>(JS_GetContextPrivate(aCx));
   // Down cast.
   return static_cast<CycleCollectedJSContext*>(atomCache);
 }
 
--- a/xpcom/base/CycleCollectedJSContext.h
+++ b/xpcom/base/CycleCollectedJSContext.h
@@ -93,28 +93,21 @@ class CycleCollectedJSContext
  protected:
   CycleCollectedJSContext();
   virtual ~CycleCollectedJSContext();
 
   MOZ_IS_CLASS_INIT
   nsresult Initialize(JSRuntime* aParentRuntime, uint32_t aMaxBytes,
                       uint32_t aMaxNurseryBytes);
 
-  // See explanation in mIsPrimaryContext.
-  MOZ_IS_CLASS_INIT
-  nsresult InitializeNonPrimary(CycleCollectedJSContext* aPrimaryContext);
-
   virtual CycleCollectedJSRuntime* CreateRuntime(JSContext* aCx) = 0;
 
   size_t SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf) const;
 
  private:
-  MOZ_IS_CLASS_INIT
-  void InitializeCommon();
-
   static JSObject* GetIncumbentGlobalCallback(JSContext* aCx);
   static bool EnqueuePromiseJobCallback(JSContext* aCx,
                                         JS::HandleObject aPromise,
                                         JS::HandleObject aJob,
                                         JS::HandleObject aAllocationSite,
                                         JS::HandleObject aIncumbentGlobal,
                                         void* aData);
   static void PromiseRejectionTrackerCallback(
@@ -268,22 +261,16 @@ class CycleCollectedJSContext
   // in SpiderMonkey!) and will deal.
   MOZ_CAN_RUN_SCRIPT_BOUNDARY
   void runJobs(JSContext* cx) override;
   bool empty() const override;
   class SavedMicroTaskQueue;
   js::UniquePtr<SavedJobQueue> saveJobQueue(JSContext*) override;
 
  private:
-  // A primary context owns the mRuntime. Non-main-thread contexts should always
-  // be primary. On the main thread, the primary context should be the first one
-  // created and the last one destroyed. Non-primary contexts are used for
-  // cooperatively scheduled threads.
-  bool mIsPrimaryContext;
-
   CycleCollectedJSRuntime* mRuntime;
 
   JSContext* mJSContext;
 
   nsCOMPtr<dom::Exception> mPendingException;
   nsThread* mOwningThread;  // Manual refcounting to avoid include hell.
 
   struct PendingIDBTransactionData {
--- a/xpcom/base/nsCycleCollector.cpp
+++ b/xpcom/base/nsCycleCollector.cpp
@@ -3810,62 +3810,26 @@ bool nsCycleCollector_init() {
   MOZ_ASSERT(NS_IsMainThread(), "Wrong thread!");
   MOZ_ASSERT(!sInitialized, "Called twice!?");
   sInitialized = true;
 #endif
 
   return sCollectorData.init();
 }
 
-static nsCycleCollector* gMainThreadCollector;
-
 void nsCycleCollector_startup() {
   if (sCollectorData.get()) {
     MOZ_CRASH();
   }
 
   CollectorData* data = new CollectorData;
   data->mCollector = new nsCycleCollector();
   data->mContext = nullptr;
 
   sCollectorData.set(data);
-
-  if (NS_IsMainThread()) {
-    MOZ_ASSERT(!gMainThreadCollector);
-    gMainThreadCollector = data->mCollector;
-  }
-}
-
-void nsCycleCollector_registerNonPrimaryContext(CycleCollectedJSContext* aCx) {
-  if (sCollectorData.get()) {
-    MOZ_CRASH();
-  }
-
-  MOZ_ASSERT(gMainThreadCollector);
-
-  CollectorData* data = new CollectorData;
-
-  data->mCollector = gMainThreadCollector;
-  data->mContext = aCx;
-
-  sCollectorData.set(data);
-}
-
-void nsCycleCollector_forgetNonPrimaryContext() {
-  CollectorData* data = sCollectorData.get();
-
-  // We should have started the cycle collector by now.
-  MOZ_ASSERT(data);
-  // And we shouldn't have already forgotten our context.
-  MOZ_ASSERT(data->mContext);
-  // We should not have shut down the cycle collector yet.
-  MOZ_ASSERT(data->mCollector);
-
-  delete data;
-  sCollectorData.set(nullptr);
 }
 
 void nsCycleCollector_setBeforeUnlinkCallback(CC_BeforeUnlinkCallback aCB) {
   CollectorData* data = sCollectorData.get();
 
   // We should have started the cycle collector by now.
   MOZ_ASSERT(data);
   MOZ_ASSERT(data->mCollector);
@@ -3988,19 +3952,16 @@ void nsCycleCollector_finishAnyCurrentCo
 
 void nsCycleCollector_shutdown(bool aDoCollect) {
   CollectorData* data = sCollectorData.get();
 
   if (data) {
     MOZ_ASSERT(data->mCollector);
     AUTO_PROFILER_LABEL("nsCycleCollector_shutdown", OTHER);
 
-    if (gMainThreadCollector == data->mCollector) {
-      gMainThreadCollector = nullptr;
-    }
     data->mCollector->Shutdown(aDoCollect);
     data->mCollector = nullptr;
     if (data->mContext) {
       // Run any remaining tasks that may have been enqueued via
       // RunInStableState or DispatchToMicroTask during the final cycle
       // collection.
       data->mContext->ProcessStableStateQueue();
       data->mContext->PerformMicroTaskCheckPoint(true);
--- a/xpcom/base/nsCycleCollector.h
+++ b/xpcom/base/nsCycleCollector.h
@@ -62,14 +62,9 @@ uint32_t nsCycleCollector_suspectedCount
 // shutting down the CC completely.
 MOZ_CAN_RUN_SCRIPT
 void nsCycleCollector_shutdown(bool aDoCollect = true);
 
 // Helpers for interacting with JS
 void nsCycleCollector_registerJSContext(mozilla::CycleCollectedJSContext* aCx);
 void nsCycleCollector_forgetJSContext();
 
-// Helpers for cooperative threads.
-void nsCycleCollector_registerNonPrimaryContext(
-    mozilla::CycleCollectedJSContext* aCx);
-void nsCycleCollector_forgetNonPrimaryContext();
-
 #endif  // nsCycleCollector_h__