Bug 1461677 - Rename compartment to realm in the memory reporting code. r=njn

This commit is contained in:
Jan de Mooij 2018-05-17 16:15:18 +02:00
Родитель 39f95c038d
Коммит 575aec161b
12 изменённых файлов: 274 добавлений и 277 удалений

Просмотреть файл

@ -1167,8 +1167,8 @@ public:
delete static_cast<xpc::ZoneStatsExtras*>(zoneStatsVector[i].extra);
}
for (size_t i = 0; i != compartmentStatsVector.length(); i++) {
delete static_cast<xpc::CompartmentStatsExtras*>(compartmentStatsVector[i].extra);
for (size_t i = 0; i != realmStatsVector.length(); i++) {
delete static_cast<xpc::RealmStatsExtras*>(realmStatsVector[i].extra);
}
}
@ -1196,24 +1196,24 @@ public:
}
virtual void
initExtraCompartmentStats(JSCompartment* aCompartment,
JS::CompartmentStats* aCompartmentStats)
override
initExtraRealmStats(JSCompartment* aCompartment,
JS::RealmStats* aRealmStats)
override
{
MOZ_ASSERT(!aCompartmentStats->extra);
MOZ_ASSERT(!aRealmStats->extra);
// ReportJSRuntimeExplicitTreeStats expects that
// aCompartmentStats->extra is a xpc::CompartmentStatsExtras pointer.
xpc::CompartmentStatsExtras* extras = new xpc::CompartmentStatsExtras;
// aRealmStats->extra is a xpc::RealmStatsExtras pointer.
xpc::RealmStatsExtras* extras = new xpc::RealmStatsExtras;
// This is the |jsPathPrefix|. Each worker has exactly two compartments:
// This is the |jsPathPrefix|. Each worker has exactly two realms:
// one for atoms, and one for everything else.
extras->jsPathPrefix.Assign(mRtPath);
extras->jsPathPrefix += nsPrintfCString("zone(0x%p)/",
(void *)js::GetCompartmentZone(aCompartment));
extras->jsPathPrefix += js::IsAtomsCompartment(aCompartment)
? NS_LITERAL_CSTRING("compartment(web-worker-atoms)/")
: NS_LITERAL_CSTRING("compartment(web-worker)/");
? NS_LITERAL_CSTRING("realm(web-worker-atoms)/")
: NS_LITERAL_CSTRING("realm(web-worker)/");
// This should never be used when reporting with workers (hence the "?!").
extras->domPathPrefix.AssignLiteral("explicit/workers/?!/");
@ -1223,7 +1223,7 @@ public:
extras->location = nullptr;
aCompartmentStats->extra = extras;
aRealmStats->extra = extras;
}
};

Просмотреть файл

@ -799,7 +799,7 @@ struct ZoneStats
#undef FOR_EACH_SIZE
};
struct CompartmentStats
struct RealmStats
{
// We assume that |objectsPrivate| is on the malloc heap, but it's not
// actually guaranteed. But for Servo, at least, it's a moot point because
@ -816,8 +816,8 @@ struct CompartmentStats
macro(Other, MallocHeap, typeInferenceAllocationSiteTables) \
macro(Other, MallocHeap, typeInferenceArrayTypeTables) \
macro(Other, MallocHeap, typeInferenceObjectTypeTables) \
macro(Other, MallocHeap, compartmentObject) \
macro(Other, MallocHeap, compartmentTables) \
macro(Other, MallocHeap, realmObject) \
macro(Other, MallocHeap, realmTables) \
macro(Other, MallocHeap, innerViewsTable) \
macro(Other, MallocHeap, lazyArrayBuffersTable) \
macro(Other, MallocHeap, objectMetadataTable) \
@ -825,11 +825,11 @@ struct CompartmentStats
macro(Other, MallocHeap, savedStacksSet) \
macro(Other, MallocHeap, varNamesSet) \
macro(Other, MallocHeap, nonSyntacticLexicalScopesTable) \
macro(Other, MallocHeap, jitCompartment) \
macro(Other, MallocHeap, jitRealm) \
macro(Other, MallocHeap, privateData) \
macro(Other, MallocHeap, scriptCountsMap)
CompartmentStats()
RealmStats()
: FOR_EACH_SIZE(ZERO_SIZE)
classInfo(),
extra(),
@ -838,7 +838,7 @@ struct CompartmentStats
isTotals(true)
{}
CompartmentStats(CompartmentStats&& other)
RealmStats(RealmStats&& other)
: FOR_EACH_SIZE(COPY_OTHER_SIZE)
classInfo(mozilla::Move(other.classInfo)),
extra(other.extra),
@ -850,9 +850,9 @@ struct CompartmentStats
MOZ_ASSERT(!other.isTotals);
}
CompartmentStats(const CompartmentStats&) = delete; // disallow copying
RealmStats(const RealmStats&) = delete; // disallow copying
~CompartmentStats() {
~RealmStats() {
// |allClasses| is usually deleted and set to nullptr before this
// destructor runs. But there are failure cases due to OOMs that may
// prevent that, so it doesn't hurt to try again here.
@ -861,7 +861,7 @@ struct CompartmentStats
bool initClasses();
void addSizes(const CompartmentStats& other) {
void addSizes(const RealmStats& other) {
MOZ_ASSERT(isTotals);
FOR_EACH_SIZE(ADD_OTHER_SIZE)
classInfo.add(other.classInfo);
@ -906,7 +906,7 @@ struct CompartmentStats
#undef FOR_EACH_SIZE
};
typedef js::Vector<CompartmentStats, 0, js::SystemAllocPolicy> CompartmentStatsVector;
typedef js::Vector<RealmStats, 0, js::SystemAllocPolicy> RealmStatsVector;
typedef js::Vector<ZoneStats, 0, js::SystemAllocPolicy> ZoneStatsVector;
struct RuntimeStats
@ -927,9 +927,9 @@ struct RuntimeStats
explicit RuntimeStats(mozilla::MallocSizeOf mallocSizeOf)
: FOR_EACH_SIZE(ZERO_SIZE)
runtime(),
cTotals(),
realmTotals(),
zTotals(),
compartmentStatsVector(),
realmStatsVector(),
zoneStatsVector(),
currZoneStats(nullptr),
mallocSizeOf_(mallocSizeOf)
@ -964,17 +964,17 @@ struct RuntimeStats
RuntimeSizes runtime;
CompartmentStats cTotals; // The sum of this runtime's compartments' measurements.
RealmStats realmTotals; // The sum of this runtime's realms' measurements.
ZoneStats zTotals; // The sum of this runtime's zones' measurements.
CompartmentStatsVector compartmentStatsVector;
RealmStatsVector realmStatsVector;
ZoneStatsVector zoneStatsVector;
ZoneStats* currZoneStats;
mozilla::MallocSizeOf mallocSizeOf_;
virtual void initExtraCompartmentStats(JSCompartment* c, CompartmentStats* cstats) = 0;
virtual void initExtraRealmStats(JSCompartment* c, RealmStats* rstats) = 0;
virtual void initExtraZoneStats(JS::Zone* zone, ZoneStats* zstats) = 0;
#undef FOR_EACH_SIZE
@ -1004,10 +1004,10 @@ extern JS_PUBLIC_API(bool)
CollectRuntimeStats(JSContext* cx, RuntimeStats* rtStats, ObjectPrivateVisitor* opv, bool anonymize);
extern JS_PUBLIC_API(size_t)
SystemCompartmentCount(JSContext* cx);
SystemRealmCount(JSContext* cx);
extern JS_PUBLIC_API(size_t)
UserCompartmentCount(JSContext* cx);
UserRealmCount(JSContext* cx);
extern JS_PUBLIC_API(size_t)
PeakSizeOfTemporary(const JSContext* cx);

Просмотреть файл

@ -82,7 +82,7 @@ JSCompartment::JSCompartment(Zone* zone, const JS::RealmOptions& options = JS::R
debugScriptMap(nullptr),
debugEnvs(nullptr),
enumerators(nullptr),
compartmentStats_(nullptr),
realmStats_(nullptr),
scheduledForDestruction(false),
maybeAlive(true),
jitCompartment_(nullptr),

Просмотреть файл

@ -1134,25 +1134,24 @@ struct JSCompartment
private:
/* Used by memory reporters and invalid otherwise. */
JS::CompartmentStats* compartmentStats_;
JS::RealmStats* realmStats_;
public:
// This should only be called when it is non-null, i.e. during memory
// reporting.
JS::CompartmentStats& compartmentStats() {
JS::RealmStats& realmStats() {
// We use MOZ_RELEASE_ASSERT here because in bug 1132502 there was some
// (inconclusive) evidence that compartmentStats_ can be nullptr
// unexpectedly.
MOZ_RELEASE_ASSERT(compartmentStats_);
return *compartmentStats_;
// (inconclusive) evidence that realmStats_ can be nullptr unexpectedly.
MOZ_RELEASE_ASSERT(realmStats_);
return *realmStats_;
}
void nullCompartmentStats() {
MOZ_ASSERT(compartmentStats_);
compartmentStats_ = nullptr;
void nullRealmStats() {
MOZ_ASSERT(realmStats_);
realmStats_ = nullptr;
}
void setCompartmentStats(JS::CompartmentStats* newStats) {
MOZ_ASSERT(!compartmentStats_ && newStats);
compartmentStats_ = newStats;
void setRealmStats(JS::RealmStats* newStats) {
MOZ_ASSERT(!realmStats_ && newStats);
realmStats_ = newStats;
}
MOZ_ALWAYS_INLINE bool objectMaybeInIteration(JSObject* obj);

Просмотреть файл

@ -35,7 +35,7 @@ using namespace js;
using JS::RuntimeStats;
using JS::ObjectPrivateVisitor;
using JS::ZoneStats;
using JS::CompartmentStats;
using JS::RealmStats;
namespace js {
@ -307,7 +307,7 @@ DecommittedArenasChunkCallback(JSRuntime* rt, void* data, gc::Chunk* chunk)
static void
StatsZoneCallback(JSRuntime* rt, void* data, Zone* zone)
{
// Append a new CompartmentStats to the vector.
// Append a new RealmStats to the vector.
RuntimeStats* rtStats = static_cast<StatsClosure*>(data)->rtStats;
// CollectRuntimeStats reserves enough space.
@ -330,37 +330,37 @@ StatsZoneCallback(JSRuntime* rt, void* data, Zone* zone)
}
static void
StatsCompartmentCallback(JSContext* cx, void* data, JSCompartment* compartment)
StatsRealmCallback(JSContext* cx, void* data, JSCompartment* compartment)
{
// Append a new CompartmentStats to the vector.
// Append a new RealmStats to the vector.
RuntimeStats* rtStats = static_cast<StatsClosure*>(data)->rtStats;
// CollectRuntimeStats reserves enough space.
MOZ_ALWAYS_TRUE(rtStats->compartmentStatsVector.growBy(1));
CompartmentStats& cStats = rtStats->compartmentStatsVector.back();
if (!cStats.initClasses())
MOZ_ALWAYS_TRUE(rtStats->realmStatsVector.growBy(1));
RealmStats& realmStats = rtStats->realmStatsVector.back();
if (!realmStats.initClasses())
MOZ_CRASH("oom");
rtStats->initExtraCompartmentStats(compartment, &cStats);
rtStats->initExtraRealmStats(compartment, &realmStats);
compartment->setCompartmentStats(&cStats);
compartment->setRealmStats(&realmStats);
// Measure the compartment object itself, and things hanging off it.
compartment->addSizeOfIncludingThis(rtStats->mallocSizeOf_,
&cStats.typeInferenceAllocationSiteTables,
&cStats.typeInferenceArrayTypeTables,
&cStats.typeInferenceObjectTypeTables,
&cStats.compartmentObject,
&cStats.compartmentTables,
&cStats.innerViewsTable,
&cStats.lazyArrayBuffersTable,
&cStats.objectMetadataTable,
&cStats.crossCompartmentWrappersTable,
&cStats.savedStacksSet,
&cStats.varNamesSet,
&cStats.nonSyntacticLexicalScopesTable,
&cStats.jitCompartment,
&cStats.privateData,
&cStats.scriptCountsMap);
&realmStats.typeInferenceAllocationSiteTables,
&realmStats.typeInferenceArrayTypeTables,
&realmStats.typeInferenceObjectTypeTables,
&realmStats.realmObject,
&realmStats.realmTables,
&realmStats.innerViewsTable,
&realmStats.lazyArrayBuffersTable,
&realmStats.objectMetadataTable,
&realmStats.crossCompartmentWrappersTable,
&realmStats.savedStacksSet,
&realmStats.varNamesSet,
&realmStats.nonSyntacticLexicalScopesTable,
&realmStats.jitRealm,
&realmStats.privateData,
&realmStats.scriptCountsMap);
}
static void
@ -391,15 +391,15 @@ enum Granularity {
};
static void
AddClassInfo(Granularity granularity, CompartmentStats& cStats, const char* className,
AddClassInfo(Granularity granularity, RealmStats& realmStats, const char* className,
JS::ClassInfo& info)
{
if (granularity == FineGrained) {
if (!className)
className = "<no class name>";
CompartmentStats::ClassesHashMap::AddPtr p = cStats.allClasses->lookupForAdd(className);
RealmStats::ClassesHashMap::AddPtr p = realmStats.allClasses->lookupForAdd(className);
if (!p) {
bool ok = cStats.allClasses->add(p, className, info);
bool ok = realmStats.allClasses->add(p, className, info);
// Ignore failure -- we just won't record the
// object/shape/base-shape as notable.
(void)ok;
@ -459,7 +459,7 @@ StatsCellCallback(JSRuntime* rt, void* data, void* thing, JS::TraceKind traceKin
switch (traceKind) {
case JS::TraceKind::Object: {
JSObject* obj = static_cast<JSObject*>(thing);
CompartmentStats& cStats = obj->compartment()->compartmentStats();
RealmStats& realmStats = obj->compartment()->realmStats();
JS::ClassInfo info; // This zeroes all the sizes.
info.objectsGCHeap += thingSize;
@ -490,29 +490,29 @@ StatsCellCallback(JSRuntime* rt, void* data, void* thing, JS::TraceKind traceKin
&info.objectsMallocHeapMisc);
}
cStats.classInfo.add(info);
realmStats.classInfo.add(info);
const Class* clasp = obj->getClass();
const char* className = clasp->name;
AddClassInfo(granularity, cStats, className, info);
AddClassInfo(granularity, realmStats, className, info);
if (ObjectPrivateVisitor* opv = closure->opv) {
nsISupports* iface;
if (opv->getISupports_(obj, &iface) && iface)
cStats.objectsPrivate += opv->sizeOfIncludingThis(iface);
realmStats.objectsPrivate += opv->sizeOfIncludingThis(iface);
}
break;
}
case JS::TraceKind::Script: {
JSScript* script = static_cast<JSScript*>(thing);
CompartmentStats& cStats = script->compartment()->compartmentStats();
cStats.scriptsGCHeap += thingSize;
cStats.scriptsMallocHeapData += script->sizeOfData(rtStats->mallocSizeOf_);
cStats.typeInferenceTypeScripts += script->sizeOfTypeScript(rtStats->mallocSizeOf_);
jit::AddSizeOfBaselineData(script, rtStats->mallocSizeOf_, &cStats.baselineData,
&cStats.baselineStubsFallback);
cStats.ionData += jit::SizeOfIonData(script, rtStats->mallocSizeOf_);
RealmStats& realmStats = script->compartment()->realmStats();
realmStats.scriptsGCHeap += thingSize;
realmStats.scriptsMallocHeapData += script->sizeOfData(rtStats->mallocSizeOf_);
realmStats.typeInferenceTypeScripts += script->sizeOfTypeScript(rtStats->mallocSizeOf_);
jit::AddSizeOfBaselineData(script, rtStats->mallocSizeOf_, &realmStats.baselineData,
&realmStats.baselineStubsFallback);
realmStats.ionData += jit::SizeOfIonData(script, rtStats->mallocSizeOf_);
CollectScriptSourceStats<granularity>(closure, script->scriptSource());
break;
}
@ -633,7 +633,7 @@ ZoneStats::initStrings()
}
bool
CompartmentStats::initClasses()
RealmStats::initClasses()
{
isTotals = false;
allClasses = js_new<ClassesHashMap>();
@ -678,14 +678,14 @@ FindNotableStrings(ZoneStats& zStats)
}
static bool
FindNotableClasses(CompartmentStats& cStats)
FindNotableClasses(RealmStats& realmStats)
{
using namespace JS;
// We should only run FindNotableClasses once per ZoneStats object.
MOZ_ASSERT(cStats.notableClasses.empty());
MOZ_ASSERT(realmStats.notableClasses.empty());
for (CompartmentStats::ClassesHashMap::Range r = cStats.allClasses->all();
for (RealmStats::ClassesHashMap::Range r = realmStats.allClasses->all();
!r.empty();
r.popFront())
{
@ -697,19 +697,19 @@ FindNotableClasses(CompartmentStats& cStats)
if (!info.isNotable())
continue;
if (!cStats.notableClasses.growBy(1))
if (!realmStats.notableClasses.growBy(1))
return false;
cStats.notableClasses.back() = NotableClassInfo(className, info);
realmStats.notableClasses.back() = NotableClassInfo(className, info);
// We're moving this class from a non-notable to a notable bucket, so
// subtract it out of the non-notable tallies.
cStats.classInfo.subtract(info);
realmStats.classInfo.subtract(info);
}
// Delete |allClasses| now, rather than waiting for zStats's destruction,
// to reduce peak memory consumption during reporting.
js_delete(cStats.allClasses);
cStats.allClasses = nullptr;
js_delete(realmStats.allClasses);
realmStats.allClasses = nullptr;
return true;
}
@ -752,7 +752,7 @@ CollectRuntimeStatsHelper(JSContext* cx, RuntimeStats* rtStats, ObjectPrivateVis
bool anonymize, IterateCellCallback statsCellCallback)
{
JSRuntime* rt = cx->runtime();
if (!rtStats->compartmentStatsVector.reserve(rt->numCompartments))
if (!rtStats->realmStatsVector.reserve(rt->numCompartments))
return false;
size_t totalZones = rt->gc.zones().length() + 1; // + 1 for the atoms zone.
@ -773,10 +773,10 @@ CollectRuntimeStatsHelper(JSContext* cx, RuntimeStats* rtStats, ObjectPrivateVis
if (!closure.init())
return false;
IterateHeapUnbarriered(cx, &closure,
StatsZoneCallback,
StatsCompartmentCallback,
StatsArenaCallback,
statsCellCallback);
StatsZoneCallback,
StatsRealmCallback,
StatsArenaCallback,
statsCellCallback);
// Take the "explicit/js/runtime/" measurements.
rt->addSizeOfIncludingThis(rtStats->mallocSizeOf_, &rtStats->runtime);
@ -799,23 +799,23 @@ CollectRuntimeStatsHelper(JSContext* cx, RuntimeStats* rtStats, ObjectPrivateVis
MOZ_ASSERT(!zTotals.allStrings);
JS::CompartmentStatsVector& cs = rtStats->compartmentStatsVector;
CompartmentStats& cTotals = rtStats->cTotals;
JS::RealmStatsVector& realmStats = rtStats->realmStatsVector;
RealmStats& realmTotals = rtStats->realmTotals;
// As with the zones, we sum all compartments first, and then get the
// As with the zones, we sum all realms first, and then get the
// notable classes within each zone.
for (size_t i = 0; i < cs.length(); i++)
cTotals.addSizes(cs[i]);
for (size_t i = 0; i < realmStats.length(); i++)
realmTotals.addSizes(realmStats[i]);
for (size_t i = 0; i < cs.length(); i++) {
if (!FindNotableClasses(cs[i]))
for (size_t i = 0; i < realmStats.length(); i++) {
if (!FindNotableClasses(realmStats[i]))
return false;
}
MOZ_ASSERT(!cTotals.allClasses);
MOZ_ASSERT(!realmTotals.allClasses);
rtStats->gcHeapGCThings = rtStats->zTotals.sizeOfLiveGCThings() +
rtStats->cTotals.sizeOfLiveGCThings();
rtStats->realmTotals.sizeOfLiveGCThings();
#ifdef DEBUG
// Check that the in-arena measurements look ok.
@ -826,7 +826,7 @@ CollectRuntimeStatsHelper(JSContext* cx, RuntimeStats* rtStats, ObjectPrivateVis
#endif
for (CompartmentsIter comp(rt, WithAtoms); !comp.done(); comp.next())
comp->nullCompartmentStats();
comp->nullRealmStats();
size_t numDirtyChunks =
(rtStats->gcHeapChunkTotal - rtStats->gcHeapUnusedChunks) / gc::ChunkSize;
@ -872,7 +872,7 @@ JS::CollectRuntimeStats(JSContext* cx, RuntimeStats *rtStats, ObjectPrivateVisit
}
JS_PUBLIC_API(size_t)
JS::SystemCompartmentCount(JSContext* cx)
JS::SystemRealmCount(JSContext* cx)
{
size_t n = 0;
for (CompartmentsIter comp(cx->runtime(), WithAtoms); !comp.done(); comp.next()) {
@ -883,7 +883,7 @@ JS::SystemCompartmentCount(JSContext* cx)
}
JS_PUBLIC_API(size_t)
JS::UserCompartmentCount(JSContext* cx)
JS::UserRealmCount(JSContext* cx)
{
size_t n = 0;
for (CompartmentsIter comp(cx->runtime(), WithAtoms); !comp.done(); comp.next()) {
@ -912,8 +912,8 @@ class SimpleJSRuntimeStats : public JS::RuntimeStats
override
{}
virtual void initExtraCompartmentStats(
JSCompartment* c, JS::CompartmentStats* cStats) override
virtual void initExtraRealmStats(
JSCompartment* c, JS::RealmStats* realmStats) override
{}
};
@ -925,7 +925,7 @@ AddSizeOfTab(JSContext* cx, HandleObject obj, MallocSizeOf mallocSizeOf, ObjectP
JS::Zone* zone = GetObjectZone(obj);
if (!rtStats.compartmentStatsVector.reserve(zone->compartments().length()))
if (!rtStats.realmStatsVector.reserve(zone->compartments().length()))
return false;
if (!rtStats.zoneStatsVector.reserve(1))
@ -938,21 +938,21 @@ AddSizeOfTab(JSContext* cx, HandleObject obj, MallocSizeOf mallocSizeOf, ObjectP
return false;
IterateHeapUnbarrieredForZone(cx, zone, &closure,
StatsZoneCallback,
StatsCompartmentCallback,
StatsRealmCallback,
StatsArenaCallback,
StatsCellCallback<CoarseGrained>);
MOZ_ASSERT(rtStats.zoneStatsVector.length() == 1);
rtStats.zTotals.addSizes(rtStats.zoneStatsVector[0]);
for (size_t i = 0; i < rtStats.compartmentStatsVector.length(); i++)
rtStats.cTotals.addSizes(rtStats.compartmentStatsVector[i]);
for (size_t i = 0; i < rtStats.realmStatsVector.length(); i++)
rtStats.realmTotals.addSizes(rtStats.realmStatsVector[i]);
for (CompartmentsInZoneIter comp(zone); !comp.done(); comp.next())
comp->nullCompartmentStats();
comp->nullRealmStats();
rtStats.zTotals.addToTabSizes(sizes);
rtStats.cTotals.addToTabSizes(sizes);
rtStats.realmTotals.addToTabSizes(sizes);
return true;
}
@ -977,7 +977,7 @@ AddServoSizeOf(JSContext* cx, MallocSizeOf mallocSizeOf, ObjectPrivateVisitor* o
rtStats.addToServoSizes(sizes);
rtStats.zTotals.addToServoSizes(sizes);
rtStats.cTotals.addToServoSizes(sizes);
rtStats.realmTotals.addToServoSizes(sizes);
#ifdef DEBUG
size_t gcHeapTotal = sizes->gcHeapUsed +

Просмотреть файл

@ -1197,17 +1197,17 @@ JSMainRuntimeTemporaryPeakDistinguishedAmount()
}
static int64_t
JSMainRuntimeCompartmentsSystemDistinguishedAmount()
JSMainRuntimeRealmsSystemDistinguishedAmount()
{
JSContext* cx = danger::GetJSContext();
return JS::SystemCompartmentCount(cx);
return JS::SystemRealmCount(cx);
}
static int64_t
JSMainRuntimeCompartmentsUserDistinguishedAmount()
JSMainRuntimeRealmsUserDistinguishedAmount()
{
JSContext* cx = XPCJSContext::Get()->Context();
return JS::UserCompartmentCount(cx);
return JS::UserRealmCount(cx);
}
class JSMainRuntimeTemporaryPeakReporter final : public nsIMemoryReporter
@ -1233,10 +1233,10 @@ class JSMainRuntimeTemporaryPeakReporter final : public nsIMemoryReporter
NS_IMPL_ISUPPORTS(JSMainRuntimeTemporaryPeakReporter, nsIMemoryReporter)
// The REPORT* macros do an unconditional report. The ZCREPORT* macros are for
// compartments and zones; they aggregate any entries smaller than
// The REPORT* macros do an unconditional report. The ZRREPORT* macros are for
// realms and zones; they aggregate any entries smaller than
// SUNDRIES_THRESHOLD into the "sundries/gc-heap" and "sundries/malloc-heap"
// entries for the compartment.
// entries for the realm.
#define SUNDRIES_THRESHOLD js::MemoryReportingSundriesThreshold()
@ -1259,8 +1259,8 @@ NS_IMPL_ISUPPORTS(JSMainRuntimeTemporaryPeakReporter, nsIMemoryReporter)
gcTotal += amount; \
} while (0)
// Report compartment/zone non-GC (KIND_HEAP) bytes.
#define ZCREPORT_BYTES(_path, _amount, _desc) \
// Report realm/zone non-GC (KIND_HEAP) bytes.
#define ZRREPORT_BYTES(_path, _amount, _desc) \
do { \
/* Assign _descLiteral plus "" into a char* to prove that it's */ \
/* actually a literal. */ \
@ -1275,8 +1275,8 @@ NS_IMPL_ISUPPORTS(JSMainRuntimeTemporaryPeakReporter, nsIMemoryReporter)
} \
} while (0)
// Report compartment/zone GC bytes.
#define ZCREPORT_GC_BYTES(_path, _amount, _desc) \
// Report realm/zone GC bytes.
#define ZRREPORT_GC_BYTES(_path, _amount, _desc) \
do { \
size_t amount = _amount; /* evaluate _amount only once */ \
if (amount >= SUNDRIES_THRESHOLD) { \
@ -1329,79 +1329,79 @@ ReportZoneStats(const JS::ZoneStats& zStats,
MOZ_ASSERT(!gcTotalOut == zStats.isTotals);
ZCREPORT_GC_BYTES(pathPrefix + NS_LITERAL_CSTRING("symbols/gc-heap"),
ZRREPORT_GC_BYTES(pathPrefix + NS_LITERAL_CSTRING("symbols/gc-heap"),
zStats.symbolsGCHeap,
"Symbols.");
ZCREPORT_GC_BYTES(pathPrefix + NS_LITERAL_CSTRING("gc-heap-arena-admin"),
ZRREPORT_GC_BYTES(pathPrefix + NS_LITERAL_CSTRING("gc-heap-arena-admin"),
zStats.gcHeapArenaAdmin,
"Bookkeeping information and alignment padding within GC arenas.");
ZCREPORT_GC_BYTES(pathPrefix + NS_LITERAL_CSTRING("unused-gc-things"),
ZRREPORT_GC_BYTES(pathPrefix + NS_LITERAL_CSTRING("unused-gc-things"),
zStats.unusedGCThings.totalSize(),
"Unused GC thing cells within non-empty arenas.");
ZCREPORT_BYTES(pathPrefix + NS_LITERAL_CSTRING("unique-id-map"),
ZRREPORT_BYTES(pathPrefix + NS_LITERAL_CSTRING("unique-id-map"),
zStats.uniqueIdMap,
"Address-independent cell identities.");
ZCREPORT_BYTES(pathPrefix + NS_LITERAL_CSTRING("shape-tables"),
ZRREPORT_BYTES(pathPrefix + NS_LITERAL_CSTRING("shape-tables"),
zStats.shapeTables,
"Tables storing shape information.");
ZCREPORT_GC_BYTES(pathPrefix + NS_LITERAL_CSTRING("lazy-scripts/gc-heap"),
ZRREPORT_GC_BYTES(pathPrefix + NS_LITERAL_CSTRING("lazy-scripts/gc-heap"),
zStats.lazyScriptsGCHeap,
"Scripts that haven't executed yet.");
ZCREPORT_BYTES(pathPrefix + NS_LITERAL_CSTRING("lazy-scripts/malloc-heap"),
ZRREPORT_BYTES(pathPrefix + NS_LITERAL_CSTRING("lazy-scripts/malloc-heap"),
zStats.lazyScriptsMallocHeap,
"Lazy script tables containing closed-over bindings or inner functions.");
ZCREPORT_GC_BYTES(pathPrefix + NS_LITERAL_CSTRING("jit-codes-gc-heap"),
ZRREPORT_GC_BYTES(pathPrefix + NS_LITERAL_CSTRING("jit-codes-gc-heap"),
zStats.jitCodesGCHeap,
"References to executable code pools used by the JITs.");
ZCREPORT_GC_BYTES(pathPrefix + NS_LITERAL_CSTRING("object-groups/gc-heap"),
ZRREPORT_GC_BYTES(pathPrefix + NS_LITERAL_CSTRING("object-groups/gc-heap"),
zStats.objectGroupsGCHeap,
"Classification and type inference information about objects.");
ZCREPORT_BYTES(pathPrefix + NS_LITERAL_CSTRING("object-groups/malloc-heap"),
ZRREPORT_BYTES(pathPrefix + NS_LITERAL_CSTRING("object-groups/malloc-heap"),
zStats.objectGroupsMallocHeap,
"Object group addenda.");
ZCREPORT_GC_BYTES(pathPrefix + NS_LITERAL_CSTRING("scopes/gc-heap"),
ZRREPORT_GC_BYTES(pathPrefix + NS_LITERAL_CSTRING("scopes/gc-heap"),
zStats.scopesGCHeap,
"Scope information for scripts.");
ZCREPORT_BYTES(pathPrefix + NS_LITERAL_CSTRING("scopes/malloc-heap"),
ZRREPORT_BYTES(pathPrefix + NS_LITERAL_CSTRING("scopes/malloc-heap"),
zStats.scopesMallocHeap,
"Arrays of binding names and other binding-related data.");
ZCREPORT_GC_BYTES(pathPrefix + NS_LITERAL_CSTRING("regexp-shareds/gc-heap"),
ZRREPORT_GC_BYTES(pathPrefix + NS_LITERAL_CSTRING("regexp-shareds/gc-heap"),
zStats.regExpSharedsGCHeap,
"Shared compiled regexp data.");
ZCREPORT_BYTES(pathPrefix + NS_LITERAL_CSTRING("regexp-shareds/malloc-heap"),
ZRREPORT_BYTES(pathPrefix + NS_LITERAL_CSTRING("regexp-shareds/malloc-heap"),
zStats.regExpSharedsMallocHeap,
"Shared compiled regexp data.");
ZCREPORT_BYTES(pathPrefix + NS_LITERAL_CSTRING("type-pool"),
ZRREPORT_BYTES(pathPrefix + NS_LITERAL_CSTRING("type-pool"),
zStats.typePool,
"Type sets and related data.");
ZCREPORT_BYTES(pathPrefix + NS_LITERAL_CSTRING("regexp-zone"),
ZRREPORT_BYTES(pathPrefix + NS_LITERAL_CSTRING("regexp-zone"),
zStats.regexpZone,
"The regexp zone and regexp data.");
ZCREPORT_BYTES(pathPrefix + NS_LITERAL_CSTRING("jit-zone"),
ZRREPORT_BYTES(pathPrefix + NS_LITERAL_CSTRING("jit-zone"),
zStats.jitZone,
"The JIT zone.");
ZCREPORT_BYTES(pathPrefix + NS_LITERAL_CSTRING("baseline/optimized-stubs"),
ZRREPORT_BYTES(pathPrefix + NS_LITERAL_CSTRING("baseline/optimized-stubs"),
zStats.baselineStubsOptimized,
"The Baseline JIT's optimized IC stubs (excluding code).");
ZCREPORT_BYTES(pathPrefix + NS_LITERAL_CSTRING("jit-cached-cfg"),
ZRREPORT_BYTES(pathPrefix + NS_LITERAL_CSTRING("jit-cached-cfg"),
zStats.cachedCFG,
"The cached CFG to construct Ion code out of it.");
@ -1569,7 +1569,7 @@ ReportZoneStats(const JS::ZoneStats& zStats,
}
if (sundriesGCHeap > 0) {
// We deliberately don't use ZCREPORT_GC_BYTES here.
// We deliberately don't use ZRREPORT_GC_BYTES here.
REPORT_GC_BYTES(pathPrefix + NS_LITERAL_CSTRING("sundries/gc-heap"),
sundriesGCHeap,
"The sum of all 'gc-heap' measurements that are too small to be "
@ -1577,7 +1577,7 @@ ReportZoneStats(const JS::ZoneStats& zStats,
}
if (sundriesMallocHeap > 0) {
// We deliberately don't use ZCREPORT_BYTES here.
// We deliberately don't use ZRREPORT_BYTES here.
REPORT_BYTES(pathPrefix + NS_LITERAL_CSTRING("sundries/malloc-heap"),
KIND_HEAP, sundriesMallocHeap,
"The sum of all 'malloc-heap' measurements that are too small to "
@ -1595,7 +1595,7 @@ ReportClassStats(const ClassInfo& classInfo, const nsACString& path,
nsIHandleReportCallback* handleReport,
nsISupports* data, size_t& gcTotal)
{
// We deliberately don't use ZCREPORT_BYTES, so that these per-class values
// We deliberately don't use ZRREPORT_BYTES, so that these per-class values
// don't go into sundries.
if (classInfo.objectsGCHeap > 0) {
@ -1671,138 +1671,138 @@ ReportClassStats(const ClassInfo& classInfo, const nsACString& path,
}
static void
ReportCompartmentStats(const JS::CompartmentStats& cStats,
const xpc::CompartmentStatsExtras& extras,
nsIHandleReportCallback* handleReport,
nsISupports* data, size_t* gcTotalOut = nullptr)
ReportRealmStats(const JS::RealmStats& realmStats,
const xpc::RealmStatsExtras& extras,
nsIHandleReportCallback* handleReport,
nsISupports* data, size_t* gcTotalOut = nullptr)
{
static const nsDependentCString addonPrefix("explicit/add-ons/");
size_t gcTotal = 0, sundriesGCHeap = 0, sundriesMallocHeap = 0;
nsAutoCString cJSPathPrefix(extras.jsPathPrefix);
nsAutoCString cDOMPathPrefix(extras.domPathPrefix);
nsAutoCString realmJSPathPrefix(extras.jsPathPrefix);
nsAutoCString realmDOMPathPrefix(extras.domPathPrefix);
MOZ_ASSERT(!gcTotalOut == cStats.isTotals);
MOZ_ASSERT(!gcTotalOut == realmStats.isTotals);
nsCString nonNotablePath = cJSPathPrefix;
nonNotablePath += cStats.isTotals
nsCString nonNotablePath = realmJSPathPrefix;
nonNotablePath += realmStats.isTotals
? NS_LITERAL_CSTRING("classes/")
: NS_LITERAL_CSTRING("classes/class(<non-notable classes>)/");
ReportClassStats(cStats.classInfo, nonNotablePath, handleReport, data,
ReportClassStats(realmStats.classInfo, nonNotablePath, handleReport, data,
gcTotal);
for (size_t i = 0; i < cStats.notableClasses.length(); i++) {
MOZ_ASSERT(!cStats.isTotals);
const JS::NotableClassInfo& classInfo = cStats.notableClasses[i];
for (size_t i = 0; i < realmStats.notableClasses.length(); i++) {
MOZ_ASSERT(!realmStats.isTotals);
const JS::NotableClassInfo& classInfo = realmStats.notableClasses[i];
nsCString classPath = cJSPathPrefix +
nsCString classPath = realmJSPathPrefix +
nsPrintfCString("classes/class(%s)/", classInfo.className_);
ReportClassStats(classInfo, classPath, handleReport, data, gcTotal);
}
// Note that we use cDOMPathPrefix here. This is because we measure orphan
// Note that we use realmDOMPathPrefix here. This is because we measure orphan
// DOM nodes in the JS reporter, but we want to report them in a "dom"
// sub-tree rather than a "js" sub-tree.
ZCREPORT_BYTES(cDOMPathPrefix + NS_LITERAL_CSTRING("orphan-nodes"),
cStats.objectsPrivate,
ZRREPORT_BYTES(realmDOMPathPrefix + NS_LITERAL_CSTRING("orphan-nodes"),
realmStats.objectsPrivate,
"Orphan DOM nodes, i.e. those that are only reachable from JavaScript "
"objects.");
ZCREPORT_GC_BYTES(cJSPathPrefix + NS_LITERAL_CSTRING("scripts/gc-heap"),
cStats.scriptsGCHeap,
ZRREPORT_GC_BYTES(realmJSPathPrefix + NS_LITERAL_CSTRING("scripts/gc-heap"),
realmStats.scriptsGCHeap,
"JSScript instances. There is one per user-defined function in a "
"script, and one for the top-level code in a script.");
ZCREPORT_BYTES(cJSPathPrefix + NS_LITERAL_CSTRING("scripts/malloc-heap/data"),
cStats.scriptsMallocHeapData,
ZRREPORT_BYTES(realmJSPathPrefix + NS_LITERAL_CSTRING("scripts/malloc-heap/data"),
realmStats.scriptsMallocHeapData,
"Various variable-length tables in JSScripts.");
ZCREPORT_BYTES(cJSPathPrefix + NS_LITERAL_CSTRING("baseline/data"),
cStats.baselineData,
ZRREPORT_BYTES(realmJSPathPrefix + NS_LITERAL_CSTRING("baseline/data"),
realmStats.baselineData,
"The Baseline JIT's compilation data (BaselineScripts).");
ZCREPORT_BYTES(cJSPathPrefix + NS_LITERAL_CSTRING("baseline/fallback-stubs"),
cStats.baselineStubsFallback,
ZRREPORT_BYTES(realmJSPathPrefix + NS_LITERAL_CSTRING("baseline/fallback-stubs"),
realmStats.baselineStubsFallback,
"The Baseline JIT's fallback IC stubs (excluding code).");
ZCREPORT_BYTES(cJSPathPrefix + NS_LITERAL_CSTRING("ion-data"),
cStats.ionData,
ZRREPORT_BYTES(realmJSPathPrefix + NS_LITERAL_CSTRING("ion-data"),
realmStats.ionData,
"The IonMonkey JIT's compilation data (IonScripts).");
ZCREPORT_BYTES(cJSPathPrefix + NS_LITERAL_CSTRING("type-inference/type-scripts"),
cStats.typeInferenceTypeScripts,
ZRREPORT_BYTES(realmJSPathPrefix + NS_LITERAL_CSTRING("type-inference/type-scripts"),
realmStats.typeInferenceTypeScripts,
"Type sets associated with scripts.");
ZCREPORT_BYTES(cJSPathPrefix + NS_LITERAL_CSTRING("type-inference/allocation-site-tables"),
cStats.typeInferenceAllocationSiteTables,
ZRREPORT_BYTES(realmJSPathPrefix + NS_LITERAL_CSTRING("type-inference/allocation-site-tables"),
realmStats.typeInferenceAllocationSiteTables,
"Tables of type objects associated with allocation sites.");
ZCREPORT_BYTES(cJSPathPrefix + NS_LITERAL_CSTRING("type-inference/array-type-tables"),
cStats.typeInferenceArrayTypeTables,
ZRREPORT_BYTES(realmJSPathPrefix + NS_LITERAL_CSTRING("type-inference/array-type-tables"),
realmStats.typeInferenceArrayTypeTables,
"Tables of type objects associated with array literals.");
ZCREPORT_BYTES(cJSPathPrefix + NS_LITERAL_CSTRING("type-inference/object-type-tables"),
cStats.typeInferenceObjectTypeTables,
ZRREPORT_BYTES(realmJSPathPrefix + NS_LITERAL_CSTRING("type-inference/object-type-tables"),
realmStats.typeInferenceObjectTypeTables,
"Tables of type objects associated with object literals.");
ZCREPORT_BYTES(cJSPathPrefix + NS_LITERAL_CSTRING("compartment-object"),
cStats.compartmentObject,
ZRREPORT_BYTES(realmJSPathPrefix + NS_LITERAL_CSTRING("realm-object"),
realmStats.realmObject,
"The JSCompartment object itself.");
ZCREPORT_BYTES(cJSPathPrefix + NS_LITERAL_CSTRING("compartment-tables"),
cStats.compartmentTables,
"Compartment-wide tables storing object group information and wasm instances.");
ZRREPORT_BYTES(realmJSPathPrefix + NS_LITERAL_CSTRING("realm-tables"),
realmStats.realmTables,
"Realm-wide tables storing object group information and wasm instances.");
ZCREPORT_BYTES(cJSPathPrefix + NS_LITERAL_CSTRING("inner-views"),
cStats.innerViewsTable,
ZRREPORT_BYTES(realmJSPathPrefix + NS_LITERAL_CSTRING("inner-views"),
realmStats.innerViewsTable,
"The table for array buffer inner views.");
ZCREPORT_BYTES(cJSPathPrefix + NS_LITERAL_CSTRING("lazy-array-buffers"),
cStats.lazyArrayBuffersTable,
ZRREPORT_BYTES(realmJSPathPrefix + NS_LITERAL_CSTRING("lazy-array-buffers"),
realmStats.lazyArrayBuffersTable,
"The table for typed object lazy array buffers.");
ZCREPORT_BYTES(cJSPathPrefix + NS_LITERAL_CSTRING("object-metadata"),
cStats.objectMetadataTable,
ZRREPORT_BYTES(realmJSPathPrefix + NS_LITERAL_CSTRING("object-metadata"),
realmStats.objectMetadataTable,
"The table used by debugging tools for tracking object metadata");
ZCREPORT_BYTES(cJSPathPrefix + NS_LITERAL_CSTRING("cross-compartment-wrapper-table"),
cStats.crossCompartmentWrappersTable,
ZRREPORT_BYTES(realmJSPathPrefix + NS_LITERAL_CSTRING("cross-compartment-wrapper-table"),
realmStats.crossCompartmentWrappersTable,
"The cross-compartment wrapper table.");
ZCREPORT_BYTES(cJSPathPrefix + NS_LITERAL_CSTRING("saved-stacks-set"),
cStats.savedStacksSet,
ZRREPORT_BYTES(realmJSPathPrefix + NS_LITERAL_CSTRING("saved-stacks-set"),
realmStats.savedStacksSet,
"The saved stacks set.");
ZCREPORT_BYTES(cJSPathPrefix + NS_LITERAL_CSTRING("non-syntactic-lexical-scopes-table"),
cStats.nonSyntacticLexicalScopesTable,
ZRREPORT_BYTES(realmJSPathPrefix + NS_LITERAL_CSTRING("non-syntactic-lexical-scopes-table"),
realmStats.nonSyntacticLexicalScopesTable,
"The non-syntactic lexical scopes table.");
ZCREPORT_BYTES(cJSPathPrefix + NS_LITERAL_CSTRING("jit-compartment"),
cStats.jitCompartment,
"The JIT compartment.");
ZRREPORT_BYTES(realmJSPathPrefix + NS_LITERAL_CSTRING("jit-realm"),
realmStats.jitRealm,
"The JIT realm.");
ZCREPORT_BYTES(cJSPathPrefix + NS_LITERAL_CSTRING("private-data"),
cStats.privateData,
"Extra data attached to the compartment by XPConnect, including "
ZRREPORT_BYTES(realmJSPathPrefix + NS_LITERAL_CSTRING("private-data"),
realmStats.privateData,
"Extra data attached to the realm by XPConnect, including "
"its wrapped-js.");
ZCREPORT_BYTES(cJSPathPrefix + NS_LITERAL_CSTRING("script-counts-map"),
cStats.scriptCountsMap,
ZRREPORT_BYTES(realmJSPathPrefix + NS_LITERAL_CSTRING("script-counts-map"),
realmStats.scriptCountsMap,
"Profiling-related information for scripts.");
if (sundriesGCHeap > 0) {
// We deliberately don't use ZCREPORT_GC_BYTES here.
REPORT_GC_BYTES(cJSPathPrefix + NS_LITERAL_CSTRING("sundries/gc-heap"),
// We deliberately don't use ZRREPORT_GC_BYTES here.
REPORT_GC_BYTES(realmJSPathPrefix + NS_LITERAL_CSTRING("sundries/gc-heap"),
sundriesGCHeap,
"The sum of all 'gc-heap' measurements that are too small to be "
"worth showing individually.");
}
if (sundriesMallocHeap > 0) {
// We deliberately don't use ZCREPORT_BYTES here.
REPORT_BYTES(cJSPathPrefix + NS_LITERAL_CSTRING("sundries/malloc-heap"),
// We deliberately don't use ZRREPORT_BYTES here.
REPORT_BYTES(realmJSPathPrefix + NS_LITERAL_CSTRING("sundries/malloc-heap"),
KIND_HEAP, sundriesMallocHeap,
"The sum of all 'malloc-heap' measurements that are too small to "
"be worth showing individually.");
@ -1843,13 +1843,12 @@ ReportJSRuntimeExplicitTreeStats(const JS::RuntimeStats& rtStats,
&gcTotal);
}
for (size_t i = 0; i < rtStats.compartmentStatsVector.length(); i++) {
const JS::CompartmentStats& cStats = rtStats.compartmentStatsVector[i];
const xpc::CompartmentStatsExtras* extras =
static_cast<const xpc::CompartmentStatsExtras*>(cStats.extra);
for (size_t i = 0; i < rtStats.realmStatsVector.length(); i++) {
const JS::RealmStats& realmStats = rtStats.realmStatsVector[i];
const xpc::RealmStatsExtras* extras =
static_cast<const xpc::RealmStatsExtras*>(realmStats.extra);
ReportCompartmentStats(cStats, *extras, handleReport,
data, &gcTotal);
ReportRealmStats(realmStats, *extras, handleReport, data, &gcTotal);
}
// Report the rtStats.runtime numbers under "runtime/", and compute their
@ -1999,7 +1998,7 @@ ReportJSRuntimeExplicitTreeStats(const JS::RuntimeStats& rtStats,
if (rtTotalOut)
*rtTotalOut = rtTotal;
// Report GC numbers that don't belong to a compartment.
// Report GC numbers that don't belong to a realm.
// We don't want to report decommitted memory in "explicit", so we just
// change the leading "explicit/" to "decommitted/".
@ -2032,10 +2031,10 @@ ReportJSRuntimeExplicitTreeStats(const JS::RuntimeStats& rtStats,
} // namespace xpc
class JSMainRuntimeCompartmentsReporter final : public nsIMemoryReporter
class JSMainRuntimeRealmsReporter final : public nsIMemoryReporter
{
~JSMainRuntimeCompartmentsReporter() {}
~JSMainRuntimeRealmsReporter() {}
public:
NS_DECL_ISUPPORTS
@ -2051,8 +2050,8 @@ class JSMainRuntimeCompartmentsReporter final : public nsIMemoryReporter
nsCString path;
GetCompartmentName(c, path, &data->anonymizeID, /* replaceSlashes = */ true);
path.Insert(js::IsSystemCompartment(c)
? NS_LITERAL_CSTRING("js-main-runtime-compartments/system/")
: NS_LITERAL_CSTRING("js-main-runtime-compartments/user/"),
? NS_LITERAL_CSTRING("js-main-runtime-realms/system/")
: NS_LITERAL_CSTRING("js-main-runtime-realms/user/"),
0);
mozilla::Unused << data->paths.append(path);
}
@ -2078,7 +2077,7 @@ class JSMainRuntimeCompartmentsReporter final : public nsIMemoryReporter
}
};
NS_IMPL_ISUPPORTS(JSMainRuntimeCompartmentsReporter, nsIMemoryReporter)
NS_IMPL_ISUPPORTS(JSMainRuntimeRealmsReporter, nsIMemoryReporter)
MOZ_DEFINE_MALLOC_SIZE_OF(OrphanMallocSizeOf)
@ -2157,8 +2156,8 @@ class XPCJSRuntimeStats : public JS::RuntimeStats
{}
~XPCJSRuntimeStats() {
for (size_t i = 0; i != compartmentStatsVector.length(); ++i)
delete static_cast<xpc::CompartmentStatsExtras*>(compartmentStatsVector[i].extra);
for (size_t i = 0; i != realmStatsVector.length(); ++i)
delete static_cast<xpc::RealmStatsExtras*>(realmStatsVector[i].extra);
for (size_t i = 0; i != zoneStatsVector.length(); ++i)
delete static_cast<xpc::ZoneStatsExtras*>(zoneStatsVector[i].extra);
@ -2190,10 +2189,10 @@ class XPCJSRuntimeStats : public JS::RuntimeStats
zStats->extra = extras;
}
virtual void initExtraCompartmentStats(JSCompartment* c,
JS::CompartmentStats* cstats) override
virtual void initExtraRealmStats(JSCompartment* c,
JS::RealmStats* realmStats) override
{
xpc::CompartmentStatsExtras* extras = new xpc::CompartmentStatsExtras;
xpc::RealmStatsExtras* extras = new xpc::RealmStatsExtras;
nsCString cName;
GetCompartmentName(c, cName, &mAnonymizeID, /* replaceSlashes = */ true);
@ -2229,24 +2228,24 @@ class XPCJSRuntimeStats : public JS::RuntimeStats
if (needZone)
extras->jsPathPrefix += nsPrintfCString("zone(0x%p)/", (void*)js::GetCompartmentZone(c));
extras->jsPathPrefix += NS_LITERAL_CSTRING("compartment(") + cName + NS_LITERAL_CSTRING(")/");
extras->jsPathPrefix += NS_LITERAL_CSTRING("realm(") + cName + NS_LITERAL_CSTRING(")/");
// extras->jsPathPrefix is used for almost all the compartment-specific
// extras->jsPathPrefix is used for almost all the realm-specific
// reports. At this point it has the form
// "<something>compartment(<cname>)/".
// "<something>realm(<rname>)/".
//
// extras->domPathPrefix is used for DOM orphan nodes, which are
// counted by the JS reporter but reported as part of the DOM
// measurements. At this point it has the form "<something>/dom/" if
// this compartment belongs to an nsGlobalWindow, and
// this realm belongs to an nsGlobalWindow, and
// "explicit/dom/<something>?!/" otherwise (in which case it shouldn't
// be used, because non-nsGlobalWindow compartments shouldn't have
// be used, because non-nsGlobalWindow realms shouldn't have
// orphan DOM nodes).
MOZ_ASSERT(StartsWithExplicit(extras->jsPathPrefix));
MOZ_ASSERT(StartsWithExplicit(extras->domPathPrefix));
cstats->extra = extras;
realmStats->extra = extras;
}
};
@ -2300,12 +2299,11 @@ JSReporter::CollectReports(WindowPaths* windowPaths,
handleReport, data,
anonymize, &rtTotal);
// Report the sums of the compartment numbers.
xpc::CompartmentStatsExtras cExtrasTotal;
cExtrasTotal.jsPathPrefix.AssignLiteral("js-main-runtime/compartments/");
cExtrasTotal.domPathPrefix.AssignLiteral("window-objects/dom/");
ReportCompartmentStats(rtStats.cTotals, cExtrasTotal,
handleReport, data);
// Report the sums of the realm numbers.
xpc::RealmStatsExtras realmExtrasTotal;
realmExtrasTotal.jsPathPrefix.AssignLiteral("js-main-runtime/realms/");
realmExtrasTotal.domPathPrefix.AssignLiteral("window-objects/dom/");
ReportRealmStats(rtStats.realmTotals, realmExtrasTotal, handleReport, data);
xpc::ZoneStatsExtras zExtrasTotal;
zExtrasTotal.pathPrefix.AssignLiteral("js-main-runtime/zones/");
@ -2333,7 +2331,7 @@ JSReporter::CollectReports(WindowPaths* windowPaths,
KIND_OTHER, rtStats.runtime.wasmRuntime,
"The memory used for wasm runtime bookkeeping.");
// Report the numbers for memory outside of compartments.
// Report the numbers for memory outside of realms.
REPORT_BYTES(NS_LITERAL_CSTRING("js-main-runtime/gc-heap/unused-chunks"),
KIND_OTHER, rtStats.gcHeapUnusedChunks,
@ -2412,7 +2410,7 @@ JSReporter::CollectReports(WindowPaths* windowPaths,
size_t gcThingTotal = 0;
MREPORT_BYTES(NS_LITERAL_CSTRING("js-main-runtime-gc-heap-committed/used/gc-things/objects"),
KIND_OTHER, rtStats.cTotals.classInfo.objectsGCHeap,
KIND_OTHER, rtStats.realmTotals.classInfo.objectsGCHeap,
"Used object cells.");
MREPORT_BYTES(NS_LITERAL_CSTRING("js-main-runtime-gc-heap-committed/used/gc-things/strings"),
@ -2441,7 +2439,7 @@ JSReporter::CollectReports(WindowPaths* windowPaths,
"Used scope cells.");
MREPORT_BYTES(NS_LITERAL_CSTRING("js-main-runtime-gc-heap-committed/used/gc-things/scripts"),
KIND_OTHER, rtStats.cTotals.scriptsGCHeap,
KIND_OTHER, rtStats.realmTotals.scriptsGCHeap,
"Used script cells.");
MREPORT_BYTES(NS_LITERAL_CSTRING("js-main-runtime-gc-heap-committed/used/gc-things/lazy-scripts"),
@ -2878,12 +2876,12 @@ XPCJSRuntime::Initialize(JSContext* cx)
js::SetSourceHook(cx, Move(hook));
// Register memory reporters and distinguished amount functions.
RegisterStrongMemoryReporter(new JSMainRuntimeCompartmentsReporter());
RegisterStrongMemoryReporter(new JSMainRuntimeRealmsReporter());
RegisterStrongMemoryReporter(new JSMainRuntimeTemporaryPeakReporter());
RegisterJSMainRuntimeGCHeapDistinguishedAmount(JSMainRuntimeGCHeapDistinguishedAmount);
RegisterJSMainRuntimeTemporaryPeakDistinguishedAmount(JSMainRuntimeTemporaryPeakDistinguishedAmount);
RegisterJSMainRuntimeCompartmentsSystemDistinguishedAmount(JSMainRuntimeCompartmentsSystemDistinguishedAmount);
RegisterJSMainRuntimeCompartmentsUserDistinguishedAmount(JSMainRuntimeCompartmentsUserDistinguishedAmount);
RegisterJSMainRuntimeRealmsSystemDistinguishedAmount(JSMainRuntimeRealmsSystemDistinguishedAmount);
RegisterJSMainRuntimeRealmsUserDistinguishedAmount(JSMainRuntimeRealmsUserDistinguishedAmount);
mozilla::RegisterJSSizeOfTab(JSSizeOfTab);
xpc_LocalizeRuntime(JS_GetRuntime(cx));

Просмотреть файл

@ -420,24 +420,24 @@ private:
};
// ReportJSRuntimeExplicitTreeStats will expect this in the |extra| member
// of JS::CompartmentStats.
class CompartmentStatsExtras {
// of JS::RealmStats.
class RealmStatsExtras {
public:
CompartmentStatsExtras() {}
RealmStatsExtras() {}
nsCString jsPathPrefix;
nsCString domPathPrefix;
nsCOMPtr<nsIURI> location;
private:
CompartmentStatsExtras(const CompartmentStatsExtras& other) = delete;
CompartmentStatsExtras& operator=(const CompartmentStatsExtras& other) = delete;
RealmStatsExtras(const RealmStatsExtras& other) = delete;
RealmStatsExtras& operator=(const RealmStatsExtras& other) = delete;
};
// This reports all the stats in |rtStats| that belong in the "explicit" tree,
// (which isn't all of them).
// @see ZoneStatsExtras
// @see CompartmentStatsExtras
// @see RealmStatsExtras
void
ReportJSRuntimeExplicitTreeStats(const JS::RuntimeStats& rtStats,
const nsACString& rtPath,

Просмотреть файл

@ -93,10 +93,10 @@
storageSqliteAmounts.push(aAmount);
// Check the presence of some other notable reporters.
} else if (aPath.search(/^explicit\/js-non-window\/.*compartment\(/) >= 0) {
present.jsNonWindowCompartments = true;
} else if (aPath.search(/^explicit\/window-objects\/top\(.*\/js-compartment\(/) >= 0) {
present.windowObjectsJsCompartments = true;
} else if (aPath.search(/^explicit\/js-non-window\/.*realm\(/) >= 0) {
present.jsNonWindowRealms = true;
} else if (aPath.search(/^explicit\/window-objects\/top\(.*\/js-realm\(/) >= 0) {
present.windowObjectsJsRealms = true;
} else if (aPath.search(/^explicit\/storage\/sqlite\/places.sqlite/) >= 0) {
present.places = true;
} else if (aPath.search(/^explicit\/images/) >= 0) {
@ -152,8 +152,8 @@
"heapOverheadFraction",
"JSMainRuntimeGCHeap",
"JSMainRuntimeTemporaryPeak",
"JSMainRuntimeCompartmentsSystem",
"JSMainRuntimeCompartmentsUser",
"JSMainRuntimeRealmsSystem",
"JSMainRuntimeRealmsUser",
"imagesContentUsedUncompressed",
"storageSQLite",
"lowMemoryEventsVirtual",
@ -254,8 +254,8 @@
checkSizeReasonable("js-main-runtime-gc-heap-committed/used/gc-things",
jsGcHeapUsedGcThingsTotal);
ok(present.jsNonWindowCompartments, "js-non-window compartments are present");
ok(present.windowObjectsJsCompartments, "window-objects/.../js compartments are present");
ok(present.jsNonWindowRealms, "js-non-window realms are present");
ok(present.windowObjectsJsRealms, "window-objects/.../js realms are present");
ok(present.places, "places is present");
ok(present.images, "images is present");
ok(present.dynamicAtomObjects, "dynamic/atom-objects is present");

Просмотреть файл

@ -1089,8 +1089,8 @@ var Impl = {
b("MEMORY_UNIQUE", "residentUnique");
p("MEMORY_HEAP_OVERHEAD_FRACTION", "heapOverheadFraction");
b("MEMORY_JS_GC_HEAP", "JSMainRuntimeGCHeap");
c("MEMORY_JS_COMPARTMENTS_SYSTEM", "JSMainRuntimeCompartmentsSystem");
c("MEMORY_JS_COMPARTMENTS_USER", "JSMainRuntimeCompartmentsUser");
c("MEMORY_JS_COMPARTMENTS_SYSTEM", "JSMainRuntimeRealmsSystem");
c("MEMORY_JS_COMPARTMENTS_USER", "JSMainRuntimeRealmsUser");
b("MEMORY_IMAGES_CONTENT_USED_UNCOMPRESSED", "imagesContentUsedUncompressed");
b("MEMORY_STORAGE_SQLITE", "storageSQLite");
cc("LOW_MEMORY_EVENTS_VIRTUAL", "lowMemoryEventsVirtual");

Просмотреть файл

@ -362,8 +362,8 @@ interface nsIMemoryReporterManager : nsISupports
* |JSMainRuntimeTemporaryPeak| (UNITS_BYTES) Peak size of the transient
* storage in the main JSRuntime.
*
* |JSMainRuntimeCompartments{System,User}| (UNITS_COUNT) The number of
* {system,user} compartments in the main JS runtime.
* |JSMainRuntimeRealms{System,User}| (UNITS_COUNT) The number of
* {system,user} realms in the main JS runtime.
*
* |imagesContentUsedUncompressed| (UNITS_BYTES) Memory used for decoded
* raster images in content.
@ -392,8 +392,8 @@ interface nsIMemoryReporterManager : nsISupports
[must_use] readonly attribute int64_t JSMainRuntimeGCHeap;
[must_use] readonly attribute int64_t JSMainRuntimeTemporaryPeak;
[must_use] readonly attribute int64_t JSMainRuntimeCompartmentsSystem;
[must_use] readonly attribute int64_t JSMainRuntimeCompartmentsUser;
[must_use] readonly attribute int64_t JSMainRuntimeRealmsSystem;
[must_use] readonly attribute int64_t JSMainRuntimeRealmsUser;
[must_use] readonly attribute int64_t imagesContentUsedUncompressed;
@ -494,8 +494,8 @@ typedef int64_t (*InfallibleAmountFn)();
DECL_REGISTER_DISTINGUISHED_AMOUNT(Infallible, JSMainRuntimeGCHeap)
DECL_REGISTER_DISTINGUISHED_AMOUNT(Infallible, JSMainRuntimeTemporaryPeak)
DECL_REGISTER_DISTINGUISHED_AMOUNT(Infallible, JSMainRuntimeCompartmentsSystem)
DECL_REGISTER_DISTINGUISHED_AMOUNT(Infallible, JSMainRuntimeCompartmentsUser)
DECL_REGISTER_DISTINGUISHED_AMOUNT(Infallible, JSMainRuntimeRealmsSystem)
DECL_REGISTER_DISTINGUISHED_AMOUNT(Infallible, JSMainRuntimeRealmsUser)
DECL_REGISTER_DISTINGUISHED_AMOUNT(Infallible, ImagesContentUsedUncompressed)
DECL_UNREGISTER_DISTINGUISHED_AMOUNT(ImagesContentUsedUncompressed)

Просмотреть файл

@ -2487,16 +2487,16 @@ nsMemoryReporterManager::GetJSMainRuntimeTemporaryPeak(int64_t* aAmount)
}
NS_IMETHODIMP
nsMemoryReporterManager::GetJSMainRuntimeCompartmentsSystem(int64_t* aAmount)
nsMemoryReporterManager::GetJSMainRuntimeRealmsSystem(int64_t* aAmount)
{
return GetInfallibleAmount(mAmountFns.mJSMainRuntimeCompartmentsSystem,
return GetInfallibleAmount(mAmountFns.mJSMainRuntimeRealmsSystem,
aAmount);
}
NS_IMETHODIMP
nsMemoryReporterManager::GetJSMainRuntimeCompartmentsUser(int64_t* aAmount)
nsMemoryReporterManager::GetJSMainRuntimeRealmsUser(int64_t* aAmount)
{
return GetInfallibleAmount(mAmountFns.mJSMainRuntimeCompartmentsUser,
return GetInfallibleAmount(mAmountFns.mJSMainRuntimeRealmsUser,
aAmount);
}
@ -2779,8 +2779,8 @@ UnregisterWeakMemoryReporter(nsIMemoryReporter* aReporter)
DEFINE_REGISTER_DISTINGUISHED_AMOUNT(Infallible, JSMainRuntimeGCHeap)
DEFINE_REGISTER_DISTINGUISHED_AMOUNT(Infallible, JSMainRuntimeTemporaryPeak)
DEFINE_REGISTER_DISTINGUISHED_AMOUNT(Infallible, JSMainRuntimeCompartmentsSystem)
DEFINE_REGISTER_DISTINGUISHED_AMOUNT(Infallible, JSMainRuntimeCompartmentsUser)
DEFINE_REGISTER_DISTINGUISHED_AMOUNT(Infallible, JSMainRuntimeRealmsSystem)
DEFINE_REGISTER_DISTINGUISHED_AMOUNT(Infallible, JSMainRuntimeRealmsUser)
DEFINE_REGISTER_DISTINGUISHED_AMOUNT(Infallible, ImagesContentUsedUncompressed)
DEFINE_UNREGISTER_DISTINGUISHED_AMOUNT(ImagesContentUsedUncompressed)

Просмотреть файл

@ -141,8 +141,8 @@ public:
{
mozilla::InfallibleAmountFn mJSMainRuntimeGCHeap;
mozilla::InfallibleAmountFn mJSMainRuntimeTemporaryPeak;
mozilla::InfallibleAmountFn mJSMainRuntimeCompartmentsSystem;
mozilla::InfallibleAmountFn mJSMainRuntimeCompartmentsUser;
mozilla::InfallibleAmountFn mJSMainRuntimeRealmsSystem;
mozilla::InfallibleAmountFn mJSMainRuntimeRealmsUser;
mozilla::InfallibleAmountFn mImagesContentUsedUncompressed;