Commit 3dafee92 authored by esprehn@chromium.org's avatar esprehn@chromium.org

Revert of Remove WebInspector.HeapSnapshotArraySlice (https://codereview.chromium.org/204563002/)

Reason for revert:
Made tests start failing

http://test-results.appspot.com/dashboards/flakiness_dashboard.html#group=%40ToT%20Blink&tests=inspector-protocol/heap-profiler/heap-snapshot-with-detached-dom-tree.html,inspector-protocol/heap-profiler/heap-snapshot-with-event-listener.html

Original issue's description:
> Remove WebInspector.HeapSnapshotArraySlice
> 
> Uin32Array already has subarray method that returns a new view for the same array buffer.
> 
> BUG=None
> R=alph@chromium.org
> 
> Committed: https://src.chromium.org/viewvc/blink?view=rev&revision=169554

TBR=alph@chromium.org,loislo@chromium.org,yurys@chromium.org
NOTREECHECKS=true
NOTRY=true
BUG=None

Review URL: https://codereview.chromium.org/205953002

git-svn-id: svn://svn.chromium.org/blink/trunk@169599 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 42f4eaf0
......@@ -29,23 +29,23 @@ InspectorTest.createJSHeapSnapshotMockObject = function()
// b\ v /
// -> B (6) -bd- D (12)
//
_nodes: new Uint32Array([
_nodes: [
0, 0, 2, // 0: root
1, 1, 2, // 3: A
1, 2, 2, // 6: B
1, 3, 1, // 9: C
1, 4, 0, // 12: D
1, 5, 0]), // 15: E
_containmentEdges: new Uint32Array([
1, 5, 0], // 15: E
_containmentEdges: [
2, 6, 3, // 0: shortcut 'a' to node 'A'
1, 7, 6, // 3: property 'b' to node 'B'
0, 1, 6, // 6: element '1' to node 'B'
1, 8, 9, // 9: property 'ac' to node 'C'
1, 9, 9, // 12: property 'bc' to node 'C'
1, 10, 12, // 15: property 'bd' to node 'D'
1, 11, 15]),// 18: property 'ce' to node 'E'
1, 11, 15], // 18: property 'ce' to node 'E'
_strings: ["", "A", "B", "C", "D", "E", "a", "b", "ac", "bc", "bd", "ce"],
_firstEdgeIndexes: new Uint32Array([0, 6, 12, 18, 21, 21, 21]),
_firstEdgeIndexes: [0, 6, 12, 18, 21, 21, 21],
createNode: WebInspector.JSHeapSnapshot.prototype.createNode,
createEdge: WebInspector.JSHeapSnapshot.prototype.createEdge,
createRetainingEdge: WebInspector.JSHeapSnapshot.prototype.createRetainingEdge
......@@ -327,12 +327,6 @@ InspectorTest.HeapSnapshotBuilder.prototype = {
return rawSnapshot;
},
createJSHeapSnapshot: function()
{
var parsedSnapshot = InspectorTest._postprocessHeapSnapshotMock(this.generateSnapshot());
return new WebInspector.JSHeapSnapshot(parsedSnapshot, new WebInspector.HeapSnapshotProgress());
},
_registerNode: function(node)
{
this._nodes.push(node);
......
......@@ -164,7 +164,7 @@ function test()
node = newNode;
}
var snapshot = builder.createJSHeapSnapshot();
var snapshot = new WebInspector.JSHeapSnapshot(builder.generateSnapshot(), new WebInspector.HeapSnapshotProgress());
InspectorTest.assertEquals(
iterations * nodeSize, snapshot.rootNode().retainedSize(),
"Ensure that root node retained size supports values exceeding 2^32 bytes.");
......@@ -205,7 +205,7 @@ function test()
var debuggerOwnedNode = new InspectorTest.HeapNode("debuggerOwnedNode");
debuggerNode.linkNode(debuggerOwnedNode, InspectorTest.HeapEdge.Type.element);
var snapshot = builder.createJSHeapSnapshot();
var snapshot = new WebInspector.JSHeapSnapshot(builder.generateSnapshot(), new WebInspector.HeapSnapshotProgress());
snapshot._flags = new Array(snapshot.nodeCount);
for (var i = 0; i < snapshot.nodeCount; ++i)
snapshot._flags[i] = 0;
......@@ -299,11 +299,11 @@ function test()
var root = snapshot.rootNode();
var rawEdges = root.rawEdges();
InspectorTest.assertEquals(6, rawEdges.length);
InspectorTest.assertEquals(6, rawEdges.subarray(0).length);
InspectorTest.assertEquals(3, rawEdges.subarray(3).length);
InspectorTest.assertEquals(3, rawEdges.subarray(3, 6).length);
InspectorTest.assertEquals(3, rawEdges.subarray(0, 3).length);
InspectorTest.assertEquals(0, rawEdges.subarray(3, 3).length);
InspectorTest.assertEquals(6, rawEdges.slice(0).length);
InspectorTest.assertEquals(3, rawEdges.slice(3).length);
InspectorTest.assertEquals(3, rawEdges.slice(3, 6).length);
InspectorTest.assertEquals(3, rawEdges.slice(0, 3).length);
InspectorTest.assertEquals(0, rawEdges.slice(3, 3).length);
},
function heapSnapshotNodesProviderTest()
......
......@@ -30,8 +30,42 @@
/**
* @constructor
* @param {!WebInspector.HeapSnapshot} snapshot
* @param {!Uint32Array} edges
* @param {!Uint32Array} array
* @param {number} start
* @param {number} end
*/
WebInspector.HeapSnapshotArraySlice = function(array, start, end)
{
this._array = array;
this._start = start;
this.length = end - start;
}
WebInspector.HeapSnapshotArraySlice.prototype = {
/**
* @param {number} index
* @return {number}
*/
item: function(index)
{
return this._array[this._start + index];
},
/**
* @param {number} start
* @param {number=} end
* @return {!Uint32Array}
*/
slice: function(start, end)
{
if (typeof end === "undefined")
end = this.length;
return this._array.subarray(this._start + start, this._start + end);
}
}
/**
* @constructor
* @param {number=} edgeIndex
*/
WebInspector.HeapSnapshotEdge = function(snapshot, edges, edgeIndex)
......@@ -95,7 +129,15 @@ WebInspector.HeapSnapshotEdge.prototype = {
*/
nodeIndex: function()
{
return this._edges[this.edgeIndex + this._snapshot._edgeToNodeOffset];
return this._edges.item(this.edgeIndex + this._snapshot._edgeToNodeOffset);
},
/**
* @return {!Array.<number>}
*/
rawEdges: function()
{
return this._edges;
},
/**
......@@ -125,7 +167,7 @@ WebInspector.HeapSnapshotEdge.prototype = {
_type: function()
{
return this._edges[this.edgeIndex + this._snapshot._edgeTypeOffset];
return this._edges.item(this.edgeIndex + this._snapshot._edgeTypeOffset);
}
};
......@@ -481,11 +523,11 @@ WebInspector.HeapSnapshotNode.prototype = {
},
/**
* @return {!Uint32Array}
* @return {!WebInspector.HeapSnapshotArraySlice}
*/
rawEdges: function()
{
return this._snapshot._containmentEdges.subarray(this._edgeIndexesStart(), this._edgeIndexesEnd());
return new WebInspector.HeapSnapshotArraySlice(this._snapshot._containmentEdges, this._edgeIndexesStart(), this._edgeIndexesEnd());
},
/**
......@@ -956,15 +998,11 @@ WebInspector.HeapSnapshot.prototype = {
return this._firstDominatedNodeIndex[nodeIndex / this._nodeFieldCount];
},
/**
* @param {!WebInspector.HeapSnapshotNode} node
* @return {!Uint32Array}
*/
_dominatedNodesOfNode: function(node)
{
var dominatedIndexFrom = this._getDominatedIndex(node.nodeIndex);
var dominatedIndexTo = this._getDominatedIndex(node._nextNodeIndex());
return this._dominatedNodes.subarray(dominatedIndexFrom, dominatedIndexTo);
return new WebInspector.HeapSnapshotArraySlice(this._dominatedNodes, dominatedIndexFrom, dominatedIndexTo);
},
/**
......@@ -1892,14 +1930,13 @@ WebInspector.HeapSnapshot.prototype = {
/**
* @constructor
* @param {(!Array.<number>|!Uint32Array)=} unfilteredIterationOrder
* @param {!Array.<number>=} unfilteredIterationOrder
*/
WebInspector.HeapSnapshotFilteredOrderedIterator = function(iterator, filter, unfilteredIterationOrder)
{
this._filter = filter;
this._iterator = iterator;
this._unfilteredIterationOrder = unfilteredIterationOrder;
/** @type {?Array.<number>|?Uint32Array} */
this._iterationOrder = null;
this._position = 0;
this._currentComparator = null;
......@@ -1913,7 +1950,7 @@ WebInspector.HeapSnapshotFilteredOrderedIterator.prototype = {
if (this._iterationOrder)
return;
if (this._unfilteredIterationOrder && !this._filter) {
this._iterationOrder = this._unfilteredIterationOrder;
this._iterationOrder = this._unfilteredIterationOrder.slice(0);
this._unfilteredIterationOrder = null;
return;
}
......@@ -1928,7 +1965,8 @@ WebInspector.HeapSnapshotFilteredOrderedIterator.prototype = {
this._iterationOrder.push(iterator.index());
}
} else {
var order = this._unfilteredIterationOrder;
var order = this._unfilteredIterationOrder.constructor === Array ?
this._unfilteredIterationOrder : this._unfilteredIterationOrder.slice(0);
for (var i = 0, l = order.length; i < l; ++i) {
iterator.setIndex(order[i]);
if (this._filter(iterator.item()))
......@@ -1969,7 +2007,8 @@ WebInspector.HeapSnapshotFilteredOrderedIterator.prototype = {
if (this._filter(iterator.item()))
return false;
} else {
var order = this._unfilteredIterationOrder;
var order = this._unfilteredIterationOrder.constructor === Array ?
this._unfilteredIterationOrder : this._unfilteredIterationOrder.slice(0);
for (var i = 0, l = order.length; i < l; ++i) {
iterator.setIndex(order[i]);
if (this._filter(iterator.item()))
......@@ -2139,7 +2178,7 @@ WebInspector.HeapSnapshotEdgesProvider.prototype = {
/**
* @constructor
* @extends {WebInspector.HeapSnapshotFilteredOrderedIterator}
* @param {(!Array.<number>|!Uint32Array)=} nodeIndexes
* @param {!Array.<number>=} nodeIndexes
*/
WebInspector.HeapSnapshotNodesProvider = function(snapshot, filter, nodeIndexes)
{
......
......@@ -58,7 +58,7 @@ WebInspector.JSHeapSnapshot.prototype = {
},
/**
* @param {!Uint32Array} edges
* @param {!Array.<number>} edges
* @param {number} edgeIndex
* @return {!WebInspector.JSHeapSnapshotEdge}
*/
......@@ -147,7 +147,7 @@ WebInspector.JSHeapSnapshot.prototype = {
&& globalObjEdge.node().isHidden()
&& globalObjEdge._hasStringName()
&& (globalObjEdge._nameOrIndex() in propNames))
globalObjEdge._edges[globalObjEdge.edgeIndex + this._edgeTypeOffset] = this._edgeInvisibleType;
this._containmentEdges[globalObjEdge._edges._start + globalObjEdge.edgeIndex + this._edgeTypeOffset] = this._edgeInvisibleType;
}
}
},
......@@ -666,7 +666,7 @@ WebInspector.JSHeapSnapshotNode.prototype = {
* @constructor
* @extends {WebInspector.HeapSnapshotEdge}
* @param {!WebInspector.JSHeapSnapshot} snapshot
* @param {!Uint32Array} edges
* @param {!Array.<number>} edges
* @param {number=} edgeIndex
*/
WebInspector.JSHeapSnapshotEdge = function(snapshot, edges, edgeIndex)
......@@ -680,8 +680,7 @@ WebInspector.JSHeapSnapshotEdge.prototype = {
*/
clone: function()
{
var snapshot = /** @type {!WebInspector.JSHeapSnapshot} */ (this._snapshot);
return new WebInspector.JSHeapSnapshotEdge(snapshot, this._edges, this.edgeIndex);
return new WebInspector.JSHeapSnapshotEdge(this._snapshot, this._edges, this.edgeIndex);
},
/**
......@@ -790,12 +789,12 @@ WebInspector.JSHeapSnapshotEdge.prototype = {
_nameOrIndex: function()
{
return this._edges[this.edgeIndex + this._snapshot._edgeNameOffset];
return this._edges.item(this.edgeIndex + this._snapshot._edgeNameOffset);
},
_type: function()
{
return this._edges[this.edgeIndex + this._snapshot._edgeTypeOffset];
return this._edges.item(this.edgeIndex + this._snapshot._edgeTypeOffset);
},
__proto__: WebInspector.HeapSnapshotEdge.prototype
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment