Title: [119714] trunk
Revision
119714
Author
[email protected]
Date
2012-06-07 06:09:18 -0700 (Thu, 07 Jun 2012)

Log Message

Web Inspector: reuse edge_count field of heap snapshot to store retained size
https://bugs.webkit.org/show_bug.cgi?id=88416

The edge_count field is unused after node first edge indexes have been built.
Store node retained size in there instead of allocating an extra array for it.

Patch by Alexei Filippov <[email protected]> on 2012-06-07
Reviewed by Vsevolod Vlasov.

Source/WebCore:

* inspector/front-end/HeapSnapshot.js:
(WebInspector.HeapSnapshotNode.prototype.retainedSize):
(WebInspector.HeapSnapshot.prototype._calculateRetainedSizes):

LayoutTests:

* inspector/profiler/heap-snapshot.html:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (119713 => 119714)


--- trunk/LayoutTests/ChangeLog	2012-06-07 12:59:54 UTC (rev 119713)
+++ trunk/LayoutTests/ChangeLog	2012-06-07 13:09:18 UTC (rev 119714)
@@ -1,3 +1,15 @@
+2012-06-07  Alexei Filippov  <[email protected]>
+
+        Web Inspector: reuse edge_count field of heap snapshot to store retained size
+        https://bugs.webkit.org/show_bug.cgi?id=88416
+
+        The edge_count field is unused after node first edge indexes have been built.
+        Store node retained size in there instead of allocating an extra array for it.
+
+        Reviewed by Vsevolod Vlasov.
+
+        * inspector/profiler/heap-snapshot.html:
+
 2012-06-07  Sheriff Bot  <[email protected]>
 
         Unreviewed, rolling out r119694.

Modified: trunk/LayoutTests/inspector/profiler/heap-snapshot.html (119713 => 119714)


--- trunk/LayoutTests/inspector/profiler/heap-snapshot.html	2012-06-07 12:59:54 UTC (rev 119713)
+++ trunk/LayoutTests/inspector/profiler/heap-snapshot.html	2012-06-07 13:09:18 UTC (rev 119714)
@@ -132,7 +132,7 @@
             var snapshot = new WebInspector.HeapSnapshot(InspectorTest.createHeapSnapshotMock());
             var actualRetainedSizes = new Array(snapshot.nodeCount);
             for (var nodeOrdinal = 0; nodeOrdinal < snapshot.nodeCount; ++nodeOrdinal)
-                actualRetainedSizes[nodeOrdinal] = snapshot._retainedSizes[nodeOrdinal];
+                actualRetainedSizes[nodeOrdinal] = snapshot._nodes[nodeOrdinal * snapshot._nodeFieldCount + snapshot._nodeRetainedSizeOffset];
             var expectedRetainedSizes = [20, 2, 8, 10, 5, 6];
             InspectorTest.assertEquals(JSON.stringify(expectedRetainedSizes), JSON.stringify(actualRetainedSizes), "Retained sizes");
             next();

Modified: trunk/Source/WebCore/ChangeLog (119713 => 119714)


--- trunk/Source/WebCore/ChangeLog	2012-06-07 12:59:54 UTC (rev 119713)
+++ trunk/Source/WebCore/ChangeLog	2012-06-07 13:09:18 UTC (rev 119714)
@@ -1,3 +1,17 @@
+2012-06-07  Alexei Filippov  <[email protected]>
+
+        Web Inspector: reuse edge_count field of heap snapshot to store retained size
+        https://bugs.webkit.org/show_bug.cgi?id=88416
+
+        The edge_count field is unused after node first edge indexes have been built.
+        Store node retained size in there instead of allocating an extra array for it.
+
+        Reviewed by Vsevolod Vlasov.
+
+        * inspector/front-end/HeapSnapshot.js:
+        (WebInspector.HeapSnapshotNode.prototype.retainedSize):
+        (WebInspector.HeapSnapshot.prototype._calculateRetainedSizes):
+
 2012-06-07  Sheriff Bot  <[email protected]>
 
         Unreviewed, rolling out r119694.

Modified: trunk/Source/WebCore/inspector/front-end/HeapSnapshot.js (119713 => 119714)


--- trunk/Source/WebCore/inspector/front-end/HeapSnapshot.js	2012-06-07 12:59:54 UTC (rev 119713)
+++ trunk/Source/WebCore/inspector/front-end/HeapSnapshot.js	2012-06-07 13:09:18 UTC (rev 119714)
@@ -508,7 +508,8 @@
 
     retainedSize: function()
     {
-        return this._snapshot._retainedSizes[this.nodeIndex / this._snapshot._nodeFieldCount];
+        var snapshot = this._snapshot;
+        return snapshot._nodes[this.nodeIndex + snapshot._nodeRetainedSizeOffset];
     },
 
     retainers: function()
@@ -1277,16 +1278,19 @@
         var nodeSelfSizeOffset = this._nodeSelfSizeOffset;
         var nodeFieldCount = this._nodeFieldCount;
         var dominatorsTree = this._dominatorsTree;
-        var retainedSizes = this._retainedSizes = new Uint32Array(nodeCount);
-        var rootNodeOrdinal = this._rootNodeIndex / nodeFieldCount;
+        // Reuse now unused edge_count field to store retained size.
+        var nodeRetainedSizeOffset = this._nodeRetainedSizeOffset = this._nodeEdgeCountOffset;
+        delete this._nodeEdgeCountOffset;
 
-        retainedSizes[rootNodeOrdinal] = nodes[this._rootNodeIndex + nodeSelfSizeOffset];
-        // Propagate retained sizes for each node excluding root, as it refers to self.
+        for (var nodeIndex = 0, l = nodes.length; nodeIndex < l; nodeIndex += nodeFieldCount)
+            nodes[nodeIndex + nodeRetainedSizeOffset] = nodes[nodeIndex + nodeSelfSizeOffset];
+
+        // Propagate retained sizes for each node excluding root.
         for (var postOrderIndex = 0; postOrderIndex < nodeCount - 1; ++postOrderIndex) {
             var nodeOrdinal = postOrderIndex2NodeOrdinal[postOrderIndex];
-            var dominatorOrdinal = dominatorsTree[nodeOrdinal];
-            retainedSizes[nodeOrdinal] += nodes[nodeOrdinal * nodeFieldCount + nodeSelfSizeOffset];
-            retainedSizes[dominatorOrdinal] += retainedSizes[nodeOrdinal];
+            var nodeIndex = nodeOrdinal * nodeFieldCount;
+            var dominatorIndex = dominatorsTree[nodeOrdinal] * nodeFieldCount;
+            nodes[dominatorIndex + nodeRetainedSizeOffset] += nodes[nodeIndex + nodeRetainedSizeOffset];
         }
     },
 
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to