mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-10 20:05:49 +00:00
Bug 882162: Part 3 - Replace GetJSRuntime() with just Runtime(). r=mccr8
This commit is contained in:
parent
fd912ef78f
commit
6459d7b826
@ -4003,7 +4003,7 @@ nsXPCComponents_Utils::GetWeakReference(const JS::Value &object, JSContext *cx,
|
||||
NS_IMETHODIMP
|
||||
nsXPCComponents_Utils::ForceGC()
|
||||
{
|
||||
JSRuntime* rt = nsXPConnect::GetRuntimeInstance()->GetJSRuntime();
|
||||
JSRuntime* rt = nsXPConnect::GetRuntimeInstance()->Runtime();
|
||||
JS::PrepareForFullGC(rt);
|
||||
JS::GCForReason(rt, JS::gcreason::COMPONENT_UTILS);
|
||||
return NS_OK;
|
||||
@ -4021,7 +4021,7 @@ nsXPCComponents_Utils::ForceCC()
|
||||
NS_IMETHODIMP
|
||||
nsXPCComponents_Utils::ForceShrinkingGC()
|
||||
{
|
||||
JSRuntime* rt = nsXPConnect::GetRuntimeInstance()->GetJSRuntime();
|
||||
JSRuntime* rt = nsXPConnect::GetRuntimeInstance()->Runtime();
|
||||
JS::PrepareForFullGC(rt);
|
||||
JS::ShrinkingGC(rt, JS::gcreason::COMPONENT_UTILS);
|
||||
return NS_OK;
|
||||
@ -4035,7 +4035,7 @@ class PreciseGCRunnable : public nsRunnable
|
||||
|
||||
NS_IMETHOD Run()
|
||||
{
|
||||
JSRuntime* rt = nsXPConnect::GetRuntimeInstance()->GetJSRuntime();
|
||||
JSRuntime* rt = nsXPConnect::GetRuntimeInstance()->Runtime();
|
||||
|
||||
JSContext *cx;
|
||||
JSContext *iter = nullptr;
|
||||
|
@ -152,7 +152,7 @@ XPCJSContextStack::GetSafeJSContext()
|
||||
if (!xpcrt)
|
||||
return NULL;
|
||||
|
||||
JSRuntime *rt = xpcrt->GetJSRuntime();
|
||||
JSRuntime *rt = xpcrt->Runtime();
|
||||
if (!rt)
|
||||
return NULL;
|
||||
|
||||
|
@ -435,7 +435,7 @@ void XPCJSRuntime::TraceBlackJS(JSTracer* trc, void* data)
|
||||
static_cast<XPCJSObjectHolder*>(e)->TraceJS(trc);
|
||||
}
|
||||
|
||||
dom::TraceBlackJS(trc, JS_GetGCParameter(self->GetJSRuntime(), JSGC_NUMBER),
|
||||
dom::TraceBlackJS(trc, JS_GetGCParameter(self->Runtime(), JSGC_NUMBER),
|
||||
nsXPConnect::XPConnect()->IsShuttingDown());
|
||||
}
|
||||
|
||||
@ -478,7 +478,7 @@ TraceJSHolder(void *holder, nsScriptObjectTracer *&tracer, void *arg)
|
||||
void XPCJSRuntime::TraceXPConnectRoots(JSTracer *trc)
|
||||
{
|
||||
JSContext *iter = nullptr;
|
||||
while (JSContext *acx = JS_ContextIterator(GetJSRuntime(), &iter)) {
|
||||
while (JSContext *acx = JS_ContextIterator(Runtime(), &iter)) {
|
||||
MOZ_ASSERT(js::HasUnrootedGlobal(acx));
|
||||
if (JSObject *global = js::GetDefaultGlobalForContext(acx))
|
||||
JS_CallObjectTracer(trc, &global, "XPC global object");
|
||||
@ -590,7 +590,7 @@ XPCJSRuntime::AddXPConnectRoots(nsCycleCollectionNoteRootCallback &cb)
|
||||
// collector.
|
||||
|
||||
JSContext *iter = nullptr, *acx;
|
||||
while ((acx = JS_ContextIterator(GetJSRuntime(), &iter))) {
|
||||
while ((acx = JS_ContextIterator(Runtime(), &iter))) {
|
||||
// Add the context to the CC graph only if traversing it would
|
||||
// end up doing something.
|
||||
JSObject* global = js::GetDefaultGlobalForContext(acx);
|
||||
@ -1494,7 +1494,7 @@ GetCompartmentName(JSCompartment *c, nsCString &name, bool replaceSlashes)
|
||||
static int64_t
|
||||
GetGCChunkTotalBytes()
|
||||
{
|
||||
JSRuntime *rt = nsXPConnect::GetRuntimeInstance()->GetJSRuntime();
|
||||
JSRuntime *rt = nsXPConnect::GetRuntimeInstance()->Runtime();
|
||||
return int64_t(JS_GetGCParameter(rt, JSGC_TOTAL_CHUNKS)) * js::gc::ChunkSize;
|
||||
}
|
||||
|
||||
@ -1511,13 +1511,13 @@ NS_MEMORY_REPORTER_IMPLEMENT(XPConnectJSGCHeap,
|
||||
static int64_t
|
||||
GetJSSystemCompartmentCount()
|
||||
{
|
||||
return JS::SystemCompartmentCount(nsXPConnect::GetRuntimeInstance()->GetJSRuntime());
|
||||
return JS::SystemCompartmentCount(nsXPConnect::GetRuntimeInstance()->Runtime());
|
||||
}
|
||||
|
||||
static int64_t
|
||||
GetJSUserCompartmentCount()
|
||||
{
|
||||
return JS::UserCompartmentCount(nsXPConnect::GetRuntimeInstance()->GetJSRuntime());
|
||||
return JS::UserCompartmentCount(nsXPConnect::GetRuntimeInstance()->Runtime());
|
||||
}
|
||||
|
||||
// Nb: js-system-compartment-count + js-user-compartment-count could be
|
||||
@ -1550,7 +1550,7 @@ NS_MEMORY_REPORTER_IMPLEMENT(XPConnectJSUserCompartmentCount,
|
||||
static int64_t
|
||||
GetJSMainRuntimeTemporaryPeakSize()
|
||||
{
|
||||
return JS::PeakSizeOfTemporary(nsXPConnect::GetRuntimeInstance()->GetJSRuntime());
|
||||
return JS::PeakSizeOfTemporary(nsXPConnect::GetRuntimeInstance()->Runtime());
|
||||
}
|
||||
|
||||
// This is also a single reporter so it can be used by telemetry.
|
||||
@ -2238,7 +2238,7 @@ class JSCompartmentsMultiReporter MOZ_FINAL : public nsIMemoryMultiReporter
|
||||
// Collect.
|
||||
|
||||
Paths paths;
|
||||
JS_IterateCompartments(nsXPConnect::GetRuntimeInstance()->GetJSRuntime(),
|
||||
JS_IterateCompartments(nsXPConnect::GetRuntimeInstance()->Runtime(),
|
||||
&paths, CompartmentCallback);
|
||||
|
||||
// Report.
|
||||
@ -2443,7 +2443,7 @@ JSMemoryMultiReporter::CollectReports(WindowPaths *windowPaths,
|
||||
bool getLocations = !!addonManager;
|
||||
XPCJSRuntimeStats rtStats(windowPaths, topWindowPaths, getLocations);
|
||||
OrphanReporter orphanReporter(XPCConvert::GetISupportsFromJSObject);
|
||||
if (!JS::CollectRuntimeStats(xpcrt->GetJSRuntime(), &rtStats, &orphanReporter))
|
||||
if (!JS::CollectRuntimeStats(xpcrt->Runtime(), &rtStats, &orphanReporter))
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
size_t xpconnect =
|
||||
@ -2890,7 +2890,7 @@ XPCJSRuntime::newXPCJSRuntime(nsXPConnect* aXPConnect)
|
||||
XPCJSRuntime* self = new XPCJSRuntime(aXPConnect);
|
||||
|
||||
if (self &&
|
||||
self->GetJSRuntime() &&
|
||||
self->Runtime() &&
|
||||
self->GetWrappedJSMap() &&
|
||||
self->GetWrappedJSClassMap() &&
|
||||
self->GetIID2NativeInterfaceMap() &&
|
||||
@ -3078,7 +3078,7 @@ void
|
||||
XPCRootSetElem::RemoveFromRootSet(XPCLock *lock)
|
||||
{
|
||||
nsXPConnect *xpc = nsXPConnect::XPConnect();
|
||||
JS::PokeGC(xpc->GetRuntime()->GetJSRuntime());
|
||||
JS::PokeGC(xpc->GetRuntime()->Runtime());
|
||||
|
||||
NS_ASSERTION(mSelfp, "Must be linked");
|
||||
|
||||
|
@ -848,7 +848,7 @@ XPCWrappedNative::Destroy()
|
||||
* the first time because mWrapperWord isn't used afterwards.
|
||||
*/
|
||||
if (XPCJSRuntime *rt = GetRuntime()) {
|
||||
if (IsIncrementalBarrierNeeded(rt->GetJSRuntime()))
|
||||
if (IsIncrementalBarrierNeeded(rt->Runtime()))
|
||||
IncrementalObjectBarrier(GetWrapperPreserveColor());
|
||||
mWrapperWord = WRAPPER_WORD_POISON;
|
||||
} else {
|
||||
@ -864,7 +864,7 @@ XPCWrappedNative::UpdateScriptableInfo(XPCNativeScriptableInfo *si)
|
||||
NS_ASSERTION(mScriptableInfo, "UpdateScriptableInfo expects an existing scriptable info");
|
||||
|
||||
// Write barrier for incremental GC.
|
||||
JSRuntime* rt = GetRuntime()->GetJSRuntime();
|
||||
JSRuntime* rt = GetRuntime()->Runtime();
|
||||
if (IsIncrementalBarrierNeeded(rt))
|
||||
mScriptableInfo->Mark();
|
||||
|
||||
@ -879,7 +879,7 @@ XPCWrappedNative::SetProto(XPCWrappedNativeProto* p)
|
||||
MOZ_ASSERT(HasProto());
|
||||
|
||||
// Write barrier for incremental GC.
|
||||
JSRuntime* rt = GetRuntime()->GetJSRuntime();
|
||||
JSRuntime* rt = GetRuntime()->Runtime();
|
||||
GetProto()->WriteBarrierPre(rt);
|
||||
|
||||
mMaybeProto = p;
|
||||
|
@ -319,7 +319,7 @@ XPCWrappedNativeScope::~XPCWrappedNativeScope()
|
||||
// XXX might not want to do this at xpconnect shutdown time???
|
||||
mComponents = nullptr;
|
||||
|
||||
JSRuntime *rt = XPCJSRuntime::Get()->GetJSRuntime();
|
||||
JSRuntime *rt = XPCJSRuntime::Get()->Runtime();
|
||||
mXBLScope.finalize(rt);
|
||||
mGlobalJSObject.finalize(rt);
|
||||
}
|
||||
|
@ -106,7 +106,7 @@ nsXPConnect::~nsXPConnect()
|
||||
// Create our own JSContext rather than an XPCCallContext, since
|
||||
// otherwise we will create a new safe JS context and attach a
|
||||
// components object that won't get GCed.
|
||||
cx = JS_NewContext(mRuntime->GetJSRuntime(), 8192);
|
||||
cx = JS_NewContext(mRuntime->Runtime(), 8192);
|
||||
}
|
||||
|
||||
// This needs to happen exactly here, otherwise we leak at shutdown. I don't
|
||||
@ -182,7 +182,7 @@ nsXPConnect::ReleaseXPConnectSingleton()
|
||||
? stdout
|
||||
: fopen(dumpName, "w");
|
||||
if (dumpFile) {
|
||||
JS_DumpHeap(xpc->GetRuntime()->GetJSRuntime(), dumpFile, nullptr,
|
||||
JS_DumpHeap(xpc->GetRuntime()->Runtime(), dumpFile, nullptr,
|
||||
JSTRACE_OBJECT, nullptr, static_cast<size_t>(-1), nullptr);
|
||||
if (dumpFile != stdout)
|
||||
fclose(dumpFile);
|
||||
@ -242,7 +242,7 @@ nsXPConnect::GetInfoForName(const char * name, nsIInterfaceInfo** info)
|
||||
bool
|
||||
nsXPConnect::NeedCollect()
|
||||
{
|
||||
return !js::AreGCGrayBitsValid(GetRuntime()->GetJSRuntime());
|
||||
return !js::AreGCGrayBitsValid(GetRuntime()->Runtime());
|
||||
}
|
||||
|
||||
void
|
||||
@ -294,7 +294,7 @@ nsXPConnect::Collect(uint32_t reason)
|
||||
MOZ_ASSERT(reason < JS::gcreason::NUM_REASONS);
|
||||
JS::gcreason::Reason gcreason = (JS::gcreason::Reason)reason;
|
||||
|
||||
JSRuntime *rt = GetRuntime()->GetJSRuntime();
|
||||
JSRuntime *rt = GetRuntime()->Runtime();
|
||||
JS::PrepareForFullGC(rt);
|
||||
JS::GCForReason(rt, gcreason);
|
||||
}
|
||||
@ -461,14 +461,14 @@ private:
|
||||
void
|
||||
nsXPConnect::FixWeakMappingGrayBits()
|
||||
{
|
||||
FixWeakMappingGrayBitsTracer fixer(GetRuntime()->GetJSRuntime());
|
||||
FixWeakMappingGrayBitsTracer fixer(GetRuntime()->Runtime());
|
||||
fixer.FixAll();
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsXPConnect::BeginCycleCollection(nsCycleCollectionNoteRootCallback &cb)
|
||||
{
|
||||
JSRuntime* rt = GetRuntime()->GetJSRuntime();
|
||||
JSRuntime* rt = GetRuntime()->Runtime();
|
||||
static bool gcHasRun = false;
|
||||
if (!gcHasRun) {
|
||||
uint32_t gcNumber = JS_GetGCParameter(rt, JSGC_NUMBER);
|
||||
@ -489,7 +489,7 @@ bool
|
||||
nsXPConnect::NotifyLeaveMainThread()
|
||||
{
|
||||
NS_ABORT_IF_FALSE(NS_IsMainThread(), "Off main thread");
|
||||
JSRuntime *rt = mRuntime->GetJSRuntime();
|
||||
JSRuntime *rt = mRuntime->Runtime();
|
||||
if (JS_IsInRequest(rt))
|
||||
return false;
|
||||
JS_ClearRuntimeThread(rt);
|
||||
@ -500,21 +500,21 @@ void
|
||||
nsXPConnect::NotifyEnterCycleCollectionThread()
|
||||
{
|
||||
NS_ABORT_IF_FALSE(!NS_IsMainThread(), "On main thread");
|
||||
JS_SetRuntimeThread(mRuntime->GetJSRuntime());
|
||||
JS_SetRuntimeThread(mRuntime->Runtime());
|
||||
}
|
||||
|
||||
void
|
||||
nsXPConnect::NotifyLeaveCycleCollectionThread()
|
||||
{
|
||||
NS_ABORT_IF_FALSE(!NS_IsMainThread(), "On main thread");
|
||||
JS_ClearRuntimeThread(mRuntime->GetJSRuntime());
|
||||
JS_ClearRuntimeThread(mRuntime->Runtime());
|
||||
}
|
||||
|
||||
void
|
||||
nsXPConnect::NotifyEnterMainThread()
|
||||
{
|
||||
NS_ABORT_IF_FALSE(NS_IsMainThread(), "Off main thread");
|
||||
JS_SetRuntimeThread(mRuntime->GetJSRuntime());
|
||||
JS_SetRuntimeThread(mRuntime->Runtime());
|
||||
}
|
||||
|
||||
/*
|
||||
@ -527,7 +527,7 @@ nsXPConnect::UsefulToMergeZones()
|
||||
{
|
||||
JSContext *iter = nullptr;
|
||||
JSContext *cx;
|
||||
while ((cx = JS_ContextIterator(GetRuntime()->GetJSRuntime(), &iter))) {
|
||||
while ((cx = JS_ContextIterator(GetRuntime()->Runtime(), &iter))) {
|
||||
// Skip anything without an nsIScriptContext, as well as any scx whose
|
||||
// NativeGlobal() is not an outer window (this happens with XUL Prototype
|
||||
// compilation scopes, for example, which we're not interested in).
|
||||
@ -794,7 +794,7 @@ TraverseGCThing(TraverseSelect ts, void *p, JSGCTraceKind traceKind,
|
||||
return;
|
||||
|
||||
if (ts == TRAVERSE_FULL)
|
||||
NoteGCThingJSChildren(nsXPConnect::GetRuntimeInstance()->GetJSRuntime(),
|
||||
NoteGCThingJSChildren(nsXPConnect::GetRuntimeInstance()->Runtime(),
|
||||
p, traceKind, cb);
|
||||
|
||||
if (traceKind == JSTRACE_OBJECT) {
|
||||
@ -1744,7 +1744,7 @@ nsXPConnect::AfterProcessNextEvent(nsIThreadInternal *aThread,
|
||||
// loop. This is a good time to make changes to debug mode.
|
||||
if (XPCJSRuntime::Get()->GetJSContextStack()->Count() == 0) {
|
||||
MOZ_ASSERT(mEventDepth == 0);
|
||||
CheckForDebugMode(XPCJSRuntime::Get()->GetJSRuntime());
|
||||
CheckForDebugMode(XPCJSRuntime::Get()->Runtime());
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
@ -1793,7 +1793,7 @@ nsXPConnect::GetRuntime(JSRuntime **runtime)
|
||||
if (!runtime)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
JSRuntime *rt = GetRuntime()->GetJSRuntime();
|
||||
JSRuntime *rt = GetRuntime()->Runtime();
|
||||
JS_AbortIfWrongThread(rt);
|
||||
*runtime = rt;
|
||||
return NS_OK;
|
||||
@ -1873,7 +1873,7 @@ xpc_ActivateDebugMode()
|
||||
{
|
||||
XPCJSRuntime* rt = nsXPConnect::GetRuntimeInstance();
|
||||
nsXPConnect::XPConnect()->SetDebugModeWhenPossible(true, true);
|
||||
nsXPConnect::CheckForDebugMode(rt->GetJSRuntime());
|
||||
nsXPConnect::CheckForDebugMode(rt->Runtime());
|
||||
}
|
||||
|
||||
/* virtual */
|
||||
@ -2030,7 +2030,7 @@ DumpJSHeap(FILE* file)
|
||||
{
|
||||
NS_ABORT_IF_FALSE(NS_IsMainThread(), "Must dump GC heap on main thread.");
|
||||
nsXPConnect* xpc = nsXPConnect::XPConnect();
|
||||
js::DumpHeapComplete(xpc->GetRuntime()->GetJSRuntime(), file);
|
||||
js::DumpHeapComplete(xpc->GetRuntime()->Runtime(), file);
|
||||
}
|
||||
|
||||
void
|
||||
@ -2116,7 +2116,7 @@ public:
|
||||
* unnecessary loop edges to the graph (bug 842137).
|
||||
*/
|
||||
TraversalTracer trc(cb);
|
||||
JSRuntime *rt = nsXPConnect::GetRuntimeInstance()->GetJSRuntime();
|
||||
JSRuntime *rt = nsXPConnect::GetRuntimeInstance()->Runtime();
|
||||
JS_TracerInit(&trc, rt, NoteJSChildTracerShim);
|
||||
trc.eagerlyTraceWeakMaps = DoNotTraceWeakMaps;
|
||||
js::VisitGrayWrapperTargets(zone, NoteJSChildGrayWrapperShim, &trc);
|
||||
@ -2166,7 +2166,7 @@ nsXPConnect::SetDebugModeWhenPossible(bool mode, bool allowSyncDisable)
|
||||
{
|
||||
gDesiredDebugMode = mode;
|
||||
if (!mode && allowSyncDisable)
|
||||
CheckForDebugMode(mRuntime->GetJSRuntime());
|
||||
CheckForDebugMode(mRuntime->Runtime());
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -2196,7 +2196,7 @@ nsXPConnect::GetTelemetryValue(JSContext *cx, jsval *rval)
|
||||
NS_IMETHODIMP
|
||||
nsXPConnect::NotifyDidPaint()
|
||||
{
|
||||
JS::NotifyDidPaint(GetRuntime()->GetJSRuntime());
|
||||
JS::NotifyDidPaint(GetRuntime()->Runtime());
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -628,7 +628,11 @@ public:
|
||||
static XPCJSRuntime* newXPCJSRuntime(nsXPConnect* aXPConnect);
|
||||
static XPCJSRuntime* Get() { return nsXPConnect::XPConnect()->GetRuntime(); }
|
||||
|
||||
JSRuntime* GetJSRuntime() const {return Runtime();}
|
||||
// Make this public for now. Ideally we'd hide the JSRuntime inside.
|
||||
JSRuntime* Runtime() const
|
||||
{
|
||||
return mozilla::CycleCollectedJSRuntime::Runtime();
|
||||
}
|
||||
|
||||
XPCJSContextStack* GetJSContextStack() {return mJSContextStack;}
|
||||
void DestroyJSContextStack();
|
||||
|
Loading…
Reference in New Issue
Block a user