From 6ec5c499b16f8f3c7db14468a9c9181611b7353a Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Thu, 27 Oct 2011 22:20:36 -0700 Subject: [PATCH] Bug 697016 - Add js-total-* memory reports. r=bhackett. --- js/xpconnect/src/XPCJSRuntime.cpp | 76 +++++++++++++++++++++++++++++-- js/xpconnect/src/xpcpublic.h | 18 ++++++++ 2 files changed, 91 insertions(+), 3 deletions(-) diff --git a/js/xpconnect/src/XPCJSRuntime.cpp b/js/xpconnect/src/XPCJSRuntime.cpp index 622a34c2f949..847efdb9022f 100644 --- a/js/xpconnect/src/XPCJSRuntime.cpp +++ b/js/xpconnect/src/XPCJSRuntime.cpp @@ -1577,7 +1577,6 @@ CollectCompartmentStatsForRuntime(JSRuntime *rt, IterateData *data) // subtract used space from it each time around the loop. data->gcHeapChunkDirtyUnused = data->gcHeapChunkTotal - data->gcHeapChunkCleanUnused; - data->gcHeapArenaUnused = 0; for (PRUint32 index = 0; index < data->compartmentStatsVector.Length(); @@ -1598,6 +1597,29 @@ CollectCompartmentStatsForRuntime(JSRuntime *rt, IterateData *data) data->gcHeapChunkDirtyUnused -= used; data->gcHeapArenaUnused += stats.gcHeapArenaUnused; + data->totalObjects += stats.gcHeapObjectsNonFunction + + stats.gcHeapObjectsFunction + + stats.objectSlots; + data->totalShapes += stats.gcHeapShapesTree + + stats.gcHeapShapesDict + + stats.shapesExtraTreeTables + + stats.shapesExtraDictTables + + stats.typeInferenceMemory.emptyShapes; + data->totalScripts += stats.gcHeapScripts + + stats.scriptData; + data->totalStrings += stats.gcHeapStrings + + stats.stringChars; +#ifdef JS_METHODJIT + data->totalMjit += stats.mjitCodeMethod + + stats.mjitCodeRegexp + + stats.mjitCodeUnused + + stats.mjitData; +#endif + data->totalTypeInference += stats.gcHeapTypeObjects + + stats.typeInferenceMemory.objects + + stats.typeInferenceMemory.scripts + + stats.typeInferenceMemory.tables; + data->totalAnalysisTemp += stats.typeInferenceMemory.temporary; } size_t numDirtyChunks = (data->gcHeapChunkTotal - @@ -1752,10 +1774,11 @@ ReportCompartmentStats(const CompartmentStats &stats, callback, closure); ReportMemoryBytes0(MakeMemoryReporterPath(pathPrefix, stats.name, - "object-empty-shapes"), + "shapes-extra/empty-shape-arrays"), nsIMemoryReporter::KIND_HEAP, stats.typeInferenceMemory.emptyShapes, - "Arrays attached to prototype JS objects managing shape information.", + "Memory used for arrays attached to prototype JS objects managing shape " + "information.", callback, closure); ReportMemoryBytes0(MakeMemoryReporterPath(pathPrefix, stats.name, @@ -1967,6 +1990,53 @@ public: "'js-gc-heap'.", callback, closure); + ReportMemoryBytes(NS_LITERAL_CSTRING("js-total-objects"), + nsIMemoryReporter::KIND_OTHER, data.totalObjects, + "Memory used for all object-related data. This is the sum of all " + "compartments' 'gc-heap/objects-non-function', " + "'gc-heap/objects-function' and 'object-slots' numbers.", + callback, closure); + + ReportMemoryBytes(NS_LITERAL_CSTRING("js-total-shapes"), + nsIMemoryReporter::KIND_OTHER, data.totalShapes, + "Memory used for all shape-related data. This is the sum of all " + "compartments' 'gc-heap/shapes/tree', 'gc-heap/shapes/dict', " + "'shapes-extra/tree-tables', 'shapes-extra/dict-tables', " + "'shapes-extra/tree-shape-kids' and 'shapes-extra/empty-shape-arrays'.", + callback, closure); + + ReportMemoryBytes(NS_LITERAL_CSTRING("js-total-scripts"), + nsIMemoryReporter::KIND_OTHER, data.totalScripts, + "Memory used for all script-related data. This is the sum of all " + "compartments' 'gc-heap/scripts' and 'script-data' numbers.", + callback, closure); + + ReportMemoryBytes(NS_LITERAL_CSTRING("js-total-strings"), + nsIMemoryReporter::KIND_OTHER, data.totalStrings, + "Memory used for all string-related data. This is the sum of all " + "compartments' 'gc-heap/strings' and 'string-chars' numbers.", + callback, closure); +#ifdef JS_METHODJIT + ReportMemoryBytes(NS_LITERAL_CSTRING("js-total-mjit"), + nsIMemoryReporter::KIND_OTHER, data.totalMjit, + "Memory used by the method JIT. This is the sum of all compartments' " + "'mjit-code-method', 'mjit-code-regexp', 'mjit-code-unused' and '" + "'mjit-data' numbers.", + callback, closure); +#endif + ReportMemoryBytes(NS_LITERAL_CSTRING("js-total-type-inference"), + nsIMemoryReporter::KIND_OTHER, data.totalTypeInference, + "Non-transient memory used by type inference. This is the sum of all " + "compartments' 'gc-heap/type-objects', 'type-inference/script-main', " + "'type-inference/object-main' and 'type-inference/tables' numbers.", + callback, closure); + + ReportMemoryBytes(NS_LITERAL_CSTRING("js-total-analysis-temporary"), + nsIMemoryReporter::KIND_OTHER, data.totalAnalysisTemp, + "Transient memory used during type inference and compilation. " + "This is the sum of all compartments' 'analysis-temporary' numbers.", + callback, closure); + return NS_OK; } }; diff --git a/js/xpconnect/src/xpcpublic.h b/js/xpconnect/src/xpcpublic.h index 7b0f84f1fd3a..1b84851f18e3 100644 --- a/js/xpconnect/src/xpcpublic.h +++ b/js/xpconnect/src/xpcpublic.h @@ -240,6 +240,15 @@ struct IterateData gcHeapArenaUnused(0), gcHeapChunkAdmin(0), gcHeapUnusedPercentage(0), + totalObjects(0), + totalShapes(0), + totalScripts(0), + totalStrings(0), +#ifdef JS_METHODJIT + totalMjit(0), +#endif + totalTypeInference(0), + totalAnalysisTemp(0), compartmentStatsVector(), currCompartmentStats(NULL) { } @@ -252,6 +261,15 @@ struct IterateData PRInt64 gcHeapArenaUnused; PRInt64 gcHeapChunkAdmin; PRInt64 gcHeapUnusedPercentage; + PRInt64 totalObjects; + PRInt64 totalShapes; + PRInt64 totalScripts; + PRInt64 totalStrings; +#ifdef JS_METHODJIT + PRInt64 totalMjit; +#endif + PRInt64 totalTypeInference; + PRInt64 totalAnalysisTemp; nsTArray compartmentStatsVector; CompartmentStats *currCompartmentStats;