| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2011 Google Inc. All rights reserved. | 2 * Copyright (C) 2011 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 29 */ | 29 */ |
| 30 | 30 |
| 31 /** | 31 /** |
| 32 * @constructor | 32 * @constructor |
| 33 * @param {!WebInspector.HeapSnapshot} snapshot | 33 * @param {!Uint32Array} array |
| 34 * @param {!Uint32Array} edges | 34 * @param {number} start |
| 35 * @param {number} end |
| 36 */ |
| 37 WebInspector.HeapSnapshotArraySlice = function(array, start, end) |
| 38 { |
| 39 this._array = array; |
| 40 this._start = start; |
| 41 this.length = end - start; |
| 42 } |
| 43 |
| 44 WebInspector.HeapSnapshotArraySlice.prototype = { |
| 45 /** |
| 46 * @param {number} index |
| 47 * @return {number} |
| 48 */ |
| 49 item: function(index) |
| 50 { |
| 51 return this._array[this._start + index]; |
| 52 }, |
| 53 |
| 54 /** |
| 55 * @param {number} start |
| 56 * @param {number=} end |
| 57 * @return {!Uint32Array} |
| 58 */ |
| 59 slice: function(start, end) |
| 60 { |
| 61 if (typeof end === "undefined") |
| 62 end = this.length; |
| 63 return this._array.subarray(this._start + start, this._start + end); |
| 64 } |
| 65 } |
| 66 |
| 67 /** |
| 68 * @constructor |
| 35 * @param {number=} edgeIndex | 69 * @param {number=} edgeIndex |
| 36 */ | 70 */ |
| 37 WebInspector.HeapSnapshotEdge = function(snapshot, edges, edgeIndex) | 71 WebInspector.HeapSnapshotEdge = function(snapshot, edges, edgeIndex) |
| 38 { | 72 { |
| 39 this._snapshot = snapshot; | 73 this._snapshot = snapshot; |
| 40 this._edges = edges; | 74 this._edges = edges; |
| 41 this.edgeIndex = edgeIndex || 0; | 75 this.edgeIndex = edgeIndex || 0; |
| 42 } | 76 } |
| 43 | 77 |
| 44 /** | 78 /** |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 88 node: function() | 122 node: function() |
| 89 { | 123 { |
| 90 return this._snapshot.createNode(this.nodeIndex()); | 124 return this._snapshot.createNode(this.nodeIndex()); |
| 91 }, | 125 }, |
| 92 | 126 |
| 93 /** | 127 /** |
| 94 * @return {number} | 128 * @return {number} |
| 95 */ | 129 */ |
| 96 nodeIndex: function() | 130 nodeIndex: function() |
| 97 { | 131 { |
| 98 return this._edges[this.edgeIndex + this._snapshot._edgeToNodeOffset]; | 132 return this._edges.item(this.edgeIndex + this._snapshot._edgeToNodeOffse
t); |
| 99 }, | 133 }, |
| 100 | 134 |
| 101 /** | 135 /** |
| 136 * @return {!Array.<number>} |
| 137 */ |
| 138 rawEdges: function() |
| 139 { |
| 140 return this._edges; |
| 141 }, |
| 142 |
| 143 /** |
| 102 * @return {string} | 144 * @return {string} |
| 103 */ | 145 */ |
| 104 toString: function() | 146 toString: function() |
| 105 { | 147 { |
| 106 return "HeapSnapshotEdge: " + this.name(); | 148 return "HeapSnapshotEdge: " + this.name(); |
| 107 }, | 149 }, |
| 108 | 150 |
| 109 /** | 151 /** |
| 110 * @return {string} | 152 * @return {string} |
| 111 */ | 153 */ |
| 112 type: function() | 154 type: function() |
| 113 { | 155 { |
| 114 return this._snapshot._edgeTypes[this._type()]; | 156 return this._snapshot._edgeTypes[this._type()]; |
| 115 }, | 157 }, |
| 116 | 158 |
| 117 /** | 159 /** |
| 118 * @return {!WebInspector.HeapSnapshotEdge.Serialized} | 160 * @return {!WebInspector.HeapSnapshotEdge.Serialized} |
| 119 */ | 161 */ |
| 120 serialize: function() | 162 serialize: function() |
| 121 { | 163 { |
| 122 var node = this.node(); | 164 var node = this.node(); |
| 123 return new WebInspector.HeapSnapshotEdge.Serialized(this.name(), node.se
rialize(), this.nodeIndex(), this.type(), node.distance()); | 165 return new WebInspector.HeapSnapshotEdge.Serialized(this.name(), node.se
rialize(), this.nodeIndex(), this.type(), node.distance()); |
| 124 }, | 166 }, |
| 125 | 167 |
| 126 _type: function() | 168 _type: function() |
| 127 { | 169 { |
| 128 return this._edges[this.edgeIndex + this._snapshot._edgeTypeOffset]; | 170 return this._edges.item(this.edgeIndex + this._snapshot._edgeTypeOffset)
; |
| 129 } | 171 } |
| 130 }; | 172 }; |
| 131 | 173 |
| 132 /** | 174 /** |
| 133 * @constructor | 175 * @constructor |
| 134 */ | 176 */ |
| 135 WebInspector.HeapSnapshotEdgeIterator = function(edge) | 177 WebInspector.HeapSnapshotEdgeIterator = function(edge) |
| 136 { | 178 { |
| 137 this.edge = edge; | 179 this.edge = edge; |
| 138 } | 180 } |
| (...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 474 | 516 |
| 475 /** | 517 /** |
| 476 * @return {string} | 518 * @return {string} |
| 477 */ | 519 */ |
| 478 name: function() | 520 name: function() |
| 479 { | 521 { |
| 480 return this._snapshot._strings[this._name()]; | 522 return this._snapshot._strings[this._name()]; |
| 481 }, | 523 }, |
| 482 | 524 |
| 483 /** | 525 /** |
| 484 * @return {!Uint32Array} | 526 * @return {!WebInspector.HeapSnapshotArraySlice} |
| 485 */ | 527 */ |
| 486 rawEdges: function() | 528 rawEdges: function() |
| 487 { | 529 { |
| 488 return this._snapshot._containmentEdges.subarray(this._edgeIndexesStart(
), this._edgeIndexesEnd()); | 530 return new WebInspector.HeapSnapshotArraySlice(this._snapshot._containme
ntEdges, this._edgeIndexesStart(), this._edgeIndexesEnd()); |
| 489 }, | 531 }, |
| 490 | 532 |
| 491 /** | 533 /** |
| 492 * @return {number} | 534 * @return {number} |
| 493 */ | 535 */ |
| 494 retainedSize: function() | 536 retainedSize: function() |
| 495 { | 537 { |
| 496 return this._snapshot._retainedSizes[this._ordinal()]; | 538 return this._snapshot._retainedSizes[this._ordinal()]; |
| 497 }, | 539 }, |
| 498 | 540 |
| (...skipping 450 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 949 return this.rootNode().retainedSize(); | 991 return this.rootNode().retainedSize(); |
| 950 }, | 992 }, |
| 951 | 993 |
| 952 _getDominatedIndex: function(nodeIndex) | 994 _getDominatedIndex: function(nodeIndex) |
| 953 { | 995 { |
| 954 if (nodeIndex % this._nodeFieldCount) | 996 if (nodeIndex % this._nodeFieldCount) |
| 955 throw new Error("Invalid nodeIndex: " + nodeIndex); | 997 throw new Error("Invalid nodeIndex: " + nodeIndex); |
| 956 return this._firstDominatedNodeIndex[nodeIndex / this._nodeFieldCount]; | 998 return this._firstDominatedNodeIndex[nodeIndex / this._nodeFieldCount]; |
| 957 }, | 999 }, |
| 958 | 1000 |
| 959 /** | |
| 960 * @param {!WebInspector.HeapSnapshotNode} node | |
| 961 * @return {!Uint32Array} | |
| 962 */ | |
| 963 _dominatedNodesOfNode: function(node) | 1001 _dominatedNodesOfNode: function(node) |
| 964 { | 1002 { |
| 965 var dominatedIndexFrom = this._getDominatedIndex(node.nodeIndex); | 1003 var dominatedIndexFrom = this._getDominatedIndex(node.nodeIndex); |
| 966 var dominatedIndexTo = this._getDominatedIndex(node._nextNodeIndex()); | 1004 var dominatedIndexTo = this._getDominatedIndex(node._nextNodeIndex()); |
| 967 return this._dominatedNodes.subarray(dominatedIndexFrom, dominatedIndexT
o); | 1005 return new WebInspector.HeapSnapshotArraySlice(this._dominatedNodes, dom
inatedIndexFrom, dominatedIndexTo); |
| 968 }, | 1006 }, |
| 969 | 1007 |
| 970 /** | 1008 /** |
| 971 * @param {!WebInspector.HeapSnapshotCommon.NodeFilter} nodeFilter | 1009 * @param {!WebInspector.HeapSnapshotCommon.NodeFilter} nodeFilter |
| 972 * @return {!Object.<string, !WebInspector.HeapSnapshotCommon.Aggregate>} | 1010 * @return {!Object.<string, !WebInspector.HeapSnapshotCommon.Aggregate>} |
| 973 */ | 1011 */ |
| 974 aggregatesWithFilter: function(nodeFilter) | 1012 aggregatesWithFilter: function(nodeFilter) |
| 975 { | 1013 { |
| 976 var minNodeId = nodeFilter.minNodeId; | 1014 var minNodeId = nodeFilter.minNodeId; |
| 977 var maxNodeId = nodeFilter.maxNodeId; | 1015 var maxNodeId = nodeFilter.maxNodeId; |
| (...skipping 907 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1885 * @return {!WebInspector.HeapSnapshotCommon.StaticData} | 1923 * @return {!WebInspector.HeapSnapshotCommon.StaticData} |
| 1886 */ | 1924 */ |
| 1887 updateStaticData: function() | 1925 updateStaticData: function() |
| 1888 { | 1926 { |
| 1889 return new WebInspector.HeapSnapshotCommon.StaticData(this.nodeCount, th
is._rootNodeIndex, this.totalSize, this._maxJsNodeId()); | 1927 return new WebInspector.HeapSnapshotCommon.StaticData(this.nodeCount, th
is._rootNodeIndex, this.totalSize, this._maxJsNodeId()); |
| 1890 } | 1928 } |
| 1891 }; | 1929 }; |
| 1892 | 1930 |
| 1893 /** | 1931 /** |
| 1894 * @constructor | 1932 * @constructor |
| 1895 * @param {(!Array.<number>|!Uint32Array)=} unfilteredIterationOrder | 1933 * @param {!Array.<number>=} unfilteredIterationOrder |
| 1896 */ | 1934 */ |
| 1897 WebInspector.HeapSnapshotFilteredOrderedIterator = function(iterator, filter, un
filteredIterationOrder) | 1935 WebInspector.HeapSnapshotFilteredOrderedIterator = function(iterator, filter, un
filteredIterationOrder) |
| 1898 { | 1936 { |
| 1899 this._filter = filter; | 1937 this._filter = filter; |
| 1900 this._iterator = iterator; | 1938 this._iterator = iterator; |
| 1901 this._unfilteredIterationOrder = unfilteredIterationOrder; | 1939 this._unfilteredIterationOrder = unfilteredIterationOrder; |
| 1902 /** @type {?Array.<number>|?Uint32Array} */ | |
| 1903 this._iterationOrder = null; | 1940 this._iterationOrder = null; |
| 1904 this._position = 0; | 1941 this._position = 0; |
| 1905 this._currentComparator = null; | 1942 this._currentComparator = null; |
| 1906 this._sortedPrefixLength = 0; | 1943 this._sortedPrefixLength = 0; |
| 1907 this._sortedSuffixLength = 0; | 1944 this._sortedSuffixLength = 0; |
| 1908 } | 1945 } |
| 1909 | 1946 |
| 1910 WebInspector.HeapSnapshotFilteredOrderedIterator.prototype = { | 1947 WebInspector.HeapSnapshotFilteredOrderedIterator.prototype = { |
| 1911 _createIterationOrder: function() | 1948 _createIterationOrder: function() |
| 1912 { | 1949 { |
| 1913 if (this._iterationOrder) | 1950 if (this._iterationOrder) |
| 1914 return; | 1951 return; |
| 1915 if (this._unfilteredIterationOrder && !this._filter) { | 1952 if (this._unfilteredIterationOrder && !this._filter) { |
| 1916 this._iterationOrder = this._unfilteredIterationOrder; | 1953 this._iterationOrder = this._unfilteredIterationOrder.slice(0); |
| 1917 this._unfilteredIterationOrder = null; | 1954 this._unfilteredIterationOrder = null; |
| 1918 return; | 1955 return; |
| 1919 } | 1956 } |
| 1920 this._iterationOrder = []; | 1957 this._iterationOrder = []; |
| 1921 var iterator = this._iterator; | 1958 var iterator = this._iterator; |
| 1922 if (!this._unfilteredIterationOrder && !this._filter) { | 1959 if (!this._unfilteredIterationOrder && !this._filter) { |
| 1923 for (iterator.rewind(); iterator.hasNext(); iterator.next()) | 1960 for (iterator.rewind(); iterator.hasNext(); iterator.next()) |
| 1924 this._iterationOrder.push(iterator.index()); | 1961 this._iterationOrder.push(iterator.index()); |
| 1925 } else if (!this._unfilteredIterationOrder) { | 1962 } else if (!this._unfilteredIterationOrder) { |
| 1926 for (iterator.rewind(); iterator.hasNext(); iterator.next()) { | 1963 for (iterator.rewind(); iterator.hasNext(); iterator.next()) { |
| 1927 if (this._filter(iterator.item())) | 1964 if (this._filter(iterator.item())) |
| 1928 this._iterationOrder.push(iterator.index()); | 1965 this._iterationOrder.push(iterator.index()); |
| 1929 } | 1966 } |
| 1930 } else { | 1967 } else { |
| 1931 var order = this._unfilteredIterationOrder; | 1968 var order = this._unfilteredIterationOrder.constructor === Array ? |
| 1969 this._unfilteredIterationOrder : this._unfilteredIterationOrder.
slice(0); |
| 1932 for (var i = 0, l = order.length; i < l; ++i) { | 1970 for (var i = 0, l = order.length; i < l; ++i) { |
| 1933 iterator.setIndex(order[i]); | 1971 iterator.setIndex(order[i]); |
| 1934 if (this._filter(iterator.item())) | 1972 if (this._filter(iterator.item())) |
| 1935 this._iterationOrder.push(iterator.index()); | 1973 this._iterationOrder.push(iterator.index()); |
| 1936 } | 1974 } |
| 1937 this._unfilteredIterationOrder = null; | 1975 this._unfilteredIterationOrder = null; |
| 1938 } | 1976 } |
| 1939 }, | 1977 }, |
| 1940 | 1978 |
| 1941 rewind: function() | 1979 rewind: function() |
| (...skipping 20 matching lines...) Expand all Loading... |
| 1962 return !this._unfilteredIterationOrder.length; | 2000 return !this._unfilteredIterationOrder.length; |
| 1963 var iterator = this._iterator; | 2001 var iterator = this._iterator; |
| 1964 if (!this._unfilteredIterationOrder && !this._filter) { | 2002 if (!this._unfilteredIterationOrder && !this._filter) { |
| 1965 iterator.rewind(); | 2003 iterator.rewind(); |
| 1966 return !iterator.hasNext(); | 2004 return !iterator.hasNext(); |
| 1967 } else if (!this._unfilteredIterationOrder) { | 2005 } else if (!this._unfilteredIterationOrder) { |
| 1968 for (iterator.rewind(); iterator.hasNext(); iterator.next()) | 2006 for (iterator.rewind(); iterator.hasNext(); iterator.next()) |
| 1969 if (this._filter(iterator.item())) | 2007 if (this._filter(iterator.item())) |
| 1970 return false; | 2008 return false; |
| 1971 } else { | 2009 } else { |
| 1972 var order = this._unfilteredIterationOrder; | 2010 var order = this._unfilteredIterationOrder.constructor === Array ? |
| 2011 this._unfilteredIterationOrder : this._unfilteredIterationOrder.
slice(0); |
| 1973 for (var i = 0, l = order.length; i < l; ++i) { | 2012 for (var i = 0, l = order.length; i < l; ++i) { |
| 1974 iterator.setIndex(order[i]); | 2013 iterator.setIndex(order[i]); |
| 1975 if (this._filter(iterator.item())) | 2014 if (this._filter(iterator.item())) |
| 1976 return false; | 2015 return false; |
| 1977 } | 2016 } |
| 1978 } | 2017 } |
| 1979 return true; | 2018 return true; |
| 1980 }, | 2019 }, |
| 1981 | 2020 |
| 1982 /** | 2021 /** |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2132 this._iterationOrder.sortRange(compareNodeAndNode, leftBound, rightB
ound, windowLeft, windowRight); | 2171 this._iterationOrder.sortRange(compareNodeAndNode, leftBound, rightB
ound, windowLeft, windowRight); |
| 2133 }, | 2172 }, |
| 2134 | 2173 |
| 2135 __proto__: WebInspector.HeapSnapshotFilteredOrderedIterator.prototype | 2174 __proto__: WebInspector.HeapSnapshotFilteredOrderedIterator.prototype |
| 2136 } | 2175 } |
| 2137 | 2176 |
| 2138 | 2177 |
| 2139 /** | 2178 /** |
| 2140 * @constructor | 2179 * @constructor |
| 2141 * @extends {WebInspector.HeapSnapshotFilteredOrderedIterator} | 2180 * @extends {WebInspector.HeapSnapshotFilteredOrderedIterator} |
| 2142 * @param {(!Array.<number>|!Uint32Array)=} nodeIndexes | 2181 * @param {!Array.<number>=} nodeIndexes |
| 2143 */ | 2182 */ |
| 2144 WebInspector.HeapSnapshotNodesProvider = function(snapshot, filter, nodeIndexes) | 2183 WebInspector.HeapSnapshotNodesProvider = function(snapshot, filter, nodeIndexes) |
| 2145 { | 2184 { |
| 2146 this.snapshot = snapshot; | 2185 this.snapshot = snapshot; |
| 2147 WebInspector.HeapSnapshotFilteredOrderedIterator.call(this, snapshot._allNod
es(), filter, nodeIndexes); | 2186 WebInspector.HeapSnapshotFilteredOrderedIterator.call(this, snapshot._allNod
es(), filter, nodeIndexes); |
| 2148 } | 2187 } |
| 2149 | 2188 |
| 2150 WebInspector.HeapSnapshotNodesProvider.prototype = { | 2189 WebInspector.HeapSnapshotNodesProvider.prototype = { |
| 2151 /** | 2190 /** |
| 2152 * @param {string} snapshotObjectId | 2191 * @param {string} snapshotObjectId |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2222 * @param {number} windowRight | 2261 * @param {number} windowRight |
| 2223 */ | 2262 */ |
| 2224 sort: function(comparator, leftBound, rightBound, windowLeft, windowRight) | 2263 sort: function(comparator, leftBound, rightBound, windowLeft, windowRight) |
| 2225 { | 2264 { |
| 2226 this._iterationOrder.sortRange(this._buildCompareFunction(comparator), l
eftBound, rightBound, windowLeft, windowRight); | 2265 this._iterationOrder.sortRange(this._buildCompareFunction(comparator), l
eftBound, rightBound, windowLeft, windowRight); |
| 2227 }, | 2266 }, |
| 2228 | 2267 |
| 2229 __proto__: WebInspector.HeapSnapshotFilteredOrderedIterator.prototype | 2268 __proto__: WebInspector.HeapSnapshotFilteredOrderedIterator.prototype |
| 2230 } | 2269 } |
| 2231 | 2270 |
| OLD | NEW |