зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1359245 - Eliminate nsXPConnect::GetContextInstance() (r=mccr8)
This method assumes there is one global XPCJSContext. This patch eliminates uses of it. MozReview-Commit-ID: L2AkBGh5TnC
This commit is contained in:
Родитель
51147a69b6
Коммит
3e774f9f8a
|
@ -37,7 +37,7 @@ MaybeForceDebugGC()
|
|||
sDebugGCs = !!PR_GetEnv("MOZ_DEBUG_DEAD_CPOWS");
|
||||
|
||||
if (sDebugGCs) {
|
||||
JSContext* cx = nsXPConnect::GetContextInstance()->Context();
|
||||
JSContext* cx = XPCJSContext::Get()->Context();
|
||||
PrepareForFullGC(cx);
|
||||
GCForReason(cx, GC_NORMAL, gcreason::COMPONENT_UTILS);
|
||||
}
|
||||
|
|
|
@ -2572,7 +2572,7 @@ nsXPCComponents_Utils::GetWeakReference(HandleValue object, JSContext* cx,
|
|||
NS_IMETHODIMP
|
||||
nsXPCComponents_Utils::ForceGC()
|
||||
{
|
||||
JSContext* cx = nsXPConnect::GetContextInstance()->Context();
|
||||
JSContext* cx = XPCJSContext::Get()->Context();
|
||||
PrepareForFullGC(cx);
|
||||
GCForReason(cx, GC_NORMAL, gcreason::COMPONENT_UTILS);
|
||||
return NS_OK;
|
||||
|
|
|
@ -715,12 +715,12 @@ nsJSCID::Construct(nsIXPConnectWrappedNative* wrapper,
|
|||
const CallArgs& args, bool* _retval)
|
||||
{
|
||||
RootedObject obj(cx, objArg);
|
||||
XPCJSContext* xpccx = nsXPConnect::GetContextInstance();
|
||||
if (!xpccx)
|
||||
XPCJSRuntime* xpcrt = nsXPConnect::GetRuntimeInstance();
|
||||
if (!xpcrt)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
// 'push' a call context and call on it
|
||||
RootedId name(cx, xpccx->GetStringID(XPCJSContext::IDX_CREATE_INSTANCE));
|
||||
RootedId name(cx, xpcrt->GetStringID(XPCJSContext::IDX_CREATE_INSTANCE));
|
||||
XPCCallContext ccx(cx, obj, nullptr, name, args.length(), args.array(),
|
||||
args.rval().address());
|
||||
|
||||
|
|
|
@ -1357,7 +1357,7 @@ JSMainRuntimeCompartmentsSystemDistinguishedAmount()
|
|||
static int64_t
|
||||
JSMainRuntimeCompartmentsUserDistinguishedAmount()
|
||||
{
|
||||
JSContext* cx = nsXPConnect::GetContextInstance()->Context();
|
||||
JSContext* cx = XPCJSContext::Get()->Context();
|
||||
return JS::UserCompartmentCount(cx);
|
||||
}
|
||||
|
||||
|
@ -2247,7 +2247,7 @@ class JSMainRuntimeCompartmentsReporter final : public nsIMemoryReporter
|
|||
|
||||
Data d;
|
||||
d.anonymizeID = anonymize ? 1 : 0;
|
||||
JS_IterateCompartments(nsXPConnect::GetContextInstance()->Context(),
|
||||
JS_IterateCompartments(XPCJSContext::Get()->Context(),
|
||||
&d, CompartmentCallback);
|
||||
|
||||
for (size_t i = 0; i < d.paths.length(); i++)
|
||||
|
@ -2673,7 +2673,7 @@ static nsresult
|
|||
JSSizeOfTab(JSObject* objArg, size_t* jsObjectsSize, size_t* jsStringsSize,
|
||||
size_t* jsPrivateSize, size_t* jsOtherSize)
|
||||
{
|
||||
JSContext* cx = nsXPConnect::GetContextInstance()->Context();
|
||||
JSContext* cx = XPCJSContext::Get()->Context();
|
||||
JS::RootedObject obj(cx, objArg);
|
||||
|
||||
TabSizes sizes;
|
||||
|
@ -3178,8 +3178,7 @@ XPCRootSetElem::AddToRootSet(XPCRootSetElem** listHead)
|
|||
void
|
||||
XPCRootSetElem::RemoveFromRootSet()
|
||||
{
|
||||
nsXPConnect* xpc = nsXPConnect::XPConnect();
|
||||
JS::PokeGC(xpc->GetContext()->Context());
|
||||
JS::PokeGC(XPCJSContext::Get()->Context());
|
||||
|
||||
MOZ_ASSERT(mSelfp, "Must be linked");
|
||||
|
||||
|
|
|
@ -590,20 +590,6 @@ XPCWrappedNative::Destroy()
|
|||
mMaybeScope = nullptr;
|
||||
}
|
||||
|
||||
void
|
||||
XPCWrappedNative::SetProto(XPCWrappedNativeProto* p)
|
||||
{
|
||||
MOZ_ASSERT(!IsWrapperExpired(), "bad ptr!");
|
||||
|
||||
MOZ_ASSERT(HasProto());
|
||||
|
||||
// Write barrier for incremental GC.
|
||||
JSContext* cx = nsXPConnect::GetContextInstance()->Context();
|
||||
GetProto()->WriteBarrierPre(cx);
|
||||
|
||||
mMaybeProto = p;
|
||||
}
|
||||
|
||||
// This is factored out so that it can be called publicly.
|
||||
// static
|
||||
nsIXPCScriptable*
|
||||
|
@ -1955,11 +1941,11 @@ CallMethodHelper::CleanupParam(nsXPTCMiniVariant& param, nsXPTType& type)
|
|||
break;
|
||||
case nsXPTType::T_ASTRING:
|
||||
case nsXPTType::T_DOMSTRING:
|
||||
nsXPConnect::GetContextInstance()->mScratchStrings.Destroy((nsString*)param.val.p);
|
||||
mCallContext.GetContext()->mScratchStrings.Destroy((nsString*)param.val.p);
|
||||
break;
|
||||
case nsXPTType::T_UTF8STRING:
|
||||
case nsXPTType::T_CSTRING:
|
||||
nsXPConnect::GetContextInstance()->mScratchCStrings.Destroy((nsCString*)param.val.p);
|
||||
mCallContext.GetContext()->mScratchCStrings.Destroy((nsCString*)param.val.p);
|
||||
break;
|
||||
default:
|
||||
MOZ_ASSERT(!type.IsArithmetic(), "Cleanup requested on unexpected type.");
|
||||
|
@ -1985,9 +1971,9 @@ CallMethodHelper::AllocateStringClass(nsXPTCVariant* dp,
|
|||
// 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::GetContextInstance()->mScratchStrings.Create();
|
||||
dp->val.p = mCallContext.GetContext()->mScratchStrings.Create();
|
||||
else
|
||||
dp->val.p = nsXPConnect::GetContextInstance()->mScratchCStrings.Create();
|
||||
dp->val.p = mCallContext.GetContext()->mScratchCStrings.Create();
|
||||
|
||||
// Check for OOM, in either case.
|
||||
if (!dp->val.p) {
|
||||
|
|
|
@ -154,14 +154,6 @@ nsXPConnect::ReleaseXPConnectSingleton()
|
|||
}
|
||||
}
|
||||
|
||||
// static
|
||||
XPCJSContext*
|
||||
nsXPConnect::GetContextInstance()
|
||||
{
|
||||
nsXPConnect* xpc = XPConnect();
|
||||
return xpc->GetContext();
|
||||
}
|
||||
|
||||
// static
|
||||
XPCJSRuntime*
|
||||
nsXPConnect::GetRuntimeInstance()
|
||||
|
|
|
@ -245,7 +245,6 @@ public:
|
|||
return gSelf;
|
||||
}
|
||||
|
||||
static XPCJSContext* GetContextInstance();
|
||||
static XPCJSRuntime* GetRuntimeInstance();
|
||||
XPCJSContext* GetContext() {return mContext;}
|
||||
|
||||
|
@ -1629,8 +1628,6 @@ public:
|
|||
(XPCWrappedNativeProto*)
|
||||
(XPC_SCOPE_WORD(mMaybeProto) & ~XPC_SCOPE_MASK) : nullptr;}
|
||||
|
||||
void SetProto(XPCWrappedNativeProto* p);
|
||||
|
||||
XPCWrappedNativeScope*
|
||||
GetScope() const
|
||||
{return GetProto() ? GetProto()->GetScope() :
|
||||
|
|
|
@ -1406,7 +1406,7 @@ XPCWrappedNativeXrayTraits::resolveNativeProperty(JSContext* cx, HandleObject wr
|
|||
}
|
||||
|
||||
if (!(iface = ccx.GetInterface()) || !(member = ccx.GetMember())) {
|
||||
if (id != nsXPConnect::GetContextInstance()->GetStringID(XPCJSContext::IDX_TO_STRING))
|
||||
if (id != XPCJSRuntime::Get()->GetStringID(XPCJSContext::IDX_TO_STRING))
|
||||
return true;
|
||||
|
||||
JSFunction* toString = JS_NewFunction(cx, XrayToString, 0, 0, "toString");
|
||||
|
|
Загрузка…
Ссылка в новой задаче