From c4ee57e5e63c209f79c441c5b5de6647f1f547a8 Mon Sep 17 00:00:00 2001 From: Karl Tomlinson Date: Mon, 16 Apr 2018 19:43:56 +1200 Subject: [PATCH] bug 1455210 call CycleCollectedJSContext::Get() only once in EnterDebuggerEventLoop() r=baku The WorkerJSContext is created and destroyed after entry and before exit from WorkerThreadPrimaryRunnable::Run(). WorkerPrivate::EnterDebuggerEventLoop() is called only while WorkerThreadPrimaryRunnable::Run is on the stack, and so the CycleCollectedJSContext will not change. MozReview-Commit-ID: HMJ8fpKC6E3 --HG-- extra : rebase_source : d481f4513f9e5ed29224ce01534fa3de95bc7ae4 --- dom/workers/WorkerPrivate.cpp | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/dom/workers/WorkerPrivate.cpp b/dom/workers/WorkerPrivate.cpp index 5fd87da83b9b..207c45ba1528 100644 --- a/dom/workers/WorkerPrivate.cpp +++ b/dom/workers/WorkerPrivate.cpp @@ -4402,6 +4402,7 @@ WorkerPrivate::EnterDebuggerEventLoop() JSContext* cx = GetJSContext(); MOZ_ASSERT(cx); + CycleCollectedJSContext* ccjscx = CycleCollectedJSContext::Get(); uint32_t currentEventLoopLevel = ++mDebuggerEventLoopLevel; @@ -4424,9 +4425,8 @@ WorkerPrivate::EnterDebuggerEventLoop() { MutexAutoLock lock(mMutex); - CycleCollectedJSContext* context = CycleCollectedJSContext::Get(); std::queue>& debuggerMtQueue = - context->GetDebuggerMicroTaskQueue(); + ccjscx->GetDebuggerMicroTaskQueue(); while (mControlQueue.IsEmpty() && !(debuggerRunnablesPending = !mDebuggerQueue.IsEmpty()) && debuggerMtQueue.empty()) { @@ -4437,8 +4437,7 @@ WorkerPrivate::EnterDebuggerEventLoop() // XXXkhuey should we abort JS on the stack here if we got Abort above? } - CycleCollectedJSContext* context = CycleCollectedJSContext::Get(); - context->PerformDebuggerMicroTaskCheckpoint(); + ccjscx->PerformDebuggerMicroTaskCheckpoint(); if (debuggerRunnablesPending) { // Start the periodic GC timer if it is not already running. SetGCTimerMode(PeriodicTimer); @@ -4455,8 +4454,7 @@ WorkerPrivate::EnterDebuggerEventLoop() static_cast(runnable)->Run(); runnable->Release(); - CycleCollectedJSContext* ccjs = CycleCollectedJSContext::Get(); - ccjs->PerformDebuggerMicroTaskCheckpoint(); + ccjscx->PerformDebuggerMicroTaskCheckpoint(); // Now *might* be a good time to GC. Let the JS engine make the decision. if (JS::CurrentGlobalOrNull(cx)) {