Bug 1316616 part 1. Replace some redundant code in GetCurrentThreadWorkerPrivate() with a call to a function that we already have. r=bkelly
authorBoris Zbarsky <bzbarsky@mit.edu>
Fri, 18 Nov 2016 16:13:06 -0500
changeset 323488 e70b0fb180a3444285502a5ecff5c2634c6f0cab
parent 323487 c1a0df0334a19e3ebd8f94772a2f48bfc920bb5e
child 323489 d9c4800ffba6692543bcda18e12b1cc197a70d63
push id30978
push usercbook@mozilla.com
push dateMon, 21 Nov 2016 14:44:46 +0000
treeherdermozilla-central@0534254e9a40 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbkelly
bugs1316616
milestone53.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 1316616 part 1. Replace some redundant code in GetCurrentThreadWorkerPrivate() with a call to a function that we already have. r=bkelly
dom/workers/RuntimeService.cpp
--- a/dom/workers/RuntimeService.cpp
+++ b/dom/workers/RuntimeService.cpp
@@ -1449,27 +1449,21 @@ GetCurrentThreadWorkerPrivate()
   CycleCollectedJSContext* ccjscx = CycleCollectedJSContext::Get();
   if (!ccjscx) {
     return nullptr;
   }
 
   JSContext* cx = ccjscx->Context();
   MOZ_ASSERT(cx);
 
-  void* cxPrivate = JS_GetContextPrivate(cx);
-  if (!cxPrivate) {
-    // This can happen if the nsCycleCollector_shutdown() in ~WorkerJSContext()
-    // triggers any calls to GetCurrentThreadWorkerPrivate().  At this stage
-    // CycleCollectedJSContext::Get() will still return a context, but
-    // the context private has already been cleared.
-    return nullptr;
-  }
-
-  return
-    static_cast<WorkerThreadContextPrivate*>(cxPrivate)->GetWorkerPrivate();
+  // Note that we can return nullptr if the nsCycleCollector_shutdown() in
+  // ~WorkerJSContext() triggers any calls to GetCurrentThreadWorkerPrivate().
+  // At this stage CycleCollectedJSContext::Get() will still return a context,
+  // but the context private has already been cleared.
+  return GetWorkerPrivateFromContext(cx);
 }
 
 bool
 IsCurrentThreadRunningChromeWorker()
 {
   return GetCurrentThreadWorkerPrivate()->UsesSystemPrincipal();
 }