Bug 1283855 part 27 - Make more GC APIs take JSContext instead of JSRuntime. r=jonco
authorJan de Mooij <jdemooij@mozilla.com>
Thu, 07 Jul 2016 09:55:45 +0200
changeset 331293 d22e5cad510bc8c642702e9e8ebb7140cff9605e
parent 331292 a064d2e7a3c00288972e4f26cba74878a3c63d04
child 331294 c521197a29b7e2f100420312788da9055ff2a8b5
push idunknown
push userunknown
push dateunknown
reviewersjonco
bugs1283855
milestone50.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 1283855 part 27 - Make more GC APIs take JSContext instead of JSRuntime. r=jonco
dom/base/nsJSEnvironment.cpp
js/public/GCAPI.h
js/src/jsapi-tests/testGCFinalizeCallback.cpp
js/src/jsfriendapi.cpp
js/src/jsgc.cpp
js/xpconnect/src/XPCJSRuntime.cpp
js/xpconnect/src/nsXPConnect.cpp
xpcom/base/CycleCollectedJSRuntime.cpp
xpcom/base/nsCycleCollector.cpp
--- a/dom/base/nsJSEnvironment.cpp
+++ b/dom/base/nsJSEnvironment.cpp
@@ -347,17 +347,17 @@ nsJSEnvironmentObserver::Observe(nsISupp
     }
   } else if (!nsCRT::strcmp(aTopic, "user-interaction-inactive")) {
     if (sCompactOnUserInactive) {
       nsJSContext::PokeShrinkingGC();
     }
   } else if (!nsCRT::strcmp(aTopic, "user-interaction-active")) {
     nsJSContext::KillShrinkingGCTimer();
     if (sIsCompactingOnUserInactive) {
-      JS::AbortIncrementalGC(sRuntime);
+      JS::AbortIncrementalGC(sContext);
     }
     MOZ_ASSERT(!sIsCompactingOnUserInactive);
   } else if (!nsCRT::strcmp(aTopic, "quit-application") ||
              !nsCRT::strcmp(aTopic, NS_XPCOM_SHUTDOWN_OBSERVER_ID)) {
     sShuttingDown = true;
     KillTimers();
   }
 
@@ -1201,57 +1201,57 @@ nsJSContext::GarbageCollectNow(JS::gcrea
 
   if (!nsContentUtils::XPConnect() || !sRuntime) {
     return;
   }
 
   if (sCCLockedOut && aIncremental == IncrementalGC) {
     // We're in the middle of incremental GC. Do another slice.
     JS::PrepareForIncrementalGC(sContext);
-    JS::IncrementalGCSlice(sRuntime, aReason, aSliceMillis);
+    JS::IncrementalGCSlice(sContext, aReason, aSliceMillis);
     return;
   }
 
   JSGCInvocationKind gckind = aShrinking == ShrinkingGC ? GC_SHRINK : GC_NORMAL;
 
   if (sNeedsFullGC || aReason != JS::gcreason::CC_WAITING) {
     sNeedsFullGC = false;
     JS::PrepareForFullGC(sContext);
   } else {
     CycleCollectedJSRuntime::Get()->PrepareWaitingZonesForGC();
   }
 
   if (aIncremental == IncrementalGC) {
-    JS::StartIncrementalGC(sRuntime, gckind, aReason, aSliceMillis);
+    JS::StartIncrementalGC(sContext, gckind, aReason, aSliceMillis);
   } else {
     JS::GCForReason(sContext, gckind, aReason);
   }
 }
 
 //static
 void
 nsJSContext::ShrinkGCBuffersNow()
 {
   PROFILER_LABEL("nsJSContext", "ShrinkGCBuffersNow",
     js::ProfileEntry::Category::GC);
 
   KillShrinkGCBuffersTimer();
 
-  JS::ShrinkGCBuffers(sRuntime);
+  JS::ShrinkGCBuffers(sContext);
 }
 
 static void
 FinishAnyIncrementalGC()
 {
   PROFILER_LABEL_FUNC(js::ProfileEntry::Category::GC);
 
   if (sCCLockedOut) {
     // We're in the middle of an incremental GC, so finish it.
     JS::PrepareForIncrementalGC(sContext);
-    JS::FinishIncrementalGC(sRuntime, JS::gcreason::CC_FORCED);
+    JS::FinishIncrementalGC(sContext, JS::gcreason::CC_FORCED);
   }
 }
 
 static void
 FireForgetSkippable(uint32_t aSuspected, bool aRemoveChildless)
 {
   PRTime startTime = PR_Now();
   FinishAnyIncrementalGC();
@@ -2444,17 +2444,17 @@ nsJSContext::EnsureStatics()
     MOZ_CRASH();
   }
 
   sContext = JS_GetContext(sRuntime);
 
   // Let's make sure that our main thread is the same as the xpcom main thread.
   MOZ_ASSERT(NS_IsMainThread());
 
-  sPrevGCSliceCallback = JS::SetGCSliceCallback(sRuntime, DOMGCSliceCallback);
+  sPrevGCSliceCallback = JS::SetGCSliceCallback(sContext, DOMGCSliceCallback);
 
   // Set up the asm.js cache callbacks
   static const JS::AsmJSCacheOps asmJSCacheOps = {
     AsmJSCacheOpenEntryForRead,
     asmjscache::CloseEntryForRead,
     AsmJSCacheOpenEntryForWrite,
     asmjscache::CloseEntryForWrite
   };
--- a/js/public/GCAPI.h
+++ b/js/public/GCAPI.h
@@ -222,53 +222,53 @@ GCForReason(JSContext* cx, JSGCInvocatio
  * Note: Even if incremental GC is enabled and working correctly,
  *       non-incremental collections can still happen when low on memory.
  */
 
 /**
  * Begin an incremental collection and perform one slice worth of work. When
  * this function returns, the collection may not be complete.
  * IncrementalGCSlice() must be called repeatedly until
- * !IsIncrementalGCInProgress(rt).
+ * !IsIncrementalGCInProgress(cx).
  *
  * Note: SpiderMonkey's GC is not realtime. Slices in practice may be longer or
  *       shorter than the requested interval.
  */
 extern JS_PUBLIC_API(void)
-StartIncrementalGC(JSRuntime* rt, JSGCInvocationKind gckind, gcreason::Reason reason,
+StartIncrementalGC(JSContext* cx, JSGCInvocationKind gckind, gcreason::Reason reason,
                    int64_t millis = 0);
 
 /**
  * Perform a slice of an ongoing incremental collection. When this function
  * returns, the collection may not be complete. It must be called repeatedly
- * until !IsIncrementalGCInProgress(rt).
+ * until !IsIncrementalGCInProgress(cx).
  *
  * Note: SpiderMonkey's GC is not realtime. Slices in practice may be longer or
  *       shorter than the requested interval.
  */
 extern JS_PUBLIC_API(void)
-IncrementalGCSlice(JSRuntime* rt, gcreason::Reason reason, int64_t millis = 0);
+IncrementalGCSlice(JSContext* cx, gcreason::Reason reason, int64_t millis = 0);
 
 /**
- * If IsIncrementalGCInProgress(rt), this call finishes the ongoing collection
- * by performing an arbitrarily long slice. If !IsIncrementalGCInProgress(rt),
+ * If IsIncrementalGCInProgress(cx), this call finishes the ongoing collection
+ * by performing an arbitrarily long slice. If !IsIncrementalGCInProgress(cx),
  * this is equivalent to GCForReason. When this function returns,
- * IsIncrementalGCInProgress(rt) will always be false.
+ * IsIncrementalGCInProgress(cx) will always be false.
  */
 extern JS_PUBLIC_API(void)
-FinishIncrementalGC(JSRuntime* rt, gcreason::Reason reason);
+FinishIncrementalGC(JSContext* cx, gcreason::Reason reason);
 
 /**
- * If IsIncrementalGCInProgress(rt), this call aborts the ongoing collection and
+ * If IsIncrementalGCInProgress(cx), this call aborts the ongoing collection and
  * performs whatever work needs to be done to return the collector to its idle
  * state. This may take an arbitrarily long time. When this function returns,
- * IsIncrementalGCInProgress(rt) will always be false.
+ * IsIncrementalGCInProgress(cx) will always be false.
  */
 extern JS_PUBLIC_API(void)
-AbortIncrementalGC(JSRuntime* rt);
+AbortIncrementalGC(JSContext* cx);
 
 namespace dbg {
 
 // The `JS::dbg::GarbageCollectionEvent` class is essentially a view of the
 // `js::gcstats::Statistics` data without the uber implementation-specific bits.
 // It should generally be palatable for web developers.
 class GarbageCollectionEvent
 {
@@ -351,17 +351,17 @@ typedef void
 (* GCSliceCallback)(JSRuntime* rt, GCProgress progress, const GCDescription& desc);
 
 /**
  * The GC slice callback is called at the beginning and end of each slice. This
  * callback may be used for GC notifications as well as to perform additional
  * marking.
  */
 extern JS_PUBLIC_API(GCSliceCallback)
-SetGCSliceCallback(JSRuntime* rt, GCSliceCallback callback);
+SetGCSliceCallback(JSContext* cx, GCSliceCallback callback);
 
 /**
  * Describes the progress of an observed nursery collection.
  */
 enum class GCNurseryProgress {
     /**
      * The nursery collection is starting.
      */
@@ -379,17 +379,17 @@ enum class GCNurseryProgress {
 using GCNurseryCollectionCallback = void(*)(JSRuntime* rt, GCNurseryProgress progress,
                                             gcreason::Reason reason);
 
 /**
  * Set the nursery collection callback for the given runtime. When set, it will
  * be called at the start and end of every nursery collection.
  */
 extern JS_PUBLIC_API(GCNurseryCollectionCallback)
-SetGCNurseryCollectionCallback(JSRuntime* rt, GCNurseryCollectionCallback callback);
+SetGCNurseryCollectionCallback(JSContext* cx, GCNurseryCollectionCallback callback);
 
 /**
  * Incremental GC defaults to enabled, but may be disabled for testing or in
  * embeddings that have not yet implemented barriers on their native classes.
  * There is not currently a way to re-enable incremental GC once it has been
  * disabled on the runtime.
  */
 extern JS_PUBLIC_API(void)
@@ -474,17 +474,17 @@ extern JS_PUBLIC_API(size_t)
 GetGCNumber();
 
 /**
  * The GC does not immediately return the unused memory freed by a collection
  * back to the system incase it is needed soon afterwards. This call forces the
  * GC to return this memory immediately.
  */
 extern JS_PUBLIC_API(void)
-ShrinkGCBuffers(JSRuntime* rt);
+ShrinkGCBuffers(JSContext* cx);
 
 /**
  * Assert if a GC occurs while this class is live. This class does not disable
  * the static rooting hazard analysis.
  */
 class JS_PUBLIC_API(AutoAssertOnGC)
 {
 #ifdef DEBUG
@@ -660,19 +660,19 @@ MarkStringAsLive(Zone* zone, JSString* s
 }
 
 /*
  * Internal to Firefox.
  *
  * Note: this is not related to the PokeGC in nsJSEnvironment.
  */
 extern JS_FRIEND_API(void)
-PokeGC(JSRuntime* rt);
+PokeGC(JSContext* cx);
 
 /*
  * Internal to Firefox.
  */
 extern JS_FRIEND_API(void)
-NotifyDidPaint(JSRuntime* rt);
+NotifyDidPaint(JSContext* cx);
 
 } /* namespace JS */
 
 #endif /* js_GCAPI_h */
--- a/js/src/jsapi-tests/testGCFinalizeCallback.cpp
+++ b/js/src/jsapi-tests/testGCFinalizeCallback.cpp
@@ -19,20 +19,20 @@ BEGIN_TEST(testGCFinalizeCallback)
     CHECK(rt->gc.isFullGc());
     CHECK(checkSingleGroup());
     CHECK(checkFinalizeStatus());
     CHECK(checkFinalizeIsCompartmentGC(false));
 
     /* Full GC, incremental. */
     FinalizeCalls = 0;
     JS::PrepareForFullGC(cx);
-    JS::StartIncrementalGC(rt, GC_NORMAL, JS::gcreason::API, 1000000);
+    JS::StartIncrementalGC(cx, GC_NORMAL, JS::gcreason::API, 1000000);
     while (rt->gc.isIncrementalGCInProgress()) {
         JS::PrepareForFullGC(cx);
-        JS::IncrementalGCSlice(rt, JS::gcreason::API, 1000000);
+        JS::IncrementalGCSlice(cx, JS::gcreason::API, 1000000);
     }
     CHECK(!rt->gc.isIncrementalGCInProgress());
     CHECK(rt->gc.isFullGc());
     CHECK(checkMultipleGroups());
     CHECK(checkFinalizeStatus());
     CHECK(checkFinalizeIsCompartmentGC(false));
 
     JS::RootedObject global1(cx, createTestGlobal());
@@ -60,38 +60,38 @@ BEGIN_TEST(testGCFinalizeCallback)
     CHECK(!rt->gc.isFullGc());
     CHECK(checkSingleGroup());
     CHECK(checkFinalizeStatus());
     CHECK(checkFinalizeIsCompartmentGC(true));
 
     /* Compartment GC, incremental, single compartment. */
     FinalizeCalls = 0;
     JS::PrepareZoneForGC(global1->zone());
-    JS::StartIncrementalGC(rt, GC_NORMAL, JS::gcreason::API, 1000000);
+    JS::StartIncrementalGC(cx, GC_NORMAL, JS::gcreason::API, 1000000);
     while (rt->gc.isIncrementalGCInProgress()) {
         JS::PrepareZoneForGC(global1->zone());
-        JS::IncrementalGCSlice(rt, JS::gcreason::API, 1000000);
+        JS::IncrementalGCSlice(cx, JS::gcreason::API, 1000000);
     }
     CHECK(!rt->gc.isIncrementalGCInProgress());
     CHECK(!rt->gc.isFullGc());
     CHECK(checkSingleGroup());
     CHECK(checkFinalizeStatus());
     CHECK(checkFinalizeIsCompartmentGC(true));
 
     /* Compartment GC, incremental, multiple compartments. */
     FinalizeCalls = 0;
     JS::PrepareZoneForGC(global1->zone());
     JS::PrepareZoneForGC(global2->zone());
     JS::PrepareZoneForGC(global3->zone());
-    JS::StartIncrementalGC(rt, GC_NORMAL, JS::gcreason::API, 1000000);
+    JS::StartIncrementalGC(cx, GC_NORMAL, JS::gcreason::API, 1000000);
     while (rt->gc.isIncrementalGCInProgress()) {
         JS::PrepareZoneForGC(global1->zone());
         JS::PrepareZoneForGC(global2->zone());
         JS::PrepareZoneForGC(global3->zone());
-        JS::IncrementalGCSlice(rt, JS::gcreason::API, 1000000);
+        JS::IncrementalGCSlice(cx, JS::gcreason::API, 1000000);
     }
     CHECK(!rt->gc.isIncrementalGCInProgress());
     CHECK(!rt->gc.isFullGc());
     CHECK(checkMultipleGroups());
     CHECK(checkFinalizeStatus());
     CHECK(checkFinalizeIsCompartmentGC(true));
 
 #ifdef JS_GC_ZEAL
--- a/js/src/jsfriendapi.cpp
+++ b/js/src/jsfriendapi.cpp
@@ -1136,25 +1136,25 @@ js::DumpHeap(JSContext* cx, FILE* fp, js
 JS_FRIEND_API(void)
 js::SetActivityCallback(JSContext* cx, ActivityCallback cb, void* arg)
 {
     cx->activityCallback = cb;
     cx->activityCallbackArg = arg;
 }
 
 JS_FRIEND_API(void)
-JS::NotifyDidPaint(JSRuntime* rt)
+JS::NotifyDidPaint(JSContext* cx)
 {
-    rt->gc.notifyDidPaint();
+    cx->gc.notifyDidPaint();
 }
 
 JS_FRIEND_API(void)
-JS::PokeGC(JSRuntime* rt)
+JS::PokeGC(JSContext* cx)
 {
-    rt->gc.poke();
+    cx->gc.poke();
 }
 
 JS_FRIEND_API(JSCompartment*)
 js::GetAnyCompartmentInZone(JS::Zone* zone)
 {
     CompartmentsInZoneIter comp(zone);
     MOZ_ASSERT(!comp.done());
     return comp.get();
--- a/js/src/jsgc.cpp
+++ b/js/src/jsgc.cpp
@@ -6466,20 +6466,20 @@ GCRuntime::debugGCSlice(SliceBudget& bud
 void
 js::PrepareForDebugGC(JSRuntime* rt)
 {
     if (!ZonesSelected(rt))
         JS::PrepareForFullGC(rt->contextFromMainThread());
 }
 
 JS_PUBLIC_API(void)
-JS::ShrinkGCBuffers(JSRuntime* rt)
-{
-    MOZ_ASSERT(!rt->isHeapBusy());
-    rt->gc.shrinkBuffers();
+JS::ShrinkGCBuffers(JSContext* cx)
+{
+    MOZ_ASSERT(!cx->isHeapBusy());
+    cx->gc.shrinkBuffers();
 }
 
 void
 GCRuntime::shrinkBuffers()
 {
     AutoLockHelperThreadState helperLock;
     AutoLockGC lock(rt);
 
@@ -6603,17 +6603,17 @@ GCRuntime::gcIfRequested(JSContext* cx /
 
     return false;
 }
 
 void js::gc::FinishGC(JSRuntime* rt)
 {
     if (JS::IsIncrementalGCInProgress(rt)) {
         JS::PrepareForIncrementalGC(rt->contextFromMainThread());
-        JS::FinishIncrementalGC(rt, JS::gcreason::API);
+        JS::FinishIncrementalGC(rt->contextFromMainThread(), JS::gcreason::API);
     }
 
     rt->gc.nursery.waitBackgroundFreeEnd();
 }
 
 AutoPrepareForTracing::AutoPrepareForTracing(JSRuntime* rt, ZoneSelector selector)
 {
     js::gc::FinishGC(rt);
@@ -7233,38 +7233,38 @@ JS::SkipZoneForGC(Zone* zone)
 JS_PUBLIC_API(void)
 JS::GCForReason(JSContext* cx, JSGCInvocationKind gckind, gcreason::Reason reason)
 {
     MOZ_ASSERT(gckind == GC_NORMAL || gckind == GC_SHRINK);
     cx->gc.gc(gckind, reason);
 }
 
 JS_PUBLIC_API(void)
-JS::StartIncrementalGC(JSRuntime* rt, JSGCInvocationKind gckind, gcreason::Reason reason, int64_t millis)
+JS::StartIncrementalGC(JSContext* cx, JSGCInvocationKind gckind, gcreason::Reason reason, int64_t millis)
 {
     MOZ_ASSERT(gckind == GC_NORMAL || gckind == GC_SHRINK);
-    rt->gc.startGC(gckind, reason, millis);
+    cx->gc.startGC(gckind, reason, millis);
 }
 
 JS_PUBLIC_API(void)
-JS::IncrementalGCSlice(JSRuntime* rt, gcreason::Reason reason, int64_t millis)
-{
-    rt->gc.gcSlice(reason, millis);
+JS::IncrementalGCSlice(JSContext* cx, gcreason::Reason reason, int64_t millis)
+{
+    cx->gc.gcSlice(reason, millis);
 }
 
 JS_PUBLIC_API(void)
-JS::FinishIncrementalGC(JSRuntime* rt, gcreason::Reason reason)
-{
-    rt->gc.finishGC(reason);
+JS::FinishIncrementalGC(JSContext* cx, gcreason::Reason reason)
+{
+    cx->gc.finishGC(reason);
 }
 
 JS_PUBLIC_API(void)
-JS::AbortIncrementalGC(JSRuntime* rt)
-{
-    rt->gc.abortGC();
+JS::AbortIncrementalGC(JSContext* cx)
+{
+    cx->gc.abortGC();
 }
 
 char16_t*
 JS::GCDescription::formatSliceMessage(JSRuntime* rt) const
 {
     UniqueChars cstr = rt->gc.stats.formatCompactSliceMessage();
 
     size_t nchars = strlen(cstr.get());
@@ -7309,25 +7309,25 @@ JS::GCDescription::formatJSON(JSRuntime*
         return nullptr;
     out.get()[nchars] = 0;
 
     CopyAndInflateChars(out.get(), cstr.get(), nchars);
     return out.release();
 }
 
 JS_PUBLIC_API(JS::GCSliceCallback)
-JS::SetGCSliceCallback(JSRuntime* rt, GCSliceCallback callback)
-{
-    return rt->gc.setSliceCallback(callback);
+JS::SetGCSliceCallback(JSContext* cx, GCSliceCallback callback)
+{
+    return cx->gc.setSliceCallback(callback);
 }
 
 JS_PUBLIC_API(JS::GCNurseryCollectionCallback)
-JS::SetGCNurseryCollectionCallback(JSRuntime* rt, GCNurseryCollectionCallback callback)
-{
-    return rt->gc.setNurseryCollectionCallback(callback);
+JS::SetGCNurseryCollectionCallback(JSContext* cx, GCNurseryCollectionCallback callback)
+{
+    return cx->gc.setNurseryCollectionCallback(callback);
 }
 
 JS_PUBLIC_API(void)
 JS::DisableIncrementalGC(JSRuntime* rt)
 {
     rt->gc.disallowIncrementalGC();
 }
 
--- a/js/xpconnect/src/XPCJSRuntime.cpp
+++ b/js/xpconnect/src/XPCJSRuntime.cpp
@@ -1650,17 +1650,17 @@ XPCJSRuntime::~XPCJSRuntime()
     JS_RemoveFinalizeCallback(Context(), FinalizeCallback);
     JS_RemoveWeakPointerZoneGroupCallback(Context(), WeakPointerZoneGroupCallback);
     JS_RemoveWeakPointerCompartmentCallback(Context(), WeakPointerCompartmentCallback);
 
     // Clear any pending exception.  It might be an XPCWrappedJS, and if we try
     // to destroy it later we will crash.
     SetPendingException(nullptr);
 
-    JS::SetGCSliceCallback(Runtime(), mPrevGCSliceCallback);
+    JS::SetGCSliceCallback(Context(), mPrevGCSliceCallback);
 
     xpc_DelocalizeRuntime(Runtime());
 
     if (mWatchdogManager->GetWatchdog())
         mWatchdogManager->StopWatchdog();
 
     if (mCallContext)
         mCallContext->SystemIsBeingShutDown();
@@ -3550,17 +3550,17 @@ XPCJSRuntime::Initialize()
     JS_SetNativeStackQuota(cx,
                            kStackQuota,
                            kStackQuota - kSystemCodeBuffer,
                            kStackQuota - kSystemCodeBuffer - kTrustedScriptBuffer);
 
     JS_SetDestroyCompartmentCallback(cx, CompartmentDestroyedCallback);
     JS_SetSizeOfIncludingThisCompartmentCallback(cx, CompartmentSizeOfIncludingThisCallback);
     JS_SetCompartmentNameCallback(cx, CompartmentNameCallback);
-    mPrevGCSliceCallback = JS::SetGCSliceCallback(runtime, GCSliceCallback);
+    mPrevGCSliceCallback = JS::SetGCSliceCallback(cx, GCSliceCallback);
     JS_AddFinalizeCallback(cx, FinalizeCallback, nullptr);
     JS_AddWeakPointerZoneGroupCallback(cx, WeakPointerZoneGroupCallback, this);
     JS_AddWeakPointerCompartmentCallback(cx, WeakPointerCompartmentCallback, this);
     JS_SetWrapObjectCallbacks(cx, &WrapObjectCallbacks);
     js::SetPreserveWrapperCallback(cx, PreserveWrapper);
 #ifdef MOZ_ENABLE_PROFILER_SPS
     if (PseudoStack* stack = mozilla_get_pseudo_stack())
         stack->sampleRuntime(runtime);
@@ -3840,17 +3840,17 @@ XPCRootSetElem::AddToRootSet(XPCRootSetE
     }
     *listHead = this;
 }
 
 void
 XPCRootSetElem::RemoveFromRootSet()
 {
     nsXPConnect* xpc = nsXPConnect::XPConnect();
-    JS::PokeGC(xpc->GetRuntime()->Runtime());
+    JS::PokeGC(xpc->GetRuntime()->Context());
 
     MOZ_ASSERT(mSelfp, "Must be linked");
 
     MOZ_ASSERT(*mSelfp == this, "Link invariant");
     *mSelfp = mNext;
     if (mNext)
         mNext->mSelfp = mSelfp;
 #ifdef DEBUG
--- a/js/xpconnect/src/nsXPConnect.cpp
+++ b/js/xpconnect/src/nsXPConnect.cpp
@@ -1078,17 +1078,17 @@ SetLocationForGlobal(JSObject* global, n
     CompartmentPrivate::Get(global)->SetLocationURI(locationURI);
 }
 
 } // namespace xpc
 
 NS_IMETHODIMP
 nsXPConnect::NotifyDidPaint()
 {
-    JS::NotifyDidPaint(GetRuntime()->Runtime());
+    JS::NotifyDidPaint(GetRuntime()->Context());
     return NS_OK;
 }
 
 static nsresult
 WriteScriptOrFunction(nsIObjectOutputStream* stream, JSContext* cx,
                       JSScript* scriptArg, HandleObject functionObj)
 {
     // Exactly one of script or functionObj must be given
--- a/xpcom/base/CycleCollectedJSRuntime.cpp
+++ b/xpcom/base/CycleCollectedJSRuntime.cpp
@@ -513,28 +513,28 @@ CycleCollectedJSRuntime::Initialize(JSRu
   }
   mJSContext = JS_GetContext(mJSRuntime);
 
   if (!JS_AddExtraGCRootsTracer(mJSContext, TraceBlackJS, this)) {
     MOZ_CRASH("JS_AddExtraGCRootsTracer failed");
   }
   JS_SetGrayGCRootsTracer(mJSContext, TraceGrayJS, this);
   JS_SetGCCallback(mJSContext, GCCallback, this);
-  mPrevGCSliceCallback = JS::SetGCSliceCallback(mJSRuntime, GCSliceCallback);
+  mPrevGCSliceCallback = JS::SetGCSliceCallback(mJSContext, GCSliceCallback);
 
   if (NS_IsMainThread()) {
     // We would like to support all threads here, but the way timeline consumers
     // are set up currently, you can either add a marker for one specific
     // docshell, or for every consumer globally. We would like to add a marker
     // for every consumer observing anything on this thread, but that is not
     // currently possible. For now, add global markers only when we are on the
     // main thread, since the UI for this tracing data only displays data
     // relevant to the main-thread.
     mPrevGCNurseryCollectionCallback = JS::SetGCNurseryCollectionCallback(
-      mJSRuntime, GCNurseryCollectionCallback);
+      mJSContext, GCNurseryCollectionCallback);
   }
 
   JS_SetObjectsTenuredCallback(mJSContext, JSObjectsTenuredCb, this);
   JS::SetOutOfMemoryCallback(mJSContext, OutOfMemoryCallback, this);
   JS::SetLargeAllocationFailureCallback(mJSContext,
                                         LargeAllocationFailureCallback, this);
   JS_SetDestroyZoneCallback(mJSContext, XPCStringConvert::FreeZoneCache);
   JS_SetSweepZoneCallback(mJSContext, XPCStringConvert::ClearZoneCache);
--- a/xpcom/base/nsCycleCollector.cpp
+++ b/xpcom/base/nsCycleCollector.cpp
@@ -3547,17 +3547,17 @@ nsCycleCollector::IsIncrementalGCInProgr
 }
 
 void
 nsCycleCollector::FinishAnyIncrementalGCInProgress()
 {
   if (IsIncrementalGCInProgress()) {
     NS_WARNING("Finishing incremental GC in progress during CC");
     JS::PrepareForIncrementalGC(mJSRuntime->Context());
-    JS::FinishIncrementalGC(mJSRuntime->Runtime(), JS::gcreason::CC_FORCED);
+    JS::FinishIncrementalGC(mJSRuntime->Context(), JS::gcreason::CC_FORCED);
   }
 }
 
 void
 nsCycleCollector::CleanupAfterCollection()
 {
   TimeLog timeLog;
   MOZ_ASSERT(mIncrementalPhase == CleanupPhase);