зеркало из https://github.com/mozilla/gecko-dev.git
Bug 799019 - Tweak per-compartment memory reporting. r=Ms2ger.
--HG-- extra : rebase_source : 66bab372c7b3a7f4cebfd059b4c64a7562ba1f5d
This commit is contained in:
Родитель
6ce031f394
Коммит
9ddf540b9b
|
@ -58,7 +58,6 @@ struct RuntimeSizes
|
||||||
, mathCache(0)
|
, mathCache(0)
|
||||||
, scriptFilenames(0)
|
, scriptFilenames(0)
|
||||||
, scriptSources(0)
|
, scriptSources(0)
|
||||||
, compartmentObjects(0)
|
|
||||||
{}
|
{}
|
||||||
|
|
||||||
size_t object;
|
size_t object;
|
||||||
|
@ -75,12 +74,6 @@ struct RuntimeSizes
|
||||||
size_t mathCache;
|
size_t mathCache;
|
||||||
size_t scriptFilenames;
|
size_t scriptFilenames;
|
||||||
size_t scriptSources;
|
size_t scriptSources;
|
||||||
|
|
||||||
// This is the exception to the "RuntimeSizes doesn't measure things within
|
|
||||||
// compartments" rule. We combine the sizes of all the JSCompartment
|
|
||||||
// objects into a single measurement because each one is fairly small, and
|
|
||||||
// they're all the same size.
|
|
||||||
size_t compartmentObjects;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct CompartmentStats
|
struct CompartmentStats
|
||||||
|
@ -123,7 +116,10 @@ struct CompartmentStats
|
||||||
size_t scriptData;
|
size_t scriptData;
|
||||||
size_t jaegerData;
|
size_t jaegerData;
|
||||||
size_t ionData;
|
size_t ionData;
|
||||||
|
size_t compartmentObject;
|
||||||
size_t crossCompartmentWrappers;
|
size_t crossCompartmentWrappers;
|
||||||
|
size_t regexpCompartment;
|
||||||
|
size_t debuggeesSet;
|
||||||
|
|
||||||
TypeInferenceSizes typeInferenceSizes;
|
TypeInferenceSizes typeInferenceSizes;
|
||||||
|
|
||||||
|
@ -159,7 +155,10 @@ struct CompartmentStats
|
||||||
ADD(scriptData);
|
ADD(scriptData);
|
||||||
ADD(jaegerData);
|
ADD(jaegerData);
|
||||||
ADD(ionData);
|
ADD(ionData);
|
||||||
|
ADD(compartmentObject);
|
||||||
ADD(crossCompartmentWrappers);
|
ADD(crossCompartmentWrappers);
|
||||||
|
ADD(regexpCompartment);
|
||||||
|
ADD(debuggeesSet);
|
||||||
|
|
||||||
#undef ADD
|
#undef ADD
|
||||||
|
|
||||||
|
|
|
@ -100,19 +100,6 @@ js::TraceCycleDetectionSet(JSTracer *trc, js::ObjectSet &set)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
struct CallbackData
|
|
||||||
{
|
|
||||||
CallbackData(JSMallocSizeOfFun f) : mallocSizeOf(f), n(0) {}
|
|
||||||
JSMallocSizeOfFun mallocSizeOf;
|
|
||||||
size_t n;
|
|
||||||
};
|
|
||||||
|
|
||||||
void CompartmentCallback(JSRuntime *rt, void *vdata, JSCompartment *compartment)
|
|
||||||
{
|
|
||||||
CallbackData *data = (CallbackData *) vdata;
|
|
||||||
data->n += data->mallocSizeOf(compartment);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
JSRuntime::sizeOfIncludingThis(JSMallocSizeOfFun mallocSizeOf, RuntimeSizes *rtSizes)
|
JSRuntime::sizeOfIncludingThis(JSMallocSizeOfFun mallocSizeOf, RuntimeSizes *rtSizes)
|
||||||
{
|
{
|
||||||
|
@ -147,11 +134,6 @@ JSRuntime::sizeOfIncludingThis(JSMallocSizeOfFun mallocSizeOf, RuntimeSizes *rtS
|
||||||
rtSizes->scriptFilenames = scriptFilenameTable.sizeOfExcludingThis(mallocSizeOf);
|
rtSizes->scriptFilenames = scriptFilenameTable.sizeOfExcludingThis(mallocSizeOf);
|
||||||
for (ScriptFilenameTable::Range r = scriptFilenameTable.all(); !r.empty(); r.popFront())
|
for (ScriptFilenameTable::Range r = scriptFilenameTable.all(); !r.empty(); r.popFront())
|
||||||
rtSizes->scriptFilenames += mallocSizeOf(r.front());
|
rtSizes->scriptFilenames += mallocSizeOf(r.front());
|
||||||
|
|
||||||
rtSizes->compartmentObjects = 0;
|
|
||||||
CallbackData data(mallocSizeOf);
|
|
||||||
JS_IterateCompartments(this, &data, CompartmentCallback);
|
|
||||||
rtSizes->compartmentObjects = data.n;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t
|
size_t
|
||||||
|
|
|
@ -847,11 +847,19 @@ JSCompartment::sweepBreakpoints(FreeOp *fop)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t
|
void
|
||||||
JSCompartment::sizeOfShapeTable(JSMallocSizeOfFun mallocSizeOf)
|
JSCompartment::sizeOfIncludingThis(JSMallocSizeOfFun mallocSizeOf, size_t *compartmentObject,
|
||||||
|
TypeInferenceSizes *tiSizes, size_t *shapesCompartmentTables,
|
||||||
|
size_t *crossCompartmentWrappersArg, size_t *regexpCompartment,
|
||||||
|
size_t *debuggeesSet)
|
||||||
{
|
{
|
||||||
return baseShapes.sizeOfExcludingThis(mallocSizeOf)
|
*compartmentObject = mallocSizeOf(this);
|
||||||
+ initialShapes.sizeOfExcludingThis(mallocSizeOf)
|
sizeOfTypeInferenceData(tiSizes, mallocSizeOf);
|
||||||
+ newTypeObjects.sizeOfExcludingThis(mallocSizeOf)
|
*shapesCompartmentTables = baseShapes.sizeOfExcludingThis(mallocSizeOf)
|
||||||
+ lazyTypeObjects.sizeOfExcludingThis(mallocSizeOf);
|
+ initialShapes.sizeOfExcludingThis(mallocSizeOf)
|
||||||
|
+ newTypeObjects.sizeOfExcludingThis(mallocSizeOf)
|
||||||
|
+ lazyTypeObjects.sizeOfExcludingThis(mallocSizeOf);
|
||||||
|
*crossCompartmentWrappersArg = crossCompartmentWrappers.sizeOfExcludingThis(mallocSizeOf);
|
||||||
|
*regexpCompartment = regExps.sizeOfExcludingThis(mallocSizeOf);
|
||||||
|
*debuggeesSet = debuggees.sizeOfExcludingThis(mallocSizeOf);
|
||||||
}
|
}
|
||||||
|
|
|
@ -278,9 +278,15 @@ struct JSCompartment
|
||||||
|
|
||||||
js::RegExpCompartment regExps;
|
js::RegExpCompartment regExps;
|
||||||
|
|
||||||
size_t sizeOfShapeTable(JSMallocSizeOfFun mallocSizeOf);
|
private:
|
||||||
void sizeOfTypeInferenceData(JS::TypeInferenceSizes *stats, JSMallocSizeOfFun mallocSizeOf);
|
void sizeOfTypeInferenceData(JS::TypeInferenceSizes *stats, JSMallocSizeOfFun mallocSizeOf);
|
||||||
|
|
||||||
|
public:
|
||||||
|
void sizeOfIncludingThis(JSMallocSizeOfFun mallocSizeOf, size_t *compartmentObject,
|
||||||
|
JS::TypeInferenceSizes *tiSizes,
|
||||||
|
size_t *shapesCompartmentTables, size_t *crossCompartmentWrappers,
|
||||||
|
size_t *regexpCompartment, size_t *debuggeesSet);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Shared scope property tree, and arena-pool for allocating its nodes.
|
* Shared scope property tree, and arena-pool for allocating its nodes.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -81,11 +81,14 @@ StatsCompartmentCallback(JSRuntime *rt, void *data, JSCompartment *compartment)
|
||||||
rtStats->initExtraCompartmentStats(compartment, &cStats);
|
rtStats->initExtraCompartmentStats(compartment, &cStats);
|
||||||
rtStats->currCompartmentStats = &cStats;
|
rtStats->currCompartmentStats = &cStats;
|
||||||
|
|
||||||
// Get the compartment-level numbers.
|
// Measure the compartment object itself, and things hanging off it.
|
||||||
compartment->sizeOfTypeInferenceData(&cStats.typeInferenceSizes, rtStats->mallocSizeOf);
|
compartment->sizeOfIncludingThis(rtStats->mallocSizeOf,
|
||||||
cStats.shapesCompartmentTables = compartment->sizeOfShapeTable(rtStats->mallocSizeOf);
|
&cStats.compartmentObject,
|
||||||
cStats.crossCompartmentWrappers =
|
&cStats.typeInferenceSizes,
|
||||||
compartment->crossCompartmentWrappers.sizeOfExcludingThis(rtStats->mallocSizeOf);
|
&cStats.shapesCompartmentTables,
|
||||||
|
&cStats.crossCompartmentWrappers,
|
||||||
|
&cStats.regexpCompartment,
|
||||||
|
&cStats.debuggeesSet);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
|
@ -617,6 +617,12 @@ RegExpCompartment::get(JSContext *cx, JSAtom *atom, JSString *opt, RegExpGuard *
|
||||||
return get(cx, atom, flags, g);
|
return get(cx, atom, flags, g);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
size_t
|
||||||
|
RegExpCompartment::sizeOfExcludingThis(JSMallocSizeOfFun mallocSizeOf)
|
||||||
|
{
|
||||||
|
return map_.sizeOfExcludingThis(mallocSizeOf);
|
||||||
|
}
|
||||||
|
|
||||||
/* Functions */
|
/* Functions */
|
||||||
|
|
||||||
JSObject *
|
JSObject *
|
||||||
|
|
|
@ -290,6 +290,8 @@ class RegExpCompartment
|
||||||
* mapping property, 'hackedSource' is unambiguous.
|
* mapping property, 'hackedSource' is unambiguous.
|
||||||
*/
|
*/
|
||||||
bool lookupHack(JSAtom *source, RegExpFlag flags, JSContext *cx, RegExpGuard *g);
|
bool lookupHack(JSAtom *source, RegExpFlag flags, JSContext *cx, RegExpGuard *g);
|
||||||
|
|
||||||
|
size_t sizeOfExcludingThis(JSMallocSizeOfFun mallocSizeOf);
|
||||||
};
|
};
|
||||||
|
|
||||||
class RegExpObject : public JSObject
|
class RegExpObject : public JSObject
|
||||||
|
|
|
@ -1615,10 +1615,22 @@ ReportCompartmentStats(const JS::CompartmentStats &cStats,
|
||||||
"Memory used by the IonMonkey JIT for compilation data: "
|
"Memory used by the IonMonkey JIT for compilation data: "
|
||||||
"IonScripts.");
|
"IonScripts.");
|
||||||
|
|
||||||
|
CREPORT_BYTES(cJSPathPrefix + NS_LITERAL_CSTRING("compartment-object"),
|
||||||
|
cStats.compartmentObject,
|
||||||
|
"Memory used for the JSCompartment object itself.");
|
||||||
|
|
||||||
CREPORT_BYTES(cJSPathPrefix + NS_LITERAL_CSTRING("cross-compartment-wrappers"),
|
CREPORT_BYTES(cJSPathPrefix + NS_LITERAL_CSTRING("cross-compartment-wrappers"),
|
||||||
cStats.crossCompartmentWrappers,
|
cStats.crossCompartmentWrappers,
|
||||||
"Memory used by cross-compartment wrappers.");
|
"Memory used by cross-compartment wrappers.");
|
||||||
|
|
||||||
|
CREPORT_BYTES(cJSPathPrefix + NS_LITERAL_CSTRING("regexp-compartment"),
|
||||||
|
cStats.regexpCompartment,
|
||||||
|
"Memory used by the regexp compartment.");
|
||||||
|
|
||||||
|
CREPORT_BYTES(cJSPathPrefix + NS_LITERAL_CSTRING("debuggees-set"),
|
||||||
|
cStats.debuggeesSet,
|
||||||
|
"Memory used by the debuggees set.");
|
||||||
|
|
||||||
CREPORT_BYTES(cJSPathPrefix + NS_LITERAL_CSTRING("type-inference/script-main"),
|
CREPORT_BYTES(cJSPathPrefix + NS_LITERAL_CSTRING("type-inference/script-main"),
|
||||||
cStats.typeInferenceSizes.scripts,
|
cStats.typeInferenceSizes.scripts,
|
||||||
"Memory used during type inference to store type sets of "
|
"Memory used during type inference to store type sets of "
|
||||||
|
@ -1753,12 +1765,6 @@ ReportJSRuntimeExplicitTreeStats(const JS::RuntimeStats &rtStats,
|
||||||
nsIMemoryReporter::KIND_HEAP, rtStats.runtime.scriptSources,
|
nsIMemoryReporter::KIND_HEAP, rtStats.runtime.scriptSources,
|
||||||
"Memory use for storing JavaScript source code.");
|
"Memory use for storing JavaScript source code.");
|
||||||
|
|
||||||
RREPORT_BYTES(rtPath + NS_LITERAL_CSTRING("runtime/compartment-objects"),
|
|
||||||
nsIMemoryReporter::KIND_HEAP, rtStats.runtime.compartmentObjects,
|
|
||||||
"Memory used for JSCompartment objects. These are fairly "
|
|
||||||
"small and all the same size, so they're not worth reporting "
|
|
||||||
"on a per-compartment basis.");
|
|
||||||
|
|
||||||
if (rtTotalOut) {
|
if (rtTotalOut) {
|
||||||
*rtTotalOut = rtTotal;
|
*rtTotalOut = rtTotal;
|
||||||
}
|
}
|
||||||
|
|
Загрузка…
Ссылка в новой задаче