Bug 1302448 part 2 - Rename XPCJSRuntime to XPCJSContext. r=mrbkap
authorJan de Mooij <jdemooij@mozilla.com>
Wed, 14 Sep 2016 15:48:17 +0200
changeset 313917 1d1db582972c2e14e1376489c6522b1c3cee05fc
parent 313916 fff0c85df59096ad9245c127d36a3baa6a337b2d
child 313918 b0675d0dcfb55224c6813f30368393327157da2f
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)
reviewersmrbkap
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 2 - Rename XPCJSRuntime to XPCJSContext. r=mrbkap
dom/base/nsDOMClassInfo.cpp
dom/base/nsGlobalWindow.cpp
dom/base/nsInProcessTabChildGlobal.cpp
js/src/shell/js.cpp
js/xpconnect/idl/xpccomponents.idl
js/xpconnect/loader/mozJSSubScriptLoader.cpp
js/xpconnect/src/ExportHelpers.cpp
js/xpconnect/src/Sandbox.cpp
js/xpconnect/src/XPCCallContext.cpp
js/xpconnect/src/XPCComponents.cpp
js/xpconnect/src/XPCForwards.h
js/xpconnect/src/XPCInlines.h
js/xpconnect/src/XPCJSContext.cpp
js/xpconnect/src/XPCJSID.cpp
js/xpconnect/src/XPCJSRuntime.cpp
js/xpconnect/src/XPCMaps.cpp
js/xpconnect/src/XPCMaps.h
js/xpconnect/src/XPCThrower.cpp
js/xpconnect/src/XPCWrappedJS.cpp
js/xpconnect/src/XPCWrappedJSClass.cpp
js/xpconnect/src/XPCWrappedNative.cpp
js/xpconnect/src/XPCWrappedNativeInfo.cpp
js/xpconnect/src/XPCWrappedNativeJSOps.cpp
js/xpconnect/src/XPCWrappedNativeProto.cpp
js/xpconnect/src/XPCWrappedNativeScope.cpp
js/xpconnect/src/moz.build
js/xpconnect/src/nsXPConnect.cpp
js/xpconnect/src/xpcprivate.h
js/xpconnect/tests/chrome/test_bug732665.xul
js/xpconnect/tests/unit/test_watchdog_hibernate.js
js/xpconnect/wrappers/AccessCheck.cpp
js/xpconnect/wrappers/XrayWrapper.cpp
toolkit/components/perfmonitoring/README.md
tools/memory-profiler/MemoryProfiler.cpp
xpcom/build/XPCOMInit.cpp
--- a/dom/base/nsDOMClassInfo.cpp
+++ b/dom/base/nsDOMClassInfo.cpp
@@ -1712,25 +1712,25 @@ static const JSClass ControllersShimClas
 #endif
 
 // static
 nsresult
 nsWindowSH::GlobalResolve(nsGlobalWindow *aWin, JSContext *cx,
                           JS::Handle<JSObject*> obj, JS::Handle<jsid> id,
                           JS::MutableHandle<JS::PropertyDescriptor> desc)
 {
-  if (id == XPCJSRuntime::Get()->GetStringID(XPCJSRuntime::IDX_COMPONENTS)) {
+  if (id == XPCJSContext::Get()->GetStringID(XPCJSContext::IDX_COMPONENTS)) {
     return LookupComponentsShim(cx, obj, aWin->AsInner(), desc);
   }
 
 #ifdef USE_CONTROLLERS_SHIM
   // Note: We use |obj| rather than |aWin| to get the principal here, because
   // this is called during Window setup when the Document isn't necessarily
   // hooked up yet.
-  if (id == XPCJSRuntime::Get()->GetStringID(XPCJSRuntime::IDX_CONTROLLERS) &&
+  if (id == XPCJSContext::Get()->GetStringID(XPCJSContext::IDX_CONTROLLERS) &&
       !xpc::IsXrayWrapper(obj) &&
       !nsContentUtils::IsSystemPrincipal(nsContentUtils::ObjectPrincipal(obj)))
   {
     if (aWin->GetDoc()) {
       aWin->GetDoc()->WarnOnceAbout(nsIDocument::eWindow_Controllers);
     }
     MOZ_ASSERT(JS_IsGlobalObject(obj));
     JS::Rooted<JSObject*> shim(cx, JS_NewObject(cx, &ControllersShimClass));
--- a/dom/base/nsGlobalWindow.cpp
+++ b/dom/base/nsGlobalWindow.cpp
@@ -4470,21 +4470,21 @@ bool
 nsGlobalWindow::MayResolve(jsid aId)
 {
   // Note: This function does not fail and may not have any side-effects.
   // Note: Keep this in sync with DoResolve.
   if (!JSID_IS_STRING(aId)) {
     return false;
   }
 
-  if (aId == XPCJSRuntime::Get()->GetStringID(XPCJSRuntime::IDX_COMPONENTS)) {
+  if (aId == XPCJSContext::Get()->GetStringID(XPCJSContext::IDX_COMPONENTS)) {
     return true;
   }
 
-  if (aId == XPCJSRuntime::Get()->GetStringID(XPCJSRuntime::IDX_CONTROLLERS)) {
+  if (aId == XPCJSContext::Get()->GetStringID(XPCJSContext::IDX_CONTROLLERS)) {
     // We only resolve .controllers in release builds and on non-chrome windows,
     // but let's not worry about any of that stuff.
     return true;
   }
 
   if (WebIDLGlobalNameHash::MayResolve(aId)) {
     return true;
   }
--- a/dom/base/nsInProcessTabChildGlobal.cpp
+++ b/dom/base/nsInProcessTabChildGlobal.cpp
@@ -286,17 +286,17 @@ nsInProcessTabChildGlobal::PreHandleEven
   }
 
   return NS_OK;
 }
 
 nsresult
 nsInProcessTabChildGlobal::InitTabChildGlobal()
 {
-  // If you change this, please change GetCompartmentName() in XPCJSRuntime.cpp
+  // If you change this, please change GetCompartmentName() in XPCJSContext.cpp
   // accordingly.
   nsAutoCString id;
   id.AssignLiteral("inProcessTabChildGlobal");
   nsIURI* uri = mOwner->OwnerDoc()->GetDocumentURI();
   if (uri) {
     nsAutoCString u;
     nsresult rv = uri->GetSpec(u);
     NS_ENSURE_SUCCESS(rv, rv);
--- a/js/src/shell/js.cpp
+++ b/js/src/shell/js.cpp
@@ -122,17 +122,17 @@ enum JSShellExitCode {
     EXITCODE_OUT_OF_MEMORY      = 5,
     EXITCODE_TIMEOUT            = 6
 };
 
 static const size_t gStackChunkSize = 8192;
 
 /*
  * Note: This limit should match the stack limit set by the browser in
- *       js/xpconnect/src/XPCJSRuntime.cpp
+ *       js/xpconnect/src/XPCJSContext.cpp
  */
 #if defined(MOZ_ASAN) || (defined(DEBUG) && !defined(XP_WIN))
 static const size_t gMaxStackSize = 2 * 128 * sizeof(size_t) * 1024;
 #else
 static const size_t gMaxStackSize = 128 * sizeof(size_t) * 1024;
 #endif
 
 /*
--- a/js/xpconnect/idl/xpccomponents.idl
+++ b/js/xpconnect/idl/xpccomponents.idl
@@ -607,17 +607,17 @@ interface nsIXPCComponents_Utils : nsISu
     [implicit_jscontext]
     nsISupports generateXPCWrappedJS(in jsval obj, [optional] in jsval scope);
 
     /**
       * Retrieve the last time, in microseconds since epoch, that a given
       * watchdog-related event occured.
       *
       * Valid categories:
-      *   "RuntimeStateChange"      - Runtime switching between active and inactive states
+      *   "ContextStateChange"      - Context switching between active and inactive states
       *   "WatchdogWakeup"          - Watchdog waking up from sleeping
       *   "WatchdogHibernateStart"  - Watchdog begins hibernating
       *   "WatchdogHibernateStop"   - Watchdog stops hibernating
       */
     PRTime getWatchdogTimestamp(in AString aCategory);
 
     [implicit_jscontext]
     jsval getJSEngineTelemetryValue();
--- a/js/xpconnect/loader/mozJSSubScriptLoader.cpp
+++ b/js/xpconnect/loader/mozJSSubScriptLoader.cpp
@@ -771,17 +771,17 @@ NS_IMETHODIMP
 NotifyPrecompilationCompleteRunnable::Run(void)
 {
     MOZ_ASSERT(NS_IsMainThread());
     MOZ_ASSERT(mPrecompiler);
 
     AutoSendObserverNotification notifier(mPrecompiler);
 
     if (mToken) {
-        JSContext* cx = XPCJSRuntime::Get()->Context();
+        JSContext* cx = XPCJSContext::Get()->Context();
         NS_ENSURE_TRUE(cx, NS_ERROR_FAILURE);
         JS::CancelOffThreadScript(cx, mToken);
     }
 
     return NS_OK;
 }
 
 NS_IMETHODIMP
--- a/js/xpconnect/src/ExportHelpers.cpp
+++ b/js/xpconnect/src/ExportHelpers.cpp
@@ -360,17 +360,17 @@ FunctionForwarder(JSContext* cx, unsigne
 }
 
 bool
 NewFunctionForwarder(JSContext* cx, HandleId idArg, HandleObject callable,
                      FunctionForwarderOptions& options, MutableHandleValue vp)
 {
     RootedId id(cx, idArg);
     if (id == JSID_VOIDHANDLE)
-        id = GetRTIdByIndex(cx, XPCJSRuntime::IDX_EMPTYSTRING);
+        id = GetJSIDByIndex(cx, XPCJSContext::IDX_EMPTYSTRING);
 
     // We have no way of knowing whether the underlying function wants to be a
     // constructor or not, so we just mark all forwarders as constructors, and
     // let the underlying function throw for construct calls if it wants.
     JSFunction* fun = js::NewFunctionByIdWithReserved(cx, FunctionForwarder,
                                                       0, JSFUN_CONSTRUCTOR, id);
     if (!fun)
         return false;
--- a/js/xpconnect/src/Sandbox.cpp
+++ b/js/xpconnect/src/Sandbox.cpp
@@ -477,17 +477,17 @@ static bool
 sandbox_addProperty(JSContext* cx, HandleObject obj, HandleId id, HandleValue v)
 {
     CompartmentPrivate* priv = CompartmentPrivate::Get(obj);
     MOZ_ASSERT(priv->writeToGlobalPrototype);
 
     // Whenever JS_EnumerateStandardClasses is called, it defines the
     // "undefined" property, even if it's already defined. We don't want to do
     // anything in that case.
-    if (id == XPCJSRuntime::Get()->GetStringID(XPCJSRuntime::IDX_UNDEFINED))
+    if (id == XPCJSContext::Get()->GetStringID(XPCJSContext::IDX_UNDEFINED))
         return true;
 
     // Avoid recursively triggering sandbox_addProperty in the
     // JS_DefinePropertyById call below.
     if (priv->skipWriteToGlobalPrototype)
         return true;
 
     AutoSkipPropertyMirroring askip(priv);
--- a/js/xpconnect/src/XPCCallContext.cpp
+++ b/js/xpconnect/src/XPCCallContext.cpp
@@ -22,34 +22,34 @@ XPCCallContext::XPCCallContext(JSContext
                                HandleObject funobj /* = nullptr               */,
                                HandleId name       /* = JSID_VOID             */,
                                unsigned argc       /* = NO_ARGS               */,
                                Value* argv         /* = nullptr               */,
                                Value* rval         /* = nullptr               */)
     :   mAr(cx),
         mState(INIT_FAILED),
         mXPC(nsXPConnect::XPConnect()),
-        mXPCJSRuntime(nullptr),
+        mXPCJSContext(nullptr),
         mJSContext(cx),
         mWrapper(nullptr),
         mTearOff(nullptr),
         mName(cx)
 {
     MOZ_ASSERT(cx);
     MOZ_ASSERT(cx == nsContentUtils::GetCurrentJSContext());
 
     if (!mXPC)
         return;
 
-    mXPCJSRuntime = XPCJSRuntime::Get();
+    mXPCJSContext = XPCJSContext::Get();
 
     // hook into call context chain.
-    mPrevCallContext = mXPCJSRuntime->SetCallContext(this);
+    mPrevCallContext = mXPCJSContext->SetCallContext(this);
 
-    mState = HAVE_RUNTIME;
+    mState = HAVE_CONTEXT;
 
     if (!obj)
         return;
 
     mMethodIndex = 0xDEAD;
 
     mState = HAVE_OBJECT;
 
@@ -120,17 +120,17 @@ XPCCallContext::SetName(jsid name)
 
     mState = HAVE_NAME;
 }
 
 void
 XPCCallContext::SetCallInfo(XPCNativeInterface* iface, XPCNativeMember* member,
                             bool isSetter)
 {
-    CHECK_STATE(HAVE_RUNTIME);
+    CHECK_STATE(HAVE_CONTEXT);
 
     // We are going straight to the method info and need not do a lookup
     // by id.
 
     // don't be tricked if method is called with wrong 'this'
     if (mTearOff && mTearOff->GetInterface() != iface)
         mTearOff = nullptr;
 
@@ -192,28 +192,28 @@ XPCCallContext::CanCallNow()
 
 void
 XPCCallContext::SystemIsBeingShutDown()
 {
     // XXX This is pretty questionable since the per thread cleanup stuff
     // can be making this call on one thread for call contexts on another
     // thread.
     NS_WARNING("Shutting Down XPConnect even through there is a live XPCCallContext");
-    mXPCJSRuntime = nullptr;
+    mXPCJSContext = nullptr;
     mState = SYSTEM_SHUTDOWN;
     mInterface = nullptr;
 
     if (mPrevCallContext)
         mPrevCallContext->SystemIsBeingShutDown();
 }
 
 XPCCallContext::~XPCCallContext()
 {
-    if (mXPCJSRuntime) {
-        DebugOnly<XPCCallContext*> old = mXPCJSRuntime->SetCallContext(mPrevCallContext);
+    if (mXPCJSContext) {
+        DebugOnly<XPCCallContext*> old = mXPCJSContext->SetCallContext(mPrevCallContext);
         MOZ_ASSERT(old == this, "bad pop from per thread data");
     }
 }
 
 NS_IMETHODIMP
 XPCCallContext::GetCallee(nsISupports * *aCallee)
 {
     nsCOMPtr<nsISupports> rval = mWrapper ? mWrapper->GetIdentityObject() : nullptr;
--- a/js/xpconnect/src/XPCComponents.cpp
+++ b/js/xpconnect/src/XPCComponents.cpp
@@ -2564,17 +2564,17 @@ nsXPCComponents_Utils::GetWeakReference(
     NS_ENSURE_SUCCESS(rv, rv);
     ref.forget(_retval);
     return NS_OK;
 }
 
 NS_IMETHODIMP
 nsXPCComponents_Utils::ForceGC()
 {
-    JSContext* cx = nsXPConnect::GetRuntimeInstance()->Context();
+    JSContext* cx = nsXPConnect::GetContextInstance()->Context();
     PrepareForFullGC(cx);
     GCForReason(cx, GC_NORMAL, gcreason::COMPONENT_UTILS);
     return NS_OK;
 }
 
 NS_IMETHODIMP
 nsXPCComponents_Utils::ForceCC(nsICycleCollectorListener* listener)
 {
@@ -3182,27 +3182,27 @@ nsXPCComponents_Utils::GenerateXPCWrappe
     holder.forget(aOut);
     return rv;
 }
 
 NS_IMETHODIMP
 nsXPCComponents_Utils::GetWatchdogTimestamp(const nsAString& aCategory, PRTime* aOut)
 {
     WatchdogTimestampCategory category;
-    if (aCategory.EqualsLiteral("RuntimeStateChange"))
-        category = TimestampRuntimeStateChange;
+    if (aCategory.EqualsLiteral("ContextStateChange"))
+        category = TimestampContextStateChange;
     else if (aCategory.EqualsLiteral("WatchdogWakeup"))
         category = TimestampWatchdogWakeup;
     else if (aCategory.EqualsLiteral("WatchdogHibernateStart"))
         category = TimestampWatchdogHibernateStart;
     else if (aCategory.EqualsLiteral("WatchdogHibernateStop"))
         category = TimestampWatchdogHibernateStop;
     else
         return NS_ERROR_INVALID_ARG;
-    *aOut = XPCJSRuntime::Get()->GetWatchdogTimestamp(category);
+    *aOut = XPCJSContext::Get()->GetWatchdogTimestamp(category);
     return NS_OK;
 }
 
 NS_IMETHODIMP
 nsXPCComponents_Utils::GetJSEngineTelemetryValue(JSContext* cx, MutableHandleValue rval)
 {
     RootedObject obj(cx, JS_NewPlainObject(cx));
     if (!obj)
@@ -3453,28 +3453,28 @@ nsXPCComponents::GetManager(nsIComponent
 {
     MOZ_ASSERT(aManager, "bad param");
     return NS_GetComponentManager(aManager);
 }
 
 NS_IMETHODIMP
 nsXPCComponents::GetReturnCode(JSContext* aCx, MutableHandleValue aOut)
 {
-    nsresult res = XPCJSRuntime::Get()->GetPendingResult();
+    nsresult res = XPCJSContext::Get()->GetPendingResult();
     aOut.setNumber(static_cast<uint32_t>(res));
     return NS_OK;
 }
 
 NS_IMETHODIMP
 nsXPCComponents::SetReturnCode(JSContext* aCx, HandleValue aCode)
 {
     nsresult rv;
     if (!ToUint32(aCx, aCode, (uint32_t*)&rv))
         return NS_ERROR_FAILURE;
-    XPCJSRuntime::Get()->SetPendingResult(rv);
+    XPCJSContext::Get()->SetPendingResult(rv);
     return NS_OK;
 }
 
 // static
 NS_IMETHODIMP nsXPCComponents::ReportError(HandleValue error, JSContext* cx)
 {
     NS_WARNING("Components.reportError deprecated, use Components.utils.reportError");
 
--- a/js/xpconnect/src/XPCForwards.h
+++ b/js/xpconnect/src/XPCForwards.h
@@ -7,17 +7,17 @@
 /* Private forward declarations. */
 
 #ifndef xpcforwards_h___
 #define xpcforwards_h___
 
 // forward declarations of interally used classes...
 
 class nsXPConnect;
-class XPCJSRuntime;
+class XPCJSContext;
 class XPCContext;
 class XPCCallContext;
 
 class XPCJSThrower;
 
 class nsXPCWrappedJS;
 class nsXPCWrappedJSClass;
 
--- a/js/xpconnect/src/XPCInlines.h
+++ b/js/xpconnect/src/XPCInlines.h
@@ -9,59 +9,59 @@
 #ifndef xpcinlines_h___
 #define xpcinlines_h___
 
 #include <algorithm>
 
 /***************************************************************************/
 
 inline void
-XPCJSRuntime::AddVariantRoot(XPCTraceableVariant* variant)
+XPCJSContext::AddVariantRoot(XPCTraceableVariant* variant)
 {
     variant->AddToRootSet(&mVariantRoots);
 }
 
 inline void
-XPCJSRuntime::AddWrappedJSRoot(nsXPCWrappedJS* wrappedJS)
+XPCJSContext::AddWrappedJSRoot(nsXPCWrappedJS* wrappedJS)
 {
     wrappedJS->AddToRootSet(&mWrappedJSRoots);
 }
 
 inline void
-XPCJSRuntime::AddObjectHolderRoot(XPCJSObjectHolder* holder)
+XPCJSContext::AddObjectHolderRoot(XPCJSObjectHolder* holder)
 {
     holder->AddToRootSet(&mObjectHolderRoots);
 }
 
 /***************************************************************************/
 
 inline bool
 XPCCallContext::IsValid() const
 {
     return mState != INIT_FAILED;
 }
 
-inline XPCJSRuntime*
-XPCCallContext::GetRuntime() const
+inline XPCJSContext*
+XPCCallContext::GetContext() const
 {
-    CHECK_STATE(HAVE_RUNTIME);
-    return mXPCJSRuntime;
+    CHECK_STATE(HAVE_CONTEXT);
+    return mXPCJSContext;
 }
 
 inline JSContext*
 XPCCallContext::GetJSContext() const
 {
-    CHECK_STATE(HAVE_RUNTIME);
+    CHECK_STATE(HAVE_CONTEXT);
     return mJSContext;
 }
 
 inline XPCCallContext*
 XPCCallContext::GetPrevCallContext() const
 {
-    CHECK_STATE(HAVE_RUNTIME);
+    CHECK_STATE(HAVE_CONTEXT);
     return mPrevCallContext;
 }
 
 inline nsISupports*
 XPCCallContext::GetIdentityObject() const
 {
     CHECK_STATE(HAVE_OBJECT);
     if (mWrapper)
@@ -180,39 +180,39 @@ XPCCallContext::SetRetVal(JS::Value val)
     CHECK_STATE(HAVE_ARGS);
     if (mRetVal)
         *mRetVal = val;
 }
 
 inline jsid
 XPCCallContext::GetResolveName() const
 {
-    CHECK_STATE(HAVE_RUNTIME);
-    return XPCJSRuntime::Get()->GetResolveName();
+    CHECK_STATE(HAVE_CONTEXT);
+    return XPCJSContext::Get()->GetResolveName();
 }
 
 inline jsid
 XPCCallContext::SetResolveName(JS::HandleId name)
 {
-    CHECK_STATE(HAVE_RUNTIME);
-    return XPCJSRuntime::Get()->SetResolveName(name);
+    CHECK_STATE(HAVE_CONTEXT);
+    return XPCJSContext::Get()->SetResolveName(name);
 }
 
 inline XPCWrappedNative*
 XPCCallContext::GetResolvingWrapper() const
 {
     CHECK_STATE(HAVE_OBJECT);
-    return XPCJSRuntime::Get()->GetResolvingWrapper();
+    return XPCJSContext::Get()->GetResolvingWrapper();
 }
 
 inline XPCWrappedNative*
 XPCCallContext::SetResolvingWrapper(XPCWrappedNative* w)
 {
     CHECK_STATE(HAVE_OBJECT);
-    return XPCJSRuntime::Get()->SetResolvingWrapper(w);
+    return XPCJSContext::Get()->SetResolvingWrapper(w);
 }
 
 inline uint16_t
 XPCCallContext::GetMethodIndex() const
 {
     CHECK_STATE(HAVE_OBJECT);
     return mMethodIndex;
 }
@@ -531,20 +531,20 @@ inline bool
 xpc_ForcePropertyResolve(JSContext* cx, JS::HandleObject obj, jsid idArg)
 {
     JS::RootedId id(cx, idArg);
     bool dummy;
     return JS_HasPropertyById(cx, obj, id, &dummy);
 }
 
 inline jsid
-GetRTIdByIndex(JSContext* cx, unsigned index)
+GetJSIDByIndex(JSContext* cx, unsigned index)
 {
-  XPCJSRuntime* rt = nsXPConnect::XPConnect()->GetRuntime();
-  return rt->GetStringID(index);
+  XPCJSContext* xpcx = nsXPConnect::XPConnect()->GetContext();
+  return xpcx->GetStringID(index);
 }
 
 inline
 bool ThrowBadParam(nsresult rv, unsigned paramNum, XPCCallContext& ccx)
 {
     XPCThrower::ThrowBadParam(rv, paramNum, ccx);
     return false;
 }
rename from js/xpconnect/src/XPCJSRuntime.cpp
rename to js/xpconnect/src/XPCJSContext.cpp
--- a/js/xpconnect/src/XPCJSRuntime.cpp
+++ b/js/xpconnect/src/XPCJSContext.cpp
@@ -1,15 +1,15 @@
 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
 /* vim: set ts=8 sts=4 et sw=4 tw=99: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
-/* Per JSRuntime object */
+/* Per JSContext object */
 
 #include "mozilla/MemoryReporting.h"
 #include "mozilla/UniquePtr.h"
 
 #include "xpcprivate.h"
 #include "xpcpublic.h"
 #include "XPCWrapper.h"
 #include "XPCJSMemoryReporter.h"
@@ -72,17 +72,17 @@
 using namespace mozilla;
 using namespace xpc;
 using namespace JS;
 using mozilla::dom::PerThreadAtomCache;
 using mozilla::dom::AutoEntryScript;
 
 /***************************************************************************/
 
-const char* const XPCJSRuntime::mStrings[] = {
+const char* const XPCJSContext::mStrings[] = {
     "constructor",          // IDX_CONSTRUCTOR
     "toString",             // IDX_TO_STRING
     "toSource",             // IDX_TO_SOURCE
     "lastResult",           // IDX_LAST_RESULT
     "returnCode",           // IDX_RETURN_CODE
     "value",                // IDX_VALUE
     "QueryInterface",       // IDX_QUERY_INTERFACE
     "Components",           // IDX_COMPONENTS
@@ -496,29 +496,29 @@ EnableUniversalXPConnect(JSContext* cx)
         return true;
     scope->ForcePrivilegedComponents();
     return scope->AttachComponentsObject(cx);
 }
 
 JSObject*
 UnprivilegedJunkScope()
 {
-    return XPCJSRuntime::Get()->UnprivilegedJunkScope();
+    return XPCJSContext::Get()->UnprivilegedJunkScope();
 }
 
 JSObject*
 PrivilegedJunkScope()
 {
-    return XPCJSRuntime::Get()->PrivilegedJunkScope();
+    return XPCJSContext::Get()->PrivilegedJunkScope();
 }
 
 JSObject*
 CompilationScope()
 {
-    return XPCJSRuntime::Get()->CompilationScope();
+    return XPCJSContext::Get()->CompilationScope();
 }
 
 nsGlobalWindow*
 WindowOrNull(JSObject* aObj)
 {
     MOZ_ASSERT(aObj);
     MOZ_ASSERT(!js::IsWrapper(aObj));
 
@@ -563,18 +563,18 @@ CurrentWindowOrNull(JSContext* cx)
     return glob ? WindowOrNull(glob) : nullptr;
 }
 
 } // namespace xpc
 
 static void
 CompartmentDestroyedCallback(JSFreeOp* fop, JSCompartment* compartment)
 {
-    // NB - This callback may be called in JS_DestroyRuntime, which happens
-    // after the XPCJSRuntime has been torn down.
+    // NB - This callback may be called in JS_DestroyContext, which happens
+    // after the XPCJSContext has been torn down.
 
     // Get the current compartment private into an AutoPtr (which will do the
     // cleanup for us), and null out the private (which may already be null).
     nsAutoPtr<CompartmentPrivate> priv(CompartmentPrivate::Get(compartment));
     JS_SetCompartmentPrivate(compartment, nullptr);
 }
 
 static size_t
@@ -584,28 +584,28 @@ CompartmentSizeOfIncludingThisCallback(M
     return priv ? priv->SizeOfIncludingThis(mallocSizeOf) : 0;
 }
 
 /*
  * Return true if there exists a non-system inner window which is a current
  * inner window and whose reflector is gray.  We don't merge system
  * compartments, so we don't use them to trigger merging CCs.
  */
-bool XPCJSRuntime::UsefulToMergeZones() const
+bool XPCJSContext::UsefulToMergeZones() const
 {
     MOZ_ASSERT(NS_IsMainThread());
 
     // Turns out, actually making this return true often enough makes Windows
     // mochitest-gl OOM a lot.  Need to figure out what's going on there; see
     // bug 1277036.
 
     return false;
 }
 
-void XPCJSRuntime::TraceNativeBlackRoots(JSTracer* trc)
+void XPCJSContext::TraceNativeBlackRoots(JSTracer* trc)
 {
     // Skip this part if XPConnect is shutting down. We get into
     // bad locking problems with the thread iteration otherwise.
     if (!nsXPConnect::XPConnect()->IsShuttingDown()) {
         // Trace those AutoMarkingPtr lists!
         if (AutoMarkingPtr* roots = Get()->mAutoRoots)
             roots->TraceJSAll(trc);
     }
@@ -615,29 +615,29 @@ void XPCJSRuntime::TraceNativeBlackRoots
     XPCRootSetElem* e;
     for (e = mObjectHolderRoots; e; e = e->GetNextRoot())
         static_cast<XPCJSObjectHolder*>(e)->TraceJS(trc);
 
     dom::TraceBlackJS(trc, JS_GetGCParameter(Context(), JSGC_NUMBER),
                       nsXPConnect::XPConnect()->IsShuttingDown());
 }
 
-void XPCJSRuntime::TraceAdditionalNativeGrayRoots(JSTracer* trc)
+void XPCJSContext::TraceAdditionalNativeGrayRoots(JSTracer* trc)
 {
     XPCWrappedNativeScope::TraceWrappedNativesInAllScopes(trc, this);
 
     for (XPCRootSetElem* e = mVariantRoots; e ; e = e->GetNextRoot())
         static_cast<XPCTraceableVariant*>(e)->TraceJS(trc);
 
     for (XPCRootSetElem* e = mWrappedJSRoots; e ; e = e->GetNextRoot())
         static_cast<nsXPCWrappedJS*>(e)->TraceJS(trc);
 }
 
 void
-XPCJSRuntime::TraverseAdditionalNativeRoots(nsCycleCollectionNoteRootCallback& cb)
+XPCJSContext::TraverseAdditionalNativeRoots(nsCycleCollectionNoteRootCallback& cb)
 {
     XPCWrappedNativeScope::SuspectAllWrappers(this, cb);
 
     for (XPCRootSetElem* e = mVariantRoots; e ; e = e->GetNextRoot()) {
         XPCTraceableVariant* v = static_cast<XPCTraceableVariant*>(e);
         if (nsCCUncollectableMarker::InGeneration(cb,
                                                   v->CCGeneration())) {
            JS::Value val = v->GetJSValPreserveColor();
@@ -648,115 +648,115 @@ XPCJSRuntime::TraverseAdditionalNativeRo
     }
 
     for (XPCRootSetElem* e = mWrappedJSRoots; e ; e = e->GetNextRoot()) {
         cb.NoteXPCOMRoot(ToSupports(static_cast<nsXPCWrappedJS*>(e)));
     }
 }
 
 void
-XPCJSRuntime::UnmarkSkippableJSHolders()
+XPCJSContext::UnmarkSkippableJSHolders()
 {
     CycleCollectedJSContext::UnmarkSkippableJSHolders();
 }
 
 void
-XPCJSRuntime::PrepareForForgetSkippable()
+XPCJSContext::PrepareForForgetSkippable()
 {
     nsCOMPtr<nsIObserverService> obs = mozilla::services::GetObserverService();
     if (obs) {
         obs->NotifyObservers(nullptr, "cycle-collector-forget-skippable", nullptr);
     }
 }
 
 void
-XPCJSRuntime::BeginCycleCollectionCallback()
+XPCJSContext::BeginCycleCollectionCallback()
 {
     nsJSContext::BeginCycleCollectionCallback();
 
     nsCOMPtr<nsIObserverService> obs = mozilla::services::GetObserverService();
     if (obs) {
         obs->NotifyObservers(nullptr, "cycle-collector-begin", nullptr);
     }
 }
 
 void
-XPCJSRuntime::EndCycleCollectionCallback(CycleCollectorResults& aResults)
+XPCJSContext::EndCycleCollectionCallback(CycleCollectorResults& aResults)
 {
     nsJSContext::EndCycleCollectionCallback(aResults);
 
     nsCOMPtr<nsIObserverService> obs = mozilla::services::GetObserverService();
     if (obs) {
         obs->NotifyObservers(nullptr, "cycle-collector-end", nullptr);
     }
 }
 
 void
-XPCJSRuntime::DispatchDeferredDeletion(bool aContinuation, bool aPurge)
+XPCJSContext::DispatchDeferredDeletion(bool aContinuation, bool aPurge)
 {
     mAsyncSnowWhiteFreer->Dispatch(aContinuation, aPurge);
 }
 
 void
 xpc_UnmarkSkippableJSHolders()
 {
-    if (nsXPConnect::XPConnect()->GetRuntime()) {
-        nsXPConnect::XPConnect()->GetRuntime()->UnmarkSkippableJSHolders();
+    if (nsXPConnect::XPConnect()->GetContext()) {
+        nsXPConnect::XPConnect()->GetContext()->UnmarkSkippableJSHolders();
     }
 }
 
 /* static */ void
-XPCJSRuntime::GCSliceCallback(JSContext* cx,
+XPCJSContext::GCSliceCallback(JSContext* cx,
                               JS::GCProgress progress,
                               const JS::GCDescription& desc)
 {
-    XPCJSRuntime* self = nsXPConnect::GetRuntimeInstance();
+    XPCJSContext* self = nsXPConnect::GetContextInstance();
     if (!self)
         return;
 
 #ifdef MOZ_CRASHREPORTER
     CrashReporter::SetGarbageCollecting(progress == JS::GC_CYCLE_BEGIN ||
                                         progress == JS::GC_SLICE_BEGIN);
 #endif
 
     if (self->mPrevGCSliceCallback)
         (*self->mPrevGCSliceCallback)(cx, progress, desc);
 }
 
 /* static */ void
-XPCJSRuntime::DoCycleCollectionCallback(JSContext* cx)
+XPCJSContext::DoCycleCollectionCallback(JSContext* cx)
 {
     // The GC has detected that a CC at this point would collect a tremendous
     // amount of garbage that is being revivified unnecessarily.
     NS_DispatchToCurrentThread(
             NS_NewRunnableFunction([](){nsJSContext::CycleCollectNow(nullptr);}));
 
-    XPCJSRuntime* self = nsXPConnect::GetRuntimeInstance();
+    XPCJSContext* self = nsXPConnect::GetContextInstance();
     if (!self)
         return;
 
     if (self->mPrevDoCycleCollectionCallback)
         (*self->mPrevDoCycleCollectionCallback)(cx);
 }
 
 void
-XPCJSRuntime::CustomGCCallback(JSGCStatus status)
+XPCJSContext::CustomGCCallback(JSGCStatus status)
 {
     nsTArray<xpcGCCallback> callbacks(extraGCCallbacks);
     for (uint32_t i = 0; i < callbacks.Length(); ++i)
         callbacks[i](status);
 }
 
 /* static */ void
-XPCJSRuntime::FinalizeCallback(JSFreeOp* fop,
+XPCJSContext::FinalizeCallback(JSFreeOp* fop,
                                JSFinalizeStatus status,
                                bool isZoneGC,
                                void* data)
 {
-    XPCJSRuntime* self = nsXPConnect::GetRuntimeInstance();
+    XPCJSContext* self = nsXPConnect::GetContextInstance();
     if (!self)
         return;
 
     switch (status) {
         case JSFINALIZE_GROUP_START:
         {
             MOZ_ASSERT(!self->mDoingFinalization, "bad state");
 
@@ -805,17 +805,17 @@ XPCJSRuntime::FinalizeCallback(JSFreeOp*
             // Skip this part if XPConnect is shutting down. We get into
             // bad locking problems with the thread iteration otherwise.
             if (!nsXPConnect::XPConnect()->IsShuttingDown()) {
 
                 // Mark those AutoMarkingPtr lists!
                 if (AutoMarkingPtr* roots = Get()->mAutoRoots)
                     roots->MarkAfterJSFinalizeAll();
 
-                XPCCallContext* ccxp = XPCJSRuntime::Get()->GetCallContext();
+                XPCCallContext* ccxp = XPCJSContext::Get()->GetCallContext();
                 while (ccxp) {
                     // Deal with the strictness of callcontext that
                     // complains if you ask for a set when
                     // it is in a state where the set could not
                     // possibly be valid.
                     if (ccxp->CanGetSet()) {
                         XPCNativeSet* set = ccxp->GetSet();
                         if (set)
@@ -872,17 +872,17 @@ XPCJSRuntime::FinalizeCallback(JSFreeOp*
             //
             // XXX We may decide to not do this on *every* gc cycle.
 
             // Skip this part if XPConnect is shutting down. We get into
             // bad locking problems with the thread iteration otherwise.
             if (!nsXPConnect::XPConnect()->IsShuttingDown()) {
                 // Do the marking...
 
-                XPCCallContext* ccxp = XPCJSRuntime::Get()->GetCallContext();
+                XPCCallContext* ccxp = XPCJSContext::Get()->GetCallContext();
                 while (ccxp) {
                     // Deal with the strictness of callcontext that
                     // complains if you ask for a tearoff when
                     // it is in a state where the tearoff could not
                     // possibly be valid.
                     if (ccxp->CanGetTearOff()) {
                         XPCWrappedNativeTearOff* to =
                             ccxp->GetTearOff();
@@ -920,43 +920,43 @@ XPCJSRuntime::FinalizeCallback(JSFreeOp*
             self->mGCIsRunning = false;
 
             break;
         }
     }
 }
 
 /* static */ void
-XPCJSRuntime::WeakPointerZoneGroupCallback(JSContext* cx, void* data)
+XPCJSContext::WeakPointerZoneGroupCallback(JSContext* cx, void* data)
 {
     // Called before each sweeping slice -- after processing any final marking
     // triggered by barriers -- to clear out any references to things that are
     // about to be finalized and update any pointers to moved GC things.
-    XPCJSRuntime* self = static_cast<XPCJSRuntime*>(data);
+    XPCJSContext* self = static_cast<XPCJSContext*>(data);
 
     self->mWrappedJSMap->UpdateWeakPointersAfterGC(self);
 
     XPCWrappedNativeScope::UpdateWeakPointersAfterGC(self);
 }
 
 /* static */ void
-XPCJSRuntime::WeakPointerCompartmentCallback(JSContext* cx, JSCompartment* comp, void* data)
+XPCJSContext::WeakPointerCompartmentCallback(JSContext* cx, JSCompartment* comp, void* data)
 {
     // Called immediately after the ZoneGroup weak pointer callback, but only
     // once for each compartment that is being swept.
-    XPCJSRuntime* self = static_cast<XPCJSRuntime*>(data);
+    XPCJSContext* self = static_cast<XPCJSContext*>(data);
     CompartmentPrivate* xpcComp = CompartmentPrivate::Get(comp);
     if (xpcComp)
         xpcComp->UpdateWeakPointersAfterGC(self);
 }
 
 void
-CompartmentPrivate::UpdateWeakPointersAfterGC(XPCJSRuntime* runtime)
+CompartmentPrivate::UpdateWeakPointersAfterGC(XPCJSContext* context)
 {
-    mWrappedJSMap->UpdateWeakPointersAfterGC(runtime);
+    mWrappedJSMap->UpdateWeakPointersAfterGC(context);
 }
 
 static void WatchdogMain(void* arg);
 class Watchdog;
 class WatchdogManager;
 class AutoLockWatchdog {
     Watchdog* const mWatchdog;
   public:
@@ -1099,22 +1099,22 @@ class Watchdog
 #define PREF_MAX_SCRIPT_RUN_TIME_CONTENT "dom.max_script_run_time"
 #define PREF_MAX_SCRIPT_RUN_TIME_CHROME "dom.max_chrome_script_run_time"
 
 class WatchdogManager : public nsIObserver
 {
   public:
 
     NS_DECL_ISUPPORTS
-    explicit WatchdogManager(XPCJSRuntime* aRuntime) : mRuntime(aRuntime)
-                                                     , mRuntimeState(RUNTIME_INACTIVE)
+    explicit WatchdogManager(XPCJSContext* aContext) : mContext(aContext)
+                                                     , mContextState(CONTEXT_INACTIVE)
     {
-        // All the timestamps start at zero except for runtime state change.
+        // All the timestamps start at zero except for context state change.
         PodArrayZero(mTimestamps);
-        mTimestamps[TimestampRuntimeStateChange] = PR_Now();
+        mTimestamps[TimestampContextStateChange] = PR_Now();
 
         // Enable the watchdog, if appropriate.
         RefreshWatchdog();
 
         // Register ourselves as an observer to get updates on the pref.
         mozilla::Preferences::AddStrongObserver(this, "dom.use_watchdog");
         mozilla::Preferences::AddStrongObserver(this, PREF_MAX_SCRIPT_RUN_TIME_CONTENT);
         mozilla::Preferences::AddStrongObserver(this, PREF_MAX_SCRIPT_RUN_TIME_CHROME);
@@ -1137,44 +1137,44 @@ class WatchdogManager : public nsIObserv
 
     NS_IMETHOD Observe(nsISupports* aSubject, const char* aTopic,
                        const char16_t* aData) override
     {
         RefreshWatchdog();
         return NS_OK;
     }
 
-    // Runtime statistics. These live on the watchdog manager, are written
+    // Context statistics. These live on the watchdog manager, are written
     // from the main thread, and are read from the watchdog thread (holding
     // the lock in each case).
     void
-    RecordRuntimeActivity(bool active)
+    RecordContextActivity(bool active)
     {
         // The watchdog reads this state, so acquire the lock before writing it.
         MOZ_ASSERT(NS_IsMainThread());
         Maybe<AutoLockWatchdog> lock;
         if (mWatchdog)
             lock.emplace(mWatchdog);
 
         // Write state.
-        mTimestamps[TimestampRuntimeStateChange] = PR_Now();
-        mRuntimeState = active ? RUNTIME_ACTIVE : RUNTIME_INACTIVE;
-
-        // The watchdog may be hibernating, waiting for the runtime to go
+        mTimestamps[TimestampContextStateChange] = PR_Now();
+        mContextState = active ? CONTEXT_ACTIVE : CONTEXT_INACTIVE;
+
+        // The watchdog may be hibernating, waiting for the context to go
         // active. Wake it up if necessary.
         if (active && mWatchdog && mWatchdog->Hibernating())
             mWatchdog->WakeUp();
     }
-    bool IsRuntimeActive() { return mRuntimeState == RUNTIME_ACTIVE; }
-    PRTime TimeSinceLastRuntimeStateChange()
+    bool IsContextActive() { return mContextState == CONTEXT_ACTIVE; }
+    PRTime TimeSinceLastContextStateChange()
     {
-        return PR_Now() - GetTimestamp(TimestampRuntimeStateChange);
+        return PR_Now() - GetTimestamp(TimestampContextStateChange);
     }
 
-    // Note - Because of the runtime activity timestamp, these are read and
+    // Note - Because of the context activity timestamp, these are read and
     // written from both threads.
     void RecordTimestamp(WatchdogTimestampCategory aCategory)
     {
         // The watchdog thread always holds the lock when it runs.
         Maybe<AutoLockWatchdog> maybeLock;
         if (NS_IsMainThread() && mWatchdog)
             maybeLock.emplace(mWatchdog);
         mTimestamps[aCategory] = PR_Now();
@@ -1183,17 +1183,17 @@ class WatchdogManager : public nsIObserv
     {
         // The watchdog thread always holds the lock when it runs.
         Maybe<AutoLockWatchdog> maybeLock;
         if (NS_IsMainThread() && mWatchdog)
             maybeLock.emplace(mWatchdog);
         return mTimestamps[aCategory];
     }
 
-    XPCJSRuntime* Runtime() { return mRuntime; }
+    XPCJSContext* Context() { return mContext; }
     Watchdog* GetWatchdog() { return mWatchdog; }
 
     void RefreshWatchdog()
     {
         bool wantWatchdog = Preferences::GetBool("dom.use_watchdog", true);
         if (wantWatchdog != !!mWatchdog) {
             if (wantWatchdog)
                 StartWatchdog();
@@ -1222,20 +1222,20 @@ class WatchdogManager : public nsIObserv
     void StopWatchdog()
     {
         MOZ_ASSERT(mWatchdog);
         mWatchdog->Shutdown();
         mWatchdog = nullptr;
     }
 
   private:
-    XPCJSRuntime* mRuntime;
+    XPCJSContext* mContext;
     nsAutoPtr<Watchdog> mWatchdog;
 
-    enum { RUNTIME_ACTIVE, RUNTIME_INACTIVE } mRuntimeState;
+    enum { CONTEXT_ACTIVE, CONTEXT_INACTIVE } mContextState;
     PRTime mTimestamps[TimestampCount];
 };
 
 NS_IMPL_ISUPPORTS(WatchdogManager, nsIObserver)
 
 AutoLockWatchdog::AutoLockWatchdog(Watchdog* aWatchdog) : mWatchdog(aWatchdog)
 {
     PR_Lock(mWatchdog->GetLock());
@@ -1256,18 +1256,18 @@ WatchdogMain(void* arg)
 
     // Lock lasts until we return
     AutoLockWatchdog lock(self);
 
     MOZ_ASSERT(self->Initialized());
     MOZ_ASSERT(!self->ShuttingDown());
     while (!self->ShuttingDown()) {
         // Sleep only 1 second if recently (or currently) active; otherwise, hibernate
-        if (manager->IsRuntimeActive() ||
-            manager->TimeSinceLastRuntimeStateChange() <= PRTime(2*PR_USEC_PER_SEC))
+        if (manager->IsContextActive() ||
+            manager->TimeSinceLastContextStateChange() <= PRTime(2*PR_USEC_PER_SEC))
         {
             self->Sleep(PR_TicksPerSecond());
         } else {
             manager->RecordTimestamp(TimestampWatchdogHibernateStart);
             self->Hibernate();
             manager->RecordTimestamp(TimestampWatchdogHibernateStop);
         }
 
@@ -1284,61 +1284,61 @@ WatchdogMain(void* arg)
         // elapsed. The callback simply records the fact that it was called in
         // the mSlowScriptSecondHalf flag. Then we wait another (timeout/2)
         // seconds and invoke the callback again. This time around it sees
         // mSlowScriptSecondHalf is set and so it shows the slow script
         // dialog. If the computer is put to sleep during one of the (timeout/2)
         // periods, the script still has the other (timeout/2) seconds to
         // finish.
         PRTime usecs = self->MinScriptRunTimeSeconds() * PR_USEC_PER_SEC / 2;
-        if (manager->IsRuntimeActive() &&
-            manager->TimeSinceLastRuntimeStateChange() >= usecs)
+        if (manager->IsContextActive() &&
+            manager->TimeSinceLastContextStateChange() >= usecs)
         {
             bool debuggerAttached = false;
             nsCOMPtr<nsIDebug2> dbg = do_GetService("@mozilla.org/xpcom/debug;1");
             if (dbg)
                 dbg->GetIsDebuggerAttached(&debuggerAttached);
             if (!debuggerAttached)
-                JS_RequestInterruptCallback(manager->Runtime()->Context());
+                JS_RequestInterruptCallback(manager->Context()->Context());
         }
     }
 
     // Tell the manager that we've shut down.
     self->Finished();
 }
 
 PRTime
-XPCJSRuntime::GetWatchdogTimestamp(WatchdogTimestampCategory aCategory)
+XPCJSContext::GetWatchdogTimestamp(WatchdogTimestampCategory aCategory)
 {
     return mWatchdogManager->GetTimestamp(aCategory);
 }
 
 void
 xpc::SimulateActivityCallback(bool aActive)
 {
-    XPCJSRuntime::ActivityCallback(XPCJSRuntime::Get(), aActive);
+    XPCJSContext::ActivityCallback(XPCJSContext::Get(), aActive);
 }
 
 // static
 void
-XPCJSRuntime::ActivityCallback(void* arg, bool active)
+XPCJSContext::ActivityCallback(void* arg, bool active)
 {
     if (!active) {
         ProcessHangMonitor::ClearHang();
     }
 
-    XPCJSRuntime* self = static_cast<XPCJSRuntime*>(arg);
-    self->mWatchdogManager->RecordRuntimeActivity(active);
+    XPCJSContext* self = static_cast<XPCJSContext*>(arg);
+    self->mWatchdogManager->RecordContextActivity(active);
 }
 
 // static
 bool
-XPCJSRuntime::InterruptCallback(JSContext* cx)
+XPCJSContext::InterruptCallback(JSContext* cx)
 {
-    XPCJSRuntime* self = XPCJSRuntime::Get();
+    XPCJSContext* self = XPCJSContext::Get();
 
     // Normally we record mSlowScriptCheckpoint when we start to process an
     // event. However, we can run JS outside of event handlers. This code takes
     // care of that case.
     if (self->mSlowScriptCheckpoint.IsNull()) {
         self->mSlowScriptCheckpoint = TimeStamp::NowLoRes();
         self->mSlowScriptSecondHalf = false;
         self->mSlowScriptActualWait = mozilla::TimeDuration();
@@ -1433,17 +1433,17 @@ XPCJSRuntime::InterruptCallback(JSContex
 
     if (response == nsGlobalWindow::AlwaysContinueSlowScript)
         Preferences::SetInt(prefName, 0);
 
     return true;
 }
 
 void
-XPCJSRuntime::CustomOutOfMemoryCallback()
+XPCJSContext::CustomOutOfMemoryCallback()
 {
     if (!Preferences::GetBool("memory.dump_reports_on_oom")) {
         return;
     }
 
     nsCOMPtr<nsIMemoryInfoDumper> dumper =
         do_GetService("@mozilla.org/memory-info-dumper;1");
     if (!dumper) {
@@ -1452,37 +1452,37 @@ XPCJSRuntime::CustomOutOfMemoryCallback(
 
     // If this fails, it fails silently.
     dumper->DumpMemoryInfoToTempDir(NS_LITERAL_STRING("due-to-JS-OOM"),
                                     /* anonymize = */ false,
                                     /* minimizeMemoryUsage = */ false);
 }
 
 void
-XPCJSRuntime::CustomLargeAllocationFailureCallback()
+XPCJSContext::CustomLargeAllocationFailureCallback()
 {
     nsCOMPtr<nsIObserverService> os = mozilla::services::GetObserverService();
     if (os) {
         os->NotifyObservers(nullptr, "memory-pressure", u"heap-minimize");
     }
 }
 
 size_t
-XPCJSRuntime::SizeOfIncludingThis(MallocSizeOf mallocSizeOf)
+XPCJSContext::SizeOfIncludingThis(MallocSizeOf mallocSizeOf)
 {
     size_t n = 0;
     n += mallocSizeOf(this);
     n += mWrappedJSMap->SizeOfIncludingThis(mallocSizeOf);
     n += mIID2NativeInterfaceMap->SizeOfIncludingThis(mallocSizeOf);
     n += mClassInfo2NativeSetMap->ShallowSizeOfIncludingThis(mallocSizeOf);
     n += mNativeSetMap->SizeOfIncludingThis(mallocSizeOf);
 
     n += CycleCollectedJSContext::SizeOfExcludingThis(mallocSizeOf);
 
-    // There are other XPCJSRuntime members that could be measured; the above
+    // There are other XPCJSContext members that could be measured; the above
     // ones have been seen by DMD to be worth measuring.  More stuff may be
     // added later.
 
     return n;
 }
 
 size_t
 CompartmentPrivate::SizeOfIncludingThis(MallocSizeOf mallocSizeOf)
@@ -1490,32 +1490,32 @@ CompartmentPrivate::SizeOfIncludingThis(
     size_t n = mallocSizeOf(this);
     n += mWrappedJSMap->SizeOfIncludingThis(mallocSizeOf);
     n += mWrappedJSMap->SizeOfWrappedJS(mallocSizeOf);
     return n;
 }
 
 /***************************************************************************/
 
-void XPCJSRuntime::SystemIsBeingShutDown()
+void XPCJSContext::SystemIsBeingShutDown()
 {
     for (auto i = mDetachedWrappedNativeProtoMap->Iter(); !i.Done(); i.Next()) {
         auto entry = static_cast<XPCWrappedNativeProtoMap::Entry*>(i.Get());
         auto proto = const_cast<XPCWrappedNativeProto*>(static_cast<const XPCWrappedNativeProto*>(entry->key));
         proto->SystemIsBeingShutDown();
     }
 }
 
 #define JS_OPTIONS_DOT_STR "javascript.options."
 
 static void
 ReloadPrefsCallback(const char* pref, void* data)
 {
-    XPCJSRuntime* runtime = reinterpret_cast<XPCJSRuntime*>(data);
-    JSContext* cx = runtime->Context();
+    XPCJSContext* xpccx = reinterpret_cast<XPCJSContext*>(data);
+    JSContext* cx = xpccx->Context();
 
     bool safeMode = false;
     nsCOMPtr<nsIXULRuntime> xr = do_GetService("@mozilla.org/xre/runtime;1");
     if (xr) {
         xr->GetInSafeMode(&safeMode);
     }
 
     bool useBaseline = Preferences::GetBool(JS_OPTIONS_DOT_STR "baselinejit") && !safeMode;
@@ -1580,19 +1580,19 @@ ReloadPrefsCallback(const char* pref, vo
     JS_SetParallelParsingEnabled(cx, parallelParsing);
     JS_SetOffthreadIonCompilationEnabled(cx, offthreadIonCompilation);
     JS_SetGlobalJitCompilerOption(cx, JSJITCOMPILER_BASELINE_WARMUP_TRIGGER,
                                   useBaselineEager ? 0 : -1);
     JS_SetGlobalJitCompilerOption(cx, JSJITCOMPILER_ION_WARMUP_TRIGGER,
                                   useIonEager ? 0 : -1);
 }
 
-XPCJSRuntime::~XPCJSRuntime()
+XPCJSContext::~XPCJSContext()
 {
-    // Elsewhere we abort immediately if XPCJSRuntime initialization fails.
+    // Elsewhere we abort immediately if XPCJSContext initialization fails.
     // Therefore the context must be non-null.
     MOZ_ASSERT(MaybeContext());
 
     // This destructor runs before ~CycleCollectedJSContext, which does the
     // actual JS_DestroyContext() call. But destroying the context triggers
     // one final GC, which can call back into the context with various
     // callbacks if we aren't careful. Null out the relevant callbacks.
     js::SetActivityCallback(Context(), nullptr, nullptr);
@@ -1643,17 +1643,17 @@ XPCJSRuntime::~XPCJSRuntime()
 
     delete mDyingWrappedNativeProtoMap;
     mDyingWrappedNativeProtoMap = nullptr;
 
     delete mDetachedWrappedNativeProtoMap;
     mDetachedWrappedNativeProtoMap = nullptr;
 
 #ifdef MOZ_ENABLE_PROFILER_SPS
-    // Tell the profiler that the runtime is gone
+    // Tell the profiler that the context is gone
     if (PseudoStack* stack = mozilla_get_pseudo_stack())
         stack->sampleContext(nullptr);
 #endif
 
     Preferences::UnregisterCallback(ReloadPrefsCallback, JS_OPTIONS_DOT_STR, this);
 }
 
 // If |*anonymizeID| is non-zero and this is a user compartment, the name will
@@ -1751,23 +1751,23 @@ xpc::GetCurrentCompartmentName(JSContext
     JSCompartment* compartment = GetObjectCompartment(global);
     int anonymizeID = 0;
     GetCompartmentName(compartment, name, &anonymizeID, false);
 }
 
 void
 xpc::AddGCCallback(xpcGCCallback cb)
 {
-    XPCJSRuntime::Get()->AddGCCallback(cb);
+    XPCJSContext::Get()->AddGCCallback(cb);
 }
 
 void
 xpc::RemoveGCCallback(xpcGCCallback cb)
 {
-    XPCJSRuntime::Get()->RemoveGCCallback(cb);
+    XPCJSContext::Get()->RemoveGCCallback(cb);
 }
 
 static int64_t
 JSMainRuntimeGCHeapDistinguishedAmount()
 {
     JSContext* cx = danger::GetJSContext();
     return int64_t(JS_GetGCParameter(cx, JSGC_TOTAL_CHUNKS)) *
            js::gc::ChunkSize;
@@ -1785,17 +1785,17 @@ JSMainRuntimeCompartmentsSystemDistingui
 {
     JSContext* cx = danger::GetJSContext();
     return JS::SystemCompartmentCount(cx);
 }
 
 static int64_t
 JSMainRuntimeCompartmentsUserDistinguishedAmount()
 {
-    JSContext* cx = nsXPConnect::GetRuntimeInstance()->Context();
+    JSContext* cx = nsXPConnect::GetContextInstance()->Context();
     return JS::UserCompartmentCount(cx);
 }
 
 class JSMainRuntimeTemporaryPeakReporter final : public nsIMemoryReporter
 {
     ~JSMainRuntimeTemporaryPeakReporter() {}
 
   public:
@@ -2640,17 +2640,17 @@ class JSMainRuntimeCompartmentsReporter 
     {
         // First we collect the compartment paths.  Then we report them.  Doing
         // the two steps interleaved is a bad idea, because calling
         // |handleReport| from within CompartmentCallback() leads to all manner
         // of assertions.
 
         Data d;
         d.anonymizeID = anonymize ? 1 : 0;
-        JS_IterateCompartments(nsXPConnect::GetRuntimeInstance()->Context(),
+        JS_IterateCompartments(nsXPConnect::GetContextInstance()->Context(),
                                &d, CompartmentCallback);
 
         for (size_t i = 0; i < d.paths.length(); i++)
             REPORT(nsCString(d.paths[i]), KIND_OTHER, UNITS_COUNT, 1,
                 "A live compartment in the main JSRuntime.");
 
         return NS_OK;
     }
@@ -2713,34 +2713,34 @@ class OrphanReporter : public JS::Object
 #ifdef DEBUG
 static bool
 StartsWithExplicit(nsACString& s)
 {
     return StringBeginsWith(s, NS_LITERAL_CSTRING("explicit/"));
 }
 #endif
 
-class XPCJSRuntimeStats : public JS::RuntimeStats
+class XPCJSContextStats : public JS::RuntimeStats
 {
     WindowPaths* mWindowPaths;
     WindowPaths* mTopWindowPaths;
     bool mGetLocations;
     int mAnonymizeID;
 
   public:
-    XPCJSRuntimeStats(WindowPaths* windowPaths, WindowPaths* topWindowPaths,
+    XPCJSContextStats(WindowPaths* windowPaths, WindowPaths* topWindowPaths,
                       bool getLocations, bool anonymize)
       : JS::RuntimeStats(JSMallocSizeOf),
         mWindowPaths(windowPaths),
         mTopWindowPaths(topWindowPaths),
         mGetLocations(getLocations),
         mAnonymizeID(anonymize ? 1 : 0)
     {}
 
-    ~XPCJSRuntimeStats() {
+    ~XPCJSContextStats() {
         for (size_t i = 0; i != compartmentStatsVector.length(); ++i)
             delete static_cast<xpc::CompartmentStatsExtras*>(compartmentStatsVector[i].extra);
 
 
         for (size_t i = 0; i != zoneStatsVector.length(); ++i)
             delete static_cast<xpc::ZoneStatsExtras*>(zoneStatsVector[i].extra);
     }
 
@@ -2848,42 +2848,42 @@ class XPCJSRuntimeStats : public JS::Run
 
 void
 JSReporter::CollectReports(WindowPaths* windowPaths,
                            WindowPaths* topWindowPaths,
                            nsIHandleReportCallback* handleReport,
                            nsISupports* data,
                            bool anonymize)
 {
-    XPCJSRuntime* xpcrt = nsXPConnect::GetRuntimeInstance();
+    XPCJSContext* xpccx = nsXPConnect::GetContextInstance();
 
     // In the first step we get all the stats and stash them in a local
     // data structure.  In the second step we pass all the stashed stats to
     // the callback.  Separating these steps is important because the
     // callback may be a JS function, and executing JS while getting these
     // stats seems like a bad idea.
 
     nsCOMPtr<amIAddonManager> addonManager;
     if (XRE_IsParentProcess()) {
         // Only try to access the service from the main process.
         addonManager = do_GetService("@mozilla.org/addons/integration;1");
     }
     bool getLocations = !!addonManager;
-    XPCJSRuntimeStats rtStats(windowPaths, topWindowPaths, getLocations,
+    XPCJSContextStats rtStats(windowPaths, topWindowPaths, getLocations,
                               anonymize);
     OrphanReporter orphanReporter(XPCConvert::GetISupportsFromJSObject);
-    if (!JS::CollectRuntimeStats(xpcrt->Context(), &rtStats, &orphanReporter,
+    if (!JS::CollectRuntimeStats(xpccx->Context(), &rtStats, &orphanReporter,
                                  anonymize))
     {
         return;
     }
 
-    size_t xpcJSRuntimeSize = xpcrt->SizeOfIncludingThis(JSMallocSizeOf);
-
-    size_t wrappedJSSize = xpcrt->GetMultiCompartmentWrappedJSMap()->SizeOfWrappedJS(JSMallocSizeOf);
+    size_t xpcJSRuntimeSize = xpccx->SizeOfIncludingThis(JSMallocSizeOf);
+
+    size_t wrappedJSSize = xpccx->GetMultiCompartmentWrappedJSMap()->SizeOfWrappedJS(JSMallocSizeOf);
 
     XPCWrappedNativeScope::ScopeSizeInfo sizeInfo(JSMallocSizeOf);
     XPCWrappedNativeScope::AddSizeOfAllScopesIncludingThis(&sizeInfo);
 
     mozJSComponentLoader* loader = mozJSComponentLoader::Get();
     size_t jsComponentLoaderSize = loader ? loader->SizeOfIncludingThis(JSMallocSizeOf) : 0;
 
     // This is the second step (see above).  First we report stuff in the
@@ -3051,17 +3051,17 @@ JSReporter::CollectReports(WindowPaths* 
         KIND_HEAP, jsComponentLoaderSize,
         "XPConnect's JS component loader.");
 }
 
 static nsresult
 JSSizeOfTab(JSObject* objArg, size_t* jsObjectsSize, size_t* jsStringsSize,
             size_t* jsPrivateSize, size_t* jsOtherSize)
 {
-    JSContext* cx = nsXPConnect::GetRuntimeInstance()->Context();
+    JSContext* cx = nsXPConnect::GetContextInstance()->Context();
     JS::RootedObject obj(cx, objArg);
 
     TabSizes sizes;
     OrphanReporter orphanReporter(XPCConvert::GetISupportsFromJSObject);
     NS_ENSURE_TRUE(JS::AddSizeOfTab(cx, obj, moz_malloc_size_of,
                                     &orphanReporter, &sizes),
                    NS_ERROR_OUT_OF_MEMORY);
 
@@ -3272,17 +3272,17 @@ ReadSourceFromFilename(JSContext* cx, co
     // accounting.  Since ConvertToUTF16() now uses js_malloc() instead we
     // update the accounting manually after the fact.
     JS_updateMallocCounter(cx, *len);
 
     return NS_OK;
 }
 
 // The JS engine calls this object's 'load' member function when it needs
-// the source for a chrome JS function. See the comment in the XPCJSRuntime
+// the source for a chrome JS function. See the comment in the XPCJSContext
 // constructor.
 class XPCJSSourceHook: public js::SourceHook {
     bool load(JSContext* cx, const char* filename, char16_t** src, size_t* length) {
         *src = nullptr;
         *length = 0;
 
         if (!nsContentUtils::IsCallerChrome())
             return true;
@@ -3300,17 +3300,17 @@ class XPCJSSourceHook: public js::Source
     }
 };
 
 static const JSWrapObjectCallbacks WrapObjectCallbacks = {
     xpc::WrapperFactory::Rewrap,
     xpc::WrapperFactory::PrepareForWrapping
 };
 
-XPCJSRuntime::XPCJSRuntime()
+XPCJSContext::XPCJSContext()
  : mCallContext(nullptr),
    mAutoRoots(nullptr),
    mResolveName(JSID_VOID),
    mResolvingWrapper(nullptr),
    mWrappedJSMap(JSObject2WrappedJSMap::newMap(XPC_JS_MAP_LENGTH)),
    mWrappedJSClassMap(IID2WrappedJSClassMap::newMap(XPC_JS_CLASS_MAP_LENGTH)),
    mIID2NativeInterfaceMap(IID2NativeInterfaceMap::newMap(XPC_NATIVE_INTERFACE_MAP_LENGTH)),
    mClassInfo2NativeSetMap(ClassInfo2NativeSetMap::newMap(XPC_NATIVE_SET_MAP_LENGTH)),
@@ -3364,17 +3364,17 @@ GetWindowsStackSize()
 
     // Subtract 40 KB (Win32) or 80 KB (Win64) to account for things like
     // the guard page and large PGO stack frames.
     return stackSize - 10 * sizeof(uintptr_t) * 1024;
 }
 #endif
 
 nsresult
-XPCJSRuntime::Initialize()
+XPCJSContext::Initialize()
 {
     nsresult rv = CycleCollectedJSContext::Initialize(nullptr,
                                                       JS::DefaultHeapMaxBytes,
                                                       JS::DefaultNurseryBytes);
     if (NS_WARN_IF(NS_FAILED(rv))) {
       return rv;
     }
 
@@ -3534,23 +3534,23 @@ XPCJSRuntime::Initialize()
     // Watch for the JS boolean options.
     ReloadPrefsCallback(nullptr, this);
     Preferences::RegisterCallback(ReloadPrefsCallback, JS_OPTIONS_DOT_STR, this);
 
     return NS_OK;
 }
 
 // static
-XPCJSRuntime*
-XPCJSRuntime::newXPCJSRuntime()
+XPCJSContext*
+XPCJSContext::newXPCJSContext()
 {
-    XPCJSRuntime* self = new XPCJSRuntime();
+    XPCJSContext* self = new XPCJSContext();
     nsresult rv = self->Initialize();
     if (NS_FAILED(rv)) {
-        NS_RUNTIMEABORT("new XPCJSRuntime failed to initialize.");
+        NS_RUNTIMEABORT("new XPCJSContext failed to initialize.");
         delete self;
         return nullptr;
     }
 
     if (self->Context()                         &&
         self->GetMultiCompartmentWrappedJSMap() &&
         self->GetWrappedJSClassMap()            &&
         self->GetIID2NativeInterfaceMap()       &&
@@ -3558,24 +3558,24 @@ XPCJSRuntime::newXPCJSRuntime()
         self->GetNativeSetMap()                 &&
         self->GetThisTranslatorMap()            &&
         self->GetNativeScriptableSharedMap()    &&
         self->GetDyingWrappedNativeProtoMap()   &&
         self->mWatchdogManager) {
         return self;
     }
 
-    NS_RUNTIMEABORT("new XPCJSRuntime failed to initialize.");
+    NS_RUNTIMEABORT("new XPCJSContext failed to initialize.");
 
     delete self;
     return nullptr;
 }
 
 bool
-XPCJSRuntime::JSContextInitialized(JSContext* cx)
+XPCJSContext::JSContextInitialized(JSContext* cx)
 {
     JSAutoRequest ar(cx);
 
     // if it is our first context then we need to generate our string ids
     if (JSID_IS_VOID(mStrIDs[0])) {
         RootedString str(cx);
         for (unsigned i = 0; i < IDX_TOTAL_COUNT; i++) {
             str = JS_AtomizeAndPinString(cx, mStrings[i]);
@@ -3591,17 +3591,17 @@ XPCJSRuntime::JSContextInitialized(JSCon
             return false;
         }
     }
 
     return true;
 }
 
 bool
-XPCJSRuntime::DescribeCustomObjects(JSObject* obj, const js::Class* clasp,
+XPCJSContext::DescribeCustomObjects(JSObject* obj, const js::Class* clasp,
                                     char (&name)[72]) const
 {
     XPCNativeScriptableInfo* si = nullptr;
 
     if (!IS_PROTO_CLASS(clasp)) {
         return false;
     }
 
@@ -3613,17 +3613,17 @@ XPCJSRuntime::DescribeCustomObjects(JSOb
         return false;
     }
 
     snprintf(name, sizeof(name), "JS Object (%s - %s)", clasp->name, si->GetJSClass()->name);
     return true;
 }
 
 bool
-XPCJSRuntime::NoteCustomGCThingXPCOMChildren(const js::Class* clasp, JSObject* obj,
+XPCJSContext::NoteCustomGCThingXPCOMChildren(const js::Class* clasp, JSObject* obj,
                                              nsCycleCollectionTraversalCallback& cb) const
 {
     if (clasp != &XPC_WN_Tearoff_JSClass) {
         return false;
     }
 
     // A tearoff holds a strong reference to its native object
     // (see XPCWrappedNative::FlatJSObjectFinalized). Its XPCWrappedNative
@@ -3631,17 +3631,17 @@ XPCJSRuntime::NoteCustomGCThingXPCOMChil
     XPCWrappedNativeTearOff* to =
         static_cast<XPCWrappedNativeTearOff*>(xpc_GetJSPrivate(obj));
     NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(cb, "xpc_GetJSPrivate(obj)->mNative");
     cb.NoteXPCOMChild(to->GetNative());
     return true;
 }
 
 void
-XPCJSRuntime::BeforeProcessTask(bool aMightBlock)
+XPCJSContext::BeforeProcessTask(bool aMightBlock)
 {
     MOZ_ASSERT(NS_IsMainThread());
 
     // If ProcessNextEvent was called during a Promise "then" callback, we
     // must process any pending microtasks before blocking in the event loop,
     // otherwise we may deadlock until an event enters the queue later.
     if (aMightBlock) {
         if (Promise::PerformMicroTaskCheckpoint()) {
@@ -3664,17 +3664,17 @@ XPCJSRuntime::BeforeProcessTask(bool aMi
     // As we may be entering a nested event loop, we need to
     // cancel any ongoing performance measurement.
     js::ResetPerformanceMonitoring(Get()->Context());
 
     CycleCollectedJSContext::BeforeProcessTask(aMightBlock);
 }
 
 void
-XPCJSRuntime::AfterProcessTask(uint32_t aNewRecursionDepth)
+XPCJSContext::AfterProcessTask(uint32_t aNewRecursionDepth)
 {
     // Now that we're back to the event loop, reset the slow script checkpoint.
     mSlowScriptCheckpoint = mozilla::TimeStamp();
     mSlowScriptSecondHalf = false;
 
     // Call cycle collector occasionally.
     MOZ_ASSERT(NS_IsMainThread());
     nsJSContext::MaybePokeCC();
@@ -3684,21 +3684,21 @@ XPCJSRuntime::AfterProcessTask(uint32_t 
     // Now that we are certain that the event is complete,
     // we can flush any ongoing performance measurement.
     js::FlushPerformanceMonitoring(Get()->Context());
 }
 
 /***************************************************************************/
 
 void
-XPCJSRuntime::DebugDump(int16_t depth)
+XPCJSContext::DebugDump(int16_t depth)
 {
 #ifdef DEBUG
     depth--;
-    XPC_LOG_ALWAYS(("XPCJSRuntime @ %x", this));
+    XPC_LOG_ALWAYS(("XPCJSContext @ %x", this));
         XPC_LOG_INDENT();
         XPC_LOG_ALWAYS(("mJSContext @ %x", Context()));
 
         XPC_LOG_ALWAYS(("mWrappedJSClassMap @ %x with %d wrapperclasses(s)",
                         mWrappedJSClassMap, mWrappedJSClassMap->Count()));
         // iterate wrappersclasses...
         if (depth && mWrappedJSClassMap->Count()) {
             XPC_LOG_INDENT();
@@ -3763,49 +3763,49 @@ XPCRootSetElem::AddToRootSet(XPCRootSetE
     }
     *listHead = this;
 }
 
 void
 XPCRootSetElem::RemoveFromRootSet()
 {
     nsXPConnect* xpc = nsXPConnect::XPConnect();
-    JS::PokeGC(xpc->GetRuntime()->Context());
+    JS::PokeGC(xpc->GetContext()->Context());
 
     MOZ_ASSERT(mSelfp, "Must be linked");
 
     MOZ_ASSERT(*mSelfp == this, "Link invariant");
     *mSelfp = mNext;
     if (mNext)
         mNext->mSelfp = mSelfp;
 #ifdef DEBUG
     mSelfp = nullptr;
     mNext = nullptr;
 #endif
 }
 
 void
-XPCJSRuntime::AddGCCallback(xpcGCCallback cb)
+XPCJSContext::AddGCCallback(xpcGCCallback cb)
 {
     MOZ_ASSERT(cb, "null callback");
     extraGCCallbacks.AppendElement(cb);
 }
 
 void
-XPCJSRuntime::RemoveGCCallback(xpcGCCallback cb)
+XPCJSContext::RemoveGCCallback(xpcGCCallback cb)
 {
     MOZ_ASSERT(cb, "null callback");
     bool found = extraGCCallbacks.RemoveElement(cb);
     if (!found) {
         NS_ERROR("Removing a callback which was never added.");
     }
 }
 
 void
-XPCJSRuntime::InitSingletonScopes()
+XPCJSContext::InitSingletonScopes()
 {
     // This all happens very early, so we don't bother with cx pushing.
     JSContext* cx = Context();
     JSAutoRequest ar(cx);
     RootedValue v(cx);
     nsresult rv;
 
     // Create the Unprivileged Junk Scope.
@@ -3831,14 +3831,14 @@ XPCJSRuntime::InitSingletonScopes()
     compilationScopeOptions.invisibleToDebugger = true;
     compilationScopeOptions.discardSource = ShouldDiscardSystemSource();
     rv = CreateSandboxObject(cx, &v, /* principal = */ nullptr, compilationScopeOptions);
     MOZ_RELEASE_ASSERT(NS_SUCCEEDED(rv));
     mCompilationScope = js::UncheckedUnwrap(&v.toObject());
 }
 
 void
-XPCJSRuntime::DeleteSingletonScopes()
+XPCJSContext::DeleteSingletonScopes()
 {
     mUnprivilegedJunkScope = nullptr;
     mPrivilegedJunkScope = nullptr;
     mCompilationScope = nullptr;
 }
--- a/js/xpconnect/src/XPCJSID.cpp
+++ b/js/xpconnect/src/XPCJSID.cpp
@@ -705,22 +705,22 @@ nsJSCID::GetService(HandleValue iidval, 
 }
 
 NS_IMETHODIMP
 nsJSCID::Construct(nsIXPConnectWrappedNative* wrapper,
                    JSContext* cx, JSObject* objArg,
                    const CallArgs& args, bool* _retval)
 {
     RootedObject obj(cx, objArg);
-    XPCJSRuntime* rt = nsXPConnect::GetRuntimeInstance();
-    if (!rt)
+    XPCJSContext* xpccx = nsXPConnect::GetContextInstance();
+    if (!xpccx)
         return NS_ERROR_FAILURE;
 
     // 'push' a call context and call on it
-    RootedId name(cx, rt->GetStringID(XPCJSRuntime::IDX_CREATE_INSTANCE));
+    RootedId name(cx, xpccx->GetStringID(XPCJSContext::IDX_CREATE_INSTANCE));
     XPCCallContext ccx(cx, obj, nullptr, name, args.length(), args.array(),
                        args.rval().address());
 
     *_retval = XPCWrappedNative::CallMethod(ccx);
     return NS_OK;
 }
 
 NS_IMETHODIMP
--- a/js/xpconnect/src/XPCMaps.cpp
+++ b/js/xpconnect/src/XPCMaps.cpp
@@ -38,17 +38,17 @@ HashNativeKey(const void* data)
 {
     return static_cast<const XPCNativeSetKey*>(data)->Hash();
 }
 
 /***************************************************************************/
 // implement JSObject2WrappedJSMap...
 
 void
-JSObject2WrappedJSMap::UpdateWeakPointersAfterGC(XPCJSRuntime* runtime)
+JSObject2WrappedJSMap::UpdateWeakPointersAfterGC(XPCJSContext* context)
 {
     // Check all wrappers and update their JSObject pointer if it has been
     // moved. Release any wrappers whose weakly held JSObject has died.
 
     nsTArray<RefPtr<nsXPCWrappedJS>> dying;
     for (Map::Enum e(mTable); !e.empty(); e.popFront()) {
         nsXPCWrappedJS* wrapper = e.front().value();
         MOZ_ASSERT(wrapper, "found a null JS wrapper!");
--- a/js/xpconnect/src/XPCMaps.h
+++ b/js/xpconnect/src/XPCMaps.h
@@ -78,17 +78,17 @@ public:
 
     inline uint32_t Count() {return mTable.count();}
 
     inline void Dump(int16_t depth) {
         for (Map::Range r = mTable.all(); !r.empty(); r.popFront())
             r.front().value()->DebugDump(depth);
     }
 
-    void UpdateWeakPointersAfterGC(XPCJSRuntime* runtime);
+    void UpdateWeakPointersAfterGC(XPCJSContext* context);
 
     void ShutdownMarker();
 
     size_t SizeOfIncludingThis(mozilla::MallocSizeOf mallocSizeOf) const;
 
     // Report the sum of SizeOfIncludingThis() for all wrapped JS in the map.
     // Each wrapped JS is only in one map.
     size_t SizeOfWrappedJS(mozilla::MallocSizeOf mallocSizeOf) const;
@@ -309,17 +309,17 @@ public:
     }
 
     inline uint32_t Count() { return mTable.EntryCount(); }
 
     PLDHashTable::Iterator Iter() { return mTable.Iter(); }
 
     // ClassInfo2NativeSetMap holds pointers to *some* XPCNativeSets.
     // So we don't want to count those XPCNativeSets, because they are better
-    // counted elsewhere (i.e. in XPCJSRuntime::mNativeSetMap, which holds
+    // counted elsewhere (i.e. in XPCJSContext::mNativeSetMap, which holds
     // pointers to *all* XPCNativeSets).  Hence the "Shallow".
     size_t ShallowSizeOfIncludingThis(mozilla::MallocSizeOf mallocSizeOf);
 
 private:
     ClassInfo2NativeSetMap();    // no implementation
     explicit ClassInfo2NativeSetMap(int size);
 private:
     PLDHashTable mTable;
--- a/js/xpconnect/src/XPCThrower.cpp
+++ b/js/xpconnect/src/XPCThrower.cpp
@@ -45,20 +45,20 @@ Throw(JSContext* cx, nsresult rv)
  * If there has already been an exception thrown, see if we're throwing the
  * same sort of exception, and if we are, don't clobber the old one. ccx
  * should be the current call context.
  */
 // static
 bool
 XPCThrower::CheckForPendingException(nsresult result, JSContext* cx)
 {
-    nsCOMPtr<nsIException> e = XPCJSRuntime::Get()->GetPendingException();
+    nsCOMPtr<nsIException> e = XPCJSContext::Get()->GetPendingException();
     if (!e)
         return false;
-    XPCJSRuntime::Get()->SetPendingException(nullptr);
+    XPCJSContext::Get()->SetPendingException(nullptr);
 
     nsresult e_result;
     if (NS_FAILED(e->GetResult(&e_result)) || e_result != result)
         return false;
 
     ThrowExceptionObject(cx, e);
     return true;
 }
--- a/js/xpconnect/src/XPCWrappedJS.cpp
+++ b/js/xpconnect/src/XPCWrappedJS.cpp
@@ -36,17 +36,17 @@ using namespace mozilla;
 // When the refcount of a rooting wrapper drops to 1, if there is no weak reference
 // to the wrapper (which can only happen for the root wrapper), it is immediately
 // Destroy()'d. Otherwise, it becomes subject to finalization.
 //
 // When a wrapper is subject to finalization, the wrapper has a refcount of 1. It is
 // now owned exclusively by its JS object. Either a weak reference will be turned into
 // a strong ref which will bring its refcount up to 2 and change the wrapper back to
 // the rooting state, or it will stay alive until the JS object dies. If the JS object
-// dies, then when XPCJSRuntime::FinalizeCallback calls FindDyingJSObjects
+// dies, then when XPCJSContext::FinalizeCallback calls FindDyingJSObjects
 // it will find the wrapper and call Release() in it, destroying the wrapper.
 // Otherwise, the wrapper will stay alive, even if it no longer has a weak reference
 // to it.
 //
 // When the wrapper is subject to finalization, it is kept alive by an implicit reference
 // from the JS object which is invisible to the cycle collector, so the cycle collector
 // does not traverse any children of wrappers that are subject to finalization. This will
 // result in a leak if a wrapper in the non-rooting state has an aggregated native that
@@ -138,17 +138,17 @@ NS_CYCLE_COLLECTION_CLASSNAME(nsXPCWrapp
 }
 
 NS_IMPL_CYCLE_COLLECTION_CLASS(nsXPCWrappedJS)
 
 NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(nsXPCWrappedJS)
     tmp->Unlink();
 NS_IMPL_CYCLE_COLLECTION_UNLINK_END
 
-// XPCJSRuntime keeps a table of WJS, so we can remove them from
+// XPCJSContext keeps a table of WJS, so we can remove them from
 // the purple buffer in between CCs.
 NS_IMPL_CYCLE_COLLECTION_CAN_SKIP_BEGIN(nsXPCWrappedJS)
     return true;
 NS_IMPL_CYCLE_COLLECTION_CAN_SKIP_END
 
 NS_IMPL_CYCLE_COLLECTION_CAN_SKIP_IN_CC_BEGIN(nsXPCWrappedJS)
     return tmp->CanSkip();
 NS_IMPL_CYCLE_COLLECTION_CAN_SKIP_IN_CC_END
@@ -244,17 +244,17 @@ nsXPCWrappedJS::AddRef(void)
 
     MOZ_ASSERT(int32_t(mRefCnt) >= 0, "illegal refcnt");
     nsISupports* base = NS_CYCLE_COLLECTION_CLASSNAME(nsXPCWrappedJS)::Upcast(this);
     nsrefcnt cnt = mRefCnt.incr(base);
     NS_LOG_ADDREF(this, cnt, "nsXPCWrappedJS", sizeof(*this));
 
     if (2 == cnt && IsValid()) {
         GetJSObject(); // Unmark gray JSObject.
-        mClass->GetRuntime()->AddWrappedJSRoot(this);
+        mClass->GetContext()->AddWrappedJSRoot(this);
     }
 
     return cnt;
 }
 
 MozExternalRefCountType
 nsXPCWrappedJS::Release(void)
 {
@@ -345,20 +345,20 @@ nsXPCWrappedJS::GetNewOrUsed(JS::HandleO
     if (!rootJSObj)
         return NS_ERROR_FAILURE;
 
     xpc::CompartmentPrivate* rootComp = xpc::CompartmentPrivate::Get(rootJSObj);
     MOZ_ASSERT(rootComp);
 
     // Find any existing wrapper.
     RefPtr<nsXPCWrappedJS> root = rootComp->GetWrappedJSMap()->Find(rootJSObj);
-    MOZ_ASSERT_IF(root, !nsXPConnect::GetRuntimeInstance()->GetMultiCompartmentWrappedJSMap()->
+    MOZ_ASSERT_IF(root, !nsXPConnect::GetContextInstance()->GetMultiCompartmentWrappedJSMap()->
                         Find(rootJSObj));
     if (!root) {
-        root = nsXPConnect::GetRuntimeInstance()->GetMultiCompartmentWrappedJSMap()->
+        root = nsXPConnect::GetContextInstance()->GetMultiCompartmentWrappedJSMap()->
             Find(rootJSObj);
     }
 
     nsresult rv = NS_ERROR_FAILURE;
     if (root) {
         RefPtr<nsXPCWrappedJS> wrapper = root->FindOrFindInherited(aIID);
         if (wrapper) {
             wrapper.forget(wrapperResult);
@@ -412,32 +412,32 @@ nsXPCWrappedJS::nsXPCWrappedJS(JSContext
         xpc::CompartmentPrivate::Get(mJSObj)->GetWrappedJSMap()->Add(cx, this);
     } else {
         NS_ADDREF(mRoot);
         mNext = mRoot->mNext;
         mRoot->mNext = this;
 
         // We always start wrappers in the per-compartment table. If adding
         // this wrapper to the chain causes it to cross compartments, we need
-        // to migrate the chain to the global table on the XPCJSRuntime.
+        // to migrate the chain to the global table on the XPCJSContext.
         if (mRoot->IsMultiCompartment()) {
             xpc::CompartmentPrivate::Get(mRoot->mJSObj)->GetWrappedJSMap()->Remove(mRoot);
-            MOZ_RELEASE_ASSERT(nsXPConnect::GetRuntimeInstance()->
+            MOZ_RELEASE_ASSERT(nsXPConnect::GetContextInstance()->
                     GetMultiCompartmentWrappedJSMap()->Add(cx, mRoot));
         }
     }
 }
 
 nsXPCWrappedJS::~nsXPCWrappedJS()
 {
     Destroy();
 }
 
 void
-XPCJSRuntime::RemoveWrappedJS(nsXPCWrappedJS* wrapper)
+XPCJSContext::RemoveWrappedJS(nsXPCWrappedJS* wrapper)
 {
     AssertInvalidWrappedJSNotInTable(wrapper);
     if (!wrapper->IsValid())
         return;
 
     // It is possible for the same JS XPCOM implementation object to be wrapped
     // with a different interface in multiple JSCompartments. In this case, the
     // wrapper chain will contain references to multiple compartments. While we
@@ -460,47 +460,47 @@ NotHasWrapperAssertionCallback(JSContext
 {
     auto wrapper = static_cast<nsXPCWrappedJS*>(data);
     auto xpcComp = xpc::CompartmentPrivate::Get(comp);
     MOZ_ASSERT_IF(xpcComp, !xpcComp->GetWrappedJSMap()->HasWrapper(wrapper));
 }
 #endif
 
 void
-XPCJSRuntime::AssertInvalidWrappedJSNotInTable(nsXPCWrappedJS* wrapper) const
+XPCJSContext::AssertInvalidWrappedJSNotInTable(nsXPCWrappedJS* wrapper) const
 {
 #ifdef DEBUG
     if (!wrapper->IsValid()) {
         MOZ_ASSERT(!GetMultiCompartmentWrappedJSMap()->HasWrapper(wrapper));
         if (!mGCIsRunning)
             JS_IterateCompartments(Context(), wrapper, NotHasWrapperAssertionCallback);
     }
 #endif
 }
 
 void
 nsXPCWrappedJS::Destroy()
 {
     MOZ_ASSERT(1 == int32_t(mRefCnt), "should be stabilized for deletion");
 
     if (IsRootWrapper())
-        nsXPConnect::GetRuntimeInstance()->RemoveWrappedJS(this);
+        nsXPConnect::GetContextInstance()->RemoveWrappedJS(this);
     Unlink();
 }
 
 void
 nsXPCWrappedJS::Unlink()
 {
-    nsXPConnect::GetRuntimeInstance()->AssertInvalidWrappedJSNotInTable(this);
+    nsXPConnect::GetContextInstance()->AssertInvalidWrappedJSNotInTable(this);
 
     if (IsValid()) {
-        XPCJSRuntime* rt = nsXPConnect::GetRuntimeInstance();
-        if (rt) {
+        XPCJSContext* cx = nsXPConnect::GetContextInstance();
+        if (cx) {
             if (IsRootWrapper())
-                rt->RemoveWrappedJS(this);
+                cx->RemoveWrappedJS(this);
 
             if (mRefCnt > 1)
                 RemoveFromRootSet();
         }
 
         mJSObj = nullptr;
     }
 
@@ -525,18 +525,18 @@ nsXPCWrappedJS::Unlink()
         // cannot get a JSContext here.
 
         // let the root go
         NS_RELEASE(mRoot);
     }
 
     mClass = nullptr;
     if (mOuter) {
-        XPCJSRuntime* rt = nsXPConnect::GetRuntimeInstance();
-        if (rt->GCIsRunning()) {
+        XPCJSContext* cx = nsXPConnect::GetContextInstance();
+        if (cx->GCIsRunning()) {
             DeferredFinalize(mOuter.forget().take());
         } else {
             mOuter = nullptr;
         }
     }
 }
 
 bool
--- a/js/xpconnect/src/XPCWrappedJSClass.cpp
+++ b/js/xpconnect/src/XPCWrappedJSClass.cpp
@@ -77,41 +77,41 @@ bool xpc_IsReportableErrorCode(nsresult 
         case NS_ERROR_FACTORY_REGISTER_AGAIN:
         case NS_BASE_STREAM_WOULD_BLOCK:
             return false;
         default:
             return true;
     }
 }
 
-// A little stack-based RAII class to help management of the XPCJSRuntime
+// A little stack-based RAII class to help management of the XPCJSContext
 // PendingResult.
 class MOZ_STACK_CLASS AutoSavePendingResult {
 public:
-    explicit AutoSavePendingResult(XPCJSRuntime* xpcrt) :
-        mXPCRuntime(xpcrt)
+    explicit AutoSavePendingResult(XPCJSContext* xpccx) :
+        mXPCContext(xpccx)
     {
         // Save any existing pending result and reset to NS_OK for this invocation.
-        mSavedResult = xpcrt->GetPendingResult();
-        xpcrt->SetPendingResult(NS_OK);
+        mSavedResult = xpccx->GetPendingResult();
+        xpccx->SetPendingResult(NS_OK);
     }
     ~AutoSavePendingResult() {
-        mXPCRuntime->SetPendingResult(mSavedResult);
+        mXPCContext->SetPendingResult(mSavedResult);
     }
 private:
-    XPCJSRuntime* mXPCRuntime;
+    XPCJSContext* mXPCContext;
     nsresult mSavedResult;
 };
 
 // static
 already_AddRefed<nsXPCWrappedJSClass>
 nsXPCWrappedJSClass::GetNewOrUsed(JSContext* cx, REFNSIID aIID, bool allowNonScriptable)
 {
-    XPCJSRuntime* rt = nsXPConnect::GetRuntimeInstance();
-    IID2WrappedJSClassMap* map = rt->GetWrappedJSClassMap();
+    XPCJSContext* xpccx = nsXPConnect::GetContextInstance();
+    IID2WrappedJSClassMap* map = xpccx->GetWrappedJSClassMap();
     RefPtr<nsXPCWrappedJSClass> clasp = map->Find(aIID);
 
     if (!clasp) {
         nsCOMPtr<nsIInterfaceInfo> info;
         nsXPConnect::XPConnect()->GetInfoForIID(&aIID, getter_AddRefs(info));
         if (info) {
             bool canScript, isBuiltin;
             if (NS_SUCCEEDED(info->IsScriptable(&canScript)) && (canScript || allowNonScriptable) &&
@@ -124,23 +124,23 @@ nsXPCWrappedJSClass::GetNewOrUsed(JSCont
             }
         }
     }
     return clasp.forget();
 }
 
 nsXPCWrappedJSClass::nsXPCWrappedJSClass(JSContext* cx, REFNSIID aIID,
                                          nsIInterfaceInfo* aInfo)
-    : mRuntime(nsXPConnect::GetRuntimeInstance()),
+    : mContext(nsXPConnect::GetContextInstance()),
       mInfo(aInfo),
       mName(nullptr),
       mIID(aIID),
       mDescriptors(nullptr)
 {
-    mRuntime->GetWrappedJSClassMap()->Add(this);
+    mContext->GetWrappedJSClassMap()->Add(this);
 
     uint16_t methodCount;
     if (NS_SUCCEEDED(mInfo->GetMethodCount(&methodCount))) {
         if (methodCount) {
             int wordCount = (methodCount/32)+1;
             if (nullptr != (mDescriptors = new uint32_t[wordCount])) {
                 int i;
                 // init flags to 0;
@@ -163,18 +163,18 @@ nsXPCWrappedJSClass::nsXPCWrappedJSClass
         }
     }
 }
 
 nsXPCWrappedJSClass::~nsXPCWrappedJSClass()
 {
     if (mDescriptors && mDescriptors != &zero_methods_descriptor)
         delete [] mDescriptors;
-    if (mRuntime)
-        mRuntime->GetWrappedJSClassMap()->Remove(this);
+    if (mContext)
+        mContext->GetWrappedJSClassMap()->Remove(this);
 
     if (mName)
         free(mName);
 }
 
 JSObject*
 nsXPCWrappedJSClass::CallQueryInterfaceOnJSObject(JSContext* cx,
                                                   JSObject* jsobjArg,
@@ -204,17 +204,17 @@ nsXPCWrappedJSClass::CallQueryInterfaceO
     AutoScriptEvaluate scriptEval(cx);
 
     // XXX we should install an error reporter that will send reports to
     // the JS error console service.
     if (!scriptEval.StartEvaluating(jsobj))
         return nullptr;
 
     // check upfront for the existence of the function property
-    HandleId funid = mRuntime->GetStringID(XPCJSRuntime::IDX_QUERY_INTERFACE);
+    HandleId funid = mContext->GetStringID(XPCJSContext::IDX_QUERY_INTERFACE);
     if (!JS_GetPropertyById(cx, jsobj, funid, &fun) || fun.isPrimitive())
         return nullptr;
 
     // Ensure that we are asking for a scriptable interface.
     // NB:  It's important for security that this check is here rather
     // than later, since it prevents untrusted objects from implementing
     // some interfaces in JS and aggregating a trusted object to
     // implement intentionally (for security) unscriptable interfaces.
@@ -773,35 +773,35 @@ nsXPCWrappedJSClass::CheckForException(X
                                        const char * anInterfaceName,
                                        nsIException* aSyntheticException)
 {
     JSContext * cx = ccx.GetJSContext();
     MOZ_ASSERT(cx == aes.cx());
     nsCOMPtr<nsIException> xpc_exception = aSyntheticException;
     /* this one would be set by our error reporter */
 
-    XPCJSRuntime* xpcrt = XPCJSRuntime::Get();
+    XPCJSContext* xpccx = XPCJSContext::Get();
 
     // Get this right away in case we do something below to cause JS code
     // to run.
-    nsresult pending_result = xpcrt->GetPendingResult();
+    nsresult pending_result = xpccx->GetPendingResult();
 
     RootedValue js_exception(cx);
     bool is_js_exception = JS_GetPendingException(cx, &js_exception);
 
     /* JS might throw an expection whether the reporter was called or not */
     if (is_js_exception) {
         if (!xpc_exception)
             XPCConvert::JSValToXPCException(&js_exception, anInterfaceName,
                                             aPropertyName,
                                             getter_AddRefs(xpc_exception));
 
         /* cleanup and set failed even if we can't build an exception */
         if (!xpc_exception) {
-            xpcrt->SetPendingException(nullptr); // XXX necessary?
+            xpccx->SetPendingException(nullptr); // XXX necessary?
         }
     }
 
     // Clear the pending exception now, because xpc_exception might be JS-
     // implemented, so invoking methods on it might re-enter JS, which we can't
     // do with an exception on the stack.
     aes.ClearException();
 
@@ -910,17 +910,17 @@ nsXPCWrappedJSClass::CheckForException(X
                     }
                     if (nullptr != scriptError)
                         consoleService->LogMessage(scriptError);
                 }
             }
             // Whether or not it passes the 'reportable' test, it might
             // still be an error and we have to do the right thing here...
             if (NS_FAILED(e_result)) {
-                xpcrt->SetPendingException(xpc_exception);
+                xpccx->SetPendingException(xpc_exception);
                 return e_result;
             }
         }
     } else {
         // see if JS code signaled failure result without throwing exception
         if (NS_FAILED(pending_result)) {
             return pending_result;
         }
@@ -980,28 +980,28 @@ nsXPCWrappedJSClass::CallMethod(nsXPCWra
     RootedObject obj(cx, wrapper->GetJSObject());
     RootedObject thisObj(cx, obj);
 
     JSAutoCompartment ac(cx, obj);
 
     AutoValueVector args(cx);
     AutoScriptEvaluate scriptEval(cx);
 
-    XPCJSRuntime* xpcrt = XPCJSRuntime::Get();
-    AutoSavePendingResult apr(xpcrt);
+    XPCJSContext* xpccx = XPCJSContext::Get();
+    AutoSavePendingResult apr(xpccx);
 
     // XXX ASSUMES that retval is last arg. The xpidl compiler ensures this.
     uint8_t paramCount = info->num_args;
     uint8_t argc = paramCount -
         (paramCount && XPT_PD_IS_RETVAL(info->params[paramCount-1].flags) ? 1 : 0);
 
     if (!scriptEval.StartEvaluating(obj))
         goto pre_call_clean_up;
 
-    xpcrt->SetPendingException(nullptr);
+    xpccx->SetPendingException(nullptr);
 
     // We use js_Invoke so that the gcthings we use as args will be rooted by
     // the engine as we do conversions and prepare to do the function call.
 
     // setup stack
 
     // if this isn't a function call then we don't need to push extra stuff
     if (!(XPT_MD_IS_SETTER(info->flags) || XPT_MD_IS_GETTER(info->flags))) {
@@ -1037,17 +1037,17 @@ nsXPCWrappedJSClass::CallMethod(nsXPCWra
                 const nsXPTParamInfo& firstParam = info->params[0];
                 if (firstParam.IsIn()) {
                     const nsXPTType& firstType = firstParam.GetType();
 
                     if (firstType.IsInterfacePointer()) {
                         nsIXPCFunctionThisTranslator* translator;
 
                         IID2ThisTranslatorMap* map =
-                            mRuntime->GetThisTranslatorMap();
+                            mContext->GetThisTranslatorMap();
 
                         translator = map->Find(mIID);
 
                         if (translator) {
                             nsCOMPtr<nsISupports> newThis;
                             if (NS_FAILED(translator->
                                           TranslateThis((nsISupports*)nativeParams[0].val.p,
                                                         getter_AddRefs(newThis)))) {
@@ -1168,17 +1168,17 @@ nsXPCWrappedJSClass::CallMethod(nsXPCWra
             RootedObject out_obj(cx, NewOutObject(cx));
             if (!out_obj) {
                 retval = NS_ERROR_OUT_OF_MEMORY;
                 goto pre_call_clean_up;
             }
 
             if (param.IsIn()) {
                 if (!JS_SetPropertyById(cx, out_obj,
-                                        mRuntime->GetStringID(XPCJSRuntime::IDX_VALUE),
+                                        mContext->GetStringID(XPCJSContext::IDX_VALUE),
                                         val)) {
                     goto pre_call_clean_up;
                 }
             }
             *sp++ = JS::ObjectValue(*out_obj);
         } else
             *sp++ = val;
     }
@@ -1230,17 +1230,17 @@ pre_call_clean_up:
             success = false;
         }
     }
 
     if (!success)
         return CheckForException(ccx, aes, name, GetInterfaceName(),
                                  syntheticException);
 
-    XPCJSRuntime::Get()->SetPendingException(nullptr); // XXX necessary?
+    XPCJSContext::Get()->SetPendingException(nullptr); // XXX necessary?
 
     // convert out args and result
     // NOTE: this is the total number of native params, not just the args
     // Convert independent params only.
     // When we later convert the dependent params (if any) we will know that
     // the params upon which they depend will have already been converted -
     // regardless of ordering.
 
@@ -1268,17 +1268,17 @@ pre_call_clean_up:
 
         if (param.IsRetval())
             val = rval;
         else if (argv[i].isPrimitive())
             break;
         else {
             RootedObject obj(cx, &argv[i].toObject());
             if (!JS_GetPropertyById(cx, obj,
-                                    mRuntime->GetStringID(XPCJSRuntime::IDX_VALUE),
+                                    mContext->GetStringID(XPCJSContext::IDX_VALUE),
                                     &val))
                 break;
         }
 
         // setup allocator and/or iid
 
         if (type_tag == nsXPTType::T_INTERFACE) {
             if (NS_FAILED(GetInterfaceInfo()->
@@ -1315,17 +1315,17 @@ pre_call_clean_up:
 
             pv = (nsXPTCMiniVariant*) nativeParams[i].val.p;
 
             if (param.IsRetval())
                 val = rval;
             else {
                 RootedObject obj(cx, &argv[i].toObject());
                 if (!JS_GetPropertyById(cx, obj,
-                                        mRuntime->GetStringID(XPCJSRuntime::IDX_VALUE),
+                                        mContext->GetStringID(XPCJSContext::IDX_VALUE),
                                         &val))
                     break;
             }
 
             // setup allocator and/or iid
 
             if (isArray) {
                 if (NS_FAILED(mInfo->GetTypeForParam(methodIndex, &param, 1,
@@ -1368,17 +1368,17 @@ pre_call_clean_up:
     }
 
     if (i != paramCount) {
         // We didn't manage all the result conversions!
         // We have to cleanup any junk that *did* get converted.
         CleanupOutparams(cx, methodIndex, info, nativeParams, /* inOutOnly = */ false, i);
     } else {
         // set to whatever the JS code might have set as the result
-        retval = xpcrt->GetPendingResult();
+        retval = xpccx->GetPendingResult();
     }
 
     return retval;
 }
 
 const char*
 nsXPCWrappedJSClass::GetInterfaceName()
 {
@@ -1431,17 +1431,17 @@ nsXPCWrappedJSClass::DebugDump(int16_t d
             mInfo->GetParent(getter_AddRefs(parent));
             XPC_LOG_ALWAYS(("parent @ %x", parent.get()));
             mInfo->GetMethodCount(&methodCount);
             XPC_LOG_ALWAYS(("MethodCount = %d", methodCount));
             mInfo->GetConstantCount(&i);
             XPC_LOG_ALWAYS(("ConstantCount = %d", i));
             XPC_LOG_OUTDENT();
         }
-        XPC_LOG_ALWAYS(("mRuntime @ %x", mRuntime));
+        XPC_LOG_ALWAYS(("mContext @ %x", mContext));
         XPC_LOG_ALWAYS(("mDescriptors @ %x count = %d", mDescriptors, methodCount));
         if (depth && mDescriptors && methodCount) {
             depth--;
             XPC_LOG_INDENT();
             for (uint16_t i = 0; i < methodCount; i++) {
                 XPC_LOG_ALWAYS(("Method %d is %s%s", \
                                 i, IsReflectable(i) ? "":" NOT ","reflectable"));
             }
--- a/js/xpconnect/src/XPCWrappedNative.cpp
+++ b/js/xpconnect/src/XPCWrappedNative.cpp
@@ -295,17 +295,17 @@ XPCWrappedNative::GetNewOrUsed(xpcObject
     nsWrapperCache* cache = helper.GetWrapperCache();
 
     MOZ_ASSERT(!cache || !cache->GetWrapperPreserveColor(),
                "We assume the caller already checked if it could get the "
                "wrapper from the cache.");
 
     nsresult rv;
 
-    MOZ_ASSERT(!Scope->GetRuntime()->GCIsRunning(),
+    MOZ_ASSERT(!Scope->GetContext()->GCIsRunning(),
                "XPCWrappedNative::GetNewOrUsed called during GC");
 
     nsISupports* identity = helper.GetCanonical();
 
     if (!identity) {
         NS_ERROR("This XPCOM object fails in QueryInterface to nsISupports!");
         return NS_ERROR_FAILURE;
     }
@@ -603,18 +603,18 @@ XPCWrappedNative::Destroy()
         Native2WrappedNativeMap* map = scope->GetWrappedNativeMap();
 
         // Post-1.9 we should not remove this wrapper from the map if it is
         // uninitialized.
         map->Remove(this);
     }
 
     if (mIdentity) {
-        XPCJSRuntime* rt = GetRuntime();
-        if (rt && rt->GetDoingFinalization()) {
+        XPCJSContext* cx = GetContext();
+        if (cx && cx->GetDoingFinalization()) {
             DeferredFinalize(mIdentity.forget().take());
         } else {
             mIdentity = nullptr;
         }
     }
 
     mMaybeScope = nullptr;
 }
@@ -629,17 +629,17 @@ XPCWrappedNative::UpdateScriptableInfo(X
 void
 XPCWrappedNative::SetProto(XPCWrappedNativeProto* p)
 {
     MOZ_ASSERT(!IsWrapperExpired(), "bad ptr!");
 
     MOZ_ASSERT(HasProto());
 
     // Write barrier for incremental GC.
-    JSContext* cx = GetRuntime()->Context();
+    JSContext* cx = GetContext()->Context();
     GetProto()->WriteBarrierPre(cx);
 
     mMaybeProto = p;
 }
 
 // This is factored out so that it can be called publicly
 // static
 void
@@ -898,17 +898,17 @@ XPCWrappedNative::FlatJSObjectFinalized(
             JS_UpdateWeakPointerAfterGCUnbarriered(&jso);
             MOZ_ASSERT(!jso);
 #endif
             to->JSObjectFinalized();
         }
 
         // We also need to release any native pointers held...
         RefPtr<nsISupports> native = to->TakeNative();
-        if (native && GetRuntime()) {
+        if (native && GetContext()) {
             DeferredFinalize(native.forget().take());
         }
 
         to->SetInterface(nullptr);
     }
 
     nsWrapperCache* cache = nullptr;
     CallQueryInterface(mIdentity, &cache);
@@ -1316,17 +1316,17 @@ public:
 
     explicit CallMethodHelper(XPCCallContext& ccx)
         : mCallContext(ccx)
         , mInvokeResult(NS_ERROR_UNEXPECTED)
         , mIFaceInfo(ccx.GetInterface()->GetInterfaceInfo())
         , mMethodInfo(nullptr)
         , mCallee(ccx.GetTearOff()->GetNative())
         , mVTableIndex(ccx.GetMethodIndex())
-        , mIdxValueId(ccx.GetRuntime()->GetStringID(XPCJSRuntime::IDX_VALUE))
+        , mIdxValueId(ccx.GetContext()->GetStringID(XPCJSContext::IDX_VALUE))
         , mJSContextIndex(UINT8_MAX)
         , mOptArgcIndex(UINT8_MAX)
         , mArgv(ccx.GetArgv())
         , mArgc(ccx.GetArgc())
 
     {
         // Success checked later.
         mIFaceInfo->GetMethodInfo(mVTableIndex, &mMethodInfo);
@@ -1351,17 +1351,17 @@ XPCWrappedNative::CallMethod(XPCCallCont
     return CallMethodHelper(ccx).Call();
 }
 
 bool
 CallMethodHelper::Call()
 {
     mCallContext.SetRetVal(JS::UndefinedValue());
 
-    XPCJSRuntime::Get()->SetPendingException(nullptr);
+    XPCJSContext::Get()->SetPendingException(nullptr);
 
     if (mVTableIndex == 0) {
         return QueryInterfaceFastPath();
     }
 
     if (!mMethodInfo) {
         Throw(NS_ERROR_XPC_CANT_GET_METHOD_INFO, mCallContext);
         return false;
@@ -2005,21 +2005,21 @@ CallMethodHelper::CleanupParam(nsXPTCMin
             js::RemoveRawValueRoot(mCallContext, (Value*)&param.val);
             break;
         case nsXPTType::T_INTERFACE:
         case nsXPTType::T_INTERFACE_IS:
             ((nsISupports*)param.val.p)->Release();
             break;
         case nsXPTType::T_ASTRING:
         case nsXPTType::T_DOMSTRING:
-            nsXPConnect::GetRuntimeInstance()->mScratchStrings.Destroy((nsString*)param.val.p);
+            nsXPConnect::GetContextInstance()->mScratchStrings.Destroy((nsString*)param.val.p);
             break;
         case nsXPTType::T_UTF8STRING:
         case nsXPTType::T_CSTRING:
-            nsXPConnect::GetRuntimeInstance()->mScratchCStrings.Destroy((nsCString*)param.val.p);
+            nsXPConnect::GetContextInstance()->mScratchCStrings.Destroy((nsCString*)param.val.p);
             break;
         default:
             MOZ_ASSERT(!type.IsArithmetic(), "Cleanup requested on unexpected type.");
             free(param.val.p);
             break;
     }
 }
 
@@ -2035,19 +2035,19 @@ CallMethodHelper::AllocateStringClass(ns
                type_tag == nsXPTType::T_DOMSTRING ||
                type_tag == nsXPTType::T_UTF8STRING ||
                type_tag == nsXPTType::T_CSTRING,
                "Unexpected string class type!");
 
     // ASTRING and DOMSTRING are very similar, and both use nsString.
     // UTF8_STRING and CSTRING are also quite similar, and both use nsCString.
     if (type_tag == nsXPTType::T_ASTRING || type_tag == nsXPTType::T_DOMSTRING)
-        dp->val.p = nsXPConnect::GetRuntimeInstance()->mScratchStrings.Create();
+        dp->val.p = nsXPConnect::GetContextInstance()->mScratchStrings.Create();
     else
-        dp->val.p = nsXPConnect::GetRuntimeInstance()->mScratchCStrings.Create();
+        dp->val.p = nsXPConnect::GetContextInstance()->mScratchCStrings.Create();
 
     // Check for OOM, in either case.
     if (!dp->val.p) {
         JS_ReportOutOfMemory(mCallContext);
         return false;
     }
 
     // We allocated, so we need to deallocate after the method call completes.
@@ -2312,17 +2312,17 @@ XPCJSObjectHolder::GetJSObject()
     NS_PRECONDITION(mJSObj, "bad object state");
     return mJSObj;
 }
 
 XPCJSObjectHolder::XPCJSObjectHolder(JSObject* obj)
     : mJSObj(obj)
 {
     MOZ_ASSERT(obj);
-    XPCJSRuntime::Get()->AddObjectHolderRoot(this);
+    XPCJSContext::Get()->AddObjectHolderRoot(this);
 }
 
 XPCJSObjectHolder::~XPCJSObjectHolder()
 {
     RemoveFromRootSet();
 }
 
 void
--- a/js/xpconnect/src/XPCWrappedNativeInfo.cpp
+++ b/js/xpconnect/src/XPCWrappedNativeInfo.cpp
@@ -104,27 +104,27 @@ XPCNativeMember::Resolve(XPCCallContext&
     return true;
 }
 
 /***************************************************************************/
 // XPCNativeInterface
 
 XPCNativeInterface::~XPCNativeInterface()
 {
-    XPCJSRuntime::Get()->GetIID2NativeInterfaceMap()->Remove(this);
+    XPCJSContext::Get()->GetIID2NativeInterfaceMap()->Remove(this);
 }
 
 // static
 already_AddRefed<XPCNativeInterface>
 XPCNativeInterface::GetNewOrUsed(const nsIID* iid)
 {
     RefPtr<XPCNativeInterface> iface;
-    XPCJSRuntime* rt = XPCJSRuntime::Get();
+    XPCJSContext* cx = XPCJSContext::Get();
 
-    IID2NativeInterfaceMap* map = rt->GetIID2NativeInterfaceMap();
+    IID2NativeInterfaceMap* map = cx->GetIID2NativeInterfaceMap();
     if (!map)
         return nullptr;
 
     iface = map->Find(*iid);
 
     if (iface)
         return iface.forget();
 
@@ -153,19 +153,19 @@ already_AddRefed<XPCNativeInterface>
 XPCNativeInterface::GetNewOrUsed(nsIInterfaceInfo* info)
 {
     RefPtr<XPCNativeInterface> iface;
 
     const nsIID* iid;
     if (NS_FAILED(info->GetIIDShared(&iid)) || !iid)
         return nullptr;
 
-    XPCJSRuntime* rt = XPCJSRuntime::Get();
+    XPCJSContext* cx = XPCJSContext::Get();
 
-    IID2NativeInterfaceMap* map = rt->GetIID2NativeInterfaceMap();
+    IID2NativeInterfaceMap* map = cx->GetIID2NativeInterfaceMap();
     if (!map)
         return nullptr;
 
     iface = map->Find(*iid);
 
     if (iface)
         return iface.forget();
 
@@ -471,18 +471,18 @@ XPCNativeSet::GetNewOrUsed(const nsIID* 
 
     RefPtr<XPCNativeInterface> iface =
         XPCNativeInterface::GetNewOrUsed(iid);
     if (!iface)
         return nullptr;
 
     XPCNativeSetKey key(iface);
 
-    XPCJSRuntime* rt = XPCJSRuntime::Get();
-    NativeSetMap* map = rt->GetNativeSetMap();
+    XPCJSContext* xpccx = XPCJSContext::Get();
+    NativeSetMap* map = xpccx->GetNativeSetMap();
     if (!map)
         return nullptr;
 
     set = map->Find(&key);
 
     if (set)
         return set;
 
@@ -500,19 +500,19 @@ XPCNativeSet::GetNewOrUsed(const nsIID* 
 }
 
 // static
 XPCNativeSet*
 XPCNativeSet::GetNewOrUsed(nsIClassInfo* classInfo)
 {
     AutoJSContext cx;
     AutoMarkingNativeSetPtr set(cx);
-    XPCJSRuntime* rt = XPCJSRuntime::Get();
+    XPCJSContext* xpccx = XPCJSContext::Get();
 
-    ClassInfo2NativeSetMap* map = rt->GetClassInfo2NativeSetMap();
+    ClassInfo2NativeSetMap* map = xpccx->GetClassInfo2NativeSetMap();
     if (!map)
         return nullptr;
 
     set = map->Find(classInfo);
 
     if (set)
         return set;
 
@@ -553,17 +553,17 @@ XPCNativeSet::GetNewOrUsed(nsIClassInfo*
             }
 
             interfaceArray.AppendElement(iface.forget());
         }
 
         if (interfaceArray.Length() > 0) {
             set = NewInstance(Move(interfaceArray));
             if (set) {
-                NativeSetMap* map2 = rt->GetNativeSetMap();
+                NativeSetMap* map2 = xpccx->GetNativeSetMap();
                 if (!map2)
                     goto out;
 
                 XPCNativeSetKey key(set);
 
                 XPCNativeSet* set2 = map2->Add(&key, set);
                 if (!set2) {
                     NS_ERROR("failed to add our set!");
@@ -598,30 +598,30 @@ out:
 
     return set;
 }
 
 // static
 void
 XPCNativeSet::ClearCacheEntryForClassInfo(nsIClassInfo* classInfo)
 {
-    XPCJSRuntime* rt = nsXPConnect::GetRuntimeInstance();
-    ClassInfo2NativeSetMap* map = rt->GetClassInfo2NativeSetMap();
+    XPCJSContext* xpccx = nsXPConnect::GetContextInstance();
+    ClassInfo2NativeSetMap* map = xpccx->GetClassInfo2NativeSetMap();
     if (map)
         map->Remove(classInfo);
 }
 
 // static
 XPCNativeSet*
 XPCNativeSet::GetNewOrUsed(XPCNativeSetKey* key)
 {
     AutoJSContext cx;
     AutoMarkingNativeSetPtr set(cx);
-    XPCJSRuntime* rt = XPCJSRuntime::Get();
-    NativeSetMap* map = rt->GetNativeSetMap();
+    XPCJSContext* xpccx = XPCJSContext::Get();
+    NativeSetMap* map = xpccx->GetNativeSetMap();
     if (!map)
         return nullptr;
 
     set = map->Find(key);
 
     if (set)
         return set;
 
--- a/js/xpconnect/src/XPCWrappedNativeJSOps.cpp
+++ b/js/xpconnect/src/XPCWrappedNativeJSOps.cpp
@@ -73,17 +73,17 @@ XPC_WN_Shared_ToString(JSContext* cx, un
     CallArgs args = CallArgsFromVp(argc, vp);
     RootedObject obj(cx, JS_THIS_OBJECT(cx, vp));
     if (!obj)
         return false;
 
     XPCCallContext ccx(cx, obj);
     if (!ccx.IsValid())
         return Throw(NS_ERROR_XPC_BAD_OP_ON_WN_PROTO, cx);
-    ccx.SetName(ccx.GetRuntime()->GetStringID(XPCJSRuntime::IDX_TO_STRING));
+    ccx.SetName(ccx.GetContext()->GetStringID(XPCJSContext::IDX_TO_STRING));
     ccx.SetArgsAndResultPtr(args.length(), args.array(), vp);
     return ToStringGuts(ccx);
 }
 
 static bool
 XPC_WN_Shared_ToSource(JSContext* cx, unsigned argc, Value* vp)
 {
     CallArgs args = CallArgsFromVp(argc, vp);
@@ -113,17 +113,17 @@ XPC_WN_Shared_toPrimitive(JSContext* cx,
         return false;
 
     if (hint == JSTYPE_NUMBER) {
         args.rval().set(JS_GetNaNValue(cx));
         return true;
     }
 
     MOZ_ASSERT(hint == JSTYPE_STRING || hint == JSTYPE_VOID);
-    ccx.SetName(ccx.GetRuntime()->GetStringID(XPCJSRuntime::IDX_TO_STRING));
+    ccx.SetName(ccx.GetContext()->GetStringID(XPCJSContext::IDX_TO_STRING));
     ccx.SetArgsAndResultPtr(0, nullptr, args.rval().address());
 
     XPCNativeMember* member = ccx.GetMember();
     if (member && member->IsMethod()) {
         if (!XPCWrappedNative::CallMethod(ccx))
             return false;
 
         if (args.rval().isPrimitive())
@@ -150,18 +150,18 @@ static JSObject*
 GetDoubleWrappedJSObject(XPCCallContext& ccx, XPCWrappedNative* wrapper)
 {
     RootedObject obj(ccx);
     nsCOMPtr<nsIXPConnectWrappedJS>
         underware = do_QueryInterface(wrapper->GetIdentityObject());
     if (underware) {
         RootedObject mainObj(ccx, underware->GetJSObject());
         if (mainObj) {
-            RootedId id(ccx, ccx.GetRuntime()->
-                            GetStringID(XPCJSRuntime::IDX_WRAPPED_JSOBJECT));
+            RootedId id(ccx, ccx.GetContext()->
+                            GetStringID(XPCJSContext::IDX_WRAPPED_JSOBJECT));
 
             JSAutoCompartment ac(ccx, mainObj);
 
             RootedValue val(ccx);
             if (JS_GetPropertyById(ccx, mainObj, id, &val) &&
                 !val.isPrimitive()) {
                 obj = val.toObjectOrNull();
             }
@@ -229,17 +229,17 @@ DefinePropertyIfFound(XPCCallContext& cc
                       XPCWrappedNative* wrapperToReflectInterfaceNames,
                       XPCWrappedNative* wrapperToReflectDoubleWrap,
                       XPCNativeScriptableInfo* scriptableInfo,
                       unsigned propFlags,
                       bool* resolved)
 {
     RootedId id(ccx, idArg);
     RefPtr<XPCNativeInterface> iface = ifaceArg;
-    XPCJSRuntime* rt = ccx.GetRuntime();
+    XPCJSContext* xpccx = ccx.GetContext();
     bool found;
     const char* name;
 
     propFlags |= JSPROP_RESOLVING;
 
     if (set) {
         if (iface)
             found = true;
@@ -262,24 +262,24 @@ DefinePropertyIfFound(XPCCallContext& cc
                     if (NS_FAILED(rv))
                         return Throw(rv, ccx);
                 }
             }
 
             bool overwriteToString = !(flags & nsIClassInfo::DOM_OBJECT)
                 || Preferences::GetBool("dom.XPCToStringForDOMClasses", false);
 
-            if(id == rt->GetStringID(XPCJSRuntime::IDX_TO_STRING)
+            if(id == xpccx->GetStringID(XPCJSContext::IDX_TO_STRING)
                 && overwriteToString)
             {
                 call = XPC_WN_Shared_ToString;
-                name = rt->GetStringName(XPCJSRuntime::IDX_TO_STRING);
-            } else if (id == rt->GetStringID(XPCJSRuntime::IDX_TO_SOURCE)) {
+                name = xpccx->GetStringName(XPCJSContext::IDX_TO_STRING);
+            } else if (id == xpccx->GetStringID(XPCJSContext::IDX_TO_SOURCE)) {
                 call = XPC_WN_Shared_ToSource;
-                name = rt->GetStringName(XPCJSRuntime::IDX_TO_SOURCE);
+                name = xpccx->GetStringName(XPCJSContext::IDX_TO_SOURCE);
             } else if (id == SYMBOL_TO_JSID(
                                JS::GetWellKnownSymbol(ccx, JS::SymbolCode::toPrimitive)))
             {
                 call = XPC_WN_Shared_toPrimitive;
                 name = "[Symbol.toPrimitive]";
             } else {
                 call = nullptr;
             }
@@ -326,25 +326,25 @@ DefinePropertyIfFound(XPCCallContext& cc
                                              propFlags & ~JSPROP_ENUMERATE);
             } else if (NS_FAILED(rv) && rv != NS_ERROR_NO_INTERFACE) {
                 return Throw(rv, ccx);
             }
         }
 
         // This *might* be a double wrapped JSObject
         if (wrapperToReflectDoubleWrap &&
-            id == rt->GetStringID(XPCJSRuntime::IDX_WRAPPED_JSOBJECT) &&
+            id == xpccx->GetStringID(XPCJSContext::IDX_WRAPPED_JSOBJECT) &&
             GetDoubleWrappedJSObject(ccx, wrapperToReflectDoubleWrap)) {
             // We build and add a getter function.
             // A security check is done on a per-get basis.
 
             JSFunction* fun;
 
-            id = rt->GetStringID(XPCJSRuntime::IDX_WRAPPED_JSOBJECT);
-            name = rt->GetStringName(XPCJSRuntime::IDX_WRAPPED_JSOBJECT);
+            id = xpccx->GetStringID(XPCJSContext::IDX_WRAPPED_JSOBJECT);
+            name = xpccx->GetStringName(XPCJSContext::IDX_WRAPPED_JSOBJECT);
 
             fun = JS_NewFunction(ccx, XPC_WN_DoubleWrappedGetter,
                                  0, 0, name);
 
             if (!fun)
                 return false;
 
             RootedObject funobj(ccx, JS_GetFunctionObject(fun));
@@ -407,21 +407,21 @@ DefinePropertyIfFound(XPCCallContext& cc
             AutoResolveName arn(ccx, id);
             if (resolved)
                 *resolved = true;
             desc.attributesRef() |= JSPROP_RESOLVING;
             return JS_DefinePropertyById(ccx, obj, id, desc);
         }
     }
 
-    if (id == rt->GetStringID(XPCJSRuntime::IDX_TO_STRING) ||
-        id == rt->GetStringID(XPCJSRuntime::IDX_TO_SOURCE) ||
+    if (id == xpccx->GetStringID(XPCJSContext::IDX_TO_STRING) ||
+        id == xpccx->GetStringID(XPCJSContext::IDX_TO_SOURCE) ||
         (scriptableInfo &&
          scriptableInfo->GetFlags().DontEnumQueryInterface() &&
-         id == rt->GetStringID(XPCJSRuntime::IDX_QUERY_INTERFACE)))
+         id == xpccx->GetStringID(XPCJSContext::IDX_QUERY_INTERFACE)))
         propFlags &= ~JSPROP_ENUMERATE;
 
     RootedValue funval(ccx);
     if (!member->NewFunctionObject(ccx, iface, obj, funval.address()))
         return false;
 
     if (member->IsMethod()) {
         AutoResolveName arn(ccx, id);
@@ -927,18 +927,18 @@ XPCNativeScriptableInfo::Construct(const
     char* name = nullptr;
     if (NS_FAILED(sci->GetCallback()->GetClassName(&name)) || !name) {
         delete newObj;
         return nullptr;
     }
 
     bool success;
 
-    XPCJSRuntime* rt = XPCJSRuntime::Get();
-    XPCNativeScriptableSharedMap* map = rt->GetNativeScriptableSharedMap();
+    XPCJSContext* cx = XPCJSContext::Get();
+    XPCNativeScriptableSharedMap* map = cx->GetNativeScriptableSharedMap();
     success = map->GetNewOrUsed(sci->GetFlags(), name, newObj);
 
     if (!success) {
         delete newObj;
         return nullptr;
     }
 
     return newObj;
@@ -1062,17 +1062,17 @@ XPCNativeScriptableShared::XPCNativeScri
 XPCNativeScriptableShared::~XPCNativeScriptableShared()
 {
     // mJSClass.cOps will be null if |this| was created with
     // populate=false. Otherwise, it was created with populate=true
     // and there is a weak reference in a global map that must be
     // removed.
 
     if (mJSClass.cOps) {
-        XPCJSRuntime::Get()->GetNativeScriptableSharedMap()->Remove(this);
+        XPCJSContext::Get()->GetNativeScriptableSharedMap()->Remove(this);
         free((void*)mJSClass.cOps);
     }
 
     free((void*)mJSClass.name);
 }
 
 /***************************************************************************/
 /***************************************************************************/
--- a/js/xpconnect/src/XPCWrappedNativeProto.cpp
+++ b/js/xpconnect/src/XPCWrappedNativeProto.cpp
@@ -117,18 +117,18 @@ XPCWrappedNativeProto::JSProtoObjectFina
 {
     MOZ_ASSERT(obj == mJSProtoObject, "huh?");
 
     // Only remove this proto from the map if it is the one in the map.
     ClassInfo2WrappedNativeProtoMap* map = GetScope()->GetWrappedNativeProtoMap();
     if (map->Find(mClassInfo) == this)
         map->Remove(mClassInfo);
 
-    GetRuntime()->GetDetachedWrappedNativeProtoMap()->Remove(this);
-    GetRuntime()->GetDyingWrappedNativeProtoMap()->Add(this);
+    GetContext()->GetDetachedWrappedNativeProtoMap()->Remove(this);
+    GetContext()->GetDyingWrappedNativeProtoMap()->Add(this);
 
     mJSProtoObject.finalize(js::CastToJSFreeOp(fop)->runtime());
 }
 
 void
 XPCWrappedNativeProto::JSProtoObjectMoved(JSObject* obj, const JSObject* old)
 {
     MOZ_ASSERT(mJSProtoObject == old);
--- a/js/xpconnect/src/XPCWrappedNativeScope.cpp
+++ b/js/xpconnect/src/XPCWrappedNativeScope.cpp
@@ -232,17 +232,17 @@ XPCWrappedNativeScope::AttachComponentsO
     // The global Components property is non-configurable if it's a full
     // nsXPCComponents object. That way, if it's an nsXPCComponentsBase,
     // enableUniversalXPConnect can upgrade it later.
     unsigned attrs = JSPROP_READONLY | JSPROP_RESOLVING;
     nsCOMPtr<nsIXPCComponents> c = do_QueryInterface(mComponents);
     if (c)
         attrs |= JSPROP_PERMANENT;
 
-    RootedId id(aCx, XPCJSRuntime::Get()->GetStringID(XPCJSRuntime::IDX_COMPONENTS));
+    RootedId id(aCx, XPCJSContext::Get()->GetStringID(XPCJSContext::IDX_COMPONENTS));
     return JS_DefinePropertyById(aCx, global, id, components, attrs);
 }
 
 static bool
 CompartmentPerAddon()
 {
     static bool initialized = false;
     static bool pref = false;
@@ -478,17 +478,17 @@ XPCWrappedNativeScope::~XPCWrappedNative
     mContentXBLScope.finalize(cx);
     for (size_t i = 0; i < mAddonScopes.Length(); i++)
         mAddonScopes[i].finalize(cx);
     mGlobalJSObject.finalize(cx);
 }
 
 // static
 void
-XPCWrappedNativeScope::TraceWrappedNativesInAllScopes(JSTracer* trc, XPCJSRuntime* rt)
+XPCWrappedNativeScope::TraceWrappedNativesInAllScopes(JSTracer* trc, XPCJSContext* cx)
 {
     // Do JS::TraceEdge for all wrapped natives with external references, as
     // well as any DOM expando objects.
     for (XPCWrappedNativeScope* cur = gScopes; cur; cur = cur->mNext) {
         for (auto i = cur->mWrappedNativeMap->Iter(); !i.Done(); i.Next()) {
             auto entry = static_cast<Native2WrappedNativeMap::Entry*>(i.Get());
             XPCWrappedNative* wrapper = entry->value;
             if (wrapper->HasExternalReference() && !wrapper->IsWrapperExpired())
@@ -507,34 +507,34 @@ SuspectDOMExpandos(JSObject* obj, nsCycl
 {
     MOZ_ASSERT(dom::GetDOMClass(obj) && dom::GetDOMClass(obj)->mDOMObjectIsISupports);
     nsISupports* native = dom::UnwrapDOMObject<nsISupports>(obj);
     cb.NoteXPCOMRoot(native);
 }
 
 // static
 void
-XPCWrappedNativeScope::SuspectAllWrappers(XPCJSRuntime* rt,
+XPCWrappedNativeScope::SuspectAllWrappers(XPCJSContext* cx,
                                           nsCycleCollectionNoteRootCallback& cb)
 {
     for (XPCWrappedNativeScope* cur = gScopes; cur; cur = cur->mNext) {
         for (auto i = cur->mWrappedNativeMap->Iter(); !i.Done(); i.Next()) {
             static_cast<Native2WrappedNativeMap::Entry*>(i.Get())->value->Suspect(cb);
         }
 
         if (cur->mDOMExpandoSet) {
             for (DOMExpandoSet::Range r = cur->mDOMExpandoSet->all(); !r.empty(); r.popFront())
                 SuspectDOMExpandos(r.front(), cb);
         }
     }
 }
 
 // static
 void
-XPCWrappedNativeScope::UpdateWeakPointersAfterGC(XPCJSRuntime* rt)
+XPCWrappedNativeScope::UpdateWeakPointersAfterGC(XPCJSContext* cx)
 {
     // If this is called from the finalization callback in JSGC_MARK_END then
     // JSGC_FINALIZE_END must always follow it calling
     // FinishedFinalizationPhaseOfGC and clearing gDyingScopes in
     // KillDyingScopes.
     MOZ_ASSERT(!gDyingScopes, "JSGC_MARK_END without JSGC_FINALIZE_END");
 
     XPCWrappedNativeScope* prev = nullptr;
--- a/js/xpconnect/src/moz.build
+++ b/js/xpconnect/src/moz.build
@@ -17,18 +17,18 @@ UNIFIED_SOURCES += [
     'nsScriptError.cpp',
     'nsScriptErrorWithStack.cpp',
     'nsXPConnect.cpp',
     'Sandbox.cpp',
     'XPCCallContext.cpp',
     'XPCConvert.cpp',
     'XPCDebug.cpp',
     'XPCException.cpp',
+    'XPCJSContext.cpp',
     'XPCJSID.cpp',
-    'XPCJSRuntime.cpp',
     'XPCJSWeakReference.cpp',
     'XPCLocale.cpp',
     'XPCLog.cpp',
     'XPCMaps.cpp',
     'XPCModule.cpp',
     'XPCRuntimeService.cpp',
     'XPCShellImpl.cpp',
     'XPCString.cpp',
--- a/js/xpconnect/src/nsXPConnect.cpp
+++ b/js/xpconnect/src/nsXPConnect.cpp
@@ -55,86 +55,86 @@ const char XPC_EXCEPTION_CONTRACTID[]   
 const char XPC_CONSOLE_CONTRACTID[]       = "@mozilla.org/consoleservice;1";
 const char XPC_SCRIPT_ERROR_CONTRACTID[]  = "@mozilla.org/scripterror;1";
 const char XPC_ID_CONTRACTID[]            = "@mozilla.org/js/xpc/ID;1";
 const char XPC_XPCONNECT_CONTRACTID[]     = "@mozilla.org/js/xpc/XPConnect;1";
 
 /***************************************************************************/
 
 nsXPConnect::nsXPConnect()
-    :   mRuntime(nullptr),
+    :   mContext(nullptr),
         mShuttingDown(false)
 {
-    mRuntime = XPCJSRuntime::newXPCJSRuntime();
-    if (!mRuntime) {
-        NS_RUNTIMEABORT("Couldn't create XPCJSRuntime.");
+    mContext = XPCJSContext::newXPCJSContext();
+    if (!mContext) {
+        NS_RUNTIMEABORT("Couldn't create XPCJSContext.");
     }
 }
 
 nsXPConnect::~nsXPConnect()
 {
-    mRuntime->DeleteSingletonScopes();
+    mContext->DeleteSingletonScopes();
 
     // In order to clean up everything properly, we need to GC twice: once now,
     // to clean anything that can go away on its own (like the Junk Scope, which
     // we unrooted above), and once after forcing a bunch of shutdown in
     // XPConnect, to clean the stuff we forcibly disconnected. The forced
     // shutdown code defaults to leaking in a number of situations, so we can't
     // get by with only the second GC. :-(
-    mRuntime->GarbageCollect(JS::gcreason::XPCONNECT_SHUTDOWN);
+    mContext->GarbageCollect(JS::gcreason::XPCONNECT_SHUTDOWN);
 
     mShuttingDown = true;
     XPCWrappedNativeScope::SystemIsBeingShutDown();
-    mRuntime->SystemIsBeingShutDown();
+    mContext->SystemIsBeingShutDown();
 
     // The above causes us to clean up a bunch of XPConnect data structures,
     // after which point we need to GC to clean everything up. We need to do
-    // this before deleting the XPCJSRuntime, because doing so destroys the
+    // this before deleting the XPCJSContext, because doing so destroys the
     // maps that our finalize callback depends on.
-    mRuntime->GarbageCollect(JS::gcreason::XPCONNECT_SHUTDOWN);
+    mContext->GarbageCollect(JS::gcreason::XPCONNECT_SHUTDOWN);
 
     NS_RELEASE(gSystemPrincipal);
     gScriptSecurityManager = nullptr;
 
     // shutdown the logging system
     XPC_LOG_FINISH();
 
-    delete mRuntime;
+    delete mContext;
 
     gSelf = nullptr;
     gOnceAliveNowDead = true;
 }
 
 // static
 void
 nsXPConnect::InitStatics()
 {
     gSelf = new nsXPConnect();
     gOnceAliveNowDead = false;
-    if (!gSelf->mRuntime) {
-        NS_RUNTIMEABORT("Couldn't create XPCJSRuntime.");
+    if (!gSelf->mContext) {
+        NS_RUNTIMEABORT("Couldn't create XPCJSContext.");
     }
 
     // Initial extra ref to keep the singleton alive
     // balanced by explicit call to ReleaseXPConnectSingleton()
     NS_ADDREF(gSelf);
 
     // Fire up the SSM.
     nsScriptSecurityManager::InitStatics();
     gScriptSecurityManager = nsScriptSecurityManager::GetScriptSecurityManager();
     gScriptSecurityManager->GetSystemPrincipal(&gSystemPrincipal);
     MOZ_RELEASE_ASSERT(gSystemPrincipal);
 
-    if (!JS::InitSelfHostedCode(gSelf->mRuntime->Context()))
+    if (!JS::InitSelfHostedCode(gSelf->mContext->Context()))
         MOZ_CRASH("InitSelfHostedCode failed");
-    if (!gSelf->mRuntime->JSContextInitialized(gSelf->mRuntime->Context()))
+    if (!gSelf->mContext->JSContextInitialized(gSelf->mContext->Context()))
         MOZ_CRASH("JSContextInitialized failed");
 
     // Initialize our singleton scopes.
-    gSelf->mRuntime->InitSingletonScopes();
+    gSelf->mContext->InitSingletonScopes();
 }
 
 nsXPConnect*
 nsXPConnect::GetSingleton()
 {
     nsXPConnect* xpc = nsXPConnect::XPConnect();
     NS_IF_ADDREF(xpc);
     return xpc;
@@ -147,21 +147,21 @@ nsXPConnect::ReleaseXPConnectSingleton()
     nsXPConnect* xpc = gSelf;
     if (xpc) {
         nsrefcnt cnt;
         NS_RELEASE2(xpc, cnt);
     }
 }
 
 // static
-XPCJSRuntime*
-nsXPConnect::GetRuntimeInstance()
+XPCJSContext*
+nsXPConnect::GetContextInstance()
 {
     nsXPConnect* xpc = XPConnect();
-    return xpc->GetRuntime();
+    return xpc->GetContext();
 }
 
 // static
 bool
 nsXPConnect::IsISupportsDescendant(nsIInterfaceInfo* info)
 {
     bool found = false;
     if (info)
@@ -316,17 +316,17 @@ nsXPConnect::GetInfoForName(const char *
 {
   nsresult rv = XPTInterfaceInfoManager::GetSingleton()->GetInfoForName(name, info);
   return NS_FAILED(rv) ? NS_OK : NS_ERROR_NO_INTERFACE;
 }
 
 NS_IMETHODIMP
 nsXPConnect::GarbageCollect(uint32_t reason)
 {
-    GetRuntime()->GarbageCollect(reason);
+    GetContext()->GarbageCollect(reason);
     return NS_OK;
 }
 
 void
 xpc_MarkInCCGeneration(nsISupports* aVariant, uint32_t aGeneration)
 {
     nsCOMPtr<XPCVariant> variant = do_QueryInterface(aVariant);
     if (variant) {
@@ -757,26 +757,26 @@ nsXPConnect::GetCurrentJSStack(nsIStackF
     return NS_OK;
 }
 
 NS_IMETHODIMP
 nsXPConnect::GetCurrentNativeCallContext(nsAXPCNativeCallContext * *aCurrentNativeCallContext)
 {
     MOZ_ASSERT(aCurrentNativeCallContext, "bad param");
 
-    *aCurrentNativeCallContext = XPCJSRuntime::Get()->GetCallContext();
+    *aCurrentNativeCallContext = XPCJSContext::Get()->GetCallContext();
     return NS_OK;
 }
 
 NS_IMETHODIMP
 nsXPConnect::SetFunctionThisTranslator(const nsIID & aIID,
                                        nsIXPCFunctionThisTranslator* aTranslator)
 {
-    XPCJSRuntime* rt = GetRuntime();
-    IID2ThisTranslatorMap* map = rt->GetThisTranslatorMap();
+    XPCJSContext* cx = GetContext();
+    IID2ThisTranslatorMap* map = cx->GetThisTranslatorMap();
     map->Add(aIID, aTranslator);
     return NS_OK;
 }
 
 NS_IMETHODIMP
 nsXPConnect::CreateSandbox(JSContext* cx, nsIPrincipal* principal,
                            JSObject** _retval)
 {
@@ -855,23 +855,23 @@ NS_IMETHODIMP
 nsXPConnect::DebugDump(int16_t depth)
 {
 #ifdef DEBUG
     depth-- ;
     XPC_LOG_ALWAYS(("nsXPConnect @ %x with mRefCnt = %d", this, mRefCnt.get()));
     XPC_LOG_INDENT();
         XPC_LOG_ALWAYS(("gSelf @ %x", gSelf));
         XPC_LOG_ALWAYS(("gOnceAliveNowDead is %d", (int)gOnceAliveNowDead));
-        if (mRuntime) {
+        if (mContext) {
             if (depth)
-                mRuntime->DebugDump(depth);
+                mContext->DebugDump(depth);
             else
-                XPC_LOG_ALWAYS(("XPCJSRuntime @ %x", mRuntime));
+                XPC_LOG_ALWAYS(("XPCJSContext @ %x", mContext));
         } else
-            XPC_LOG_ALWAYS(("mRuntime is null"));
+            XPC_LOG_ALWAYS(("mContext is null"));
         XPCWrappedNativeScope::DebugDumpAllScopes(depth);
     XPC_LOG_OUTDENT();
 #endif
     return NS_OK;
 }
 
 NS_IMETHODIMP
 nsXPConnect::DebugDumpObject(nsISupports* p, int16_t depth)
@@ -1063,17 +1063,17 @@ SetLocationForGlobal(JSObject* global, n
     CompartmentPrivate::Get(global)->SetLocationURI(locationURI);
 }
 
 } // namespace xpc
 
 NS_IMETHODIMP
 nsXPConnect::NotifyDidPaint()
 {
-    JS::NotifyDidPaint(GetRuntime()->Context());
+    JS::NotifyDidPaint(GetContext()->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/js/xpconnect/src/xpcprivate.h
+++ b/js/xpconnect/src/xpcprivate.h
@@ -252,18 +252,18 @@ public:
         // XPConnect off the main thread. If you're an extension developer hitting
         // this, you need to change your code. See bug 716167.
         if (!MOZ_LIKELY(NS_IsMainThread()))
             MOZ_CRASH();
 
         return gSelf;
     }
 
-    static XPCJSRuntime* GetRuntimeInstance();
-    XPCJSRuntime* GetRuntime() {return mRuntime;}
+    static XPCJSContext* GetContextInstance();
+    XPCJSContext* GetContext() {return mContext;}
 
     static bool IsISupportsDescendant(nsIInterfaceInfo* info);
 
     static nsIScriptSecurityManager* SecurityManager()
     {
         MOZ_ASSERT(NS_IsMainThread());
         MOZ_ASSERT(gScriptSecurityManager);
         return gScriptSecurityManager;
@@ -304,17 +304,17 @@ protected:
 
     nsXPConnect();
 
 private:
     // Singleton instance
     static nsXPConnect*             gSelf;
     static bool                     gOnceAliveNowDead;
 
-    XPCJSRuntime*                   mRuntime;
+    XPCJSContext*                   mContext;
     bool                            mShuttingDown;
 
 public:
     static nsIScriptSecurityManager* gScriptSecurityManager;
     static nsIPrincipal* gSystemPrincipal;
 };
 
 /***************************************************************************/
@@ -342,24 +342,24 @@ public:
 
 private:
     XPCRootSetElem* mNext;
     XPCRootSetElem** mSelfp;
 };
 
 /***************************************************************************/
 
-// In the current xpconnect system there can only be one XPCJSRuntime.
-// So, xpconnect can only be used on one JSRuntime within the process.
+// In the current xpconnect system there can only be one XPCJSContext.
+// So, xpconnect can only be used on one JSContext within the process.
 
 class WatchdogManager;
 
 enum WatchdogTimestampCategory
 {
-    TimestampRuntimeStateChange = 0,
+    TimestampContextStateChange = 0,
     TimestampWatchdogWakeup,
     TimestampWatchdogHibernateStart,
     TimestampWatchdogHibernateStop,
     TimestampCount
 };
 
 class AsyncFreeSnowWhite;
 
@@ -404,21 +404,21 @@ public:
         }
 #endif
     }
 
 private:
     mozilla::Maybe<StringType> mStrings[2];
 };
 
-class XPCJSRuntime final : public mozilla::CycleCollectedJSContext
+class XPCJSContext final : public mozilla::CycleCollectedJSContext
 {
 public:
-    static XPCJSRuntime* newXPCJSRuntime();
-    static XPCJSRuntime* Get() { return nsXPConnect::XPConnect()->GetRuntime(); }
+    static XPCJSContext* newXPCJSContext();
+    static XPCJSContext* Get() { return nsXPConnect::XPConnect()->GetContext(); }
 
     void RemoveWrappedJS(nsXPCWrappedJS* wrapper);
     void AssertInvalidWrappedJSNotInTable(nsXPCWrappedJS* wrapper) const;
 
     XPCCallContext*  GetCallContext() const {return mCallContext;}
     XPCCallContext*  SetCallContext(XPCCallContext* ccx)
         {XPCCallContext* old = mCallContext; mCallContext = ccx; return old;}
 
@@ -476,18 +476,18 @@ public:
      * destroy during the GC.
      */
 
 public:
     bool GetDoingFinalization() const {return mDoingFinalization;}
 
     // Mapping of often used strings to jsid atoms that live 'forever'.
     //
-    // To add a new string: add to this list and to XPCJSRuntime::mStrings
-    // at the top of XPCJSRuntime.cpp
+    // To add a new string: add to this list and to XPCJSContext::mStrings
+    // at the top of XPCJSContext.cpp
     enum {
         IDX_CONSTRUCTOR             = 0 ,
         IDX_TO_STRING               ,
         IDX_TO_SOURCE               ,
         IDX_LAST_RESULT             ,
         IDX_RETURN_CODE             ,
         IDX_VALUE                   ,
         IDX_QUERY_INTERFACE         ,
@@ -564,17 +564,17 @@ public:
     inline void AddObjectHolderRoot(XPCJSObjectHolder* holder);
 
     void DebugDump(int16_t depth);
 
     void SystemIsBeingShutDown();
 
     bool GCIsRunning() const {return mGCIsRunning;}
 
-    ~XPCJSRuntime();
+    ~XPCJSContext();
 
     ShortLivedStringBuffer<nsString> mScratchStrings;
     ShortLivedStringBuffer<nsCString> mScratchCStrings;
 
     void AddGCCallback(xpcGCCallback cb);
     void RemoveGCCallback(xpcGCCallback cb);
 
     static void ActivityCallback(void* arg, bool active);
@@ -592,17 +592,17 @@ public:
     void DeleteSingletonScopes();
 
     PRTime GetWatchdogTimestamp(WatchdogTimestampCategory aCategory);
 
     nsresult GetPendingResult() { return mPendingResult; }
     void SetPendingResult(nsresult rv) { mPendingResult = rv; }
 
 private:
-    XPCJSRuntime();
+    XPCJSContext();
 
     nsresult Initialize();
 
     void ReleaseIncrementally(nsTArray<nsISupports*>& array);
 
     static const char* const mStrings[IDX_TOTAL_COUNT];
     jsid mStrIDs[IDX_TOTAL_COUNT];
     JS::Value mStrJSVals[IDX_TOTAL_COUNT];
@@ -704,17 +704,17 @@ public:
                             unsigned argc           = NO_ARGS,
                             JS::Value* argv         = nullptr,
                             JS::Value* rval         = nullptr);
 
     virtual ~XPCCallContext();
 
     inline bool                         IsValid() const ;
 
-    inline XPCJSRuntime*                GetRuntime() const ;
+    inline XPCJSContext*                GetContext() const ;
     inline JSContext*                   GetJSContext() const ;
     inline bool                         GetContextPopRequired() const ;
     inline XPCCallContext*              GetPrevCallContext() const ;
 
     inline JSObject*                    GetFlattenedJSObject() const ;
     inline nsISupports*                 GetIdentityObject() const ;
     inline XPCWrappedNative*            GetWrapper() const ;
     inline XPCWrappedNativeProto*       GetProto() const ;
@@ -763,17 +763,17 @@ private:
     XPCCallContext(const XPCCallContext& r) = delete;
     XPCCallContext& operator= (const XPCCallContext& r) = delete;
 
 private:
     // posible values for mState
     enum State {
         INIT_FAILED,
         SYSTEM_SHUTDOWN,
-        HAVE_RUNTIME,
+        HAVE_CONTEXT,
         HAVE_OBJECT,
         HAVE_NAME,
         HAVE_ARGS,
         READY_TO_CALL,
         CALL_DONE
     };
 
 #ifdef DEBUG
@@ -783,17 +783,17 @@ inline void CHECK_STATE(int s) const {MO
 #endif
 
 private:
     JSAutoRequest                   mAr;
     State                           mState;
 
     RefPtr<nsXPConnect>           mXPC;
 
-    XPCJSRuntime*                   mXPCJSRuntime;
+    XPCJSContext*                   mXPCJSContext;
     JSContext*                      mJSContext;
 
     // ctor does not necessarily init the following. BEWARE!
 
     XPCCallContext*                 mPrevCallContext;
 
     XPCWrappedNative*               mWrapper;
     XPCWrappedNativeTearOff*        mTearOff;
@@ -863,18 +863,18 @@ typedef nsTArray<InterpositionWhitelistP
 // XPCWrappedNativeScope is one-to-one with a JS global object.
 
 class nsIAddonInterposition;
 class nsXPCComponentsBase;
 class XPCWrappedNativeScope final : public PRCList
 {
 public:
 
-    XPCJSRuntime*
-    GetRuntime() const {return XPCJSRuntime::Get();}
+    XPCJSContext*
+    GetContext() const {return XPCJSContext::Get();}
 
     Native2WrappedNativeMap*
     GetWrappedNativeMap() const {return mWrappedNativeMap;}
 
     ClassInfo2WrappedNativeProtoMap*
     GetWrappedNativeProtoMap() const {return mWrappedNativeProtoMap;}
 
     nsXPCComponentsBase*
@@ -911,48 +911,48 @@ public:
 
     bool
     SetExpandoChain(JSContext* cx, JS::HandleObject target, JS::HandleObject chain);
 
     static void
     SystemIsBeingShutDown();
 
     static void
-    TraceWrappedNativesInAllScopes(JSTracer* trc, XPCJSRuntime* rt);
+    TraceWrappedNativesInAllScopes(JSTracer* trc, XPCJSContext* cx);
 
     void TraceSelf(JSTracer* trc) {
         MOZ_ASSERT(mGlobalJSObject);
         mGlobalJSObject.trace(trc, "XPCWrappedNativeScope::mGlobalJSObject");
     }
 
     void TraceInside(JSTracer* trc) {
         if (mContentXBLScope)
             mContentXBLScope.trace(trc, "XPCWrappedNativeScope::mXBLScope");
         for (size_t i = 0; i < mAddonScopes.Length(); i++)
             mAddonScopes[i].trace(trc, "XPCWrappedNativeScope::mAddonScopes");
         if (mXrayExpandos.initialized())
             mXrayExpandos.trace(trc);
     }
 
     static void
-    SuspectAllWrappers(XPCJSRuntime* rt, nsCycleCollectionNoteRootCallback& cb);
+    SuspectAllWrappers(XPCJSContext* cx, nsCycleCollectionNoteRootCallback& cb);
 
     static void
     MarkAllWrappedNativesAndProtos();
 
 #ifdef DEBUG
     static void
     ASSERT_NoInterfaceSetsAreMarked();
 #endif
 
     static void
     SweepAllWrappedNativeTearOffs();
 
     static void
-    UpdateWeakPointersAfterGC(XPCJSRuntime* rt);
+    UpdateWeakPointersAfterGC(XPCJSContext* cx);
 
     static void
     KillDyingScopes();
 
     static void
     DebugDumpAllScopes(int16_t depth);
 
     void
@@ -972,17 +972,17 @@ public:
 
     static void
     AddSizeOfAllScopesIncludingThis(ScopeSizeInfo* scopeSizeInfo);
 
     void
     AddSizeOfIncludingThis(ScopeSizeInfo* scopeSizeInfo);
 
     bool
-    IsValid() const {return mRuntime != nullptr;}
+    IsValid() const {return mContext != nullptr;}
 
     static bool
     IsDyingScope(XPCWrappedNativeScope* scope);
 
     typedef js::HashSet<JS::Heap<JSObject*>,
                         js::MovableCellHasher<JS::Heap<JSObject*>>,
                         js::SystemAllocPolicy> DOMExpandoSet;
 
@@ -1065,17 +1065,17 @@ private:
     static XPCWrappedNativeScope* gDyingScopes;
 
     static bool                      gShutdownObserverInitialized;
     static InterpositionMap*         gInterpositionMap;
     static AddonSet*                 gAllowCPOWAddonSet;
 
     static InterpositionWhitelistArray* gInterpositionWhitelists;
 
-    XPCJSRuntime*                    mRuntime;
+    XPCJSContext*                    mContext;
     Native2WrappedNativeMap*         mWrappedNativeMap;
     ClassInfo2WrappedNativeProtoMap* mWrappedNativeProtoMap;
     RefPtr<nsXPCComponentsBase>    mComponents;
     XPCWrappedNativeScope*           mNext;
     // The JS global object for this scope.  If non-null, this will be the
     // default parent for the XPCWrappedNatives that have us as the scope,
     // unless a PreCreate hook overrides it.  Note that this _may_ be null (see
     // constructor).
@@ -1491,17 +1491,17 @@ public:
 private:
     uint32_t mFlags;
 };
 
 /***************************************************************************/
 
 // XPCNativeScriptableShared is used to hold the JSClass and the
 // associated scriptable flags for XPCWrappedNatives. These are shared across
-// the runtime and are garbage collected by xpconnect. We *used* to just store
+// the context and are garbage collected by xpconnect. We *used* to just store
 // this inside the XPCNativeScriptableInfo (usually owned by instances of
 // XPCWrappedNativeProto. This had two problems... It was wasteful, and it
 // was a big problem when wrappers are reparented to different scopes (and
 // thus different protos (the DOM does this).
 
 class XPCNativeScriptableShared final
 {
 public:
@@ -1623,18 +1623,18 @@ public:
     GetNewOrUsed(XPCWrappedNativeScope* scope,
                  nsIClassInfo* classInfo,
                  const XPCNativeScriptableCreateInfo* scriptableCreateInfo,
                  bool callPostCreatePrototype = true);
 
     XPCWrappedNativeScope*
     GetScope()   const {return mScope;}
 
-    XPCJSRuntime*
-    GetRuntime() const {return mScope->GetRuntime();}
+    XPCJSContext*
+    GetContext() const {return mScope->GetContext();}
 
     JSObject*
     GetJSProtoObject() const {
         JS::ExposeObjectToActiveJS(mJSProtoObject);
         return mJSProtoObject;
     }
 
     nsIClassInfo*
@@ -1888,19 +1888,19 @@ public:
     GetClassInfo() const {return IsValid() && HasProto() ?
                             GetProto()->GetClassInfo() : nullptr;}
 
     bool
     HasMutatedSet() const {return IsValid() &&
                                   (!HasProto() ||
                                    GetSet() != GetProto()->GetSet());}
 
-    XPCJSRuntime*
-    GetRuntime() const {XPCWrappedNativeScope* scope = GetScope();
-                        return scope ? scope->GetRuntime() : nullptr;}
+    XPCJSContext*
+    GetContext() const {XPCWrappedNativeScope* scope = GetScope();
+                        return scope ? scope->GetContext() : nullptr;}
 
     static nsresult
     WrapNewGlobal(xpcObjectHelper& nativeHelper,
                   nsIPrincipal* principal, bool initStandardClasses,
                   JS::CompartmentOptions& aOptions,
                   XPCWrappedNative** wrappedGlobal);
 
     static nsresult
@@ -2084,17 +2084,17 @@ class nsXPCWrappedJSClass final : public
 public:
 
     static already_AddRefed<nsXPCWrappedJSClass>
     GetNewOrUsed(JSContext* cx,
                  REFNSIID aIID,
                  bool allowNonScriptable = false);
 
     REFNSIID GetIID() const {return mIID;}
-    XPCJSRuntime* GetRuntime() const {return mRuntime;}
+    XPCJSContext* GetContext() const {return mContext;}
     nsIInterfaceInfo* GetInterfaceInfo() const {return mInfo;}
     const char* GetInterfaceName();
 
     static bool IsWrappedJS(nsISupports* aPtr);
 
     NS_IMETHOD DelegatedQueryInterface(nsXPCWrappedJS* self, REFNSIID aIID,
                                        void** aInstancePtr);
 
@@ -2159,17 +2159,17 @@ private:
 
     static void CleanupPointerTypeObject(const nsXPTType& type,
                                          void** pp);
 
     void CleanupOutparams(JSContext* cx, uint16_t methodIndex, const nsXPTMethodInfo* info,
                           nsXPTCMiniVariant* nativeParams, bool inOutOnly, uint8_t n) const;
 
 private:
-    XPCJSRuntime* mRuntime;
+    XPCJSContext* mContext;
     nsCOMPtr<nsIInterfaceInfo> mInfo;
     char* mName;
     nsIID mIID;
     uint32_t* mDescriptors;
 };
 
 /*************************/
 // nsXPCWrappedJS is a wrapper for a single JSObject for use from native code.
@@ -2216,17 +2216,17 @@ public:
      * This should only be called if you are certain that the return value won't
      * be passed into a JS API function and that it won't be stored without
      * being rooted (or otherwise signaling the stored value to the CC).
      */
     JSObject* GetJSObjectPreserveColor() const {return mJSObj;}
 
     // Returns true if the wrapper chain contains references to multiple
     // compartments. If the wrapper chain contains references to multiple
-    // compartments, then it must be registered on the XPCJSRuntime. Otherwise,
+    // compartments, then it must be registered on the XPCJSContext. Otherwise,
     // it should be registered in the CompartmentPrivate for the compartment of
     // the root's JS object. This will only return correct results when called
     // on the root wrapper and will assert if not called on a root wrapper.
     bool IsMultiCompartment() const;
 
     nsXPCWrappedJSClass*  GetClass() const {return mClass;}
     REFNSIID GetIID() const {return GetClass()->GetIID();}
     nsXPCWrappedJS* GetRootWrapper() const {return mRoot;}
@@ -2785,29 +2785,29 @@ private:
 };
 
 /***************************************************************************/
 class MOZ_RAII AutoResolveName
 {
 public:
     AutoResolveName(XPCCallContext& ccx, JS::HandleId name
                     MOZ_GUARD_OBJECT_NOTIFIER_PARAM) :
-          mOld(ccx, XPCJSRuntime::Get()->SetResolveName(name))
+          mOld(ccx, XPCJSContext::Get()->SetResolveName(name))
 #ifdef DEBUG
           ,mCheck(ccx, name)
 #endif
     {
         MOZ_GUARD_OBJECT_NOTIFIER_INIT;
     }
     ~AutoResolveName()
         {
 #ifdef DEBUG
             jsid old =
 #endif
-            XPCJSRuntime::Get()->SetResolveName(mOld);
+            XPCJSContext::Get()->SetResolveName(mOld);
             MOZ_ASSERT(old == mCheck, "Bad Nesting!");
         }
 
 private:
     JS::RootedId mOld;
 #ifdef DEBUG
     JS::RootedId mCheck;
 #endif
@@ -2820,17 +2820,17 @@ private:
 // collected types after they are constructed but before they are safely
 // attached to other rooted objects.
 // This base class has pure virtual support for marking.
 
 class AutoMarkingPtr
 {
   public:
     explicit AutoMarkingPtr(JSContext* cx) {
-        mRoot = XPCJSRuntime::Get()->GetAutoRootsAdr();
+        mRoot = XPCJSContext::Get()->GetAutoRootsAdr();
         mNext = *mRoot;
         *mRoot = this;
     }
 
     virtual ~AutoMarkingPtr() {
         if (mRoot) {
             MOZ_ASSERT(*mRoot == this);
             *mRoot = mNext;
@@ -3002,17 +3002,17 @@ NS_DEFINE_STATIC_IID_ACCESSOR(XPCVariant
 
 class XPCTraceableVariant: public XPCVariant,
                            public XPCRootSetElem
 {
 public:
     XPCTraceableVariant(JSContext* cx, JS::Value aJSVal)
         : XPCVariant(cx, aJSVal)
     {
-         nsXPConnect::GetRuntimeInstance()->AddVariantRoot(this);
+         nsXPConnect::GetContextInstance()->AddVariantRoot(this);
     }
 
     virtual ~XPCTraceableVariant();
 
     void TraceJS(JSTracer* trc);
 };
 
 /***************************************************************************/
@@ -3022,17 +3022,17 @@ inline void*
 xpc_GetJSPrivate(JSObject* obj)
 {
     return js::GetObjectPrivate(obj);
 }
 
 inline JSContext*
 xpc_GetSafeJSContext()
 {
-    return XPCJSRuntime::Get()->Context();
+    return XPCJSContext::Get()->Context();
 }
 
 namespace xpc {
 
 JSAddonId*
 NewAddonId(JSContext* cx, const nsACString& id);
 
 // JSNatives to expose atob and btoa in various non-DOM XPConnect scopes.
@@ -3333,17 +3333,17 @@ StackScopedClone(JSContext* cx, StackSco
 
 /***************************************************************************/
 // Inlined utilities.
 
 inline bool
 xpc_ForcePropertyResolve(JSContext* cx, JS::HandleObject obj, jsid id);
 
 inline jsid
-GetRTIdByIndex(JSContext* cx, unsigned index);
+GetJSIDByIndex(JSContext* cx, unsigned index);
 
 namespace xpc {
 
 enum WrapperDenialType {
     WrapperDenialForXray = 0,
     WrapperDenialForCOW,
     WrapperDenialTypeCount
 };
@@ -3477,17 +3477,17 @@ public:
         if (!aLocationURI)
             return;
         if (locationURI)
             return;
         locationURI = aLocationURI;
     }
 
     JSObject2WrappedJSMap* GetWrappedJSMap() const { return mWrappedJSMap; }
-    void UpdateWeakPointersAfterGC(XPCJSRuntime* runtime);
+    void UpdateWeakPointersAfterGC(XPCJSContext* context);
 
     size_t SizeOfIncludingThis(mozilla::MallocSizeOf mallocSizeOf);
 
 private:
     nsCString location;
     nsCOMPtr<nsIURI> locationURI;
     JSObject2WrappedJSMap* mWrappedJSMap;
 
--- a/js/xpconnect/tests/chrome/test_bug732665.xul
+++ b/js/xpconnect/tests/chrome/test_bug732665.xul
@@ -15,17 +15,17 @@ https://bugzilla.mozilla.org/show_bug.cg
   </body>
 
   <!-- test code goes here -->
   <script type="application/javascript">
   <![CDATA[
 
   //
   // Important! If this test starts failing after a tricky platform-y change,
-  // the stack quota numbers in XPCJSRuntime probably need twiddling. We want
+  // the stack quota numbers in XPCJSContext probably need twiddling. We want
   // to maintain the invariants in this test (at least to some approximation)
   // for security reasons.
   //
 
   // Executes f() d steps from the probed native stack limit, and returns
   // the number of steps to the recursion limit from the caller.
   function nearNativeStackLimit(d, f) {
     f = f || function() {};
@@ -66,16 +66,16 @@ https://bugzilla.mozilla.org/show_bug.cg
   // so close to the border in content that we can't even get ourselves together
   // enough to make the cross-compartment call. So rather than exhausting the
   // stack entirely and then checking for 10 chrome frames, we leave ourselves
   // one frame's worth, and check for 11.
   //
   // If this assertion fails, the current work-around so far is to measure
   // again the worst frame size, by using the JS Shell to run
   // test_bug732665_meta.js . This script will output numbers to update
-  // XPCJSRuntime.cpp comment, as well as the kTrustedScriptBuffer constant.
+  // XPCJSContext.cpp comment, as well as the kTrustedScriptBuffer constant.
   contentSb.nnslChrome = chromeSb.nearNativeStackLimit;
   var nestedLimit = Cu.evalInSandbox("nearNativeStackLimit(1, function() { nestedLimit = nnslChrome(0);}); nestedLimit;", contentSb);
   ok(nestedLimit >= 11, "Chrome should be invokable from content script with an exhausted stack: " + nestedLimit);
 
   ]]>
   </script>
 </window>
--- a/js/xpconnect/tests/unit/test_watchdog_hibernate.js
+++ b/js/xpconnect/tests/unit/test_watchdog_hibernate.js
@@ -25,17 +25,17 @@ function testBody() {
   // must begin between 2 and 5 seconds from now.
   var timer = Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer);
   timer.initWithCallback(continueTest, 10000, Ci.nsITimer.TYPE_ONE_SHOT);
   simulateActivityCallback(false);
   yield;
 
   simulateActivityCallback(true);
   busyWait(1000); // Give the watchdog time to wake up on the condvar.
-  var stateChange = Cu.getWatchdogTimestamp("RuntimeStateChange");
+  var stateChange = Cu.getWatchdogTimestamp("ContextStateChange");
   startHibernation = Cu.getWatchdogTimestamp("WatchdogHibernateStart");
   stopHibernation = Cu.getWatchdogTimestamp("WatchdogHibernateStop");
   do_log_info("Post-hibernation statistics:");
   do_log_info("stateChange: " + stateChange / 1000000);
   do_log_info("startHibernation: " + startHibernation / 1000000);
   do_log_info("stopHibernation: " + stopHibernation / 1000000);
   // XPCOM timers, JS times, and PR_Now() are apparently not directly
   // comparable, as evidenced by certain seemingly-impossible timing values
--- a/js/xpconnect/wrappers/AccessCheck.cpp
+++ b/js/xpconnect/wrappers/AccessCheck.cpp
@@ -234,17 +234,17 @@ AccessCheck::checkPassToPrivilegedCode(J
     }
 
     // COWs are fine to pass to chrome if and only if they have __exposedProps__,
     // since presumably content should never have a reason to pass an opaque
     // object back to chrome.
     if (AccessCheck::isChrome(js::UncheckedUnwrap(wrapper)) && WrapperFactory::IsCOW(obj)) {
         RootedObject target(cx, js::UncheckedUnwrap(obj));
         JSAutoCompartment ac(cx, target);
-        RootedId id(cx, GetRTIdByIndex(cx, XPCJSRuntime::IDX_EXPOSEDPROPS));
+        RootedId id(cx, GetJSIDByIndex(cx, XPCJSContext::IDX_EXPOSEDPROPS));
         bool found = false;
         if (!JS_HasPropertyById(cx, target, id, &found))
             return false;
         if (found)
             return true;
     }
 
     // Same-origin wrappers are fine.
@@ -287,17 +287,17 @@ ExposedPropertiesOnly::check(JSContext* 
 
     // For the case of getting a property descriptor, we allow if either GET or SET
     // is allowed, and rely on FilteringWrapper to filter out any disallowed accessors.
     if (act == Wrapper::GET_PROPERTY_DESCRIPTOR) {
         return check(cx, wrapper, id, Wrapper::GET) ||
                check(cx, wrapper, id, Wrapper::SET);
     }
 
-    RootedId exposedPropsId(cx, GetRTIdByIndex(cx, XPCJSRuntime::IDX_EXPOSEDPROPS));
+    RootedId exposedPropsId(cx, GetJSIDByIndex(cx, XPCJSContext::IDX_EXPOSEDPROPS));
 
     // We need to enter the wrappee's compartment to look at __exposedProps__,
     // but we want to be in the wrapper's compartment if we call Deny().
     //
     // Unfortunately, |cx| can be in either compartment when we call ::check. :-(
     JSAutoCompartment ac(cx, wrappedObject);
 
     bool found = false;
--- a/js/xpconnect/wrappers/XrayWrapper.cpp
+++ b/js/xpconnect/wrappers/XrayWrapper.cpp
@@ -543,32 +543,32 @@ JSXrayTraits::resolveOwnProperty(JSConte
                 } else {
                     JS_ReportError(cx, "Accessing TypedArray data over Xrays is slow, and forbidden "
                                        "in order to encourage performant code. To copy TypedArrays "
                                        "across origin boundaries, consider using Components.utils.cloneInto().");
                     return false;
                 }
             }
         } else if (key == JSProto_Function) {
-            if (id == GetRTIdByIndex(cx, XPCJSRuntime::IDX_LENGTH)) {
+            if (id == GetJSIDByIndex(cx, XPCJSContext::IDX_LENGTH)) {
                 FillPropertyDescriptor(desc, wrapper, JSPROP_PERMANENT | JSPROP_READONLY,
                                        NumberValue(JS_GetFunctionArity(JS_GetObjectFunction(target))));
                 return true;
-            } else if (id == GetRTIdByIndex(cx, XPCJSRuntime::IDX_NAME)) {
+            } else if (id == GetJSIDByIndex(cx, XPCJSContext::IDX_NAME)) {
                 RootedString fname(cx, JS_GetFunctionId(JS_GetObjectFunction(target)));
                 FillPropertyDescriptor(desc, wrapper, JSPROP_PERMANENT | JSPROP_READONLY,
                                        fname ? StringValue(fname) : JS_GetEmptyStringValue(cx));
             } else {
                 // Look for various static properties/methods and the
                 // 'prototype' property.
                 JSProtoKey standardConstructor = constructorFor(holder);
                 if (standardConstructor != JSProto_Null) {
                     // Handle the 'prototype' property to make
                     // xrayedGlobal.StandardClass.prototype work.
-                    if (id == GetRTIdByIndex(cx, XPCJSRuntime::IDX_PROTOTYPE)) {
+                    if (id == GetJSIDByIndex(cx, XPCJSContext::IDX_PROTOTYPE)) {
                         RootedObject standardProto(cx);
                         {
                             JSAutoCompartment ac(cx, target);
                             if (!JS_GetClassPrototype(cx, standardConstructor, &standardProto))
                                 return false;
                             MOZ_ASSERT(standardProto);
                         }
 
@@ -601,44 +601,44 @@ JSXrayTraits::resolveOwnProperty(JSConte
             // (unfortunately) represented as own data properties per-spec. This
             // means that we can't have a a clean representation of the data
             // (free from tampering) without doubling the slots of Error
             // objects, which isn't great. So we forward these properties to the
             // underlying object and then just censor any values with the wrong
             // type. This limits the ability of content to do anything all that
             // confusing.
             bool isErrorIntProperty =
-                id == GetRTIdByIndex(cx, XPCJSRuntime::IDX_LINENUMBER) ||
-                id == GetRTIdByIndex(cx, XPCJSRuntime::IDX_COLUMNNUMBER);
+                id == GetJSIDByIndex(cx, XPCJSContext::IDX_LINENUMBER) ||
+                id == GetJSIDByIndex(cx, XPCJSContext::IDX_COLUMNNUMBER);
             bool isErrorStringProperty =
-                id == GetRTIdByIndex(cx, XPCJSRuntime::IDX_FILENAME) ||
-                id == GetRTIdByIndex(cx, XPCJSRuntime::IDX_MESSAGE);
+                id == GetJSIDByIndex(cx, XPCJSContext::IDX_FILENAME) ||
+                id == GetJSIDByIndex(cx, XPCJSContext::IDX_MESSAGE);
             if (isErrorIntProperty || isErrorStringProperty) {
                 RootedObject waiver(cx, wrapper);
                 if (!WrapperFactory::WaiveXrayAndWrap(cx, &waiver))
                     return false;
                 if (!JS_GetOwnPropertyDescriptorById(cx, waiver, id, desc))
                     return false;
                 bool valueMatchesType = (isErrorIntProperty && desc.value().isInt32()) ||
                                         (isErrorStringProperty && desc.value().isString());
                 if (desc.hasGetterOrSetter() || !valueMatchesType)
                     FillPropertyDescriptor(desc, nullptr, 0, UndefinedValue());
                 return true;
             }
         } else if (key == JSProto_RegExp) {
-            if (id == GetRTIdByIndex(cx, XPCJSRuntime::IDX_LASTINDEX))
+            if (id == GetJSIDByIndex(cx, XPCJSContext::IDX_LASTINDEX))
                 return getOwnPropertyFromWrapperIfSafe(cx, wrapper, id, desc);
         }
 
         // The rest of this function applies only to prototypes.
         return true;
     }
 
     // Handle the 'constructor' property.
-    if (id == GetRTIdByIndex(cx, XPCJSRuntime::IDX_CONSTRUCTOR)) {
+    if (id == GetJSIDByIndex(cx, XPCJSContext::IDX_CONSTRUCTOR)) {
         RootedObject constructor(cx);
         {
             JSAutoCompartment ac(cx, target);
             if (!JS_GetClassObject(cx, key, &constructor))
                 return false;
         }
         if (!JS_WrapObject(cx, &constructor))
             return false;
@@ -646,25 +646,25 @@ JSXrayTraits::resolveOwnProperty(JSConte
         desc.setAttributes(0);
         desc.setGetter(nullptr);
         desc.setSetter(nullptr);
         desc.value().setObject(*constructor);
         return true;
     }
 
     // Handle the 'name' property for error prototypes.
-    if (IsErrorObjectKey(key) && id == GetRTIdByIndex(cx, XPCJSRuntime::IDX_NAME)) {
+    if (IsErrorObjectKey(key) && id == GetJSIDByIndex(cx, XPCJSContext::IDX_NAME)) {
         RootedId className(cx);
         ProtoKeyToId(cx, key, &className);
         FillPropertyDescriptor(desc, wrapper, 0, UndefinedValue());
         return JS_IdToValue(cx, className, desc.value());
     }
 
     // Handle the 'lastIndex' property for RegExp prototypes.
-    if (key == JSProto_RegExp && id == GetRTIdByIndex(cx, XPCJSRuntime::IDX_LASTINDEX))
+    if (key == JSProto_RegExp && id == GetJSIDByIndex(cx, XPCJSContext::IDX_LASTINDEX))
         return getOwnPropertyFromWrapperIfSafe(cx, wrapper, id, desc);
 
     // Grab the JSClass. We require all Xrayable classes to have a ClassSpec.
     const js::Class* clasp = js::GetObjectClass(target);
     MOZ_ASSERT(clasp->specDefined());
 
     // Indexed array properties are handled above, so we can just work with the
     // class spec here.
@@ -854,66 +854,66 @@ JSXrayTraits::enumerateNames(JSContext* 
             uint32_t length = JS_GetTypedArrayLength(target);
             // TypedArrays enumerate every indexed property in range, but
             // |length| is a getter that lives on the proto, like it should be.
             if (!props.reserve(length))
                 return false;
             for (int32_t i = 0; i <= int32_t(length - 1); ++i)
                 props.infallibleAppend(INT_TO_JSID(i));
         } else if (key == JSProto_Function) {
-            if (!props.append(GetRTIdByIndex(cx, XPCJSRuntime::IDX_LENGTH)))
+            if (!props.append(GetJSIDByIndex(cx, XPCJSContext::IDX_LENGTH)))
                 return false;
-            if (!props.append(GetRTIdByIndex(cx, XPCJSRuntime::IDX_NAME)))
+            if (!props.append(GetJSIDByIndex(cx, XPCJSContext::IDX_NAME)))
                 return false;
             // Handle the .prototype property and static properties on standard
             // constructors.
             JSProtoKey standardConstructor = constructorFor(holder);
             if (standardConstructor != JSProto_Null) {
-                if (!props.append(GetRTIdByIndex(cx, XPCJSRuntime::IDX_PROTOTYPE)))
+                if (!props.append(GetJSIDByIndex(cx, XPCJSContext::IDX_PROTOTYPE)))
                     return false;
 
                 if (ShouldResolveStaticProperties(standardConstructor)) {
                     const js::Class* clasp = js::ProtoKeyToClass(standardConstructor);
                     MOZ_ASSERT(clasp->specDefined());
 
                     if (!AppendNamesFromFunctionAndPropertySpecs(
                            cx, clasp->specConstructorFunctions(),
                            clasp->specConstructorProperties(), flags, props)) {
                         return false;
                     }
                 }
             }
         } else if (IsErrorObjectKey(key)) {
-            if (!props.append(GetRTIdByIndex(cx, XPCJSRuntime::IDX_FILENAME)) ||
-                !props.append(GetRTIdByIndex(cx, XPCJSRuntime::IDX_LINENUMBER)) ||
-                !props.append(GetRTIdByIndex(cx, XPCJSRuntime::IDX_COLUMNNUMBER)) ||
-                !props.append(GetRTIdByIndex(cx, XPCJSRuntime::IDX_STACK)) ||
-                !props.append(GetRTIdByIndex(cx, XPCJSRuntime::IDX_MESSAGE)))
+            if (!props.append(GetJSIDByIndex(cx, XPCJSContext::IDX_FILENAME)) ||
+                !props.append(GetJSIDByIndex(cx, XPCJSContext::IDX_LINENUMBER)) ||
+                !props.append(GetJSIDByIndex(cx, XPCJSContext::IDX_COLUMNNUMBER)) ||
+                !props.append(GetJSIDByIndex(cx, XPCJSContext::IDX_STACK)) ||
+                !props.append(GetJSIDByIndex(cx, XPCJSContext::IDX_MESSAGE)))
             {
                 return false;
             }
         } else if (key == JSProto_RegExp) {
-            if (!props.append(GetRTIdByIndex(cx, XPCJSRuntime::IDX_LASTINDEX)))
+            if (!props.append(GetJSIDByIndex(cx, XPCJSContext::IDX_LASTINDEX)))
                 return false;
         }
 
         // The rest of this function applies only to prototypes.
         return true;
     }
 
     // Add the 'constructor' property.
-    if (!props.append(GetRTIdByIndex(cx, XPCJSRuntime::IDX_CONSTRUCTOR)))
+    if (!props.append(GetJSIDByIndex(cx, XPCJSContext::IDX_CONSTRUCTOR)))
         return false;
 
     // For Error protoypes, add the 'name' property.
-    if (IsErrorObjectKey(key) && !props.append(GetRTIdByIndex(cx, XPCJSRuntime::IDX_NAME)))
+    if (IsErrorObjectKey(key) && !props.append(GetJSIDByIndex(cx, XPCJSContext::IDX_NAME)))
         return false;
 
     // For RegExp protoypes, add the 'lastIndex' property.
-    if (key == JSProto_RegExp && !props.append(GetRTIdByIndex(cx, XPCJSRuntime::IDX_LASTINDEX)))
+    if (key == JSProto_RegExp && !props.append(GetJSIDByIndex(cx, XPCJSContext::IDX_LASTINDEX)))
         return false;
 
     // Grab the JSClass. We require all Xrayable classes to have a ClassSpec.
     const js::Class* clasp = js::GetObjectClass(target);
     MOZ_ASSERT(clasp->specDefined());
 
     return AppendNamesFromFunctionAndPropertySpecs(
         cx, clasp->specPrototypeFunctions(),
@@ -1356,17 +1356,17 @@ XPCWrappedNativeXrayTraits::resolveNativ
     XPCNativeMember* member;
     XPCWrappedNative* wn = getWN(wrapper);
 
     if (ccx.GetWrapper() != wn || !wn->IsValid()) {
         return true;
     }
 
     if (!(iface = ccx.GetInterface()) || !(member = ccx.GetMember())) {
-        if (id != nsXPConnect::GetRuntimeInstance()->GetStringID(XPCJSRuntime::IDX_TO_STRING))
+        if (id != nsXPConnect::GetContextInstance()->GetStringID(XPCJSContext::IDX_TO_STRING))
             return true;
 
         JSFunction* toString = JS_NewFunction(cx, XrayToString, 0, 0, "toString");
         if (!toString)
             return false;
 
         FillPropertyDescriptor(desc, wrapper, 0,
                                ObjectValue(*JS_GetFunctionObject(toString)));
@@ -1477,17 +1477,17 @@ XrayTraits::resolveOwnProperty(JSContext
         if (key != JSProto_Null) {
             MOZ_ASSERT(key < JSProto_LIMIT);
             RootedObject constructor(cx);
             if (!JS_GetClassObject(cx, key, &constructor))
                 return false;
             MOZ_ASSERT(constructor);
             desc.value().set(ObjectValue(*constructor));
             found = true;
-        } else if (id == GetRTIdByIndex(cx, XPCJSRuntime::IDX_EVAL)) {
+        } else if (id == GetJSIDByIndex(cx, XPCJSContext::IDX_EVAL)) {
             RootedObject eval(cx);
             if (!js::GetOriginalEval(cx, target, &eval))
                 return false;
             desc.value().set(ObjectValue(*eval));
             found = true;
         }
     }
 
@@ -1496,17 +1496,17 @@ XrayTraits::resolveOwnProperty(JSContext
             return false;
         // Pretend the property lives on the wrapper.
         desc.object().set(wrapper);
         return true;
     }
 
     // Handle .wrappedJSObject for subsuming callers. This should move once we
     // sort out own-ness for the holder.
-    if (id == GetRTIdByIndex(cx, XPCJSRuntime::IDX_WRAPPED_JSOBJECT) &&
+    if (id == GetJSIDByIndex(cx, XPCJSContext::IDX_WRAPPED_JSOBJECT) &&
         WrapperFactory::AllowWaiver(wrapper))
     {
         if (!JS_AlreadyHasOwnPropertyById(cx, holder, id, &found))
             return false;
         if (!found && !JS_DefinePropertyById(cx, holder, id, UndefinedHandleValue,
                                              JSPROP_ENUMERATE | JSPROP_SHARED,
                                              wrappedJSObject_getter)) {
             return false;
--- a/toolkit/components/perfmonitoring/README.md
+++ b/toolkit/components/perfmonitoring/README.md
@@ -56,17 +56,17 @@ 2. Release all groups;
 3. Reset all CPU/CPOW costs to 0.
 
 ## Cross-Process Object Wrapper-level
 
 The instrumentation of CPOW lives in `js/ipc/src`. It maintains a CPOW clock that increases whenever the process is blocked by a CPOW call.
 
 ## XPConnect-level
 
-The instrumentation of XPConnect lives in `js/xpconnect/src/XPCJSRuntime.cpp`.
+The instrumentation of XPConnect lives in `js/xpconnect/src/XPCJSContext.cpp`.
 
 ### When we enter a nested event loop
 
 1. Inform the SpiderMonkey-level instrumentation, to let it cancel any ongoing measure.
 
 ### When we finish executing an iteration of the event loop, including microtasks:
 
 1. Inform the SpiderMonkey-level instrumentation, to let it commit its recent data.
--- a/tools/memory-profiler/MemoryProfiler.cpp
+++ b/tools/memory-profiler/MemoryProfiler.cpp
@@ -102,17 +102,17 @@ MemoryProfiler::InitOnce()
 }
 
 NS_IMETHODIMP
 MemoryProfiler::StartProfiler()
 {
   InitOnce();
   AutoUseUncensoredAllocator ua;
   AutoMPLock lock(sLock);
-  JSContext* context = XPCJSRuntime::Get()->Context();
+  JSContext* context = XPCJSContext::Get()->Context();
   ProfilerForJSContext profiler;
   if (!sJSContextProfilerMap->Get(context, &profiler) ||
       !profiler.mEnabled) {
     if (sProfileContextCount == 0) {
       js::EnableContextProfilingStack(context, true);
       if (!sNativeProfiler) {
         sNativeProfiler = new NativeProfilerImpl();
       }
@@ -132,17 +132,17 @@ MemoryProfiler::StartProfiler()
 }
 
 NS_IMETHODIMP
 MemoryProfiler::StopProfiler()
 {
   InitOnce();
   AutoUseUncensoredAllocator ua;
   AutoMPLock lock(sLock);
-  JSContext* context = XPCJSRuntime::Get()->Context();
+  JSContext* context = XPCJSContext::Get()->Context();
   ProfilerForJSContext profiler;
   if (sJSContextProfilerMap->Get(context, &profiler) &&
       profiler.mEnabled) {
     MemProfiler::GetMemProfiler(context)->stop();
     if (--sProfileContextCount == 0) {
       MallocHook::Disable();
       MemProfiler::SetNativeProfiler(nullptr);
       js::EnableContextProfilingStack(context, false);
@@ -154,17 +154,17 @@ MemoryProfiler::StopProfiler()
 }
 
 NS_IMETHODIMP
 MemoryProfiler::ResetProfiler()
 {
   InitOnce();
   AutoUseUncensoredAllocator ua;
   AutoMPLock lock(sLock);
-  JSContext* context = XPCJSRuntime::Get()->Context();
+  JSContext* context = XPCJSContext::Get()->Context();
   ProfilerForJSContext profiler;
   if (!sJSContextProfilerMap->Get(context, &profiler) ||
       !profiler.mEnabled) {
     delete profiler.mProfiler;
     profiler.mProfiler = nullptr;
     sJSContextProfilerMap->Put(context, profiler);
   }
   if (sProfileContextCount == 0) {
@@ -244,17 +244,17 @@ MergeResults(const nsTArray<nsCString>& 
 }
 
 NS_IMETHODIMP
 MemoryProfiler::GetResults(JSContext* cx, JS::MutableHandle<JS::Value> aResult)
 {
   InitOnce();
   AutoUseUncensoredAllocator ua;
   AutoMPLock lock(sLock);
-  JSContext* context = XPCJSRuntime::Get()->Context();
+  JSContext* context = XPCJSContext::Get()->Context();
   // Getting results when the profiler is running is not allowed.
   if (sProfileContextCount > 0) {
     return NS_OK;
   }
   // Return immediately when native profiler does not exist.
   if (!sNativeProfiler) {
     return NS_OK;
   }
--- a/xpcom/build/XPCOMInit.cpp
+++ b/xpcom/build/XPCOMInit.cpp
@@ -1014,21 +1014,21 @@ ShutdownXPCOM(nsIServiceManager* aServMg
     NS_ASSERTION(NS_SUCCEEDED(rv), "Component Manager shutdown failed.");
   } else {
     NS_WARNING("Component Manager was never created ...");
   }
 
 #ifdef MOZ_ENABLE_PROFILER_SPS
   // In optimized builds we don't do shutdown collections by default, so
   // uncollected (garbage) objects may keep the nsXPConnect singleton alive,
-  // and its XPCJSRuntime along with it. However, we still destroy various
+  // and its XPCJSContext along with it. However, we still destroy various
   // bits of state in JS_ShutDown(), so we need to make sure the profiler
   // can't access them when it shuts down. This call nulls out the
-  // JS pseudo-stack's internal reference to the main thread JSRuntime,
-  // duplicating the call in XPCJSRuntime::~XPCJSRuntime() in case that
+  // JS pseudo-stack's internal reference to the main thread JSContext,
+  // duplicating the call in XPCJSContext::~XPCJSContext() in case that
   // never fired.
   if (PseudoStack* stack = mozilla_get_pseudo_stack()) {
     stack->sampleContext(nullptr);
   }
 #endif
 
   if (sInitializedJS) {
     // Shut down the JS engine.