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

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

Issue 204563002: 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
1001 _dominatedNodesOfNode: function(node) 959 _dominatedNodesOfNode: function(node)
alph 2014/03/19 15:01:01 Annotate plz.
yurys 2014/03/19 15:24:59 Done.
1002 { 960 {
1003 var dominatedIndexFrom = this._getDominatedIndex(node.nodeIndex); 961 var dominatedIndexFrom = this._getDominatedIndex(node.nodeIndex);
1004 var dominatedIndexTo = this._getDominatedIndex(node._nextNodeIndex()); 962 var dominatedIndexTo = this._getDominatedIndex(node._nextNodeIndex());
1005 return new WebInspector.HeapSnapshotArraySlice(this._dominatedNodes, dom inatedIndexFrom, dominatedIndexTo); 963 return this._dominatedNodes.subarray(dominatedIndexFrom, dominatedIndexT o);
1006 }, 964 },
1007 965
1008 /** 966 /**
1009 * @param {!WebInspector.HeapSnapshotCommon.NodeFilter} nodeFilter 967 * @param {!WebInspector.HeapSnapshotCommon.NodeFilter} nodeFilter
1010 * @return {!Object.<string, !WebInspector.HeapSnapshotCommon.Aggregate>} 968 * @return {!Object.<string, !WebInspector.HeapSnapshotCommon.Aggregate>}
1011 */ 969 */
1012 aggregatesWithFilter: function(nodeFilter) 970 aggregatesWithFilter: function(nodeFilter)
1013 { 971 {
1014 var minNodeId = nodeFilter.minNodeId; 972 var minNodeId = nodeFilter.minNodeId;
1015 var maxNodeId = nodeFilter.maxNodeId; 973 var maxNodeId = nodeFilter.maxNodeId;
(...skipping 907 matching lines...) Expand 10 before | Expand all | Expand 10 after
1923 * @return {!WebInspector.HeapSnapshotCommon.StaticData} 1881 * @return {!WebInspector.HeapSnapshotCommon.StaticData}
1924 */ 1882 */
1925 updateStaticData: function() 1883 updateStaticData: function()
1926 { 1884 {
1927 return new WebInspector.HeapSnapshotCommon.StaticData(this.nodeCount, th is._rootNodeIndex, this.totalSize, this._maxJsNodeId()); 1885 return new WebInspector.HeapSnapshotCommon.StaticData(this.nodeCount, th is._rootNodeIndex, this.totalSize, this._maxJsNodeId());
1928 } 1886 }
1929 }; 1887 };
1930 1888
1931 /** 1889 /**
1932 * @constructor 1890 * @constructor
1933 * @param {!Array.<number>=} unfilteredIterationOrder 1891 * @param {!Array.<number>=} unfilteredIterationOrder
alph 2014/03/19 15:01:01 It might be an Uint32Array, e.g. when created from
yurys 2014/03/19 15:24:59 Done.
1934 */ 1892 */
1935 WebInspector.HeapSnapshotFilteredOrderedIterator = function(iterator, filter, un filteredIterationOrder) 1893 WebInspector.HeapSnapshotFilteredOrderedIterator = function(iterator, filter, un filteredIterationOrder)
1936 { 1894 {
1937 this._filter = filter; 1895 this._filter = filter;
1938 this._iterator = iterator; 1896 this._iterator = iterator;
1939 this._unfilteredIterationOrder = unfilteredIterationOrder; 1897 this._unfilteredIterationOrder = unfilteredIterationOrder;
1940 this._iterationOrder = null; 1898 this._iterationOrder = null;
alph 2014/03/19 15:01:01 could you please add type annotation to _iteration
yurys 2014/03/19 15:24:59 Done.
1941 this._position = 0; 1899 this._position = 0;
1942 this._currentComparator = null; 1900 this._currentComparator = null;
1943 this._sortedPrefixLength = 0; 1901 this._sortedPrefixLength = 0;
1944 this._sortedSuffixLength = 0; 1902 this._sortedSuffixLength = 0;
1945 } 1903 }
1946 1904
1947 WebInspector.HeapSnapshotFilteredOrderedIterator.prototype = { 1905 WebInspector.HeapSnapshotFilteredOrderedIterator.prototype = {
1948 _createIterationOrder: function() 1906 _createIterationOrder: function()
1949 { 1907 {
1950 if (this._iterationOrder) 1908 if (this._iterationOrder)
1951 return; 1909 return;
1952 if (this._unfilteredIterationOrder && !this._filter) { 1910 if (this._unfilteredIterationOrder && !this._filter) {
1953 this._iterationOrder = this._unfilteredIterationOrder.slice(0); 1911 this._iterationOrder = this._unfilteredIterationOrder;
1954 this._unfilteredIterationOrder = null; 1912 this._unfilteredIterationOrder = null;
1955 return; 1913 return;
1956 } 1914 }
1957 this._iterationOrder = []; 1915 this._iterationOrder = [];
1958 var iterator = this._iterator; 1916 var iterator = this._iterator;
1959 if (!this._unfilteredIterationOrder && !this._filter) { 1917 if (!this._unfilteredIterationOrder && !this._filter) {
1960 for (iterator.rewind(); iterator.hasNext(); iterator.next()) 1918 for (iterator.rewind(); iterator.hasNext(); iterator.next())
1961 this._iterationOrder.push(iterator.index()); 1919 this._iterationOrder.push(iterator.index());
1962 } else if (!this._unfilteredIterationOrder) { 1920 } else if (!this._unfilteredIterationOrder) {
1963 for (iterator.rewind(); iterator.hasNext(); iterator.next()) { 1921 for (iterator.rewind(); iterator.hasNext(); iterator.next()) {
1964 if (this._filter(iterator.item())) 1922 if (this._filter(iterator.item()))
1965 this._iterationOrder.push(iterator.index()); 1923 this._iterationOrder.push(iterator.index());
1966 } 1924 }
1967 } else { 1925 } else {
1968 var order = this._unfilteredIterationOrder.constructor === Array ? 1926 var order = this._unfilteredIterationOrder;
1969 this._unfilteredIterationOrder : this._unfilteredIterationOrder. slice(0);
1970 for (var i = 0, l = order.length; i < l; ++i) { 1927 for (var i = 0, l = order.length; i < l; ++i) {
1971 iterator.setIndex(order[i]); 1928 iterator.setIndex(order[i]);
1972 if (this._filter(iterator.item())) 1929 if (this._filter(iterator.item()))
1973 this._iterationOrder.push(iterator.index()); 1930 this._iterationOrder.push(iterator.index());
1974 } 1931 }
1975 this._unfilteredIterationOrder = null; 1932 this._unfilteredIterationOrder = null;
1976 } 1933 }
1977 }, 1934 },
1978 1935
1979 rewind: function() 1936 rewind: function()
(...skipping 20 matching lines...) Expand all
2000 return !this._unfilteredIterationOrder.length; 1957 return !this._unfilteredIterationOrder.length;
2001 var iterator = this._iterator; 1958 var iterator = this._iterator;
2002 if (!this._unfilteredIterationOrder && !this._filter) { 1959 if (!this._unfilteredIterationOrder && !this._filter) {
2003 iterator.rewind(); 1960 iterator.rewind();
2004 return !iterator.hasNext(); 1961 return !iterator.hasNext();
2005 } else if (!this._unfilteredIterationOrder) { 1962 } else if (!this._unfilteredIterationOrder) {
2006 for (iterator.rewind(); iterator.hasNext(); iterator.next()) 1963 for (iterator.rewind(); iterator.hasNext(); iterator.next())
2007 if (this._filter(iterator.item())) 1964 if (this._filter(iterator.item()))
2008 return false; 1965 return false;
2009 } else { 1966 } else {
2010 var order = this._unfilteredIterationOrder.constructor === Array ? 1967 var order = this._unfilteredIterationOrder;
2011 this._unfilteredIterationOrder : this._unfilteredIterationOrder. slice(0);
2012 for (var i = 0, l = order.length; i < l; ++i) { 1968 for (var i = 0, l = order.length; i < l; ++i) {
2013 iterator.setIndex(order[i]); 1969 iterator.setIndex(order[i]);
2014 if (this._filter(iterator.item())) 1970 if (this._filter(iterator.item()))
2015 return false; 1971 return false;
2016 } 1972 }
2017 } 1973 }
2018 return true; 1974 return true;
2019 }, 1975 },
2020 1976
2021 /** 1977 /**
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after
2261 * @param {number} windowRight 2217 * @param {number} windowRight
2262 */ 2218 */
2263 sort: function(comparator, leftBound, rightBound, windowLeft, windowRight) 2219 sort: function(comparator, leftBound, rightBound, windowLeft, windowRight)
2264 { 2220 {
2265 this._iterationOrder.sortRange(this._buildCompareFunction(comparator), l eftBound, rightBound, windowLeft, windowRight); 2221 this._iterationOrder.sortRange(this._buildCompareFunction(comparator), l eftBound, rightBound, windowLeft, windowRight);
2266 }, 2222 },
2267 2223
2268 __proto__: WebInspector.HeapSnapshotFilteredOrderedIterator.prototype 2224 __proto__: WebInspector.HeapSnapshotFilteredOrderedIterator.prototype
2269 } 2225 }
2270 2226
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