Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(243)

Side by Side Diff: Source/devtools/front_end/HeapSnapshot.js

Issue 197533009: Remove WebInspector.HeapSnapshotArraySlice (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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 {!Uint32Array} array 33 * @param {!WebInspector.HeapSnapshot} snapshot
34 * @param {number} start 34 * @param {!Uint32Array} edges
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
69 * @param {number=} edgeIndex 35 * @param {number=} edgeIndex
70 */ 36 */
71 WebInspector.HeapSnapshotEdge = function(snapshot, edges, edgeIndex) 37 WebInspector.HeapSnapshotEdge = function(snapshot, edges, edgeIndex)
72 { 38 {
73 this._snapshot = snapshot; 39 this._snapshot = snapshot;
74 this._edges = edges; 40 this._edges = edges;
75 this.edgeIndex = edgeIndex || 0; 41 this.edgeIndex = edgeIndex || 0;
76 } 42 }
77 43
78 /** 44 /**
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 node: function() 88 node: function()
123 { 89 {
124 return this._snapshot.createNode(this.nodeIndex()); 90 return this._snapshot.createNode(this.nodeIndex());
125 }, 91 },
126 92
127 /** 93 /**
128 * @return {number} 94 * @return {number}
129 */ 95 */
130 nodeIndex: function() 96 nodeIndex: function()
131 { 97 {
132 return this._edges.item(this.edgeIndex + this._snapshot._edgeToNodeOffse t); 98 return this._edges[this.edgeIndex + this._snapshot._edgeToNodeOffset];
133 }, 99 },
134 100
135 /** 101 /**
136 * @return {!Array.<number>}
137 */
138 rawEdges: function()
139 {
140 return this._edges;
141 },
142
143 /**
144 * @return {string} 102 * @return {string}
145 */ 103 */
146 toString: function() 104 toString: function()
147 { 105 {
148 return "HeapSnapshotEdge: " + this.name(); 106 return "HeapSnapshotEdge: " + this.name();
149 }, 107 },
150 108
151 /** 109 /**
152 * @return {string} 110 * @return {string}
153 */ 111 */
154 type: function() 112 type: function()
155 { 113 {
156 return this._snapshot._edgeTypes[this._type()]; 114 return this._snapshot._edgeTypes[this._type()];
157 }, 115 },
158 116
159 /** 117 /**
160 * @return {!WebInspector.HeapSnapshotEdge.Serialized} 118 * @return {!WebInspector.HeapSnapshotEdge.Serialized}
161 */ 119 */
162 serialize: function() 120 serialize: function()
163 { 121 {
164 var node = this.node(); 122 var node = this.node();
165 return new WebInspector.HeapSnapshotEdge.Serialized(this.name(), node.se rialize(), this.nodeIndex(), this.type(), node.distance()); 123 return new WebInspector.HeapSnapshotEdge.Serialized(this.name(), node.se rialize(), this.nodeIndex(), this.type(), node.distance());
166 }, 124 },
167 125
168 _type: function() 126 _type: function()
169 { 127 {
170 return this._edges.item(this.edgeIndex + this._snapshot._edgeTypeOffset) ; 128 return this._edges[this.edgeIndex + this._snapshot._edgeTypeOffset];
171 } 129 }
172 }; 130 };
173 131
174 /** 132 /**
175 * @constructor 133 * @constructor
176 */ 134 */
177 WebInspector.HeapSnapshotEdgeIterator = function(edge) 135 WebInspector.HeapSnapshotEdgeIterator = function(edge)
178 { 136 {
179 this.edge = edge; 137 this.edge = edge;
180 } 138 }
(...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after
516 474
517 /** 475 /**
518 * @return {string} 476 * @return {string}
519 */ 477 */
520 name: function() 478 name: function()
521 { 479 {
522 return this._snapshot._strings[this._name()]; 480 return this._snapshot._strings[this._name()];
523 }, 481 },
524 482
525 /** 483 /**
526 * @return {!WebInspector.HeapSnapshotArraySlice} 484 * @return {!Uint32Array}
527 */ 485 */
528 rawEdges: function() 486 rawEdges: function()
529 { 487 {
530 return new WebInspector.HeapSnapshotArraySlice(this._snapshot._containme ntEdges, this._edgeIndexesStart(), this._edgeIndexesEnd()); 488 return this._snapshot._containmentEdges.subarray(this._edgeIndexesStart( ), this._edgeIndexesEnd());
531 }, 489 },
532 490
533 /** 491 /**
534 * @return {number} 492 * @return {number}
535 */ 493 */
536 retainedSize: function() 494 retainedSize: function()
537 { 495 {
538 return this._snapshot._retainedSizes[this._ordinal()]; 496 return this._snapshot._retainedSizes[this._ordinal()];
539 }, 497 },
540 498
(...skipping 450 matching lines...) Expand 10 before | Expand all | Expand 10 after
991 return this.rootNode().retainedSize(); 949 return this.rootNode().retainedSize();
992 }, 950 },
993 951
994 _getDominatedIndex: function(nodeIndex) 952 _getDominatedIndex: function(nodeIndex)
995 { 953 {
996 if (nodeIndex % this._nodeFieldCount) 954 if (nodeIndex % this._nodeFieldCount)
997 throw new Error("Invalid nodeIndex: " + nodeIndex); 955 throw new Error("Invalid nodeIndex: " + nodeIndex);
998 return this._firstDominatedNodeIndex[nodeIndex / this._nodeFieldCount]; 956 return this._firstDominatedNodeIndex[nodeIndex / this._nodeFieldCount];
999 }, 957 },
1000 958
959 /**
960 * @param {!WebInspector.HeapSnapshotNode} node
961 * @return {!Uint32Array}
962 */
1001 _dominatedNodesOfNode: function(node) 963 _dominatedNodesOfNode: function(node)
1002 { 964 {
1003 var dominatedIndexFrom = this._getDominatedIndex(node.nodeIndex); 965 var dominatedIndexFrom = this._getDominatedIndex(node.nodeIndex);
1004 var dominatedIndexTo = this._getDominatedIndex(node._nextNodeIndex()); 966 var dominatedIndexTo = this._getDominatedIndex(node._nextNodeIndex());
1005 return new WebInspector.HeapSnapshotArraySlice(this._dominatedNodes, dom inatedIndexFrom, dominatedIndexTo); 967 return this._dominatedNodes.subarray(dominatedIndexFrom, dominatedIndexT o);
1006 }, 968 },
1007 969
1008 /** 970 /**
1009 * @param {!WebInspector.HeapSnapshotCommon.NodeFilter} nodeFilter 971 * @param {!WebInspector.HeapSnapshotCommon.NodeFilter} nodeFilter
1010 * @return {!Object.<string, !WebInspector.HeapSnapshotCommon.Aggregate>} 972 * @return {!Object.<string, !WebInspector.HeapSnapshotCommon.Aggregate>}
1011 */ 973 */
1012 aggregatesWithFilter: function(nodeFilter) 974 aggregatesWithFilter: function(nodeFilter)
1013 { 975 {
1014 var minNodeId = nodeFilter.minNodeId; 976 var minNodeId = nodeFilter.minNodeId;
1015 var maxNodeId = nodeFilter.maxNodeId; 977 var maxNodeId = nodeFilter.maxNodeId;
(...skipping 907 matching lines...) Expand 10 before | Expand all | Expand 10 after
1923 * @return {!WebInspector.HeapSnapshotCommon.StaticData} 1885 * @return {!WebInspector.HeapSnapshotCommon.StaticData}
1924 */ 1886 */
1925 updateStaticData: function() 1887 updateStaticData: function()
1926 { 1888 {
1927 return new WebInspector.HeapSnapshotCommon.StaticData(this.nodeCount, th is._rootNodeIndex, this.totalSize, this._maxJsNodeId()); 1889 return new WebInspector.HeapSnapshotCommon.StaticData(this.nodeCount, th is._rootNodeIndex, this.totalSize, this._maxJsNodeId());
1928 } 1890 }
1929 }; 1891 };
1930 1892
1931 /** 1893 /**
1932 * @constructor 1894 * @constructor
1933 * @param {!Array.<number>=} unfilteredIterationOrder 1895 * @param {(!Array.<number>|!Uint32Array)=} unfilteredIterationOrder
1934 */ 1896 */
1935 WebInspector.HeapSnapshotFilteredOrderedIterator = function(iterator, filter, un filteredIterationOrder) 1897 WebInspector.HeapSnapshotFilteredOrderedIterator = function(iterator, filter, un filteredIterationOrder)
1936 { 1898 {
1937 this._filter = filter; 1899 this._filter = filter;
1938 this._iterator = iterator; 1900 this._iterator = iterator;
1939 this._unfilteredIterationOrder = unfilteredIterationOrder; 1901 this._unfilteredIterationOrder = unfilteredIterationOrder;
1902 /** @type {?Array.<number>|?Uint32Array} */
1940 this._iterationOrder = null; 1903 this._iterationOrder = null;
1941 this._position = 0; 1904 this._position = 0;
1942 this._currentComparator = null; 1905 this._currentComparator = null;
1943 this._sortedPrefixLength = 0; 1906 this._sortedPrefixLength = 0;
1944 this._sortedSuffixLength = 0; 1907 this._sortedSuffixLength = 0;
1945 } 1908 }
1946 1909
1947 WebInspector.HeapSnapshotFilteredOrderedIterator.prototype = { 1910 WebInspector.HeapSnapshotFilteredOrderedIterator.prototype = {
1948 _createIterationOrder: function() 1911 _createIterationOrder: function()
1949 { 1912 {
1950 if (this._iterationOrder) 1913 if (this._iterationOrder)
1951 return; 1914 return;
1952 if (this._unfilteredIterationOrder && !this._filter) { 1915 if (this._unfilteredIterationOrder && !this._filter) {
1953 this._iterationOrder = this._unfilteredIterationOrder.slice(0); 1916 this._iterationOrder = this._unfilteredIterationOrder;
1954 this._unfilteredIterationOrder = null; 1917 this._unfilteredIterationOrder = null;
1955 return; 1918 return;
1956 } 1919 }
1957 this._iterationOrder = []; 1920 this._iterationOrder = [];
1958 var iterator = this._iterator; 1921 var iterator = this._iterator;
1959 if (!this._unfilteredIterationOrder && !this._filter) { 1922 if (!this._unfilteredIterationOrder && !this._filter) {
1960 for (iterator.rewind(); iterator.hasNext(); iterator.next()) 1923 for (iterator.rewind(); iterator.hasNext(); iterator.next())
1961 this._iterationOrder.push(iterator.index()); 1924 this._iterationOrder.push(iterator.index());
1962 } else if (!this._unfilteredIterationOrder) { 1925 } else if (!this._unfilteredIterationOrder) {
1963 for (iterator.rewind(); iterator.hasNext(); iterator.next()) { 1926 for (iterator.rewind(); iterator.hasNext(); iterator.next()) {
1964 if (this._filter(iterator.item())) 1927 if (this._filter(iterator.item()))
1965 this._iterationOrder.push(iterator.index()); 1928 this._iterationOrder.push(iterator.index());
1966 } 1929 }
1967 } else { 1930 } else {
1968 var order = this._unfilteredIterationOrder.constructor === Array ? 1931 var order = this._unfilteredIterationOrder;
1969 this._unfilteredIterationOrder : this._unfilteredIterationOrder. slice(0);
1970 for (var i = 0, l = order.length; i < l; ++i) { 1932 for (var i = 0, l = order.length; i < l; ++i) {
1971 iterator.setIndex(order[i]); 1933 iterator.setIndex(order[i]);
1972 if (this._filter(iterator.item())) 1934 if (this._filter(iterator.item()))
1973 this._iterationOrder.push(iterator.index()); 1935 this._iterationOrder.push(iterator.index());
1974 } 1936 }
1975 this._unfilteredIterationOrder = null; 1937 this._unfilteredIterationOrder = null;
1976 } 1938 }
1977 }, 1939 },
1978 1940
1979 rewind: function() 1941 rewind: function()
(...skipping 20 matching lines...) Expand all
2000 return !this._unfilteredIterationOrder.length; 1962 return !this._unfilteredIterationOrder.length;
2001 var iterator = this._iterator; 1963 var iterator = this._iterator;
2002 if (!this._unfilteredIterationOrder && !this._filter) { 1964 if (!this._unfilteredIterationOrder && !this._filter) {
2003 iterator.rewind(); 1965 iterator.rewind();
2004 return !iterator.hasNext(); 1966 return !iterator.hasNext();
2005 } else if (!this._unfilteredIterationOrder) { 1967 } else if (!this._unfilteredIterationOrder) {
2006 for (iterator.rewind(); iterator.hasNext(); iterator.next()) 1968 for (iterator.rewind(); iterator.hasNext(); iterator.next())
2007 if (this._filter(iterator.item())) 1969 if (this._filter(iterator.item()))
2008 return false; 1970 return false;
2009 } else { 1971 } else {
2010 var order = this._unfilteredIterationOrder.constructor === Array ? 1972 var order = this._unfilteredIterationOrder;
2011 this._unfilteredIterationOrder : this._unfilteredIterationOrder. slice(0);
2012 for (var i = 0, l = order.length; i < l; ++i) { 1973 for (var i = 0, l = order.length; i < l; ++i) {
2013 iterator.setIndex(order[i]); 1974 iterator.setIndex(order[i]);
2014 if (this._filter(iterator.item())) 1975 if (this._filter(iterator.item()))
2015 return false; 1976 return false;
2016 } 1977 }
2017 } 1978 }
2018 return true; 1979 return true;
2019 }, 1980 },
2020 1981
2021 /** 1982 /**
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
2171 this._iterationOrder.sortRange(compareNodeAndNode, leftBound, rightB ound, windowLeft, windowRight); 2132 this._iterationOrder.sortRange(compareNodeAndNode, leftBound, rightB ound, windowLeft, windowRight);
2172 }, 2133 },
2173 2134
2174 __proto__: WebInspector.HeapSnapshotFilteredOrderedIterator.prototype 2135 __proto__: WebInspector.HeapSnapshotFilteredOrderedIterator.prototype
2175 } 2136 }
2176 2137
2177 2138
2178 /** 2139 /**
2179 * @constructor 2140 * @constructor
2180 * @extends {WebInspector.HeapSnapshotFilteredOrderedIterator} 2141 * @extends {WebInspector.HeapSnapshotFilteredOrderedIterator}
2181 * @param {!Array.<number>=} nodeIndexes 2142 * @param {(!Array.<number>|!Uint32Array)=} nodeIndexes
2182 */ 2143 */
2183 WebInspector.HeapSnapshotNodesProvider = function(snapshot, filter, nodeIndexes) 2144 WebInspector.HeapSnapshotNodesProvider = function(snapshot, filter, nodeIndexes)
2184 { 2145 {
2185 this.snapshot = snapshot; 2146 this.snapshot = snapshot;
2186 WebInspector.HeapSnapshotFilteredOrderedIterator.call(this, snapshot._allNod es(), filter, nodeIndexes); 2147 WebInspector.HeapSnapshotFilteredOrderedIterator.call(this, snapshot._allNod es(), filter, nodeIndexes);
2187 } 2148 }
2188 2149
2189 WebInspector.HeapSnapshotNodesProvider.prototype = { 2150 WebInspector.HeapSnapshotNodesProvider.prototype = {
2190 /** 2151 /**
2191 * @param {string} snapshotObjectId 2152 * @param {string} snapshotObjectId
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
2261 * @param {number} windowRight 2222 * @param {number} windowRight
2262 */ 2223 */
2263 sort: function(comparator, leftBound, rightBound, windowLeft, windowRight) 2224 sort: function(comparator, leftBound, rightBound, windowLeft, windowRight)
2264 { 2225 {
2265 this._iterationOrder.sortRange(this._buildCompareFunction(comparator), l eftBound, rightBound, windowLeft, windowRight); 2226 this._iterationOrder.sortRange(this._buildCompareFunction(comparator), l eftBound, rightBound, windowLeft, windowRight);
2266 }, 2227 },
2267 2228
2268 __proto__: WebInspector.HeapSnapshotFilteredOrderedIterator.prototype 2229 __proto__: WebInspector.HeapSnapshotFilteredOrderedIterator.prototype
2269 } 2230 }
2270 2231
OLDNEW
« no previous file with comments | « LayoutTests/inspector/profiler/heap-snapshot-test.js ('k') | Source/devtools/front_end/JSHeapSnapshot.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698