Bug 1302448 part 3 - Rename WorkerJSRuntime to WorkerJSContext. r=baku
authorJan de Mooij <jdemooij@mozilla.com>
Wed, 14 Sep 2016 15:48:42 +0200
changeset 313918 b0675d0dcfb55224c6813f30368393327157da2f
parent 313917 1d1db582972c2e14e1376489c6522b1c3cee05fc
child 313919 0ee12557d6e630d90e07fdecf88016fde7e68ea7
push id81734
push userjandemooij@gmail.com
push dateWed, 14 Sep 2016 13:51:18 +0000
treeherdermozilla-inbound@b0675d0dcfb5 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbaku
bugs1302448
milestone51.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 1302448 part 3 - Rename WorkerJSRuntime to WorkerJSContext. r=baku
dom/workers/RuntimeService.cpp
dom/workers/WorkerPrivate.cpp
--- a/dom/workers/RuntimeService.cpp
+++ b/dom/workers/RuntimeService.cpp
@@ -887,21 +887,21 @@ FinishAsyncTaskCallback(JS::AsyncTask* a
 
     MOZ_ALWAYS_TRUE(cr->Dispatch());
     return false;
   }
 
   return true;
 }
 
-class WorkerJSRuntime;
+class WorkerJSContext;
 
 class WorkerThreadContextPrivate : private PerThreadAtomCache
 {
-  friend class WorkerJSRuntime;
+  friend class WorkerJSContext;
 
   WorkerPrivate* mWorkerPrivate;
 
 public:
   // This can't return null, but we can't lose the "Get" prefix in the name or
   // it will be ambiguous with the WorkerPrivate class name.
   WorkerPrivate*
   GetWorkerPrivate() const
@@ -1038,28 +1038,28 @@ Wrap(JSContext *cx, JS::HandleObject exi
   return js::Wrapper::New(cx, obj, wrapper);
 }
 
 static const JSWrapObjectCallbacks WrapObjectCallbacks = {
   Wrap,
   nullptr,
 };
 
-class WorkerJSRuntime : public mozilla::CycleCollectedJSContext
+class MOZ_STACK_CLASS WorkerJSContext final : public mozilla::CycleCollectedJSContext
 {
 public:
   // The heap size passed here doesn't matter, we will change it later in the
   // call to JS_SetGCParameter inside InitJSContextForWorker.
-  explicit WorkerJSRuntime(WorkerPrivate* aWorkerPrivate)
+  explicit WorkerJSContext(WorkerPrivate* aWorkerPrivate)
     : mWorkerPrivate(aWorkerPrivate)
   {
     MOZ_ASSERT(aWorkerPrivate);
   }
 
-  ~WorkerJSRuntime()
+  ~WorkerJSContext()
   {
     JSContext* cx = MaybeContext();
     if (!cx) {
       return;   // Initialize() must have failed
     }
 
     delete static_cast<WorkerThreadContextPrivate*>(JS_GetContextPrivate(cx));
     JS_SetContextPrivate(cx, nullptr);
@@ -1455,17 +1455,17 @@ GetCurrentThreadWorkerPrivate()
     return nullptr;
   }
 
   JSContext* cx = ccjscx->Context();
   MOZ_ASSERT(cx);
 
   void* cxPrivate = JS_GetContextPrivate(cx);
   if (!cxPrivate) {
-    // This can happen if the nsCycleCollector_shutdown() in ~WorkerJSRuntime()
+    // 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();
@@ -2827,27 +2827,27 @@ WorkerThreadPrimaryRunnable::Run()
 
   SetThreadHelper threadHelper(mWorkerPrivate, mThread);
 
   mWorkerPrivate->AssertIsOnWorkerThread();
 
   {
     nsCycleCollector_startup();
 
-    WorkerJSRuntime runtime(mWorkerPrivate);
-    nsresult rv = runtime.Initialize(mParentContext);
+    WorkerJSContext context(mWorkerPrivate);
+    nsresult rv = context.Initialize(mParentContext);
     if (NS_WARN_IF(NS_FAILED(rv))) {
       return rv;
     }
 
-    JSContext* cx = runtime.Context();
+    JSContext* cx = context.Context();
 
     if (!InitJSContextForWorker(mWorkerPrivate, cx)) {
       // XXX need to fire an error at parent.
-      NS_ERROR("Failed to create runtime and context!");
+      NS_ERROR("Failed to create context!");
       return NS_ERROR_FAILURE;
     }
 
     {
 #ifdef MOZ_ENABLE_PROFILER_SPS
       PseudoStack* stack = mozilla_get_pseudo_stack();
       if (stack) {
         stack->sampleContext(cx);
@@ -2884,17 +2884,17 @@ WorkerThreadPrimaryRunnable::Run()
     // which should break all cycles that touch JS.
     JS_GC(cx);
 
     // Before shutting down the cycle collector we need to do one more pass
     // through the event loop to clean up any C++ objects that need deferred
     // cleanup.
     mWorkerPrivate->ClearMainEventQueue(WorkerPrivate::WorkerRan);
 
-    // Now WorkerJSRuntime goes out of scope and its destructor will shut
+    // Now WorkerJSContext goes out of scope and its destructor will shut
     // down the cycle collector. This breaks any remaining cycles and collects
     // any remaining C++ objects.
   }
 
   threadHelper.Nullify();
 
   mWorkerPrivate->ScheduleDeletion(WorkerPrivate::WorkerRan);
 
--- a/dom/workers/WorkerPrivate.cpp
+++ b/dom/workers/WorkerPrivate.cpp
@@ -1503,26 +1503,26 @@ public:
 #ifdef DEBUG
 static bool
 StartsWithExplicit(nsACString& s)
 {
     return StringBeginsWith(s, NS_LITERAL_CSTRING("explicit/"));
 }
 #endif
 
-class WorkerJSRuntimeStats : public JS::RuntimeStats
+class MOZ_STACK_CLASS WorkerJSContextStats final : public JS::RuntimeStats
 {
   const nsACString& mRtPath;
 
 public:
-  explicit WorkerJSRuntimeStats(const nsACString& aRtPath)
+  explicit WorkerJSContextStats(const nsACString& aRtPath)
   : JS::RuntimeStats(JsWorkerMallocSizeOf), mRtPath(aRtPath)
   { }
 
-  ~WorkerJSRuntimeStats()
+  ~WorkerJSContextStats()
   {
     for (size_t i = 0; i != zoneStatsVector.length(); i++) {
       delete static_cast<xpc::ZoneStatsExtras*>(zoneStatsVector[i].extra);
     }
 
     for (size_t i = 0; i != compartmentStatsVector.length(); i++) {
       delete static_cast<xpc::CompartmentStatsExtras*>(compartmentStatsVector[i].extra);
     }
@@ -2022,20 +2022,20 @@ public:
   }
 
   NS_IMETHOD
   CollectReports(nsIHandleReportCallback* aHandleReport,
                  nsISupports* aData, bool aAnonymize) override
   {
     AssertIsOnMainThread();
 
-    // Assumes that WorkerJSRuntimeStats will hold a reference to |path|, and
+    // Assumes that WorkerJSContextStats will hold a reference to |path|, and
     // not a copy, as TryToMapAddon() may later modify it.
     nsCString path;
-    WorkerJSRuntimeStats rtStats(path);
+    WorkerJSContextStats cxStats(path);
 
     {
       MutexAutoLock lock(mMutex);
 
       if (!mWorkerPrivate) {
         // Returning NS_OK here will effectively report 0 memory.
         return NS_OK;
       }
@@ -2055,23 +2055,23 @@ public:
         NS_ConvertUTF16toUTF8 escapedURL(mWorkerPrivate->ScriptURL());
         escapedURL.ReplaceChar('/', '\\');
         path.Append(escapedURL);
       }
       path.AppendPrintf(", 0x%p)/", static_cast<void*>(mWorkerPrivate));
 
       TryToMapAddon(path);
 
-      if (!mWorkerPrivate->BlockAndCollectRuntimeStats(&rtStats, aAnonymize)) {
+      if (!mWorkerPrivate->BlockAndCollectRuntimeStats(&cxStats, aAnonymize)) {
         // Returning NS_OK here will effectively report 0 memory.
         return NS_OK;
       }
     }
 
-    xpc::ReportJSRuntimeExplicitTreeStats(rtStats, path, aHandleReport, aData,
+    xpc::ReportJSRuntimeExplicitTreeStats(cxStats, path, aHandleReport, aData,
                                           aAnonymize);
     return NS_OK;
   }
 
 private:
   ~MemoryReporter()
   { }