Bug 805915 (part 2) - Add more detail to object memory reports. r=luke.
authorNicholas Nethercote <nnethercote@mozilla.com>
Mon, 29 Oct 2012 08:51:21 +1100
changeset 111776 31395c6bb9b80f59fa327e17999547869d475e8d
parent 111775 22a934cbde1fca4b3e57cb85b7b333a77a964342
child 111777 aa23bf4b9a20f172de10ba2a3bfd592266ab9167
push id93
push usernmatsakis@mozilla.com
push dateWed, 31 Oct 2012 21:26:57 +0000
reviewersluke
bugs805915
milestone19.0a1
Bug 805915 (part 2) - Add more detail to object memory reports. r=luke.
js/public/MemoryMetrics.h
js/src/jsmemorymetrics.cpp
js/xpconnect/src/XPCJSRuntime.cpp
--- a/js/public/MemoryMetrics.h
+++ b/js/public/MemoryMetrics.h
@@ -124,18 +124,21 @@ struct RuntimeSizes
 
 struct CompartmentStats
 {
     CompartmentStats()
       : extra1(0)
       , extra2(0)
       , gcHeapArenaAdmin(0)
       , gcHeapUnusedGcThings(0)
-      , gcHeapObjectsNonFunction(0)
+      , gcHeapObjectsOrdinary(0)
       , gcHeapObjectsFunction(0)
+      , gcHeapObjectsDenseArray(0)
+      , gcHeapObjectsSlowArray(0)
+      , gcHeapObjectsCrossCompartmentWrapper(0)
       , gcHeapStrings(0)
       , gcHeapShapesTree(0)
       , gcHeapShapesDict(0)
       , gcHeapShapesBase(0)
       , gcHeapScripts(0)
       , gcHeapTypeObjects(0)
       , gcHeapIonCodes(0)
 #if JS_HAS_XML_SUPPORT
@@ -159,18 +162,21 @@ struct CompartmentStats
       , debuggeesSet(0)
     {}
 
     CompartmentStats(const CompartmentStats &other)
       : extra1(other.extra1)
       , extra2(other.extra2)
       , gcHeapArenaAdmin(other.gcHeapArenaAdmin)
       , gcHeapUnusedGcThings(other.gcHeapUnusedGcThings)
-      , gcHeapObjectsNonFunction(other.gcHeapObjectsNonFunction)
+      , gcHeapObjectsOrdinary(other.gcHeapObjectsOrdinary)
       , gcHeapObjectsFunction(other.gcHeapObjectsFunction)
+      , gcHeapObjectsDenseArray(other.gcHeapObjectsDenseArray)
+      , gcHeapObjectsSlowArray(other.gcHeapObjectsSlowArray)
+      , gcHeapObjectsCrossCompartmentWrapper(other.gcHeapObjectsCrossCompartmentWrapper)
       , gcHeapStrings(other.gcHeapStrings)
       , gcHeapShapesTree(other.gcHeapShapesTree)
       , gcHeapShapesDict(other.gcHeapShapesDict)
       , gcHeapShapesBase(other.gcHeapShapesBase)
       , gcHeapScripts(other.gcHeapScripts)
       , gcHeapTypeObjects(other.gcHeapTypeObjects)
       , gcHeapIonCodes(other.gcHeapIonCodes)
 #if JS_HAS_XML_SUPPORT
@@ -201,18 +207,21 @@ struct CompartmentStats
     void   *extra1;
     void   *extra2;
 
     // If you add a new number, remember to update the constructors, add(), and
     // maybe gcHeapThingsSize()!
     size_t gcHeapArenaAdmin;
     size_t gcHeapUnusedGcThings;
 
-    size_t gcHeapObjectsNonFunction;
+    size_t gcHeapObjectsOrdinary;
     size_t gcHeapObjectsFunction;
+    size_t gcHeapObjectsDenseArray;
+    size_t gcHeapObjectsSlowArray;
+    size_t gcHeapObjectsCrossCompartmentWrapper;
     size_t gcHeapStrings;
     size_t gcHeapShapesTree;
     size_t gcHeapShapesDict;
     size_t gcHeapShapesBase;
     size_t gcHeapScripts;
     size_t gcHeapTypeObjects;
     size_t gcHeapIonCodes;
 #if JS_HAS_XML_SUPPORT
@@ -242,18 +251,21 @@ struct CompartmentStats
     // Add cStats's numbers to this object's numbers.
     void add(CompartmentStats &cStats)
     {
         #define ADD(x)  this->x += cStats.x
 
         ADD(gcHeapArenaAdmin);
         ADD(gcHeapUnusedGcThings);
 
-        ADD(gcHeapObjectsNonFunction);
+        ADD(gcHeapObjectsOrdinary);
         ADD(gcHeapObjectsFunction);
+        ADD(gcHeapObjectsDenseArray);
+        ADD(gcHeapObjectsSlowArray);
+        ADD(gcHeapObjectsCrossCompartmentWrapper);
         ADD(gcHeapStrings);
         ADD(gcHeapShapesTree);
         ADD(gcHeapShapesDict);
         ADD(gcHeapShapesBase);
         ADD(gcHeapScripts);
         ADD(gcHeapTypeObjects);
         ADD(gcHeapIonCodes);
     #if JS_HAS_XML_SUPPORT
--- a/js/src/jsmemorymetrics.cpp
+++ b/js/src/jsmemorymetrics.cpp
@@ -49,18 +49,21 @@ struct IteratorClosure
   }
 };
 
 size_t
 CompartmentStats::gcHeapThingsSize()
 {
     // These are just the GC-thing measurements.
     size_t n = 0;
-    n += gcHeapObjectsNonFunction;
+    n += gcHeapObjectsOrdinary;
     n += gcHeapObjectsFunction;
+    n += gcHeapObjectsDenseArray;
+    n += gcHeapObjectsSlowArray;
+    n += gcHeapObjectsCrossCompartmentWrapper;
     n += gcHeapStrings;
     n += gcHeapShapesTree;
     n += gcHeapShapesDict;
     n += gcHeapShapesBase;
     n += gcHeapScripts;
     n += gcHeapTypeObjects;
     n += gcHeapIonCodes;
 #if JS_HAS_XML_SUPPORT
@@ -136,18 +139,24 @@ StatsCellCallback(JSRuntime *rt, void *d
     RuntimeStats *rtStats = closure->rtStats;
     CompartmentStats *cStats = rtStats->currCompartmentStats;
     switch (traceKind) {
     case JSTRACE_OBJECT:
     {
         JSObject *obj = static_cast<JSObject *>(thing);
         if (obj->isFunction()) {
             cStats->gcHeapObjectsFunction += thingSize;
+        } else if (obj->isDenseArray()) {
+            cStats->gcHeapObjectsDenseArray += thingSize;
+        } else if (obj->isSlowArray()) {
+            cStats->gcHeapObjectsSlowArray += thingSize;
+        } else if (obj->isCrossCompartmentWrapper()) {
+            cStats->gcHeapObjectsCrossCompartmentWrapper += thingSize;
         } else {
-            cStats->gcHeapObjectsNonFunction += thingSize;
+            cStats->gcHeapObjectsOrdinary += thingSize;
         }
         size_t slotsSize, elementsSize, miscSize;
         obj->sizeOfExcludingThis(rtStats->mallocSizeOf, &slotsSize,
                                  &elementsSize, &miscSize);
         cStats->objectSlots += slotsSize;
         cStats->objectElements += elementsSize;
         cStats->objectMisc += miscSize;
 
--- a/js/xpconnect/src/XPCJSRuntime.cpp
+++ b/js/xpconnect/src/XPCJSRuntime.cpp
@@ -1466,26 +1466,42 @@ ReportCompartmentStats(const JS::Compart
                      "align GC things.");
 
     CREPORT_GC_BYTES(cJSPathPrefix + NS_LITERAL_CSTRING("gc-heap/unused-gc-things"),
                      cStats.gcHeapUnusedGcThings,
                      "Memory on the garbage-collected JavaScript "
                      "heap taken by empty GC thing slots within non-empty "
                      "arenas.");
 
-    CREPORT_GC_BYTES(cJSPathPrefix + NS_LITERAL_CSTRING("gc-heap/objects/non-function"),
-                     cStats.gcHeapObjectsNonFunction,
+    CREPORT_GC_BYTES(cJSPathPrefix + NS_LITERAL_CSTRING("gc-heap/objects/ordinary"),
+                     cStats.gcHeapObjectsOrdinary,
                      "Memory on the garbage-collected JavaScript "
-                     "heap that holds non-function objects.");
+                     "heap that holds ordinary (i.e. not otherwise distinguished "
+                     "my memory reporters) objects.");
 
     CREPORT_GC_BYTES(cJSPathPrefix + NS_LITERAL_CSTRING("gc-heap/objects/function"),
                      cStats.gcHeapObjectsFunction,
                      "Memory on the garbage-collected JavaScript "
                      "heap that holds function objects.");
 
+    CREPORT_GC_BYTES(cJSPathPrefix + NS_LITERAL_CSTRING("gc-heap/objects/dense-array"),
+                     cStats.gcHeapObjectsDenseArray,
+                     "Memory on the garbage-collected JavaScript "
+                     "heap that holds dense array objects.");
+
+    CREPORT_GC_BYTES(cJSPathPrefix + NS_LITERAL_CSTRING("gc-heap/objects/slow-array"),
+                     cStats.gcHeapObjectsSlowArray,
+                     "Memory on the garbage-collected JavaScript "
+                     "heap that holds slow array objects.");
+
+    CREPORT_GC_BYTES(cJSPathPrefix + NS_LITERAL_CSTRING("gc-heap/objects/cross-compartment-wrapper"),
+                     cStats.gcHeapObjectsCrossCompartmentWrapper,
+                     "Memory on the garbage-collected JavaScript "
+                     "heap that holds cross-compartment wrapper objects.");
+
     CREPORT_GC_BYTES(cJSPathPrefix + NS_LITERAL_CSTRING("gc-heap/strings"),
                      cStats.gcHeapStrings,
                      "Memory on the garbage-collected JavaScript "
                      "heap that holds string headers.  String headers contain "
                      "various pieces of information about a string, but do not "
                      "contain (except in the case of very short strings) the "
                      "string characters;  characters in longer strings are "
                      "counted under 'gc-heap/string-chars' instead.");