Bug 882162: Part 3 - Replace GetJSRuntime() with just Runtime(). r=mccr8
authorKyle Huey <khuey@kylehuey.com>
Tue, 18 Jun 2013 12:02:15 -0700
changeset 135855 ef6329710710dac46332cfeea5dfc12f741ca339
parent 135854 55331b05723b58f59b74f20d9409ee1052c71a89
child 135856 69408f4ca5e93fa36e4538d852d464ebc13671f5
push id270
push userpvanderbeken@mozilla.com
push dateThu, 06 Mar 2014 09:24:21 +0000
reviewersmccr8
bugs882162
milestone24.0a1
Bug 882162: Part 3 - Replace GetJSRuntime() with just Runtime(). r=mccr8
js/xpconnect/src/XPCComponents.cpp
js/xpconnect/src/XPCJSContextStack.cpp
js/xpconnect/src/XPCJSRuntime.cpp
js/xpconnect/src/XPCWrappedNative.cpp
js/xpconnect/src/XPCWrappedNativeScope.cpp
js/xpconnect/src/nsXPConnect.cpp
js/xpconnect/src/xpcprivate.h
--- a/js/xpconnect/src/XPCComponents.cpp
+++ b/js/xpconnect/src/XPCComponents.cpp
@@ -3998,17 +3998,17 @@ nsXPCComponents_Utils::GetWeakReference(
     ref.forget(_retval);
     return NS_OK;
 }
 
 /* void forceGC (); */
 NS_IMETHODIMP
 nsXPCComponents_Utils::ForceGC()
 {
-    JSRuntime* rt = nsXPConnect::GetRuntimeInstance()->GetJSRuntime();
+    JSRuntime* rt = nsXPConnect::GetRuntimeInstance()->Runtime();
     JS::PrepareForFullGC(rt);
     JS::GCForReason(rt, JS::gcreason::COMPONENT_UTILS);
     return NS_OK;
 }
 
 /* void forceCC (); */
 NS_IMETHODIMP
 nsXPCComponents_Utils::ForceCC()
@@ -4016,31 +4016,31 @@ nsXPCComponents_Utils::ForceCC()
     nsJSContext::CycleCollectNow();
     return NS_OK;
 }
 
 /* void forceShrinkingGC (); */
 NS_IMETHODIMP
 nsXPCComponents_Utils::ForceShrinkingGC()
 {
-    JSRuntime* rt = nsXPConnect::GetRuntimeInstance()->GetJSRuntime();
+    JSRuntime* rt = nsXPConnect::GetRuntimeInstance()->Runtime();
     JS::PrepareForFullGC(rt);
     JS::ShrinkingGC(rt, JS::gcreason::COMPONENT_UTILS);
     return NS_OK;
 }
 
 class PreciseGCRunnable : public nsRunnable
 {
   public:
     PreciseGCRunnable(ScheduledGCCallback* aCallback, bool aShrinking)
     : mCallback(aCallback), mShrinking(aShrinking) {}
 
     NS_IMETHOD Run()
     {
-        JSRuntime* rt = nsXPConnect::GetRuntimeInstance()->GetJSRuntime();
+        JSRuntime* rt = nsXPConnect::GetRuntimeInstance()->Runtime();
 
         JSContext *cx;
         JSContext *iter = nullptr;
         while ((cx = JS_ContextIterator(rt, &iter)) != NULL) {
             if (JS_IsRunning(cx)) {
                 return NS_DispatchToMainThread(this);
             }
         }
--- a/js/xpconnect/src/XPCJSContextStack.cpp
+++ b/js/xpconnect/src/XPCJSContextStack.cpp
@@ -147,17 +147,17 @@ XPCJSContextStack::GetSafeJSContext()
     if (NS_FAILED(rv))
         return NULL;
 
     nsXPConnect* xpc = nsXPConnect::XPConnect();
     XPCJSRuntime* xpcrt = xpc->GetRuntime();
     if (!xpcrt)
         return NULL;
 
-    JSRuntime *rt = xpcrt->GetJSRuntime();
+    JSRuntime *rt = xpcrt->Runtime();
     if (!rt)
         return NULL;
 
     mSafeJSContext = JS_NewContext(rt, 8192);
     if (!mSafeJSContext)
         return NULL;
 
     JS::RootedObject glob(mSafeJSContext);
--- a/js/xpconnect/src/XPCJSRuntime.cpp
+++ b/js/xpconnect/src/XPCJSRuntime.cpp
@@ -430,17 +430,17 @@ void XPCJSRuntime::TraceBlackJS(JSTracer
 
         // XPCJSObjectHolders don't participate in cycle collection, so always
         // trace them here.
         XPCRootSetElem *e;
         for (e = self->mObjectHolderRoots; e; e = e->GetNextRoot())
             static_cast<XPCJSObjectHolder*>(e)->TraceJS(trc);
     }
 
-    dom::TraceBlackJS(trc, JS_GetGCParameter(self->GetJSRuntime(), JSGC_NUMBER),
+    dom::TraceBlackJS(trc, JS_GetGCParameter(self->Runtime(), JSGC_NUMBER),
                       nsXPConnect::XPConnect()->IsShuttingDown());
 }
 
 // static
 void XPCJSRuntime::TraceGrayJS(JSTracer* trc, void* data)
 {
     XPCJSRuntime* self = (XPCJSRuntime*)data;
 
@@ -473,17 +473,17 @@ TraceJSHolder(void *holder, nsScriptObje
     tracer->Trace(holder, JsGcTracer(), arg);
 
     return PL_DHASH_NEXT;
 }
 
 void XPCJSRuntime::TraceXPConnectRoots(JSTracer *trc)
 {
     JSContext *iter = nullptr;
-    while (JSContext *acx = JS_ContextIterator(GetJSRuntime(), &iter)) {
+    while (JSContext *acx = JS_ContextIterator(Runtime(), &iter)) {
         MOZ_ASSERT(js::HasUnrootedGlobal(acx));
         if (JSObject *global = js::GetDefaultGlobalForContext(acx))
             JS_CallObjectTracer(trc, &global, "XPC global object");
     }
 
     XPCAutoLock lock(mMapLock);
 
     XPCWrappedNativeScope::TraceWrappedNativesInAllScopes(trc, this);
@@ -585,17 +585,17 @@ XPCJSRuntime::AddXPConnectRoots(nsCycleC
     // through rooting or locking, we need to add all the native objects that
     // hold them so that the JS objects are colored correctly in the cycle
     // collector. This includes JSContexts that don't have outstanding requests,
     // because their global object wasn't marked by the JS GC. All other JS
     // roots were marked by the JS GC and will be colored correctly in the cycle
     // collector.
 
     JSContext *iter = nullptr, *acx;
-    while ((acx = JS_ContextIterator(GetJSRuntime(), &iter))) {
+    while ((acx = JS_ContextIterator(Runtime(), &iter))) {
         // Add the context to the CC graph only if traversing it would
         // end up doing something.
         JSObject* global = js::GetDefaultGlobalForContext(acx);
         if (global && xpc_IsGrayGCThing(global)) {
             cb.NoteNativeRoot(acx, nsXPConnect::JSContextParticipant());
         }
     }
 
@@ -1489,40 +1489,40 @@ GetCompartmentName(JSCompartment *c, nsC
     } else {
         name.AssignLiteral("null-principal");
     }
 }
 
 static int64_t
 GetGCChunkTotalBytes()
 {
-    JSRuntime *rt = nsXPConnect::GetRuntimeInstance()->GetJSRuntime();
+    JSRuntime *rt = nsXPConnect::GetRuntimeInstance()->Runtime();
     return int64_t(JS_GetGCParameter(rt, JSGC_TOTAL_CHUNKS)) * js::gc::ChunkSize;
 }
 
 // Telemetry relies on this memory reporter being a single-reporter (rather
 // than part of the "js" multi-reporter, which is too slow to run during a
 // telemetry ping).
 NS_MEMORY_REPORTER_IMPLEMENT(XPConnectJSGCHeap,
                              "js-gc-heap",
                              KIND_OTHER,
                              nsIMemoryReporter::UNITS_BYTES,
                              GetGCChunkTotalBytes,
                              "Memory used by the garbage-collected JavaScript heap.")
 
 static int64_t
 GetJSSystemCompartmentCount()
 {
-    return JS::SystemCompartmentCount(nsXPConnect::GetRuntimeInstance()->GetJSRuntime());
+    return JS::SystemCompartmentCount(nsXPConnect::GetRuntimeInstance()->Runtime());
 }
 
 static int64_t
 GetJSUserCompartmentCount()
 {
-    return JS::UserCompartmentCount(nsXPConnect::GetRuntimeInstance()->GetJSRuntime());
+    return JS::UserCompartmentCount(nsXPConnect::GetRuntimeInstance()->Runtime());
 }
 
 // Nb: js-system-compartment-count + js-user-compartment-count could be
 // different to the number of compartments reported by
 // JSMemoryMultiReporter if a garbage collection occurred
 // between them being consulted.  We could move these reporters into
 // XPConnectJSCompartmentCount to avoid that problem, but then we couldn't
 // easily report them via telemetry, so we live with the small risk of
@@ -1545,17 +1545,17 @@ NS_MEMORY_REPORTER_IMPLEMENT(XPConnectJS
     "The number of JavaScript compartments for user code.  The sum of this "
     "and 'js-compartments-system' might not match the number of compartments "
     "listed under 'js' if a garbage collection occurs at an inopportune time, "
     "but such cases should be rare.")
 
 static int64_t
 GetJSMainRuntimeTemporaryPeakSize()
 {
-    return JS::PeakSizeOfTemporary(nsXPConnect::GetRuntimeInstance()->GetJSRuntime());
+    return JS::PeakSizeOfTemporary(nsXPConnect::GetRuntimeInstance()->Runtime());
 }
 
 // This is also a single reporter so it can be used by telemetry.
 NS_MEMORY_REPORTER_IMPLEMENT(JSMainRuntimeTemporaryPeak,
     "js-main-runtime-temporary-peak",
     KIND_OTHER,
     nsIMemoryReporter::UNITS_BYTES,
     GetJSMainRuntimeTemporaryPeakSize,
@@ -2233,17 +2233,17 @@ class JSCompartmentsMultiReporter MOZ_FI
     {
         // First we collect the compartment paths.  Then we report them.  Doing
         // the two steps interleaved is a bad idea, because calling |cb|
         // from within CompartmentCallback() leads to all manner of assertions.
 
         // Collect.
 
         Paths paths;
-        JS_IterateCompartments(nsXPConnect::GetRuntimeInstance()->GetJSRuntime(),
+        JS_IterateCompartments(nsXPConnect::GetRuntimeInstance()->Runtime(),
                                &paths, CompartmentCallback);
 
         // Report.
         for (size_t i = 0; i < paths.length(); i++)
             // These ones don't need a description, hence the "".
             REPORT(nsCString(paths[i]),
                    nsIMemoryReporter::KIND_OTHER,
                    nsIMemoryReporter::UNITS_COUNT,
@@ -2438,17 +2438,17 @@ JSMemoryMultiReporter::CollectReports(Wi
     // callback may be a JS function, and executing JS while getting these
     // stats seems like a bad idea.
 
     nsCOMPtr<amIAddonManager> addonManager =
       do_GetService("@mozilla.org/addons/integration;1");
     bool getLocations = !!addonManager;
     XPCJSRuntimeStats rtStats(windowPaths, topWindowPaths, getLocations);
     OrphanReporter orphanReporter(XPCConvert::GetISupportsFromJSObject);
-    if (!JS::CollectRuntimeStats(xpcrt->GetJSRuntime(), &rtStats, &orphanReporter))
+    if (!JS::CollectRuntimeStats(xpcrt->Runtime(), &rtStats, &orphanReporter))
         return NS_ERROR_FAILURE;
 
     size_t xpconnect =
         xpcrt->SizeOfIncludingThis(JsMallocSizeOf) +
         XPCWrappedNativeScope::SizeOfAllScopesIncludingThis(JsMallocSizeOf);
 
     // This is the second step (see above).  First we report stuff in the
     // "explicit" tree, then we report other stuff.
@@ -2885,17 +2885,17 @@ XPCJSRuntime::XPCJSRuntime(nsXPConnect* 
 XPCJSRuntime*
 XPCJSRuntime::newXPCJSRuntime(nsXPConnect* aXPConnect)
 {
     NS_PRECONDITION(aXPConnect,"bad param");
 
     XPCJSRuntime* self = new XPCJSRuntime(aXPConnect);
 
     if (self                                    &&
-        self->GetJSRuntime()                    &&
+        self->Runtime()                    &&
         self->GetWrappedJSMap()                 &&
         self->GetWrappedJSClassMap()            &&
         self->GetIID2NativeInterfaceMap()       &&
         self->GetClassInfo2NativeSetMap()       &&
         self->GetNativeSetMap()                 &&
         self->GetThisTranslatorMap()            &&
         self->GetNativeScriptableSharedMap()    &&
         self->GetDyingWrappedNativeProtoMap()   &&
@@ -3073,17 +3073,17 @@ XPCRootSetElem::AddToRootSet(XPCLock *lo
     }
     *listHead = this;
 }
 
 void
 XPCRootSetElem::RemoveFromRootSet(XPCLock *lock)
 {
     nsXPConnect *xpc = nsXPConnect::XPConnect();
-    JS::PokeGC(xpc->GetRuntime()->GetJSRuntime());
+    JS::PokeGC(xpc->GetRuntime()->Runtime());
 
     NS_ASSERTION(mSelfp, "Must be linked");
 
     XPCAutoLock autoLock(lock);
 
     NS_ASSERTION(*mSelfp == this, "Link invariant");
     *mSelfp = mNext;
     if (mNext)
--- a/js/xpconnect/src/XPCWrappedNative.cpp
+++ b/js/xpconnect/src/XPCWrappedNative.cpp
@@ -843,48 +843,48 @@ XPCWrappedNative::Destroy()
 
     /*
      * The only time GetRuntime() will be NULL is if Destroy is called a second
      * time on a wrapped native. Since we already unregistered the pointer the
      * first time, there's no need to unregister again. Unregistration is safe
      * the first time because mWrapperWord isn't used afterwards.
      */
     if (XPCJSRuntime *rt = GetRuntime()) {
-        if (IsIncrementalBarrierNeeded(rt->GetJSRuntime()))
+        if (IsIncrementalBarrierNeeded(rt->Runtime()))
             IncrementalObjectBarrier(GetWrapperPreserveColor());
         mWrapperWord = WRAPPER_WORD_POISON;
     } else {
         MOZ_ASSERT(mWrapperWord == WRAPPER_WORD_POISON);
     }
 
     mMaybeScope = nullptr;
 }
 
 void
 XPCWrappedNative::UpdateScriptableInfo(XPCNativeScriptableInfo *si)
 {
     NS_ASSERTION(mScriptableInfo, "UpdateScriptableInfo expects an existing scriptable info");
 
     // Write barrier for incremental GC.
-    JSRuntime* rt = GetRuntime()->GetJSRuntime();
+    JSRuntime* rt = GetRuntime()->Runtime();
     if (IsIncrementalBarrierNeeded(rt))
         mScriptableInfo->Mark();
 
     mScriptableInfo = si;
 }
 
 void
 XPCWrappedNative::SetProto(XPCWrappedNativeProto* p)
 {
     NS_ASSERTION(!IsWrapperExpired(), "bad ptr!");
 
     MOZ_ASSERT(HasProto());
 
     // Write barrier for incremental GC.
-    JSRuntime* rt = GetRuntime()->GetJSRuntime();
+    JSRuntime* rt = GetRuntime()->Runtime();
     GetProto()->WriteBarrierPre(rt);
 
     mMaybeProto = p;
 }
 
 // This is factored out so that it can be called publicly
 // static
 void
--- a/js/xpconnect/src/XPCWrappedNativeScope.cpp
+++ b/js/xpconnect/src/XPCWrappedNativeScope.cpp
@@ -314,17 +314,17 @@ XPCWrappedNativeScope::~XPCWrappedNative
     // with the scope but just in case.
     if (mComponents)
         mComponents->mScope = nullptr;
 
     // XXX we should assert that we are dead or that xpconnect has shutdown
     // XXX might not want to do this at xpconnect shutdown time???
     mComponents = nullptr;
 
-    JSRuntime *rt = XPCJSRuntime::Get()->GetJSRuntime();
+    JSRuntime *rt = XPCJSRuntime::Get()->Runtime();
     mXBLScope.finalize(rt);
     mGlobalJSObject.finalize(rt);
 }
 
 static JSDHashOperator
 WrappedNativeJSGCThingTracer(JSDHashTable *table, JSDHashEntryHdr *hdr,
                              uint32_t number, void *arg)
 {
--- a/js/xpconnect/src/nsXPConnect.cpp
+++ b/js/xpconnect/src/nsXPConnect.cpp
@@ -101,17 +101,17 @@ nsXPConnect::~nsXPConnect()
     mRuntime->DeleteJunkScope();
     nsCycleCollector_forgetJSRuntime();
 
     JSContext *cx = nullptr;
     if (mRuntime) {
         // Create our own JSContext rather than an XPCCallContext, since
         // otherwise we will create a new safe JS context and attach a
         // components object that won't get GCed.
-        cx = JS_NewContext(mRuntime->GetJSRuntime(), 8192);
+        cx = JS_NewContext(mRuntime->Runtime(), 8192);
     }
 
     // This needs to happen exactly here, otherwise we leak at shutdown. I don't
     // know why. :-(
     mRuntime->DestroyJSContextStack();
 
     mShuttingDown = true;
     if (cx) {
@@ -177,17 +177,17 @@ nsXPConnect::ReleaseXPConnectSingleton()
         {
             const char* dumpName = getenv("XPC_SHUTDOWN_HEAP_DUMP");
             if (dumpName) {
                 FILE* dumpFile = (*dumpName == '\0' ||
                                   strcmp(dumpName, "stdout") == 0)
                                  ? stdout
                                  : fopen(dumpName, "w");
                 if (dumpFile) {
-                    JS_DumpHeap(xpc->GetRuntime()->GetJSRuntime(), dumpFile, nullptr,
+                    JS_DumpHeap(xpc->GetRuntime()->Runtime(), dumpFile, nullptr,
                                 JSTRACE_OBJECT, nullptr, static_cast<size_t>(-1), nullptr);
                     if (dumpFile != stdout)
                         fclose(dumpFile);
                 }
             }
         }
 #endif
 #ifdef XPC_DUMP_AT_SHUTDOWN
@@ -237,17 +237,17 @@ nsXPConnect::GetInfoForName(const char *
 {
   nsresult rv = XPTInterfaceInfoManager::GetSingleton()->GetInfoForName(name, info);
   return NS_FAILED(rv) ? NS_OK : NS_ERROR_NO_INTERFACE;
 }
 
 bool
 nsXPConnect::NeedCollect()
 {
-    return !js::AreGCGrayBitsValid(GetRuntime()->GetJSRuntime());
+    return !js::AreGCGrayBitsValid(GetRuntime()->Runtime());
 }
 
 void
 nsXPConnect::Collect(uint32_t reason)
 {
     // We're dividing JS objects into 2 categories:
     //
     // 1. "real" roots, held by the JS engine itself or rooted through the root
@@ -289,17 +289,17 @@ nsXPConnect::Collect(uint32_t reason)
     // too. This decreases the number of objects that the cycle collector has to
     // deal with.
     // To improve debugging, if WantAllTraces() is true all JS objects are
     // traversed.
 
     MOZ_ASSERT(reason < JS::gcreason::NUM_REASONS);
     JS::gcreason::Reason gcreason = (JS::gcreason::Reason)reason;
 
-    JSRuntime *rt = GetRuntime()->GetJSRuntime();
+    JSRuntime *rt = GetRuntime()->Runtime();
     JS::PrepareForFullGC(rt);
     JS::GCForReason(rt, gcreason);
 }
 
 NS_IMETHODIMP
 nsXPConnect::GarbageCollect(uint32_t reason)
 {
     Collect(reason);
@@ -456,24 +456,24 @@ private:
     }
 
     bool mAnyMarked;
 };
 
 void
 nsXPConnect::FixWeakMappingGrayBits()
 {
-    FixWeakMappingGrayBitsTracer fixer(GetRuntime()->GetJSRuntime());
+    FixWeakMappingGrayBitsTracer fixer(GetRuntime()->Runtime());
     fixer.FixAll();
 }
 
 nsresult
 nsXPConnect::BeginCycleCollection(nsCycleCollectionNoteRootCallback &cb)
 {
-    JSRuntime* rt = GetRuntime()->GetJSRuntime();
+    JSRuntime* rt = GetRuntime()->Runtime();
     static bool gcHasRun = false;
     if (!gcHasRun) {
         uint32_t gcNumber = JS_GetGCParameter(rt, JSGC_NUMBER);
         if (!gcNumber)
             NS_RUNTIMEABORT("Cannot cycle collect if GC has not run first!");
         gcHasRun = true;
     }
 
@@ -484,55 +484,55 @@ nsXPConnect::BeginCycleCollection(nsCycl
 
     return NS_OK;
 }
 
 bool
 nsXPConnect::NotifyLeaveMainThread()
 {
     NS_ABORT_IF_FALSE(NS_IsMainThread(), "Off main thread");
-    JSRuntime *rt = mRuntime->GetJSRuntime();
+    JSRuntime *rt = mRuntime->Runtime();
     if (JS_IsInRequest(rt))
         return false;
     JS_ClearRuntimeThread(rt);
     return true;
 }
 
 void
 nsXPConnect::NotifyEnterCycleCollectionThread()
 {
     NS_ABORT_IF_FALSE(!NS_IsMainThread(), "On main thread");
-    JS_SetRuntimeThread(mRuntime->GetJSRuntime());
+    JS_SetRuntimeThread(mRuntime->Runtime());
 }
 
 void
 nsXPConnect::NotifyLeaveCycleCollectionThread()
 {
     NS_ABORT_IF_FALSE(!NS_IsMainThread(), "On main thread");
-    JS_ClearRuntimeThread(mRuntime->GetJSRuntime());
+    JS_ClearRuntimeThread(mRuntime->Runtime());
 }
 
 void
 nsXPConnect::NotifyEnterMainThread()
 {
     NS_ABORT_IF_FALSE(NS_IsMainThread(), "Off main thread");
-    JS_SetRuntimeThread(mRuntime->GetJSRuntime());
+    JS_SetRuntimeThread(mRuntime->Runtime());
 }
 
 /*
  * Return true if there exists a JSContext with a default global whose current
  * inner is gray. The intent is to look for JS Object windows. We don't merge
  * system compartments, so we don't use them to trigger merging CCs.
  */
 bool
 nsXPConnect::UsefulToMergeZones()
 {
     JSContext *iter = nullptr;
     JSContext *cx;
-    while ((cx = JS_ContextIterator(GetRuntime()->GetJSRuntime(), &iter))) {
+    while ((cx = JS_ContextIterator(GetRuntime()->Runtime(), &iter))) {
         // Skip anything without an nsIScriptContext, as well as any scx whose
         // NativeGlobal() is not an outer window (this happens with XUL Prototype
         // compilation scopes, for example, which we're not interested in).
         nsIScriptContext *scx = GetScriptContextFromJSContext(cx);
         JS::RootedObject global(cx, scx ? scx->GetNativeGlobal() : nullptr);
         if (!global || !js::GetObjectParent(global)) {
             continue;
         }
@@ -789,17 +789,17 @@ TraverseGCThing(TraverseSelect ts, void 
     // If this object is alive, then all of its children are alive. For JS objects,
     // the black-gray invariant ensures the children are also marked black. For C++
     // objects, the ref count from this object will keep them alive. Thus we don't
     // need to trace our children, unless we are debugging using WantAllTraces.
     if (!isMarkedGray && !cb.WantAllTraces())
         return;
 
     if (ts == TRAVERSE_FULL)
-        NoteGCThingJSChildren(nsXPConnect::GetRuntimeInstance()->GetJSRuntime(),
+        NoteGCThingJSChildren(nsXPConnect::GetRuntimeInstance()->Runtime(),
                               p, traceKind, cb);
  
     if (traceKind == JSTRACE_OBJECT) {
         JSObject *obj = static_cast<JSObject*>(p);
         NoteGCThingXPCOMChildren(js::GetObjectClass(obj), obj, cb);
     }
 }
 
@@ -1739,17 +1739,17 @@ nsXPConnect::AfterProcessNextEvent(nsITh
     nsDOMMutationObserver::HandleMutations();
 
     PopJSContext();
 
     // If the cx stack is empty, that means we're at the an un-nested event
     // loop. This is a good time to make changes to debug mode.
     if (XPCJSRuntime::Get()->GetJSContextStack()->Count() == 0) {
         MOZ_ASSERT(mEventDepth == 0);
-        CheckForDebugMode(XPCJSRuntime::Get()->GetJSRuntime());
+        CheckForDebugMode(XPCJSRuntime::Get()->Runtime());
     }
     return NS_OK;
 }
 
 NS_IMETHODIMP
 nsXPConnect::OnDispatchedEvent(nsIThreadInternal* aThread)
 {
     NS_NOTREACHED("Why tell us?");
@@ -1788,17 +1788,17 @@ nsXPConnect::SetReportAllJSExceptions(bo
 
 /* attribute JSRuntime runtime; */
 NS_IMETHODIMP
 nsXPConnect::GetRuntime(JSRuntime **runtime)
 {
     if (!runtime)
         return NS_ERROR_NULL_POINTER;
 
-    JSRuntime *rt = GetRuntime()->GetJSRuntime();
+    JSRuntime *rt = GetRuntime()->Runtime();
     JS_AbortIfWrongThread(rt);
     *runtime = rt;
     return NS_OK;
 }
 
 /* [noscript, notxpcom] void registerGCCallback(in JSGCCallback func); */
 NS_IMETHODIMP_(void)
 nsXPConnect::RegisterGCCallback(JSGCCallback func)
@@ -1868,17 +1868,17 @@ nsXPConnect::CheckForDebugMode(JSRuntime
 #endif //#ifdef MOZ_JSDEBUGGER
 
 
 NS_EXPORT_(void)
 xpc_ActivateDebugMode()
 {
     XPCJSRuntime* rt = nsXPConnect::GetRuntimeInstance();
     nsXPConnect::XPConnect()->SetDebugModeWhenPossible(true, true);
-    nsXPConnect::CheckForDebugMode(rt->GetJSRuntime());
+    nsXPConnect::CheckForDebugMode(rt->Runtime());
 }
 
 /* virtual */
 JSContext*
 nsXPConnect::GetCurrentJSContext()
 {
     JSContext *cx = GetRuntime()->GetJSContextStack()->Peek();
     return xpc_UnmarkGrayContext(cx);
@@ -2025,17 +2025,17 @@ Base64Decode(JSContext *cx, JS::Value va
     return true;
 }
 
 void
 DumpJSHeap(FILE* file)
 {
     NS_ABORT_IF_FALSE(NS_IsMainThread(), "Must dump GC heap on main thread.");
     nsXPConnect* xpc = nsXPConnect::XPConnect();
-    js::DumpHeapComplete(xpc->GetRuntime()->GetJSRuntime(), file);
+    js::DumpHeapComplete(xpc->GetRuntime()->Runtime(), file);
 }
 
 void
 SetLocationForGlobal(JSObject *global, const nsACString& location)
 {
     MOZ_ASSERT(global);
     EnsureCompartmentPrivate(global)->SetLocation(location);
 }
@@ -2111,17 +2111,17 @@ public:
          * Every JS child of everything in the zone is either in the zone
          * or is a cross-compartment wrapper. In the former case, we don't need to
          * represent these edges in the CC graph because JS objects are not ref counted.
          * In the latter case, the JS engine keeps a map of these wrappers, which we
          * iterate over. Edges between compartments in the same zone will add
          * unnecessary loop edges to the graph (bug 842137).
          */
         TraversalTracer trc(cb);
-        JSRuntime *rt = nsXPConnect::GetRuntimeInstance()->GetJSRuntime();
+        JSRuntime *rt = nsXPConnect::GetRuntimeInstance()->Runtime();
         JS_TracerInit(&trc, rt, NoteJSChildTracerShim);
         trc.eagerlyTraceWeakMaps = DoNotTraceWeakMaps;
         js::VisitGrayWrapperTargets(zone, NoteJSChildGrayWrapperShim, &trc);
 
         /*
          * To find C++ children of things in the zone, we scan every JS Object in
          * the zone. Only JS Objects can have C++ children.
          */
@@ -2161,17 +2161,17 @@ xpc_JSZoneParticipant()
     return JSZone_cycleCollectorGlobal.GetParticipant();
 }
 
 NS_IMETHODIMP
 nsXPConnect::SetDebugModeWhenPossible(bool mode, bool allowSyncDisable)
 {
     gDesiredDebugMode = mode;
     if (!mode && allowSyncDisable)
-        CheckForDebugMode(mRuntime->GetJSRuntime());
+        CheckForDebugMode(mRuntime->Runtime());
     return NS_OK;
 }
 
 NS_IMETHODIMP
 nsXPConnect::GetTelemetryValue(JSContext *cx, jsval *rval)
 {
     RootedObject obj(cx, JS_NewObject(cx, NULL, NULL, NULL));
     if (!obj)
@@ -2191,17 +2191,17 @@ nsXPConnect::GetTelemetryValue(JSContext
 
     *rval = OBJECT_TO_JSVAL(obj);
     return NS_OK;
 }
 
 NS_IMETHODIMP
 nsXPConnect::NotifyDidPaint()
 {
-    JS::NotifyDidPaint(GetRuntime()->GetJSRuntime());
+    JS::NotifyDidPaint(GetRuntime()->Runtime());
     return NS_OK;
 }
 
 const uint8_t HAS_PRINCIPALS_FLAG               = 1;
 const uint8_t HAS_ORIGIN_PRINCIPALS_FLAG        = 2;
 
 static nsresult
 WriteScriptOrFunction(nsIObjectOutputStream *stream, JSContext *cx,
--- a/js/xpconnect/src/xpcprivate.h
+++ b/js/xpconnect/src/xpcprivate.h
@@ -623,17 +623,21 @@ public:
 class XPCJSContextStack;
 class XPCIncrementalReleaseRunnable;
 class XPCJSRuntime : public mozilla::CycleCollectedJSRuntime
 {
 public:
     static XPCJSRuntime* newXPCJSRuntime(nsXPConnect* aXPConnect);
     static XPCJSRuntime* Get() { return nsXPConnect::XPConnect()->GetRuntime(); }
 
-    JSRuntime*     GetJSRuntime() const {return Runtime();}
+    // Make this public for now.  Ideally we'd hide the JSRuntime inside.
+    JSRuntime* Runtime() const
+    {
+      return mozilla::CycleCollectedJSRuntime::Runtime();
+    }
 
     XPCJSContextStack* GetJSContextStack() {return mJSContextStack;}
     void DestroyJSContextStack();
 
     XPCCallContext*  GetCallContext() const {return mCallContext;}
     XPCCallContext*  SetCallContext(XPCCallContext* ccx)
         {XPCCallContext* old = mCallContext; mCallContext = ccx; return old;}