зеркало из https://github.com/mozilla/gecko-dev.git
Bug 831193 (part 3) - Don't use NS_MEMORY_REPORTER_IMPLEMENT in XPCJSRuntime.cpp. r=terrence.
--HG-- extra : rebase_source : 09df0ea5b3bb546e5c75d59d170f54124d834b4d
This commit is contained in:
Родитель
0aebcf0ac0
Коммит
eb0a0a84bd
|
@ -1554,77 +1554,85 @@ GetCompartmentName(JSCompartment *c, nsCString &name, bool replaceSlashes)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int64_t
|
// Telemetry relies on this being a single reporter (rather than part of the
|
||||||
GetGCChunkTotalBytes()
|
// "js" multi-reporter).
|
||||||
|
class JSGCHeapReporter MOZ_FINAL : public MemoryReporterBase
|
||||||
{
|
{
|
||||||
JSRuntime *rt = nsXPConnect::GetRuntimeInstance()->Runtime();
|
public:
|
||||||
return int64_t(JS_GetGCParameter(rt, JSGC_TOTAL_CHUNKS)) * js::gc::ChunkSize;
|
JSGCHeapReporter()
|
||||||
}
|
: MemoryReporterBase("js-gc-heap", KIND_OTHER, UNITS_BYTES,
|
||||||
|
"Memory used by the garbage-collected JavaScript heap.")
|
||||||
|
{}
|
||||||
|
private:
|
||||||
|
int64_t Amount() MOZ_OVERRIDE
|
||||||
|
{
|
||||||
|
JSRuntime *rt = nsXPConnect::GetRuntimeInstance()->Runtime();
|
||||||
|
return int64_t(JS_GetGCParameter(rt, JSGC_TOTAL_CHUNKS)) *
|
||||||
|
js::gc::ChunkSize;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
// Telemetry relies on this memory reporter being a single-reporter (rather
|
// Nb: js-compartments/system + js-compartments/user could be
|
||||||
// than part of the "js" multi-reporter, which is too slow to run during a
|
|
||||||
// telemetry ping).
|
|
||||||
NS_MEMORY_REPORTER_IMPLEMENT(XPConnectJSGCHeap,
|
|
||||||
"js-gc-heap",
|
|
||||||
KIND_OTHER,
|
|
||||||
nsIMemoryReporter::UNITS_BYTES,
|
|
||||||
GetGCChunkTotalBytes,
|
|
||||||
"Memory used by the garbage-collected JavaScript heap.")
|
|
||||||
|
|
||||||
static int64_t
|
|
||||||
GetJSSystemCompartmentCount()
|
|
||||||
{
|
|
||||||
return JS::SystemCompartmentCount(nsXPConnect::GetRuntimeInstance()->Runtime());
|
|
||||||
}
|
|
||||||
|
|
||||||
static int64_t
|
|
||||||
GetJSUserCompartmentCount()
|
|
||||||
{
|
|
||||||
return JS::UserCompartmentCount(nsXPConnect::GetRuntimeInstance()->Runtime());
|
|
||||||
}
|
|
||||||
|
|
||||||
// Nb: js-system-compartment-count + js-user-compartment-count could be
|
|
||||||
// different to the number of compartments reported by
|
// different to the number of compartments reported by
|
||||||
// JSMemoryMultiReporter if a garbage collection occurred
|
// JSMemoryMultiReporter if a garbage collection occurred
|
||||||
// between them being consulted. We could move these reporters into
|
// between them being consulted. We could move these reporters into
|
||||||
// XPConnectJSCompartmentCount to avoid that problem, but then we couldn't
|
// XPConnectJSCompartmentCount to avoid that problem, but then we couldn't
|
||||||
// easily report them via telemetry, so we live with the small risk of
|
// easily report them via telemetry, so we live with the small risk of
|
||||||
// inconsistencies.
|
// inconsistencies.
|
||||||
NS_MEMORY_REPORTER_IMPLEMENT(XPConnectJSSystemCompartmentCount,
|
|
||||||
"js-compartments/system",
|
|
||||||
KIND_OTHER,
|
|
||||||
nsIMemoryReporter::UNITS_COUNT,
|
|
||||||
GetJSSystemCompartmentCount,
|
|
||||||
"The number of JavaScript compartments for system code. The sum of this "
|
|
||||||
"and 'js-compartments-user' might not match the number of compartments "
|
|
||||||
"listed under 'js' if a garbage collection occurs at an inopportune time, "
|
|
||||||
"but such cases should be rare.")
|
|
||||||
|
|
||||||
NS_MEMORY_REPORTER_IMPLEMENT(XPConnectJSUserCompartmentCount,
|
class JSCompartmentsSystemReporter MOZ_FINAL : public MemoryReporterBase
|
||||||
"js-compartments/user",
|
|
||||||
KIND_OTHER,
|
|
||||||
nsIMemoryReporter::UNITS_COUNT,
|
|
||||||
GetJSUserCompartmentCount,
|
|
||||||
"The number of JavaScript compartments for user code. The sum of this "
|
|
||||||
"and 'js-compartments-system' might not match the number of compartments "
|
|
||||||
"listed under 'js' if a garbage collection occurs at an inopportune time, "
|
|
||||||
"but such cases should be rare.")
|
|
||||||
|
|
||||||
static int64_t
|
|
||||||
GetJSMainRuntimeTemporaryPeakSize()
|
|
||||||
{
|
{
|
||||||
return JS::PeakSizeOfTemporary(nsXPConnect::GetRuntimeInstance()->Runtime());
|
public:
|
||||||
}
|
JSCompartmentsSystemReporter()
|
||||||
|
: MemoryReporterBase("js-compartments/system", KIND_OTHER, UNITS_COUNT,
|
||||||
|
"The number of JavaScript compartments for system code. The sum of this and "
|
||||||
|
"'js-compartments/user' might not match the number of compartments listed "
|
||||||
|
"in the 'explicit' tree if a garbage collection occurs at an inopportune "
|
||||||
|
"time, but such cases should be rare.")
|
||||||
|
{}
|
||||||
|
private:
|
||||||
|
int64_t Amount() MOZ_OVERRIDE
|
||||||
|
{
|
||||||
|
JSRuntime *rt = nsXPConnect::GetRuntimeInstance()->Runtime();
|
||||||
|
return JS::SystemCompartmentCount(rt);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
class JSCompartmentsUserReporter MOZ_FINAL : public MemoryReporterBase
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
JSCompartmentsUserReporter()
|
||||||
|
: MemoryReporterBase("js-compartments/user", KIND_OTHER, UNITS_COUNT,
|
||||||
|
"The number of JavaScript compartments for user code. The sum of this and "
|
||||||
|
"'js-compartments/system' might not match the number of compartments listed "
|
||||||
|
"under 'js' if a garbage collection occurs at an inopportune time, but such "
|
||||||
|
"cases should be rare.")
|
||||||
|
{}
|
||||||
|
private:
|
||||||
|
int64_t Amount() MOZ_OVERRIDE
|
||||||
|
{
|
||||||
|
JSRuntime *rt = nsXPConnect::GetRuntimeInstance()->Runtime();
|
||||||
|
return JS::UserCompartmentCount(rt);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
// This is also a single reporter so it can be used by telemetry.
|
// This is also a single reporter so it can be used by telemetry.
|
||||||
NS_MEMORY_REPORTER_IMPLEMENT(JSMainRuntimeTemporaryPeak,
|
class JSMainRuntimeTemporaryPeakReporter MOZ_FINAL : public MemoryReporterBase
|
||||||
"js-main-runtime-temporary-peak",
|
{
|
||||||
KIND_OTHER,
|
public:
|
||||||
nsIMemoryReporter::UNITS_BYTES,
|
JSMainRuntimeTemporaryPeakReporter()
|
||||||
GetJSMainRuntimeTemporaryPeakSize,
|
: MemoryReporterBase("js-main-runtime-temporary-peak",
|
||||||
"The peak size of the transient storage in the main JSRuntime (the "
|
KIND_OTHER, UNITS_BYTES,
|
||||||
"current size of which is reported as "
|
"The peak size of the transient storage in the main JSRuntime (the current "
|
||||||
"'explicit/js-non-window/runtime/temporary').");
|
"size of which is reported as 'explicit/js-non-window/runtime/temporary').")
|
||||||
|
{}
|
||||||
|
private:
|
||||||
|
int64_t Amount() MOZ_OVERRIDE
|
||||||
|
{
|
||||||
|
JSRuntime *rt = nsXPConnect::GetRuntimeInstance()->Runtime();
|
||||||
|
return JS::PeakSizeOfTemporary(rt);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
// The REPORT* macros do an unconditional report. The ZCREPORT* macros are for
|
// The REPORT* macros do an unconditional report. The ZCREPORT* macros are for
|
||||||
// compartments and zones; they aggregate any entries smaller than
|
// compartments and zones; they aggregate any entries smaller than
|
||||||
|
@ -2972,10 +2980,10 @@ XPCJSRuntime::XPCJSRuntime(nsXPConnect* aXPConnect)
|
||||||
if (!xpc_LocalizeRuntime(runtime))
|
if (!xpc_LocalizeRuntime(runtime))
|
||||||
NS_RUNTIMEABORT("xpc_LocalizeRuntime failed.");
|
NS_RUNTIMEABORT("xpc_LocalizeRuntime failed.");
|
||||||
|
|
||||||
NS_RegisterMemoryReporter(new NS_MEMORY_REPORTER_NAME(XPConnectJSGCHeap));
|
NS_RegisterMemoryReporter(new JSGCHeapReporter());
|
||||||
NS_RegisterMemoryReporter(new NS_MEMORY_REPORTER_NAME(XPConnectJSSystemCompartmentCount));
|
NS_RegisterMemoryReporter(new JSCompartmentsSystemReporter());
|
||||||
NS_RegisterMemoryReporter(new NS_MEMORY_REPORTER_NAME(XPConnectJSUserCompartmentCount));
|
NS_RegisterMemoryReporter(new JSCompartmentsUserReporter());
|
||||||
NS_RegisterMemoryReporter(new NS_MEMORY_REPORTER_NAME(JSMainRuntimeTemporaryPeak));
|
NS_RegisterMemoryReporter(new JSMainRuntimeTemporaryPeakReporter());
|
||||||
NS_RegisterMemoryMultiReporter(new JSCompartmentsMultiReporter);
|
NS_RegisterMemoryMultiReporter(new JSCompartmentsMultiReporter);
|
||||||
|
|
||||||
// Install a JavaScript 'debugger' keyword handler in debug builds only
|
// Install a JavaScript 'debugger' keyword handler in debug builds only
|
||||||
|
|
Загрузка…
Ссылка в новой задаче