Web Inspector: speed-up markQueriableHeapObjects function.
authorloislo@chromium.org <loislo@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 18 May 2012 05:44:42 +0000 (05:44 +0000)
committerloislo@chromium.org <loislo@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 18 May 2012 05:44:42 +0000 (05:44 +0000)
https://bugs.webkit.org/show_bug.cgi?id=86732

Reviewed by Yury Semikhatsky.

* inspector/front-end/HeapSnapshot.js:
(WebInspector.HeapSnapshot.prototype._flagsOfNode):
(WebInspector.HeapSnapshot.prototype._markDetachedDOMTreeNodes):
(WebInspector.HeapSnapshot.prototype._markQueriableHeapObjects):
(WebInspector.HeapSnapshot.prototype._calculateFlags):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@117545 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/inspector/front-end/HeapSnapshot.js

index 30718eb..39b01a0 100644 (file)
@@ -1,3 +1,16 @@
+2012-05-17  Ilya Tikhonovsky  <loislo@chromium.org>
+
+        Web Inspector: speed-up markQueriableHeapObjects function.
+        https://bugs.webkit.org/show_bug.cgi?id=86732
+
+        Reviewed by Yury Semikhatsky.
+
+        * inspector/front-end/HeapSnapshot.js:
+        (WebInspector.HeapSnapshot.prototype._flagsOfNode):
+        (WebInspector.HeapSnapshot.prototype._markDetachedDOMTreeNodes):
+        (WebInspector.HeapSnapshot.prototype._markQueriableHeapObjects):
+        (WebInspector.HeapSnapshot.prototype._calculateFlags):
+
 2012-05-15  Kinuko Yasuda  <kinuko@chromium.org>
 
         Some Spelling Mistakes Result in Compile Errors with ENABLE(FILE_SYSTEM) in LocalFileSystem.cpp
index a0d6549..301c782 100644 (file)
@@ -825,7 +825,7 @@ WebInspector.HeapSnapshot.prototype = {
 
     _flagsOfNode: function(node)
     {
-        return this._flags[node.nodeIndex];
+        return this._flags[node.nodeIndex / this._nodeFieldCount];
     },
 
     /**
@@ -1155,7 +1155,7 @@ WebInspector.HeapSnapshot.prototype = {
             var node = iter.edge.node;
             if (node.isDetachedDOMTree) {
                 for (var edgesIter = node.edges; edgesIter.hasNext(); edgesIter.next())
-                    this._flags[edgesIter.edge.node.nodeIndex] |= flag;
+                    this._flags[edgesIter.edge.node.nodeIndex / this._nodeFieldCount] |= flag;
             }
         }
     },
@@ -1172,6 +1172,11 @@ WebInspector.HeapSnapshot.prototype = {
         var edgeToNodeOffset = this._edgeToNodeOffset;
         var edgeTypeOffset = this._edgeTypeOffset;
         var edgeFieldsCount = this._edgeFieldsCount;
+        var containmentEdges = this._containmentEdges;
+        var nodes = this._nodes;
+        var nodeCount = this.nodeCount;
+        var nodeFieldCount = this._nodeFieldCount;
+        var firstEdgeIndexOffset = this._firstEdgeIndexOffset;
 
         var flags = this._flags;
         var list = [];
@@ -1180,31 +1185,31 @@ WebInspector.HeapSnapshot.prototype = {
                 list.push(iter.edge.node.nodeIndex);
         }
 
-        var node = new WebInspector.HeapSnapshotNode(this);
         while (list.length) {
             var nodeIndex = list.pop();
-            if (flags[nodeIndex] & flag)
+            var nodeOrdinal = nodeIndex / nodeFieldCount;
+            if (flags[nodeOrdinal] & flag)
                 continue;
-            node.nodeIndex = nodeIndex;
-            flags[nodeIndex] |= flag;
-            var edgesCount = node.edgesCount;
-            var edges = node.rawEdges;
-            for (var j = 0; j < edgesCount; ++j) {
-                var edgeIndex = j * edgeFieldsCount;
-                nodeIndex = edges.item(edgeIndex + edgeToNodeOffset);
-                if (flags[nodeIndex] & flag)
+            flags[nodeOrdinal] |= flag;
+            var beginEdgeIndex = nodes[nodeIndex + firstEdgeIndexOffset];
+            var endEdgeIndex = nodeOrdinal < nodeCount - 1
+                               ? nodes[nodeIndex + firstEdgeIndexOffset + nodeFieldCount]
+                               : containmentEdges.length;
+            for (var edgeIndex = beginEdgeIndex; edgeIndex < endEdgeIndex; edgeIndex += edgeFieldsCount) {
+                var childNodeIndex = containmentEdges[edgeIndex + edgeToNodeOffset];
+                if (flags[childNodeIndex / nodeFieldCount] & flag)
                     continue;
-                var type = edges.item(edgeIndex + edgeTypeOffset);
+                var type = containmentEdges[edgeIndex + edgeTypeOffset];
                 if (type === hiddenEdgeType || type === invisibleEdgeType || type === internalEdgeType)
                     continue;
-                list.push(nodeIndex);
+                list.push(childNodeIndex);
             }
         }
     },
 
     _calculateFlags: function()
     {
-        this._flags = new Array(this.nodeCount);
+        this._flags = new Uint32Array(this.nodeCount);
         this._markDetachedDOMTreeNodes();
         this._markQueriableHeapObjects();
     },