⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 117786 in webkit


Ignore:
Timestamp:
May 21, 2012, 9:02:07 AM (14 years ago)
Author:
loislo@chromium.org
Message:

Web Inspector: switch buildDominatedNodes function to front-end calculated _dominatorsTree
https://bugs.webkit.org/show_bug.cgi?id=87022

The new version is using _dominatorsTree array that was build at front-end.

Reviewed by Yury Semikhatsky.

Source/WebCore:

  • inspector/front-end/HeapSnapshot.js:

(WebInspector.HeapSnapshot.prototype._init):
(WebInspector.HeapSnapshot.prototype._buildDominatedNodes):

LayoutTests:

  • inspector/profiler/heap-snapshot-expected.txt:
  • inspector/profiler/heap-snapshot.html:
Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r117780 r117786  
     12012-05-21  Ilya Tikhonovsky  <loislo@chromium.org>
     2
     3        Web Inspector: switch buildDominatedNodes function to front-end calculated _dominatorsTree
     4        https://bugs.webkit.org/show_bug.cgi?id=87022
     5
     6        The new version is using _dominatorsTree array that was build at front-end.
     7
     8        Reviewed by Yury Semikhatsky.
     9
     10        * inspector/profiler/heap-snapshot-expected.txt:
     11        * inspector/profiler/heap-snapshot.html:
     12
    1132012-05-21  Ilya Tikhonovsky  <loislo@chromium.org>
    214
  • trunk/LayoutTests/inspector/profiler/heap-snapshot-expected.txt

    r117780 r117786  
    1818Running: heapSnapshotDominatorsTreeTest
    1919
     20Running: heapSnapshotDominatedNodesTest
     21
    2022Running: heapSnapshotPageOwnedTest
    2123
  • trunk/LayoutTests/inspector/profiler/heap-snapshot.html

    r117780 r117786  
    114114            for (var i = 0; i < expected.length; ++i)
    115115                InspectorTest.assertEquals(expected[i], dominatorsTree[i], "Dominators Tree");
     116            next();
     117        },
     118
     119        function heapSnapshotDominatedNodesTest(next)
     120        {
     121            var snapshot = new WebInspector.HeapSnapshot(InspectorTest.createHeapSnapshotMock());
     122
     123            var expectedDominatedNodes = [21, 14, 7, 28, 35];
     124            var actualDominatedNodes = snapshot._dominatedNodes;
     125            InspectorTest.assertEquals(expectedDominatedNodes.length, actualDominatedNodes.length, "Dominated Nodes length");
     126            for (var i = 0; i < expectedDominatedNodes.length; ++i)
     127                InspectorTest.assertEquals(expectedDominatedNodes[i], actualDominatedNodes[i], "Dominated Nodes");
     128
     129            var expectedDominatedNodeIndex = [0, 3, 3, 4, 5, 5, 5];
     130            var actualDominatedNodeIndex = snapshot._firstDominatedNodeIndex;
     131            InspectorTest.assertEquals(expectedDominatedNodeIndex.length, actualDominatedNodeIndex.length, "Dominated Nodes Index length");
     132            for (var i = 0; i < expectedDominatedNodeIndex.length; ++i)
     133                InspectorTest.assertEquals(expectedDominatedNodeIndex[i], actualDominatedNodeIndex[i], "Dominated Nodes Index");
    116134            next();
    117135        },
  • trunk/Source/WebCore/ChangeLog

    r117784 r117786  
     12012-05-21  Ilya Tikhonovsky  <loislo@chromium.org>
     2
     3        Web Inspector: switch buildDominatedNodes function to front-end calculated _dominatorsTree
     4        https://bugs.webkit.org/show_bug.cgi?id=87022
     5
     6        The new version is using _dominatorsTree array that was build at front-end.
     7
     8        Reviewed by Yury Semikhatsky.
     9
     10        * inspector/front-end/HeapSnapshot.js:
     11        (WebInspector.HeapSnapshot.prototype._init):
     12        (WebInspector.HeapSnapshot.prototype._buildDominatedNodes):
     13
    1142012-05-21  Pavel Feldman  <pfeldman@chromium.org>
    215
  • trunk/Source/WebCore/inspector/front-end/HeapSnapshot.js

    r117749 r117786  
    720720        this._markInvisibleEdges();
    721721        this._buildRetainers();
    722         if (this._dominatorOffset !== -1) // For tests where we may not have dominator field.
    723             this._buildDominatedNodes()
    724722        this._calculateFlags();
    725723        this._calculateObjectToWindowDistance();
    726724        var result = this._buildPostOrderIndex();
    727725        this._dominatorsTree = this._buildDominatorTree(result.postOrderIndex2NodeIndex, result.nodeOrdinal2PostOrderIndex);
     726        this._buildDominatedNodes();
    728727    },
    729728
     
    12711270        // Count the number of dominated nodes for each node. Skip the root (node at
    12721271        // index 0) as it is the only node that dominates itself.
    1273         for (var nodeIndex = this._nodeFieldCount; nodeIndex < this._nodes.length; nodeIndex += this._nodeFieldCount) {
    1274             var dominatorIndex = this._nodes[nodeIndex + this._dominatorOffset];
    1275             if (dominatorIndex % this._nodeFieldCount)
    1276                 throw new Error("Wrong dominatorIndex " + dominatorIndex + " nodeIndex = " + nodeIndex + " nodeCount = " + this.nodeCount);
    1277             ++indexArray[dominatorIndex / this._nodeFieldCount];
    1278         }
     1272        var nodeFieldCount = this._nodeFieldCount;
     1273        var dominatorsTree = this._dominatorsTree;
     1274        for (var nodeOrdinal = 1, l = this.nodeCount; nodeOrdinal < l; ++nodeOrdinal)
     1275            ++indexArray[dominatorsTree[nodeOrdinal] / this._nodeFieldCount];
    12791276        // Put in the first slot of each dominatedNodes slice the count of entries
    12801277        // that will be filled.
    12811278        var firstDominatedNodeIndex = 0;
    1282         for (var i = 0; i < this.nodeCount; ++i) {
     1279        for (var i = 0, l = this.nodeCount; i < l; ++i) {
    12831280            var dominatedCount = dominatedNodes[firstDominatedNodeIndex] = indexArray[i];
    12841281            indexArray[i] = firstDominatedNodeIndex;
     
    12881285        // Fill up the dominatedNodes array with indexes of dominated nodes. Skip the root (node at
    12891286        // index 0) as it is the only node that dominates itself.
    1290         for (var nodeIndex = this._nodeFieldCount; nodeIndex < this._nodes.length; nodeIndex += this._nodeFieldCount) {
    1291             var dominatorIndex = this._nodes[nodeIndex + this._dominatorOffset];
    1292             if (dominatorIndex % this._nodeFieldCount)
    1293                 throw new Error("Wrong dominatorIndex " + dominatorIndex);
    1294             var dominatorPos = dominatorIndex / this._nodeFieldCount;
    1295             var dominatedRefIndex = indexArray[dominatorPos];
     1287        for (var nodeOrdinal = 1, l = this.nodeCount; nodeOrdinal < l; ++nodeOrdinal) {
     1288            var dominatorOrdinal = dominatorsTree[nodeOrdinal] / nodeFieldCount;
     1289            var dominatedRefIndex = indexArray[dominatorOrdinal];
    12961290            dominatedRefIndex += (--dominatedNodes[dominatedRefIndex]);
    1297             dominatedNodes[dominatedRefIndex] = nodeIndex;
     1291            dominatedNodes[dominatedRefIndex] = nodeOrdinal * nodeFieldCount;
    12981292        }
    12991293    },
Note: See TracChangeset for help on using the changeset viewer.