From b1772a3a73bba9307028193d21c11937d6de3d0b Mon Sep 17 00:00:00 2001 From: Bobby Holley Date: Tue, 24 Sep 2013 08:03:23 -0700 Subject: [PATCH] Bug 917909 - Remove mLastContext hackery in workers. r=khuey r=billm --- dom/workers/RuntimeService.cpp | 24 ++++++------------------ 1 file changed, 6 insertions(+), 18 deletions(-) diff --git a/dom/workers/RuntimeService.cpp b/dom/workers/RuntimeService.cpp index b5a3ac57268..a2a1465a2e1 100644 --- a/dom/workers/RuntimeService.cpp +++ b/dom/workers/RuntimeService.cpp @@ -833,15 +833,7 @@ public: : CycleCollectedJSRuntime(WORKER_DEFAULT_RUNTIME_HEAPSIZE, JS_NO_HELPER_THREADS), mWorkerPrivate(aWorkerPrivate) - { - // We need to ensure that a JSContext outlives the cycle collector, and - // that the internal JSContext created by ctypes is not the last JSContext - // to die. So we create an unused JSContext here and destroy it after - // the cycle collector shuts down. Thus all cycles will be broken before - // the last GC and all finalizers will be run. - mLastJSContext = JS_NewContext(Runtime(), 0); - MOZ_ASSERT(mLastJSContext); - } + { } ~WorkerJSRuntime() { @@ -849,18 +841,15 @@ public: delete rtPrivate; JS_SetRuntimePrivate(Runtime(), nullptr); - // All JSContexts except mLastJSContext should be destroyed now. The - // worker global will be unrooted and the shutdown cycle collection - // should break all remaining cycles. Destroying mLastJSContext will run - // the GC the final time and finalize any JSObjects that were participating + // The worker global should be unrooted and the shutdown cycle collection + // should break all remaining cycles. The superclass destructor will run + // the GC one final time and finalize any JSObjects that were participating // in cycles that were broken during CC shutdown. nsCycleCollector_shutdown(); - // The CC is shutdown, and this will GC, so make sure we don't try to CC - // again. + // The CC is shut down, and the superclass destructor will GC, so make sure + // we don't try to CC again. mWorkerPrivate = nullptr; - JS_DestroyContext(mLastJSContext); - mLastJSContext = nullptr; } void @@ -888,7 +877,6 @@ public: private: WorkerPrivate* mWorkerPrivate; - JSContext* mLastJSContext; }; class WorkerThreadRunnable : public nsRunnable