Bug 1510226 - Remove vestigial references to cooperative scheduling r=froydnj
☠☠ backed out by 09e240c6177f ☠ ☠
authorDoug Thayer <dothayer@mozilla.com>
Tue, 20 Aug 2019 18:03:11 +0000
changeset 494835 b6f670610dc3bafe2e954863c0dd3afc16cf7a5b
parent 494834 931639899eddf0e02e145cf046fc40ea4611ded7
child 494836 cb739de6606d42c96b6986d6653fdcb0f90997b1
push id114131
push userdluca@mozilla.com
push dateThu, 26 Sep 2019 09:47:34 +0000
treeherdermozilla-inbound@1dc1a755079a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfroydnj
bugs1510226
milestone71.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 1510226 - Remove vestigial references to cooperative scheduling r=froydnj GetCurrentPhysicalThread and GetCurrentVirtualThread are, in practice, identical, as the TLS override that GetCurrentVirtualThread depends on is never actually set. This simply removes that and renames some things/ deletes some comments. Differential Revision: https://phabricator.services.mozilla.com/D41247
dom/canvas/ImageBitmap.cpp
dom/indexedDB/ActorsParent.cpp
dom/media/MediaManager.cpp
ipc/glue/MessageChannel.cpp
ipc/glue/MessageChannel.h
tools/fuzzing/ipc/ProtocolFuzzer.cpp
xpcom/base/nsISupportsImpl.cpp
xpcom/threads/TaskQueue.cpp
xpcom/threads/TaskQueue.h
xpcom/threads/ThreadEventTarget.cpp
xpcom/threads/nsIEventTarget.idl
xpcom/threads/nsThread.cpp
xpcom/threads/nsThread.h
xpcom/threads/nsThreadManager.cpp
xpcom/threads/nsThreadUtils.cpp
xpcom/threads/nsThreadUtils.h
--- a/dom/canvas/ImageBitmap.cpp
+++ b/dom/canvas/ImageBitmap.cpp
@@ -1078,21 +1078,21 @@ class CreateImageBitmapFromBlob final : 
       : CancelableRunnable("dom::CreateImageBitmapFromBlob"),
         mMutex("dom::CreateImageBitmapFromBlob::mMutex"),
         mPromise(aPromise),
         mGlobalObject(aGlobal),
         mInputStream(std::move(aInputStream)),
         mCropRect(aCropRect),
         mOriginalCropRect(aCropRect),
         mMainThreadEventTarget(aMainThreadEventTarget),
-        mThread(GetCurrentVirtualThread()) {}
+        mThread(PR_GetCurrentThread()) {}
 
   virtual ~CreateImageBitmapFromBlob() {}
 
-  bool IsCurrentThread() const { return mThread == GetCurrentVirtualThread(); }
+  bool IsCurrentThread() const { return mThread == PR_GetCurrentThread(); }
 
   // Called on the owning thread.
   nsresult StartMimeTypeAndDecodeAndCropBlob();
 
   // Will be called when the decoding + cropping is completed on the
   // main-thread. This could the not the owning thread!
   void MimeTypeAndDecodeAndCropBlobCompletedMainThread(layers::Image* aImage,
                                                        nsresult aStatus);
--- a/dom/indexedDB/ActorsParent.cpp
+++ b/dom/indexedDB/ActorsParent.cpp
@@ -5142,17 +5142,17 @@ struct ConnectionPool::DatabaseInfo fina
 #ifdef DEBUG
   PRThread* mDEBUGConnectionThread;
 #endif
 
   DatabaseInfo(ConnectionPool* aConnectionPool, const nsACString& aDatabaseId);
 
   void AssertIsOnConnectionThread() const {
     MOZ_ASSERT(mDEBUGConnectionThread);
-    MOZ_ASSERT(GetCurrentPhysicalThread() == mDEBUGConnectionThread);
+    MOZ_ASSERT(PR_GetCurrentThread() == mDEBUGConnectionThread);
   }
 
   uint64_t TotalTransactionCount() const {
     return mReadTransactionCount + mWriteTransactionCount;
   }
 
  private:
   ~DatabaseInfo();
@@ -10899,17 +10899,17 @@ nsresult ConnectionPool::GetOrCreateConn
 
     dbInfo->mConnection = connection;
 
     IDB_DEBUG_LOG(("ConnectionPool created connection 0x%p for '%s'",
                    dbInfo->mConnection.get(),
                    NS_ConvertUTF16toUTF8(aDatabase->FilePath()).get()));
 
 #ifdef DEBUG
-    dbInfo->mDEBUGConnectionThread = GetCurrentPhysicalThread();
+    dbInfo->mDEBUGConnectionThread = PR_GetCurrentThread();
 #endif
   }
 
   dbInfo->AssertIsOnConnectionThread();
 
   connection.forget(aConnection);
   return NS_OK;
 }
--- a/dom/media/MediaManager.cpp
+++ b/dom/media/MediaManager.cpp
@@ -4067,17 +4067,17 @@ void SourceListener::Activate(RefPtr<Med
   MOZ_ASSERT(NS_IsMainThread(), "Only call on main thread");
 
   LOG("SourceListener %p activating audio=%p video=%p", this,
       aAudioDevice.get(), aVideoDevice.get());
 
   MOZ_ASSERT(!mStopped, "Cannot activate stopped source listener");
   MOZ_ASSERT(!Activated(), "Already activated");
 
-  mMainThreadCheck = GetCurrentVirtualThread();
+  mMainThreadCheck = PR_GetCurrentThread();
   if (aAudioDevice) {
     bool offWhileDisabled =
         aAudioDevice->GetMediaSource() == MediaSourceEnum::Microphone &&
         Preferences::GetBool(
             "media.getusermedia.microphone.off_while_disabled.enabled", true);
     mAudioDeviceState =
         MakeUnique<DeviceState>(std::move(aAudioDevice),
                                 std::move(aAudioTrackSource), offWhileDisabled);
--- a/ipc/glue/MessageChannel.cpp
+++ b/ipc/glue/MessageChannel.cpp
@@ -824,17 +824,17 @@ void MessageChannel::Clear() {
 }
 
 bool MessageChannel::Open(Transport* aTransport, MessageLoop* aIOLoop,
                           Side aSide) {
   MOZ_ASSERT(!mLink, "Open() called > once");
 
   mMonitor = new RefCountedMonitor();
   mWorkerLoop = MessageLoop::current();
-  mWorkerThread = GetCurrentVirtualThread();
+  mWorkerThread = PR_GetCurrentThread();
   mWorkerLoop->AddDestructionObserver(this);
   mListener->OnIPCChannelOpened();
 
   ProcessLink* link = new ProcessLink(this);
   link->Open(aTransport, aIOLoop, aSide);  // :TODO: n.b.: sets mChild
   mLink = link;
   mIsCrossProcess = true;
   ChannelCountReporter::Increment(mName);
@@ -905,17 +905,17 @@ void MessageChannel::OnOpenAsSlave(Messa
   mChannelState = ChannelConnected;
   aTargetChan->mChannelState = ChannelConnected;
   aTargetChan->mMonitor->Notify();
 }
 
 void MessageChannel::CommonThreadOpenInit(MessageChannel* aTargetChan,
                                           Side aSide) {
   mWorkerLoop = MessageLoop::current();
-  mWorkerThread = GetCurrentVirtualThread();
+  mWorkerThread = PR_GetCurrentThread();
   mWorkerLoop->AddDestructionObserver(this);
   mListener->OnIPCChannelOpened();
 
   mLink = new ThreadLink(this, aTargetChan);
   mSide = aSide;
 }
 
 bool MessageChannel::OpenOnSameThread(MessageChannel* aTargetChan,
--- a/ipc/glue/MessageChannel.h
+++ b/ipc/glue/MessageChannel.h
@@ -539,17 +539,17 @@ class MessageChannel : HasResultCodes, M
   // Run on the not current thread.
   void NotifyChannelClosed();
   void NotifyMaybeChannelError();
 
  private:
   // Can be run on either thread
   void AssertWorkerThread() const {
     MOZ_ASSERT(mWorkerThread, "Channel hasn't been opened yet");
-    MOZ_RELEASE_ASSERT(mWorkerThread == GetCurrentVirtualThread(),
+    MOZ_RELEASE_ASSERT(mWorkerThread == PR_GetCurrentThread(),
                        "not on worker thread!");
   }
 
   // The "link" thread is either the I/O thread (ProcessLink), the other
   // actor's work thread (ThreadLink), or the worker thread (same-thread
   // channels).
   void AssertLinkThread() const {
     if (mIsSameThreadChannel) {
@@ -557,17 +557,17 @@ class MessageChannel : HasResultCodes, M
       // thread.
       AssertWorkerThread();
       return;
     }
 
     // If we aren't a same-thread channel, our "link" thread is _not_ our
     // worker thread!
     MOZ_ASSERT(mWorkerThread, "Channel hasn't been opened yet");
-    MOZ_RELEASE_ASSERT(mWorkerThread != GetCurrentVirtualThread(),
+    MOZ_RELEASE_ASSERT(mWorkerThread != PR_GetCurrentThread(),
                        "on worker thread but should not be!");
   }
 
  private:
   class MessageTask : public CancelableRunnable,
                       public LinkedListElement<RefPtr<MessageTask>>,
                       public nsIRunnablePriority,
                       public nsIRunnableIPCMessageType {
--- a/tools/fuzzing/ipc/ProtocolFuzzer.cpp
+++ b/tools/fuzzing/ipc/ProtocolFuzzer.cpp
@@ -19,17 +19,17 @@ nsTArray<nsCString> LoadIPCMessageBlackl
   }
   return blacklist;
 }
 
 mozilla::dom::ContentParent* ProtocolFuzzerHelper::CreateContentParent(
     mozilla::dom::ContentParent* aOpener, const nsAString& aRemoteType) {
   auto* cp = new mozilla::dom::ContentParent(aOpener, aRemoteType);
   // TODO: this duplicates MessageChannel::Open
-  cp->GetIPCChannel()->mWorkerThread = GetCurrentVirtualThread();
+  cp->GetIPCChannel()->mWorkerThread = PR_GetCurrentThread();
   cp->GetIPCChannel()->mMonitor = new RefCountedMonitor();
   return cp;
 }
 
 void ProtocolFuzzerHelper::CompositorBridgeParentSetup() {
   mozilla::layers::CompositorBridgeParent::Setup();
 }
 
--- a/xpcom/base/nsISupportsImpl.cpp
+++ b/xpcom/base/nsISupportsImpl.cpp
@@ -27,21 +27,21 @@ nsresult NS_FASTCALL NS_TableDrivenQI(vo
     ++aEntries;
   } while (aEntries->iid);
 
   *aInstancePtr = nullptr;
   return NS_ERROR_NO_INTERFACE;
 }
 
 #ifdef MOZ_THREAD_SAFETY_OWNERSHIP_CHECKS_SUPPORTED
-nsAutoOwningThread::nsAutoOwningThread() : mThread(GetCurrentVirtualThread()) {}
+nsAutoOwningThread::nsAutoOwningThread() : mThread(PR_GetCurrentThread()) {}
 
 void nsAutoOwningThread::AssertCurrentThreadOwnsMe(const char* msg) const {
   if (MOZ_UNLIKELY(!IsCurrentThread())) {
     // `msg` is a string literal by construction.
     MOZ_CRASH_UNSAFE(msg);
   }
 }
 
 bool nsAutoOwningThread::IsCurrentThread() const {
-  return mThread == GetCurrentVirtualThread();
+  return mThread == PR_GetCurrentThread();
 }
 #endif
--- a/xpcom/threads/TaskQueue.cpp
+++ b/xpcom/threads/TaskQueue.cpp
@@ -159,17 +159,17 @@ RefPtr<ShutdownPromise> TaskQueue::Begin
 }
 
 bool TaskQueue::IsEmpty() {
   MonitorAutoLock mon(mQueueMonitor);
   return mTasks.empty();
 }
 
 bool TaskQueue::IsCurrentThreadIn() const {
-  bool in = mRunningThread == GetCurrentPhysicalThread();
+  bool in = mRunningThread == PR_GetCurrentThread();
   return in;
 }
 
 already_AddRefed<nsISerialEventTarget> TaskQueue::WrapAsEventTarget() {
   nsCOMPtr<nsISerialEventTarget> ref = new EventTargetWrapper(this);
   return ref.forget();
 }
 
--- a/xpcom/threads/TaskQueue.h
+++ b/xpcom/threads/TaskQueue.h
@@ -151,23 +151,23 @@ class TaskQueue : public AbstractThread 
       // might require it.
       MOZ_ASSERT(!mQueue->mTailDispatcher);
       mQueue->mTailDispatcher = this;
 
       mLastCurrentThread = sCurrentThreadTLS.get();
       sCurrentThreadTLS.set(aQueue);
 
       MOZ_ASSERT(mQueue->mRunningThread == nullptr);
-      mQueue->mRunningThread = GetCurrentPhysicalThread();
+      mQueue->mRunningThread = PR_GetCurrentThread();
     }
 
     ~AutoTaskGuard() {
       DrainDirectTasks();
 
-      MOZ_ASSERT(mQueue->mRunningThread == GetCurrentPhysicalThread());
+      MOZ_ASSERT(mQueue->mRunningThread == PR_GetCurrentThread());
       mQueue->mRunningThread = nullptr;
 
       sCurrentThreadTLS.set(mLastCurrentThread);
       mQueue->mTailDispatcher = nullptr;
     }
 
    private:
     TaskQueue* mQueue;
--- a/xpcom/threads/ThreadEventTarget.cpp
+++ b/xpcom/threads/ThreadEventTarget.cpp
@@ -84,22 +84,20 @@ class DelayedRunnable : public Runnable,
 
 NS_IMPL_ISUPPORTS_INHERITED(DelayedRunnable, Runnable, nsITimerCallback)
 
 }  // anonymous namespace
 
 ThreadEventTarget::ThreadEventTarget(ThreadTargetSink* aSink,
                                      bool aIsMainThread)
     : mSink(aSink), mIsMainThread(aIsMainThread) {
-  mVirtualThread = GetCurrentVirtualThread();
+  mThread = PR_GetCurrentThread();
 }
 
-void ThreadEventTarget::SetCurrentThread() {
-  mVirtualThread = GetCurrentVirtualThread();
-}
+void ThreadEventTarget::SetCurrentThread() { mThread = PR_GetCurrentThread(); }
 
 NS_IMPL_ISUPPORTS(ThreadEventTarget, nsIEventTarget, nsISerialEventTarget)
 
 NS_IMETHODIMP
 ThreadEventTarget::DispatchFromScript(nsIRunnable* aRunnable, uint32_t aFlags) {
   return Dispatch(do_AddRef(aRunnable), aFlags);
 }
 
@@ -180,11 +178,11 @@ ThreadEventTarget::DelayedDispatch(alrea
 NS_IMETHODIMP
 ThreadEventTarget::IsOnCurrentThread(bool* aIsOnCurrentThread) {
   *aIsOnCurrentThread = IsOnCurrentThread();
   return NS_OK;
 }
 
 NS_IMETHODIMP_(bool)
 ThreadEventTarget::IsOnCurrentThreadInfallible() {
-  // Rely on mVirtualThread being correct.
+  // Rely on mThread being correct.
   MOZ_CRASH("IsOnCurrentThreadInfallible should never be called on nsIThread");
 }
--- a/xpcom/threads/nsIEventTarget.idl
+++ b/xpcom/threads/nsIEventTarget.idl
@@ -64,35 +64,35 @@ interface nsIEventTarget : nsISupports
    * When called on an nsISerialEventTarget, IsOnCurrentThread can be used to
    * ensure that no other thread has "ownership" of the event target. As such,
    * it's useful for asserting that an object is only used on a particular
    * thread. IsOnCurrentThread can't guarantee that the current event has been
    * dispatched through a particular event target.
    *
    * The infallible version of IsOnCurrentThread() is optimized to avoid a
    * virtual call for non-thread event targets. Thread targets should set
-   * mVirtualThread to their virtual PRThread. Non-thread targets should leave
-   * mVirtualThread null and implement IsOnCurrentThreadInfallible() to
+   * mThread to their virtual PRThread. Non-thread targets should leave
+   * mThread null and implement IsOnCurrentThreadInfallible() to
    * return the correct answer.
    *
    * The fallible version of IsOnCurrentThread may return errors, such as during
    * shutdown. If it does not return an error, it should return the same result
    * as the infallible version. The infallible method should return the correct
    * result regardless of whether the fallible method returns an error.
    */
   %{C++
 public:
   // Infallible. Defined in nsThreadUtils.cpp. Delegates to
-  // IsOnCurrentThreadInfallible when mVirtualThread is null.
+  // IsOnCurrentThreadInfallible when mThread is null.
   bool IsOnCurrentThread();
 
 protected:
-  PRThread* mVirtualThread;
+  PRThread* mThread;
 
-  nsIEventTarget() : mVirtualThread(nullptr) {}
+  nsIEventTarget() : mThread(nullptr) {}
   %}
   // Note that this method is protected.  We define it through IDL, rather than
   // in a %{C++ block, to ensure that the correct method indices are recorded
   // for XPConnect purposes.
   [noscript,notxpcom] boolean isOnCurrentThreadInfallible();
   %{C++
 public:
   %}
--- a/xpcom/threads/nsThread.cpp
+++ b/xpcom/threads/nsThread.cpp
@@ -413,17 +413,16 @@ void nsThread::ThreadFunc(void* aArg) {
 
   ThreadInitData* initData = static_cast<ThreadInitData*>(aArg);
   nsThread* self = initData->thread;  // strong reference
 
   MOZ_ASSERT(self->mEventTarget);
   MOZ_ASSERT(self->mEvents);
 
   self->mThread = PR_GetCurrentThread();
-  self->mVirtualThread = GetCurrentVirtualThread();
   self->mEventTarget->SetCurrentThread();
   SetupCurrentThreadForChaosMode();
 
   if (!initData->name.IsEmpty()) {
     NS_SetCurrentThreadName(initData->name.BeginReading());
   }
 
   self->InitCommon();
@@ -589,17 +588,16 @@ int sCanaryOutputFD = -1;
 
 nsThread::nsThread(NotNull<SynchronizedEventQueue*> aQueue,
                    MainThreadFlag aMainThread, uint32_t aStackSize)
     : mEvents(aQueue.get()),
       mEventTarget(
           new ThreadEventTarget(mEvents.get(), aMainThread == MAIN_THREAD)),
       mShutdownContext(nullptr),
       mScriptObserver(nullptr),
-      mThread(nullptr),
       mStackSize(aStackSize),
       mNestedEventLoopDepth(0),
       mCurrentEventLoopDepth(MaxValue<uint32_t>::value),
       mShutdownRequired(false),
       mPriority(PRIORITY_NORMAL),
       mIsMainThread(aMainThread == MAIN_THREAD),
       mCanInvokeJS(false),
       mCurrentEvent(nullptr),
@@ -612,17 +610,16 @@ nsThread::nsThread(NotNull<SynchronizedE
   mLastLongNonIdleTaskEnd = mCurrentEventStart;
 }
 
 nsThread::nsThread()
     : mEvents(nullptr),
       mEventTarget(nullptr),
       mShutdownContext(nullptr),
       mScriptObserver(nullptr),
-      mThread(nullptr),
       mStackSize(0),
       mNestedEventLoopDepth(0),
       mCurrentEventLoopDepth(MaxValue<uint32_t>::value),
       mShutdownRequired(false),
       mPriority(PRIORITY_NORMAL),
       mIsMainThread(false),
       mCanInvokeJS(false),
       mCurrentEvent(nullptr),
@@ -687,17 +684,16 @@ nsresult nsThread::Init(const nsACString
   // Wait for thread to call ThreadManager::SetupCurrentThread, which completes
   // initialization of ThreadFunc.
   startup->Wait();
   return NS_OK;
 }
 
 nsresult nsThread::InitCurrentThread() {
   mThread = PR_GetCurrentThread();
-  mVirtualThread = GetCurrentVirtualThread();
   SetupCurrentThreadForChaosMode();
   InitCommon();
 
   nsThreadManager::get().RegisterCurrentThread(*this);
   return NS_OK;
 }
 
 //-----------------------------------------------------------------------------
@@ -731,23 +727,23 @@ nsThread::DelayedDispatch(already_AddRef
   return mEventTarget->DelayedDispatch(std::move(aEvent), aDelayMs);
 }
 
 NS_IMETHODIMP
 nsThread::IsOnCurrentThread(bool* aResult) {
   if (mEventTarget) {
     return mEventTarget->IsOnCurrentThread(aResult);
   }
-  *aResult = GetCurrentVirtualThread() == mVirtualThread;
+  *aResult = PR_GetCurrentThread() == mThread;
   return NS_OK;
 }
 
 NS_IMETHODIMP_(bool)
 nsThread::IsOnCurrentThreadInfallible() {
-  // Rely on mVirtualThread being correct.
+  // Rely on mThread being correct.
   MOZ_CRASH("IsOnCurrentThreadInfallible should never be called on nsIThread");
 }
 
 //-----------------------------------------------------------------------------
 // nsIThread
 
 NS_IMETHODIMP
 nsThread::GetPRThread(PRThread** aResult) {
@@ -854,17 +850,16 @@ void nsThread::ShutdownComplete(NotNull<
     // we're done and unwind the stack so it can call us again.
     aContext->mAwaitingShutdownAck = false;
     return;
   }
 
   // Now, it should be safe to join without fear of dead-locking.
 
   PR_JoinThread(mThread);
-  mThread = nullptr;
 
 #ifdef DEBUG
   nsCOMPtr<nsIThreadObserver> obs = mEvents->GetObserver();
   MOZ_ASSERT(!obs, "Should have been cleared at shutdown!");
 #endif
 
   // Delete aContext.
   // aContext might not be in mRequestedShutdownContexts if it belongs to a
--- a/xpcom/threads/nsThread.h
+++ b/xpcom/threads/nsThread.h
@@ -207,17 +207,16 @@ class nsThread : public nsIThreadInterna
   // The shutdown contexts for any other threads we've asked to shut down.
   using ShutdownContexts = nsTArray<nsAutoPtr<struct nsThreadShutdownContext>>;
   ShutdownContexts mRequestedShutdownContexts;
   // The shutdown context for ourselves.
   struct nsThreadShutdownContext* mShutdownContext;
 
   mozilla::CycleCollectedJSContext* mScriptObserver;
 
-  PRThread* mThread;
   void* mStackBase = nullptr;
   uint32_t mStackSize;
   uint32_t mThreadId;
 
   uint32_t mNestedEventLoopDepth;
   uint32_t mCurrentEventLoopDepth;
 
   mozilla::TimeStamp mLastLongTaskEnd;
--- a/xpcom/threads/nsThreadManager.cpp
+++ b/xpcom/threads/nsThreadManager.cpp
@@ -27,17 +27,16 @@
 #endif
 
 #include "MainThreadIdlePeriod.h"
 #include "InputEventStatistics.h"
 
 using namespace mozilla;
 
 static MOZ_THREAD_LOCAL(bool) sTLSIsMainThread;
-static MOZ_THREAD_LOCAL(PRThread*) gTlsCurrentVirtualThread;
 
 bool NS_IsMainThreadTLSInitialized() { return sTLSIsMainThread.initialized(); }
 
 extern "C" {
 // This uses the C language linkage because it's exposed to Rust
 // via the xpcom/rust/moz_task crate.
 bool NS_IsMainThread() { return sTLSIsMainThread.get(); }
 }
@@ -45,28 +44,16 @@ bool NS_IsMainThread() { return sTLSIsMa
 void NS_SetMainThread() {
   if (!sTLSIsMainThread.init()) {
     MOZ_CRASH();
   }
   sTLSIsMainThread.set(true);
   MOZ_ASSERT(NS_IsMainThread());
 }
 
-void NS_SetMainThread(PRThread* aVirtualThread) {
-  MOZ_ASSERT(!gTlsCurrentVirtualThread.get());
-  gTlsCurrentVirtualThread.set(aVirtualThread);
-  NS_SetMainThread();
-}
-
-void NS_UnsetMainThread() {
-  sTLSIsMainThread.set(false);
-  MOZ_ASSERT(!NS_IsMainThread());
-  gTlsCurrentVirtualThread.set(nullptr);
-}
-
 #ifdef DEBUG
 
 namespace mozilla {
 
 void AssertIsOnMainThread() { MOZ_ASSERT(NS_IsMainThread(), "Wrong thread!"); }
 
 }  // namespace mozilla
 
@@ -197,20 +184,16 @@ void nsThreadManager::InitializeShutdown
 nsresult nsThreadManager::Init() {
   // Child processes need to initialize the thread manager before they
   // initialize XPCOM in order to set up the crash reporter. This leads to
   // situations where we get initialized twice.
   if (mInitialized) {
     return NS_OK;
   }
 
-  if (!gTlsCurrentVirtualThread.init()) {
-    return NS_ERROR_UNEXPECTED;
-  }
-
   if (PR_NewThreadPrivateIndex(&mCurThreadIndex, ReleaseThread) == PR_FAILURE) {
     return NS_ERROR_FAILURE;
   }
 
 #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");
@@ -593,25 +576,8 @@ nsThreadManager::IdleDispatchToMainThrea
   if (aTimeout) {
     return NS_DispatchToThreadQueue(event.forget(), aTimeout, mMainThread,
                                     EventQueuePriority::Idle);
   }
 
   return NS_DispatchToThreadQueue(event.forget(), mMainThread,
                                   EventQueuePriority::Idle);
 }
-
-namespace mozilla {
-
-PRThread* GetCurrentVirtualThread() {
-  // We call GetCurrentVirtualThread very early in startup, before the TLS is
-  // initialized. Make sure we don't assert in that case.
-  if (gTlsCurrentVirtualThread.initialized()) {
-    if (gTlsCurrentVirtualThread.get()) {
-      return gTlsCurrentVirtualThread.get();
-    }
-  }
-  return PR_GetCurrentThread();
-}
-
-PRThread* GetCurrentPhysicalThread() { return PR_GetCurrentThread(); }
-
-}  // namespace mozilla
--- a/xpcom/threads/nsThreadUtils.cpp
+++ b/xpcom/threads/nsThreadUtils.cpp
@@ -596,18 +596,18 @@ size_t GetNumberOfProcessors() {
 #endif
   MOZ_ASSERT(procs > 0);
   return static_cast<size_t>(procs);
 }
 
 }  // namespace mozilla
 
 bool nsIEventTarget::IsOnCurrentThread() {
-  if (mVirtualThread) {
-    return mVirtualThread == GetCurrentVirtualThread();
+  if (mThread) {
+    return mThread == PR_GetCurrentThread();
   }
   return IsOnCurrentThreadInfallible();
 }
 
 extern "C" {
 // These functions use the C language linkage because they're exposed to Rust
 // via the xpcom/rust/moz_task crate, which wraps them in safe Rust functions
 // that enable Rust code to get/create threads and dispatch runnables on them.
--- a/xpcom/threads/nsThreadUtils.h
+++ b/xpcom/threads/nsThreadUtils.h
@@ -1690,60 +1690,16 @@ void NS_UnsetMainThread();
  * have lower priority than callbacks dispatched from
  * nsIThread::IdleDispatch.
  */
 extern mozilla::TimeStamp NS_GetTimerDeadlineHintOnCurrentThread(
     mozilla::TimeStamp aDefault, uint32_t aSearchBound);
 
 namespace mozilla {
 
-/**
- * Cooperative thread scheduling is governed by two rules:
- * - Only one thread in the pool of cooperatively scheduled threads runs at a
- *   time.
- * - Thread switching happens at well-understood safe points.
- *
- * In some cases we may want to treat all the threads in a cooperative pool as a
- * single thread, while other parts of the code may want to view them as
- * separate threads. GetCurrentVirtualThread() will return the same value for
- * all threads in a cooperative thread pool. GetCurrentPhysicalThread will
- * return a different value for each thread in the pool.
- *
- * Thread safety assertions are a concrete example where GetCurrentVirtualThread
- * should be used. An object may want to assert that it only can be used on the
- * thread that created it. Such assertions would normally prevent the object
- * from being used on different cooperative threads. However, the object might
- * really only care that it's used atomically. Cooperative scheduling guarantees
- * that it will be (assuming we don't yield in the middle of modifying the
- * object). So we can weaken the assertion to compare the virtual thread the
- * object was created on to the virtual thread on which it's being used. This
- * assertion allows the object to be used across threads in a cooperative thread
- * pool while preventing accesses across preemptively scheduled threads (which
- * would be unsafe).
- */
-
-// Returns the PRThread on which this code is running.
-PRThread* GetCurrentPhysicalThread();
-
-// Returns a "virtual" PRThread that should only be used for comparison with
-// other calls to GetCurrentVirtualThread. Two threads in the same cooperative
-// thread pool will return the same virtual thread. Threads that are not
-// cooperatively scheduled will have their own unique virtual PRThread (which
-// will be equal to their physical PRThread).
-//
-// The return value of GetCurrentVirtualThread() is guaranteed not to change
-// throughout the lifetime of a thread.
-//
-// Note that the original main thread (the first one created in the process) is
-// considered as part of the pool of cooperative threads, so the return value of
-// GetCurrentVirtualThread() for this thread (throughout its lifetime, even
-// during shutdown) is the same as the return value from any other thread in the
-// cooperative pool.
-PRThread* GetCurrentVirtualThread();
-
 // These functions return event targets that can be used to dispatch to the
 // current or main thread. They can also be used to test if you're on those
 // threads (via IsOnCurrentThread). These functions should be used in preference
 // to the nsIThread-based NS_Get{Current,Main}Thread functions since they will
 // return more useful answers in the case of threads sharing an event loop.
 
 nsIEventTarget* GetCurrentThreadEventTarget();