Bug 720219 (part 3) - Clean up JS shape measurement. r=bhackett.
authorNicholas Nethercote <nnethercote@mozilla.com>
Mon, 23 Jan 2012 15:39:00 -0800
changeset 86550 4af91c6b9316ec670db4510a5cd38e9d0f81f6aa
parent 86549 a818c5a6d0216e42826f95e43e3a6db1c579db43
child 86551 a6849eb97d824cdc6731de769c369f2cadf6204e
push id805
push userakeybl@mozilla.com
push dateWed, 01 Feb 2012 18:17:35 +0000
treeherdermozilla-aurora@6fb3bf232436 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbhackett
bugs720219
milestone12.0a1
Bug 720219 (part 3) - Clean up JS shape measurement. r=bhackett.
js/src/MemoryMetrics.cpp
js/src/jsscope.h
--- a/js/src/MemoryMetrics.cpp
+++ b/js/src/MemoryMetrics.cpp
@@ -141,26 +141,26 @@ CellCallback(JSContext *cx, void *vdata,
         JSString *str = static_cast<JSString *>(thing);
         curr->gcHeapStrings += thingSize;
         curr->stringChars += str->sizeOfExcludingThis(data->mallocSizeOf);
         break;
     }
     case JSTRACE_SHAPE:
     {
         Shape *shape = static_cast<Shape*>(thing);
+        size_t propTableSize, kidsSize;
+        shape->sizeOfExcludingThis(data->mallocSizeOf, &propTableSize, &kidsSize);
         if (shape->inDictionary()) {
             curr->gcHeapShapesDict += thingSize;
-            curr->shapesExtraDictTables +=
-                shape->sizeOfPropertyTable(data->mallocSizeOf);
+            curr->shapesExtraDictTables += propTableSize;
+            JS_ASSERT(kidsSize == 0);
         } else {
             curr->gcHeapShapesTree += thingSize;
-            curr->shapesExtraTreeTables +=
-                shape->sizeOfPropertyTable(data->mallocSizeOf);
-            curr->shapesExtraTreeShapeKids +=
-                shape->sizeOfKids(data->mallocSizeOf);
+            curr->shapesExtraTreeTables += propTableSize;
+            curr->shapesExtraTreeShapeKids += kidsSize;
         }
         break;
     }
     case JSTRACE_BASE_SHAPE:
     {
         curr->gcHeapShapesBase += thingSize;
         break;
     }
--- a/js/src/jsscope.h
+++ b/js/src/jsscope.h
@@ -542,25 +542,22 @@ struct Shape : public js::gc::Cell
     }
 
     bool makeOwnBaseShape(JSContext *cx);
 
   public:
     bool hasTable() const { return base()->hasTable(); }
     js::PropertyTable &table() const { return base()->table(); }
 
-    size_t sizeOfPropertyTable(JSMallocSizeOfFun mallocSizeOf) const {
-        return hasTable() ? table().sizeOfIncludingThis(mallocSizeOf) : 0;
-    }
-
-    size_t sizeOfKids(JSMallocSizeOfFun mallocSizeOf) const {
-        JS_ASSERT(!inDictionary());
-        return kids.isHash()
-             ? kids.toHash()->sizeOfIncludingThis(mallocSizeOf)
-             : 0;
+    void sizeOfExcludingThis(JSMallocSizeOfFun mallocSizeOf,
+                             size_t *propTableSize, size_t *kidsSize) const {
+        *propTableSize = hasTable() ? table().sizeOfIncludingThis(mallocSizeOf) : 0;
+        *kidsSize = !inDictionary() && kids.isHash()
+                  ? kids.toHash()->sizeOfIncludingThis(mallocSizeOf)
+                  : 0;
     }
 
     bool isNative() const {
         JS_ASSERT(!(flags & NON_NATIVE) == getObjectClass()->isNative());
         return !(flags & NON_NATIVE);
     }
 
     const HeapPtrShape &previous() const {