Index: chrome_linux/resources/inspector/HeapSnapshotWorker.js |
=================================================================== |
--- chrome_linux/resources/inspector/HeapSnapshotWorker.js (revision 273864) |
+++ chrome_linux/resources/inspector/HeapSnapshotWorker.js (working copy) |
@@ -1,110 +1,120 @@ |
-WebInspector={};WebInspector.AllocationProfile=function(profile) |
-{this._strings=profile.strings;this._nextNodeId=1;this._idToFunctionInfo={};this._idToNode={};this._collapsedTopNodeIdToFunctionInfo={};this._traceTops=null;this._buildAllocationFunctionInfos(profile);this._traceTree=this._buildInvertedAllocationTree(profile);} |
-WebInspector.AllocationProfile.prototype={_buildAllocationFunctionInfos:function(profile) |
-{var strings=this._strings;var functionInfoFields=profile.snapshot.meta.trace_function_info_fields;var functionIdOffset=functionInfoFields.indexOf("function_id");var functionNameOffset=functionInfoFields.indexOf("name");var scriptNameOffset=functionInfoFields.indexOf("script_name");var scriptIdOffset=functionInfoFields.indexOf("script_id");var lineOffset=functionInfoFields.indexOf("line");var columnOffset=functionInfoFields.indexOf("column");var functionInfoFieldCount=functionInfoFields.length;var map=this._idToFunctionInfo;map[0]=new WebInspector.FunctionAllocationInfo("(root)","<unknown>",0,-1,-1);var rawInfos=profile.trace_function_infos;var infoLength=rawInfos.length;for(var i=0;i<infoLength;i+=functionInfoFieldCount){map[rawInfos[i+functionIdOffset]]=new WebInspector.FunctionAllocationInfo(strings[rawInfos[i+functionNameOffset]],strings[rawInfos[i+scriptNameOffset]],rawInfos[i+scriptIdOffset],rawInfos[i+lineOffset],rawInfos[i+columnOffset]);}},_buildInvertedAllocationTree:function(profile) |
-{var traceTreeRaw=profile.trace_tree;var idToFunctionInfo=this._idToFunctionInfo;var traceNodeFields=profile.snapshot.meta.trace_node_fields;var nodeIdOffset=traceNodeFields.indexOf("id");var functionIdOffset=traceNodeFields.indexOf("function_id");var allocationCountOffset=traceNodeFields.indexOf("count");var allocationSizeOffset=traceNodeFields.indexOf("size");var childrenOffset=traceNodeFields.indexOf("children");var nodeFieldCount=traceNodeFields.length;function traverseNode(rawNodeArray,nodeOffset,parent) |
-{var functionInfo=idToFunctionInfo[rawNodeArray[nodeOffset+functionIdOffset]];var result=new WebInspector.AllocationTraceNode(rawNodeArray[nodeOffset+nodeIdOffset],functionInfo,rawNodeArray[nodeOffset+allocationCountOffset],rawNodeArray[nodeOffset+allocationSizeOffset],parent);functionInfo.addTraceTopNode(result);var rawChildren=rawNodeArray[nodeOffset+childrenOffset];for(var i=0;i<rawChildren.length;i+=nodeFieldCount){result.children.push(traverseNode(rawChildren,i,result));} |
+WebInspector={};WebInspector.AllocationProfile=function(profile,liveObjectStats) |
+{this._strings=profile.strings;this._liveObjectStats=liveObjectStats;this._nextNodeId=1;this._functionInfos=[] |
+this._idToNode={};this._collapsedTopNodeIdToFunctionInfo={};this._traceTops=null;this._buildFunctionAllocationInfos(profile);this._traceTree=this._buildAllocationTree(profile,liveObjectStats);} |
+WebInspector.AllocationProfile.prototype={_buildFunctionAllocationInfos:function(profile) |
+{var strings=this._strings;var functionInfoFields=profile.snapshot.meta.trace_function_info_fields;var functionIdOffset=functionInfoFields.indexOf("function_id");var functionNameOffset=functionInfoFields.indexOf("name");var scriptNameOffset=functionInfoFields.indexOf("script_name");var scriptIdOffset=functionInfoFields.indexOf("script_id");var lineOffset=functionInfoFields.indexOf("line");var columnOffset=functionInfoFields.indexOf("column");var functionInfoFieldCount=functionInfoFields.length;var rawInfos=profile.trace_function_infos;var infoLength=rawInfos.length;var functionInfos=this._functionInfos=new Array(infoLength/functionInfoFieldCount);var index=0;for(var i=0;i<infoLength;i+=functionInfoFieldCount){functionInfos[index++]=new WebInspector.FunctionAllocationInfo(strings[rawInfos[i+functionNameOffset]],strings[rawInfos[i+scriptNameOffset]],rawInfos[i+scriptIdOffset],rawInfos[i+lineOffset],rawInfos[i+columnOffset]);}},_buildAllocationTree:function(profile,liveObjectStats) |
+{var traceTreeRaw=profile.trace_tree;var functionInfos=this._functionInfos;var traceNodeFields=profile.snapshot.meta.trace_node_fields;var nodeIdOffset=traceNodeFields.indexOf("id");var functionInfoIndexOffset=traceNodeFields.indexOf("function_info_index");var allocationCountOffset=traceNodeFields.indexOf("count");var allocationSizeOffset=traceNodeFields.indexOf("size");var childrenOffset=traceNodeFields.indexOf("children");var nodeFieldCount=traceNodeFields.length;function traverseNode(rawNodeArray,nodeOffset,parent) |
+{var functionInfo=functionInfos[rawNodeArray[nodeOffset+functionInfoIndexOffset]];var id=rawNodeArray[nodeOffset+nodeIdOffset];var stats=liveObjectStats[id];var liveCount=stats?stats.count:0;var liveSize=stats?stats.size:0;var result=new WebInspector.TopDownAllocationNode(id,functionInfo,rawNodeArray[nodeOffset+allocationCountOffset],rawNodeArray[nodeOffset+allocationSizeOffset],liveCount,liveSize,parent);functionInfo.addTraceTopNode(result);var rawChildren=rawNodeArray[nodeOffset+childrenOffset];for(var i=0;i<rawChildren.length;i+=nodeFieldCount){result.children.push(traverseNode(rawChildren,i,result));} |
return result;} |
return traverseNode(traceTreeRaw,0,null);},serializeTraceTops:function() |
{if(this._traceTops) |
-return this._traceTops;var result=this._traceTops=[];var idToFunctionInfo=this._idToFunctionInfo;for(var id in idToFunctionInfo){var info=idToFunctionInfo[id];if(info.totalCount===0) |
-continue;var nodeId=this._nextNodeId++;result.push(this._serializeNode(nodeId,info,info.totalCount,info.totalSize,true));this._collapsedTopNodeIdToFunctionInfo[nodeId]=info;} |
+return this._traceTops;var result=this._traceTops=[];var functionInfos=this._functionInfos;for(var i=0;i<functionInfos.length;i++){var info=functionInfos[i];if(info.totalCount===0) |
+continue;var nodeId=this._nextNodeId++;result.push(this._serializeNode(nodeId,info,info.totalCount,info.totalSize,info.totalLiveCount,info.totalLiveSize,true));this._collapsedTopNodeIdToFunctionInfo[nodeId]=info;} |
result.sort(function(a,b){return b.size-a.size;});return result;},serializeCallers:function(nodeId) |
-{var node=this._idToNode[nodeId];if(!node){var functionInfo=this._collapsedTopNodeIdToFunctionInfo[nodeId];node=functionInfo.tracesWithThisTop();delete this._collapsedTopNodeIdToFunctionInfo[nodeId];this._idToNode[nodeId]=node;} |
-var nodesWithSingleCaller=[];while(node.callers().length===1){node=node.callers()[0];nodesWithSingleCaller.push(this._serializeCaller(node));} |
+{var node=this._ensureBottomUpNode(nodeId);var nodesWithSingleCaller=[];while(node.callers().length===1){node=node.callers()[0];nodesWithSingleCaller.push(this._serializeCaller(node));} |
var branchingCallers=[];var callers=node.callers();for(var i=0;i<callers.length;i++){branchingCallers.push(this._serializeCaller(callers[i]));} |
-return{nodesWithSingleCaller:nodesWithSingleCaller,branchingCallers:branchingCallers};},_serializeCaller:function(node) |
-{var callerId=this._nextNodeId++;this._idToNode[callerId]=node;return this._serializeNode(callerId,node.functionInfo,node.allocationCount,node.allocationSize,node.hasCallers());},_serializeNode:function(nodeId,functionInfo,count,size,hasChildren) |
-{return{id:nodeId,name:functionInfo.functionName,scriptName:functionInfo.scriptName,line:functionInfo.line,column:functionInfo.column,count:count,size:size,hasChildren:hasChildren};}} |
-WebInspector.AllocationTraceNode=function(id,functionInfo,count,size,parent) |
-{this.id=id;this.functionInfo=functionInfo;this.allocationCount=count;this.allocationSize=size;this.parent=parent;this.children=[];} |
-WebInspector.AllocationBackTraceNode=function(functionInfo) |
-{this.functionInfo=functionInfo;this.allocationCount=0;this.allocationSize=0;this._callers=[];} |
-WebInspector.AllocationBackTraceNode.prototype={addCaller:function(traceNode) |
+return new WebInspector.HeapSnapshotCommon.AllocationNodeCallers(nodesWithSingleCaller,branchingCallers);},traceIds:function(allocationNodeId) |
+{return this._ensureBottomUpNode(allocationNodeId).traceTopIds;},_ensureBottomUpNode:function(nodeId) |
+{var node=this._idToNode[nodeId];if(!node){var functionInfo=this._collapsedTopNodeIdToFunctionInfo[nodeId];node=functionInfo.bottomUpRoot();delete this._collapsedTopNodeIdToFunctionInfo[nodeId];this._idToNode[nodeId]=node;} |
+return node;},_serializeCaller:function(node) |
+{var callerId=this._nextNodeId++;this._idToNode[callerId]=node;return this._serializeNode(callerId,node.functionInfo,node.allocationCount,node.allocationSize,node.liveCount,node.liveSize,node.hasCallers());},_serializeNode:function(nodeId,functionInfo,count,size,liveCount,liveSize,hasChildren) |
+{return new WebInspector.HeapSnapshotCommon.SerializedAllocationNode(nodeId,functionInfo.functionName,functionInfo.scriptName,functionInfo.line,functionInfo.column,count,size,liveCount,liveSize,hasChildren);}} |
+WebInspector.TopDownAllocationNode=function(id,functionInfo,count,size,liveCount,liveSize,parent) |
+{this.id=id;this.functionInfo=functionInfo;this.allocationCount=count;this.allocationSize=size;this.liveCount=liveCount;this.liveSize=liveSize;this.parent=parent;this.children=[];} |
+WebInspector.BottomUpAllocationNode=function(functionInfo) |
+{this.functionInfo=functionInfo;this.allocationCount=0;this.allocationSize=0;this.liveCount=0;this.liveSize=0;this.traceTopIds=[];this._callers=[];} |
+WebInspector.BottomUpAllocationNode.prototype={addCaller:function(traceNode) |
{var functionInfo=traceNode.functionInfo;var result;for(var i=0;i<this._callers.length;i++){var caller=this._callers[i];if(caller.functionInfo===functionInfo){result=caller;break;}} |
-if(!result){result=new WebInspector.AllocationBackTraceNode(functionInfo);this._callers.push(result);} |
+if(!result){result=new WebInspector.BottomUpAllocationNode(functionInfo);this._callers.push(result);} |
return result;},callers:function() |
{return this._callers;},hasCallers:function() |
{return this._callers.length>0;}} |
WebInspector.FunctionAllocationInfo=function(functionName,scriptName,scriptId,line,column) |
-{this.functionName=functionName;this.scriptName=scriptName;this.scriptId=scriptId;this.line=line;this.column=column;this.totalCount=0;this.totalSize=0;this._traceTops=[];} |
+{this.functionName=functionName;this.scriptName=scriptName;this.scriptId=scriptId;this.line=line;this.column=column;this.totalCount=0;this.totalSize=0;this.totalLiveCount=0;this.totalLiveSize=0;this._traceTops=[];} |
WebInspector.FunctionAllocationInfo.prototype={addTraceTopNode:function(node) |
{if(node.allocationCount===0) |
-return;this._traceTops.push(node);this.totalCount+=node.allocationCount;this.totalSize+=node.allocationSize;},tracesWithThisTop:function() |
+return;this._traceTops.push(node);this.totalCount+=node.allocationCount;this.totalSize+=node.allocationSize;this.totalLiveCount+=node.liveCount;this.totalLiveSize+=node.liveSize;},bottomUpRoot:function() |
{if(!this._traceTops.length) |
-return null;if(!this._backTraceTree) |
-this._buildAllocationTraceTree();return this._backTraceTree;},_buildAllocationTraceTree:function() |
-{this._backTraceTree=new WebInspector.AllocationBackTraceNode(this._traceTops[0].functionInfo);for(var i=0;i<this._traceTops.length;i++){var node=this._traceTops[i];var backTraceNode=this._backTraceTree;var count=node.allocationCount;var size=node.allocationSize;while(true){backTraceNode.allocationCount+=count;backTraceNode.allocationSize+=size;node=node.parent;if(node===null){break;} |
-backTraceNode=backTraceNode.addCaller(node);}}}};WebInspector.HeapSnapshotArraySlice=function(array,start,end) |
-{this._array=array;this._start=start;this.length=end-start;} |
-WebInspector.HeapSnapshotArraySlice.prototype={item:function(index) |
-{return this._array[this._start+index];},slice:function(start,end) |
-{if(typeof end==="undefined") |
-end=this.length;return this._array.subarray(this._start+start,this._start+end);}} |
-WebInspector.HeapSnapshotEdge=function(snapshot,edges,edgeIndex) |
-{this._snapshot=snapshot;this._edges=edges;this.edgeIndex=edgeIndex||0;} |
-WebInspector.HeapSnapshotEdge.prototype={clone:function() |
-{return new WebInspector.HeapSnapshotEdge(this._snapshot,this._edges,this.edgeIndex);},hasStringName:function() |
+return null;if(!this._bottomUpTree) |
+this._buildAllocationTraceTree();return this._bottomUpTree;},_buildAllocationTraceTree:function() |
+{this._bottomUpTree=new WebInspector.BottomUpAllocationNode(this);for(var i=0;i<this._traceTops.length;i++){var node=this._traceTops[i];var bottomUpNode=this._bottomUpTree;var count=node.allocationCount;var size=node.allocationSize;var liveCount=node.liveCount;var liveSize=node.liveSize;var traceId=node.id;while(true){bottomUpNode.allocationCount+=count;bottomUpNode.allocationSize+=size;bottomUpNode.liveCount+=liveCount;bottomUpNode.liveSize+=liveSize;bottomUpNode.traceTopIds.push(traceId);node=node.parent;if(node===null){break;} |
+bottomUpNode=bottomUpNode.addCaller(node);}}}};WebInspector.HeapSnapshotItem=function(){} |
+WebInspector.HeapSnapshotItem.prototype={itemIndex:function(){},serialize:function(){}};WebInspector.HeapSnapshotEdge=function(snapshot,edgeIndex) |
+{this._snapshot=snapshot;this._edges=snapshot._containmentEdges;this.edgeIndex=edgeIndex||0;} |
+WebInspector.HeapSnapshotEdge.Serialized=function(name,node,nodeIndex,type) |
+{this.name=name;this.node=node;this.nodeIndex=nodeIndex;this.type=type;};WebInspector.HeapSnapshotEdge.prototype={clone:function() |
+{return new WebInspector.HeapSnapshotEdge(this._snapshot,this.edgeIndex);},hasStringName:function() |
{throw new Error("Not implemented");},name:function() |
{throw new Error("Not implemented");},node:function() |
{return this._snapshot.createNode(this.nodeIndex());},nodeIndex:function() |
-{return this._edges.item(this.edgeIndex+this._snapshot._edgeToNodeOffset);},rawEdges:function() |
-{return this._edges;},toString:function() |
+{return this._edges[this.edgeIndex+this._snapshot._edgeToNodeOffset];},toString:function() |
{return"HeapSnapshotEdge: "+this.name();},type:function() |
-{return this._snapshot._edgeTypes[this._type()];},serialize:function() |
-{var node=this.node();return{name:this.name(),node:node.serialize(),nodeIndex:this.nodeIndex(),type:this.type(),distance:node.distance()};},_type:function() |
-{return this._edges.item(this.edgeIndex+this._snapshot._edgeTypeOffset);}};WebInspector.HeapSnapshotEdgeIterator=function(edge) |
-{this.edge=edge;} |
-WebInspector.HeapSnapshotEdgeIterator.prototype={rewind:function() |
-{this.edge.edgeIndex=0;},hasNext:function() |
-{return this.edge.edgeIndex<this.edge._edges.length;},index:function() |
-{return this.edge.edgeIndex;},setIndex:function(newIndex) |
-{this.edge.edgeIndex=newIndex;},item:function() |
+{return this._snapshot._edgeTypes[this._type()];},itemIndex:function() |
+{return this.edgeIndex;},serialize:function() |
+{var node=this.node();return new WebInspector.HeapSnapshotEdge.Serialized(this.name(),node.serialize(),this.nodeIndex(),this.type());},_type:function() |
+{return this._edges[this.edgeIndex+this._snapshot._edgeTypeOffset];}};WebInspector.HeapSnapshotItemIterator=function(){} |
+WebInspector.HeapSnapshotItemIterator.prototype={hasNext:function(){},item:function(){},next:function(){}};WebInspector.HeapSnapshotItemIndexProvider=function(){} |
+WebInspector.HeapSnapshotItemIndexProvider.prototype={itemForIndex:function(newIndex){},};WebInspector.HeapSnapshotNodeIndexProvider=function(snapshot) |
+{this._node=snapshot.createNode();} |
+WebInspector.HeapSnapshotNodeIndexProvider.prototype={itemForIndex:function(index) |
+{this._node.nodeIndex=index;return this._node;}};WebInspector.HeapSnapshotEdgeIndexProvider=function(snapshot) |
+{this._edge=snapshot.createEdge(0);} |
+WebInspector.HeapSnapshotEdgeIndexProvider.prototype={itemForIndex:function(index) |
+{this._edge.edgeIndex=index;return this._edge;}};WebInspector.HeapSnapshotRetainerEdgeIndexProvider=function(snapshot) |
+{this._retainerEdge=snapshot.createRetainingEdge(0);} |
+WebInspector.HeapSnapshotRetainerEdgeIndexProvider.prototype={itemForIndex:function(index) |
+{this._retainerEdge.setRetainerIndex(index);return this._retainerEdge;}};WebInspector.HeapSnapshotEdgeIterator=function(node) |
+{this._sourceNode=node;this.edge=node._snapshot.createEdge(node._edgeIndexesStart());} |
+WebInspector.HeapSnapshotEdgeIterator.prototype={hasNext:function() |
+{return this.edge.edgeIndex<this._sourceNode._edgeIndexesEnd();},item:function() |
{return this.edge;},next:function() |
-{this.edge.edgeIndex+=this.edge._snapshot._edgeFieldsCount;}};WebInspector.HeapSnapshotRetainerEdge=function(snapshot,retainedNodeIndex,retainerIndex) |
-{this._snapshot=snapshot;this._retainedNodeIndex=retainedNodeIndex;var retainedNodeOrdinal=retainedNodeIndex/snapshot._nodeFieldCount;this._firstRetainer=snapshot._firstRetainerIndex[retainedNodeOrdinal];this._retainersCount=snapshot._firstRetainerIndex[retainedNodeOrdinal+1]-this._firstRetainer;this.setRetainerIndex(retainerIndex);} |
+{this.edge.edgeIndex+=this.edge._snapshot._edgeFieldsCount;}};WebInspector.HeapSnapshotRetainerEdge=function(snapshot,retainerIndex) |
+{this._snapshot=snapshot;this.setRetainerIndex(retainerIndex);} |
+WebInspector.HeapSnapshotRetainerEdge.Serialized=function(name,node,nodeIndex,type){this.name=name;this.node=node;this.nodeIndex=nodeIndex;this.type=type;} |
WebInspector.HeapSnapshotRetainerEdge.prototype={clone:function() |
-{return new WebInspector.HeapSnapshotRetainerEdge(this._snapshot,this._retainedNodeIndex,this.retainerIndex());},hasStringName:function() |
+{return new WebInspector.HeapSnapshotRetainerEdge(this._snapshot,this.retainerIndex());},hasStringName:function() |
{return this._edge().hasStringName();},name:function() |
{return this._edge().name();},node:function() |
{return this._node();},nodeIndex:function() |
-{return this._nodeIndex;},retainerIndex:function() |
-{return this._retainerIndex;},setRetainerIndex:function(newIndex) |
-{if(newIndex!==this._retainerIndex){this._retainerIndex=newIndex;this.edgeIndex=newIndex;}},set edgeIndex(edgeIndex) |
-{var retainerIndex=this._firstRetainer+edgeIndex;this._globalEdgeIndex=this._snapshot._retainingEdges[retainerIndex];this._nodeIndex=this._snapshot._retainingNodes[retainerIndex];delete this._edgeInstance;delete this._nodeInstance;},_node:function() |
+{return this._retainingNodeIndex;},retainerIndex:function() |
+{return this._retainerIndex;},setRetainerIndex:function(retainerIndex) |
+{if(retainerIndex===this._retainerIndex) |
+return;this._retainerIndex=retainerIndex;this._globalEdgeIndex=this._snapshot._retainingEdges[retainerIndex];this._retainingNodeIndex=this._snapshot._retainingNodes[retainerIndex];this._edgeInstance=null;this._nodeInstance=null;},set edgeIndex(edgeIndex) |
+{this.setRetainerIndex(edgeIndex);},_node:function() |
{if(!this._nodeInstance) |
-this._nodeInstance=this._snapshot.createNode(this._nodeIndex);return this._nodeInstance;},_edge:function() |
-{if(!this._edgeInstance){var edgeIndex=this._globalEdgeIndex-this._node()._edgeIndexesStart();this._edgeInstance=this._snapshot.createEdge(this._node().rawEdges(),edgeIndex);} |
-return this._edgeInstance;},toString:function() |
-{return this._edge().toString();},serialize:function() |
-{var node=this.node();return{name:this.name(),node:node.serialize(),nodeIndex:this.nodeIndex(),type:this.type(),distance:node.distance()};},type:function() |
+this._nodeInstance=this._snapshot.createNode(this._retainingNodeIndex);return this._nodeInstance;},_edge:function() |
+{if(!this._edgeInstance) |
+this._edgeInstance=this._snapshot.createEdge(this._globalEdgeIndex);return this._edgeInstance;},toString:function() |
+{return this._edge().toString();},itemIndex:function() |
+{return this._retainerIndex;},serialize:function() |
+{var node=this.node();return new WebInspector.HeapSnapshotRetainerEdge.Serialized(this.name(),node.serialize(),this.nodeIndex(),this.type());},type:function() |
{return this._edge().type();}} |
-WebInspector.HeapSnapshotRetainerEdgeIterator=function(retainer) |
-{this.retainer=retainer;} |
-WebInspector.HeapSnapshotRetainerEdgeIterator.prototype={rewind:function() |
-{this.retainer.setRetainerIndex(0);},hasNext:function() |
-{return this.retainer.retainerIndex()<this.retainer._retainersCount;},index:function() |
-{return this.retainer.retainerIndex();},setIndex:function(newIndex) |
-{this.retainer.setRetainerIndex(newIndex);},item:function() |
+WebInspector.HeapSnapshotRetainerEdgeIterator=function(retainedNode) |
+{var snapshot=retainedNode._snapshot;var retainedNodeOrdinal=retainedNode._ordinal();var retainerIndex=snapshot._firstRetainerIndex[retainedNodeOrdinal];this._retainersEnd=snapshot._firstRetainerIndex[retainedNodeOrdinal+1];this.retainer=snapshot.createRetainingEdge(retainerIndex);} |
+WebInspector.HeapSnapshotRetainerEdgeIterator.prototype={hasNext:function() |
+{return this.retainer.retainerIndex()<this._retainersEnd;},item:function() |
{return this.retainer;},next:function() |
{this.retainer.setRetainerIndex(this.retainer.retainerIndex()+1);}};WebInspector.HeapSnapshotNode=function(snapshot,nodeIndex) |
-{this._snapshot=snapshot;this._firstNodeIndex=nodeIndex;this.nodeIndex=nodeIndex;} |
+{this._snapshot=snapshot;this.nodeIndex=nodeIndex||0;} |
+WebInspector.HeapSnapshotNode.Serialized=function(id,name,distance,nodeIndex,retainedSize,selfSize,type){this.id=id;this.name=name;this.distance=distance;this.nodeIndex=nodeIndex;this.retainedSize=retainedSize;this.selfSize=selfSize;this.type=type;} |
WebInspector.HeapSnapshotNode.prototype={distance:function() |
{return this._snapshot._nodeDistances[this.nodeIndex/this._snapshot._nodeFieldCount];},className:function() |
{throw new Error("Not implemented");},classIndex:function() |
{throw new Error("Not implemented");},dominatorIndex:function() |
{var nodeFieldCount=this._snapshot._nodeFieldCount;return this._snapshot._dominatorsTree[this.nodeIndex/this._snapshot._nodeFieldCount]*nodeFieldCount;},edges:function() |
-{return new WebInspector.HeapSnapshotEdgeIterator(this._snapshot.createEdge(this.rawEdges(),0));},edgesCount:function() |
+{return new WebInspector.HeapSnapshotEdgeIterator(this);},edgesCount:function() |
{return(this._edgeIndexesEnd()-this._edgeIndexesStart())/this._snapshot._edgeFieldsCount;},id:function() |
{throw new Error("Not implemented");},isRoot:function() |
{return this.nodeIndex===this._snapshot._rootNodeIndex;},name:function() |
-{return this._snapshot._strings[this._name()];},rawEdges:function() |
-{return new WebInspector.HeapSnapshotArraySlice(this._snapshot._containmentEdges,this._edgeIndexesStart(),this._edgeIndexesEnd());},retainedSize:function() |
-{var snapshot=this._snapshot;return snapshot._nodes[this.nodeIndex+snapshot._nodeRetainedSizeOffset];},retainers:function() |
-{return new WebInspector.HeapSnapshotRetainerEdgeIterator(this._snapshot.createRetainingEdge(this.nodeIndex,0));},selfSize:function() |
+{return this._snapshot._strings[this._name()];},retainedSize:function() |
+{return this._snapshot._retainedSizes[this._ordinal()];},retainers:function() |
+{return new WebInspector.HeapSnapshotRetainerEdgeIterator(this);},retainersCount:function() |
+{var snapshot=this._snapshot;var ordinal=this._ordinal();return snapshot._firstRetainerIndex[ordinal+1]-snapshot._firstRetainerIndex[ordinal];},selfSize:function() |
{var snapshot=this._snapshot;return snapshot._nodes[this.nodeIndex+snapshot._nodeSelfSizeOffset];},type:function() |
-{return this._snapshot._nodeTypes[this._type()];},serialize:function() |
-{return{id:this.id(),name:this.name(),distance:this.distance(),nodeIndex:this.nodeIndex,retainedSize:this.retainedSize(),selfSize:this.selfSize(),type:this.type(),};},_name:function() |
+{return this._snapshot._nodeTypes[this._type()];},traceNodeId:function() |
+{var snapshot=this._snapshot;return snapshot._nodes[this.nodeIndex+snapshot._nodeTraceNodeIdOffset];},itemIndex:function() |
+{return this.nodeIndex;},serialize:function() |
+{return new WebInspector.HeapSnapshotNode.Serialized(this.id(),this.name(),this.distance(),this.nodeIndex,this.retainedSize(),this.selfSize(),this.type());},_name:function() |
{var snapshot=this._snapshot;return snapshot._nodes[this.nodeIndex+snapshot._nodeNameOffset];},_edgeIndexesStart:function() |
{return this._snapshot._firstEdgeIndexes[this._ordinal()];},_edgeIndexesEnd:function() |
{return this._snapshot._firstEdgeIndexes[this._ordinal()+1];},_ordinal:function() |
@@ -112,13 +122,23 @@ |
{return this.nodeIndex+this._snapshot._nodeFieldCount;},_type:function() |
{var snapshot=this._snapshot;return snapshot._nodes[this.nodeIndex+snapshot._nodeTypeOffset];}};WebInspector.HeapSnapshotNodeIterator=function(node) |
{this.node=node;this._nodesLength=node._snapshot._nodes.length;} |
-WebInspector.HeapSnapshotNodeIterator.prototype={rewind:function() |
-{this.node.nodeIndex=this.node._firstNodeIndex;},hasNext:function() |
-{return this.node.nodeIndex<this._nodesLength;},index:function() |
-{return this.node.nodeIndex;},setIndex:function(newIndex) |
-{this.node.nodeIndex=newIndex;},item:function() |
+WebInspector.HeapSnapshotNodeIterator.prototype={hasNext:function() |
+{return this.node.nodeIndex<this._nodesLength;},item:function() |
{return this.node;},next:function() |
{this.node.nodeIndex=this.node._nextNodeIndex();}} |
+WebInspector.HeapSnapshotIndexRangeIterator=function(itemProvider,indexes) |
+{this._itemProvider=itemProvider;this._indexes=indexes;this._position=0;} |
+WebInspector.HeapSnapshotIndexRangeIterator.prototype={hasNext:function() |
+{return this._position<this._indexes.length},item:function() |
+{var index=this._indexes[this._position];return this._itemProvider.itemForIndex(index);},next:function() |
+{++this._position;}} |
+WebInspector.HeapSnapshotFilteredIterator=function(iterator,filter) |
+{this._iterator=iterator;this._filter=filter;this._skipFilteredItems();} |
+WebInspector.HeapSnapshotFilteredIterator.prototype={hasNext:function() |
+{return this._iterator.hasNext();},item:function() |
+{return this._iterator.item();},next:function() |
+{this._iterator.next();this._skipFilteredItems();},_skipFilteredItems:function() |
+{while(this._iterator.hasNext()&&!this._filter(this._iterator.item())){this._iterator.next();}}} |
WebInspector.HeapSnapshotProgress=function(dispatcher) |
{this._dispatcher=dispatcher;} |
WebInspector.HeapSnapshotProgress.prototype={updateStatus:function(status) |
@@ -126,39 +146,48 @@ |
{var percentValue=((total?(value/total):0)*100).toFixed(0);this._sendUpdateEvent(WebInspector.UIString(title,percentValue));},_sendUpdateEvent:function(text) |
{if(this._dispatcher) |
this._dispatcher.sendEvent(WebInspector.HeapSnapshotProgressEvent.Update,text);}} |
-WebInspector.HeapSnapshot=function(profile,progress) |
-{this.uid=profile.snapshot.uid;this._nodes=profile.nodes;this._containmentEdges=profile.edges;this._metaNode=profile.snapshot.meta;this._strings=profile.strings;this._progress=progress;this._noDistance=-5;this._rootNodeIndex=0;if(profile.snapshot.root_index) |
-this._rootNodeIndex=profile.snapshot.root_index;this._snapshotDiffs={};this._aggregatesForDiff=null;this._init();if(WebInspector.HeapSnapshot.enableAllocationProfiler){this._progress.updateStatus("Buiding allocation statistics\u2026");this._allocationProfile=new WebInspector.AllocationProfile(profile);this._progress.updateStatus("Done");}} |
-WebInspector.HeapSnapshot.enableAllocationProfiler=false;function HeapSnapshotMetainfo() |
+WebInspector.HeapSnapshot=function(profile,progress,showHiddenData) |
+{this._nodes=profile.nodes;this._containmentEdges=profile.edges;this._metaNode=profile.snapshot.meta;this._strings=profile.strings;this._progress=progress;this._noDistance=-5;this._rootNodeIndex=0;if(profile.snapshot.root_index) |
+this._rootNodeIndex=profile.snapshot.root_index;this._snapshotDiffs={};this._aggregatesForDiff=null;this._aggregates={};this._aggregatesSortedFlags={};this._showHiddenData=showHiddenData;this._init();if(profile.snapshot.trace_function_count){this._progress.updateStatus("Buiding allocation statistics\u2026");var nodes=this._nodes;var nodesLength=nodes.length;var nodeFieldCount=this._nodeFieldCount;var node=this.rootNode();var liveObjects={};for(var nodeIndex=0;nodeIndex<nodesLength;nodeIndex+=nodeFieldCount){node.nodeIndex=nodeIndex;var traceNodeId=node.traceNodeId();var stats=liveObjects[traceNodeId];if(!stats){liveObjects[traceNodeId]=stats={count:0,size:0,ids:[]};} |
+stats.count++;stats.size+=node.selfSize();stats.ids.push(node.id());} |
+this._allocationProfile=new WebInspector.AllocationProfile(profile,liveObjects);this._progress.updateStatus("Done");}} |
+function HeapSnapshotMetainfo() |
{this.node_fields=[];this.node_types=[];this.edge_fields=[];this.edge_types=[];this.trace_function_info_fields=[];this.trace_node_fields=[];this.type_strings={};} |
function HeapSnapshotHeader() |
-{this.title="";this.uid=0;this.meta=new HeapSnapshotMetainfo();this.node_count=0;this.edge_count=0;} |
+{this.title="";this.meta=new HeapSnapshotMetainfo();this.node_count=0;this.edge_count=0;} |
WebInspector.HeapSnapshot.prototype={_init:function() |
-{var meta=this._metaNode;this._nodeTypeOffset=meta.node_fields.indexOf("type");this._nodeNameOffset=meta.node_fields.indexOf("name");this._nodeIdOffset=meta.node_fields.indexOf("id");this._nodeSelfSizeOffset=meta.node_fields.indexOf("self_size");this._nodeEdgeCountOffset=meta.node_fields.indexOf("edge_count");this._nodeFieldCount=meta.node_fields.length;this._nodeTypes=meta.node_types[this._nodeTypeOffset];this._nodeHiddenType=this._nodeTypes.indexOf("hidden");this._nodeObjectType=this._nodeTypes.indexOf("object");this._nodeNativeType=this._nodeTypes.indexOf("native");this._nodeConsStringType=this._nodeTypes.indexOf("concatenated string");this._nodeSlicedStringType=this._nodeTypes.indexOf("sliced string");this._nodeCodeType=this._nodeTypes.indexOf("code");this._nodeSyntheticType=this._nodeTypes.indexOf("synthetic");this._edgeFieldsCount=meta.edge_fields.length;this._edgeTypeOffset=meta.edge_fields.indexOf("type");this._edgeNameOffset=meta.edge_fields.indexOf("name_or_index");this._edgeToNodeOffset=meta.edge_fields.indexOf("to_node");this._edgeTypes=meta.edge_types[this._edgeTypeOffset];this._edgeTypes.push("invisible");this._edgeElementType=this._edgeTypes.indexOf("element");this._edgeHiddenType=this._edgeTypes.indexOf("hidden");this._edgeInternalType=this._edgeTypes.indexOf("internal");this._edgeShortcutType=this._edgeTypes.indexOf("shortcut");this._edgeWeakType=this._edgeTypes.indexOf("weak");this._edgeInvisibleType=this._edgeTypes.indexOf("invisible");this.nodeCount=this._nodes.length/this._nodeFieldCount;this._edgeCount=this._containmentEdges.length/this._edgeFieldsCount;this._progress.updateStatus("Building edge indexes\u2026");this._buildEdgeIndexes();this._progress.updateStatus("Marking invisible edges\u2026");this._markInvisibleEdges();this._progress.updateStatus("Building retainers\u2026");this._buildRetainers();this._progress.updateStatus("Calculating node flags\u2026");this._calculateFlags();this._progress.updateStatus("Calculating distances\u2026");this._calculateDistances();this._progress.updateStatus("Building postorder index\u2026");var result=this._buildPostOrderIndex();this._progress.updateStatus("Building dominator tree\u2026");this._dominatorsTree=this._buildDominatorTree(result.postOrderIndex2NodeOrdinal,result.nodeOrdinal2PostOrderIndex);this._progress.updateStatus("Calculating retained sizes\u2026");this._calculateRetainedSizes(result.postOrderIndex2NodeOrdinal);this._progress.updateStatus("Buiding dominated nodes\u2026");this._buildDominatedNodes();this._progress.updateStatus("Finished processing.");},_buildEdgeIndexes:function() |
+{var meta=this._metaNode;this._nodeTypeOffset=meta.node_fields.indexOf("type");this._nodeNameOffset=meta.node_fields.indexOf("name");this._nodeIdOffset=meta.node_fields.indexOf("id");this._nodeSelfSizeOffset=meta.node_fields.indexOf("self_size");this._nodeEdgeCountOffset=meta.node_fields.indexOf("edge_count");this._nodeTraceNodeIdOffset=meta.node_fields.indexOf("trace_node_id");this._nodeFieldCount=meta.node_fields.length;this._nodeTypes=meta.node_types[this._nodeTypeOffset];this._nodeHiddenType=this._nodeTypes.indexOf("hidden");this._nodeObjectType=this._nodeTypes.indexOf("object");this._nodeNativeType=this._nodeTypes.indexOf("native");this._nodeConsStringType=this._nodeTypes.indexOf("concatenated string");this._nodeSlicedStringType=this._nodeTypes.indexOf("sliced string");this._nodeCodeType=this._nodeTypes.indexOf("code");this._nodeSyntheticType=this._nodeTypes.indexOf("synthetic");this._edgeFieldsCount=meta.edge_fields.length;this._edgeTypeOffset=meta.edge_fields.indexOf("type");this._edgeNameOffset=meta.edge_fields.indexOf("name_or_index");this._edgeToNodeOffset=meta.edge_fields.indexOf("to_node");this._edgeTypes=meta.edge_types[this._edgeTypeOffset];this._edgeTypes.push("invisible");this._edgeElementType=this._edgeTypes.indexOf("element");this._edgeHiddenType=this._edgeTypes.indexOf("hidden");this._edgeInternalType=this._edgeTypes.indexOf("internal");this._edgeShortcutType=this._edgeTypes.indexOf("shortcut");this._edgeWeakType=this._edgeTypes.indexOf("weak");this._edgeInvisibleType=this._edgeTypes.indexOf("invisible");this.nodeCount=this._nodes.length/this._nodeFieldCount;this._edgeCount=this._containmentEdges.length/this._edgeFieldsCount;this._progress.updateStatus("Building edge indexes\u2026");this._buildEdgeIndexes();this._progress.updateStatus("Building retainers\u2026");this._buildRetainers();this._progress.updateStatus("Calculating node flags\u2026");this._calculateFlags();this._progress.updateStatus("Calculating distances\u2026");this._calculateDistances();this._progress.updateStatus("Building postorder index\u2026");var result=this._buildPostOrderIndex();this._progress.updateStatus("Building dominator tree\u2026");this._dominatorsTree=this._buildDominatorTree(result.postOrderIndex2NodeOrdinal,result.nodeOrdinal2PostOrderIndex);this._progress.updateStatus("Calculating retained sizes\u2026");this._calculateRetainedSizes(result.postOrderIndex2NodeOrdinal);this._progress.updateStatus("Buiding dominated nodes\u2026");this._buildDominatedNodes();this._progress.updateStatus("Calculating statistics\u2026");this._calculateStatistics();this._progress.updateStatus("Finished processing.");},_buildEdgeIndexes:function() |
{var nodes=this._nodes;var nodeCount=this.nodeCount;var firstEdgeIndexes=this._firstEdgeIndexes=new Uint32Array(nodeCount+1);var nodeFieldCount=this._nodeFieldCount;var edgeFieldsCount=this._edgeFieldsCount;var nodeEdgeCountOffset=this._nodeEdgeCountOffset;firstEdgeIndexes[nodeCount]=this._containmentEdges.length;for(var nodeOrdinal=0,edgeIndex=0;nodeOrdinal<nodeCount;++nodeOrdinal){firstEdgeIndexes[nodeOrdinal]=edgeIndex;edgeIndex+=nodes[nodeOrdinal*nodeFieldCount+nodeEdgeCountOffset]*edgeFieldsCount;}},_buildRetainers:function() |
{var retainingNodes=this._retainingNodes=new Uint32Array(this._edgeCount);var retainingEdges=this._retainingEdges=new Uint32Array(this._edgeCount);var firstRetainerIndex=this._firstRetainerIndex=new Uint32Array(this.nodeCount+1);var containmentEdges=this._containmentEdges;var edgeFieldsCount=this._edgeFieldsCount;var nodeFieldCount=this._nodeFieldCount;var edgeToNodeOffset=this._edgeToNodeOffset;var firstEdgeIndexes=this._firstEdgeIndexes;var nodeCount=this.nodeCount;for(var toNodeFieldIndex=edgeToNodeOffset,l=containmentEdges.length;toNodeFieldIndex<l;toNodeFieldIndex+=edgeFieldsCount){var toNodeIndex=containmentEdges[toNodeFieldIndex];if(toNodeIndex%nodeFieldCount) |
throw new Error("Invalid toNodeIndex "+toNodeIndex);++firstRetainerIndex[toNodeIndex/nodeFieldCount];} |
for(var i=0,firstUnusedRetainerSlot=0;i<nodeCount;i++){var retainersCount=firstRetainerIndex[i];firstRetainerIndex[i]=firstUnusedRetainerSlot;retainingNodes[firstUnusedRetainerSlot]=retainersCount;firstUnusedRetainerSlot+=retainersCount;} |
firstRetainerIndex[nodeCount]=retainingNodes.length;var nextNodeFirstEdgeIndex=firstEdgeIndexes[0];for(var srcNodeOrdinal=0;srcNodeOrdinal<nodeCount;++srcNodeOrdinal){var firstEdgeIndex=nextNodeFirstEdgeIndex;nextNodeFirstEdgeIndex=firstEdgeIndexes[srcNodeOrdinal+1];var srcNodeIndex=srcNodeOrdinal*nodeFieldCount;for(var edgeIndex=firstEdgeIndex;edgeIndex<nextNodeFirstEdgeIndex;edgeIndex+=edgeFieldsCount){var toNodeIndex=containmentEdges[edgeIndex+edgeToNodeOffset];if(toNodeIndex%nodeFieldCount) |
throw new Error("Invalid toNodeIndex "+toNodeIndex);var firstRetainerSlotIndex=firstRetainerIndex[toNodeIndex/nodeFieldCount];var nextUnusedRetainerSlotIndex=firstRetainerSlotIndex+(--retainingNodes[firstRetainerSlotIndex]);retainingNodes[nextUnusedRetainerSlotIndex]=srcNodeIndex;retainingEdges[nextUnusedRetainerSlotIndex]=edgeIndex;}}},createNode:function(nodeIndex) |
-{throw new Error("Not implemented");},createEdge:function(edges,edgeIndex) |
-{throw new Error("Not implemented");},createRetainingEdge:function(retainedNodeIndex,retainerIndex) |
+{throw new Error("Not implemented");},createEdge:function(edgeIndex) |
+{throw new Error("Not implemented");},createRetainingEdge:function(retainerIndex) |
{throw new Error("Not implemented");},dispose:function() |
-{delete this._nodes;delete this._strings;delete this._retainingEdges;delete this._retainingNodes;delete this._firstRetainerIndex;if(this._aggregates){delete this._aggregates;delete this._aggregatesSortedFlags;} |
-delete this._dominatedNodes;delete this._firstDominatedNodeIndex;delete this._nodeDistances;delete this._dominatorsTree;},_allNodes:function() |
+{delete this._nodes;delete this._strings;delete this._retainingEdges;delete this._retainingNodes;delete this._firstRetainerIndex;delete this._aggregates;delete this._aggregatesSortedFlags;delete this._dominatedNodes;delete this._firstDominatedNodeIndex;delete this._nodeDistances;delete this._dominatorsTree;},_allNodes:function() |
{return new WebInspector.HeapSnapshotNodeIterator(this.rootNode());},rootNode:function() |
{return this.createNode(this._rootNodeIndex);},get rootNodeIndex() |
{return this._rootNodeIndex;},get totalSize() |
{return this.rootNode().retainedSize();},_getDominatedIndex:function(nodeIndex) |
{if(nodeIndex%this._nodeFieldCount) |
throw new Error("Invalid nodeIndex: "+nodeIndex);return this._firstDominatedNodeIndex[nodeIndex/this._nodeFieldCount];},_dominatedNodesOfNode:function(node) |
-{var dominatedIndexFrom=this._getDominatedIndex(node.nodeIndex);var dominatedIndexTo=this._getDominatedIndex(node._nextNodeIndex());return new WebInspector.HeapSnapshotArraySlice(this._dominatedNodes,dominatedIndexFrom,dominatedIndexTo);},aggregates:function(sortedIndexes,key,filterString) |
-{if(!this._aggregates){this._aggregates={};this._aggregatesSortedFlags={};} |
-var aggregatesByClassName=this._aggregates[key];if(aggregatesByClassName){if(sortedIndexes&&!this._aggregatesSortedFlags[key]){this._sortAggregateIndexes(aggregatesByClassName);this._aggregatesSortedFlags[key]=sortedIndexes;} |
-return aggregatesByClassName;} |
-var filter;if(filterString) |
-filter=this._parseFilter(filterString);var aggregates=this._buildAggregates(filter);this._calculateClassesRetainedSize(aggregates.aggregatesByClassIndex,filter);aggregatesByClassName=aggregates.aggregatesByClassName;if(sortedIndexes) |
-this._sortAggregateIndexes(aggregatesByClassName);this._aggregatesSortedFlags[key]=sortedIndexes;this._aggregates[key]=aggregatesByClassName;return aggregatesByClassName;},allocationTracesTops:function() |
+{var dominatedIndexFrom=this._getDominatedIndex(node.nodeIndex);var dominatedIndexTo=this._getDominatedIndex(node._nextNodeIndex());return this._dominatedNodes.subarray(dominatedIndexFrom,dominatedIndexTo);},aggregatesWithFilter:function(nodeFilter) |
+{var minNodeId=nodeFilter.minNodeId;var maxNodeId=nodeFilter.maxNodeId;var allocationNodeId=nodeFilter.allocationNodeId;var key;var filter;if(typeof allocationNodeId==="number"){filter=this._createAllocationStackFilter(allocationNodeId);}else if(typeof minNodeId==="number"&&typeof maxNodeId==="number"){key=minNodeId+".."+maxNodeId;filter=this._createNodeIdFilter(minNodeId,maxNodeId);}else{key="allObjects";} |
+return this.aggregates(false,key,filter);},_createNodeIdFilter:function(minNodeId,maxNodeId) |
+{function nodeIdFilter(node) |
+{var id=node.id();return id>minNodeId&&id<=maxNodeId;} |
+return nodeIdFilter;},_createAllocationStackFilter:function(bottomUpAllocationNodeId) |
+{var traceIds=this._allocationProfile.traceIds(bottomUpAllocationNodeId);if(!traceIds.length) |
+return undefined;var set={};for(var i=0;i<traceIds.length;i++) |
+set[traceIds[i]]=true;function traceIdFilter(node) |
+{return!!set[node.traceNodeId()];};return traceIdFilter;},aggregates:function(sortedIndexes,key,filter) |
+{var aggregatesByClassName=key&&this._aggregates[key];if(!aggregatesByClassName){var aggregates=this._buildAggregates(filter);this._calculateClassesRetainedSize(aggregates.aggregatesByClassIndex,filter);aggregatesByClassName=aggregates.aggregatesByClassName;if(key) |
+this._aggregates[key]=aggregatesByClassName;} |
+if(sortedIndexes&&(!key||!this._aggregatesSortedFlags[key])){this._sortAggregateIndexes(aggregatesByClassName);if(key) |
+this._aggregatesSortedFlags[key]=sortedIndexes;} |
+return aggregatesByClassName;},allocationTracesTops:function() |
{return this._allocationProfile.serializeTraceTops();},allocationNodeCallers:function(nodeId) |
{return this._allocationProfile.serializeCallers(nodeId);},aggregatesForDiff:function() |
{if(this._aggregatesForDiff) |
@@ -168,11 +197,11 @@ |
{return true;},forEachRoot:function(action,userRootsOnly) |
{for(var iter=this.rootNode().edges();iter.hasNext();iter.next()){var node=iter.edge.node();if(!userRootsOnly||this._isUserRoot(node)) |
action(node);}},_calculateDistances:function() |
-{var nodeFieldCount=this._nodeFieldCount;var nodeCount=this.nodeCount;var distances=new Int32Array(nodeCount);var noDistance=this._noDistance;for(var i=0;i<nodeCount;++i) |
-distances[i]=noDistance;var nodesToVisit=new Uint32Array(this.nodeCount);var nodesToVisitLength=0;function enqueueNode(node) |
+{var nodeFieldCount=this._nodeFieldCount;var nodeCount=this.nodeCount;var distances=this._nodeDistances=new Int32Array(nodeCount);var noDistance=this._noDistance;for(var i=0;i<nodeCount;++i) |
+distances[i]=noDistance;var nodesToVisit=new Uint32Array(this.nodeCount);var nodesToVisitLength=0;function enqueueNode(distance,node) |
{var ordinal=node._ordinal();if(distances[ordinal]!==noDistance) |
-return;distances[ordinal]=0;nodesToVisit[nodesToVisitLength++]=node.nodeIndex;} |
-this.forEachRoot(enqueueNode,true);this._bfs(nodesToVisit,nodesToVisitLength,distances);nodesToVisitLength=0;this.forEachRoot(enqueueNode);this._bfs(nodesToVisit,nodesToVisitLength,distances);this._nodeDistances=distances;},_bfs:function(nodesToVisit,nodesToVisitLength,distances) |
+return;distances[ordinal]=distance;nodesToVisit[nodesToVisitLength++]=node.nodeIndex;} |
+this.forEachRoot(enqueueNode.bind(null,1),true);this._bfs(nodesToVisit,nodesToVisitLength,distances);nodesToVisitLength=0;this.forEachRoot(enqueueNode.bind(null,0),false);this._bfs(nodesToVisit,nodesToVisitLength,distances);},_bfs:function(nodesToVisit,nodesToVisitLength,distances) |
{var edgeFieldsCount=this._edgeFieldsCount;var nodeFieldCount=this._nodeFieldCount;var containmentEdges=this._containmentEdges;var firstEdgeIndexes=this._firstEdgeIndexes;var edgeToNodeOffset=this._edgeToNodeOffset;var edgeTypeOffset=this._edgeTypeOffset;var nodeCount=this.nodeCount;var containmentEdgesLength=containmentEdges.length;var edgeWeakType=this._edgeWeakType;var noDistance=this._noDistance;var index=0;while(index<nodesToVisitLength){var nodeIndex=nodesToVisit[index++];var nodeOrdinal=nodeIndex/nodeFieldCount;var distance=distances[nodeOrdinal]+1;var firstEdgeIndex=firstEdgeIndexes[nodeOrdinal];var edgesEnd=firstEdgeIndexes[nodeOrdinal+1];for(var edgeIndex=firstEdgeIndex;edgeIndex<edgesEnd;edgeIndex+=edgeFieldsCount){var edgeType=containmentEdges[edgeIndex+edgeTypeOffset];if(edgeType==edgeWeakType) |
continue;var childNodeIndex=containmentEdges[edgeIndex+edgeToNodeOffset];var childNodeOrdinal=childNodeIndex/nodeFieldCount;if(distances[childNodeOrdinal]!==noDistance) |
continue;distances[childNodeOrdinal]=distance;nodesToVisit[nodesToVisitLength++]=childNodeIndex;}} |
@@ -210,24 +239,24 @@ |
if(newDominatorIndex!==noEntry&&dominators[postOrderIndex]!==newDominatorIndex){dominators[postOrderIndex]=newDominatorIndex;changed=true;nodeOrdinal=postOrderIndex2NodeOrdinal[postOrderIndex];beginEdgeToNodeFieldIndex=firstEdgeIndexes[nodeOrdinal]+edgeToNodeOffset;endEdgeToNodeFieldIndex=firstEdgeIndexes[nodeOrdinal+1];for(var toNodeFieldIndex=beginEdgeToNodeFieldIndex;toNodeFieldIndex<endEdgeToNodeFieldIndex;toNodeFieldIndex+=edgeFieldsCount){var childNodeOrdinal=containmentEdges[toNodeFieldIndex]/nodeFieldCount;affected[nodeOrdinal2PostOrderIndex[childNodeOrdinal]]=1;}}}} |
var dominatorsTree=new Uint32Array(nodesCount);for(var postOrderIndex=0,l=dominators.length;postOrderIndex<l;++postOrderIndex){nodeOrdinal=postOrderIndex2NodeOrdinal[postOrderIndex];dominatorsTree[nodeOrdinal]=postOrderIndex2NodeOrdinal[dominators[postOrderIndex]];} |
return dominatorsTree;},_calculateRetainedSizes:function(postOrderIndex2NodeOrdinal) |
-{var nodeCount=this.nodeCount;var nodes=this._nodes;var nodeSelfSizeOffset=this._nodeSelfSizeOffset;var nodeFieldCount=this._nodeFieldCount;var dominatorsTree=this._dominatorsTree;var nodeRetainedSizeOffset=this._nodeRetainedSizeOffset=this._nodeEdgeCountOffset;delete this._nodeEdgeCountOffset;for(var nodeIndex=0,l=nodes.length;nodeIndex<l;nodeIndex+=nodeFieldCount) |
-nodes[nodeIndex+nodeRetainedSizeOffset]=nodes[nodeIndex+nodeSelfSizeOffset];for(var postOrderIndex=0;postOrderIndex<nodeCount-1;++postOrderIndex){var nodeOrdinal=postOrderIndex2NodeOrdinal[postOrderIndex];var nodeIndex=nodeOrdinal*nodeFieldCount;var dominatorIndex=dominatorsTree[nodeOrdinal]*nodeFieldCount;nodes[dominatorIndex+nodeRetainedSizeOffset]+=nodes[nodeIndex+nodeRetainedSizeOffset];}},_buildDominatedNodes:function() |
+{var nodeCount=this.nodeCount;var nodes=this._nodes;var nodeSelfSizeOffset=this._nodeSelfSizeOffset;var nodeFieldCount=this._nodeFieldCount;var dominatorsTree=this._dominatorsTree;var retainedSizes=this._retainedSizes=new Float64Array(nodeCount);for(var nodeOrdinal=0;nodeOrdinal<nodeCount;++nodeOrdinal) |
+retainedSizes[nodeOrdinal]=nodes[nodeOrdinal*nodeFieldCount+nodeSelfSizeOffset];for(var postOrderIndex=0;postOrderIndex<nodeCount-1;++postOrderIndex){var nodeOrdinal=postOrderIndex2NodeOrdinal[postOrderIndex];var dominatorOrdinal=dominatorsTree[nodeOrdinal];retainedSizes[dominatorOrdinal]+=retainedSizes[nodeOrdinal];}},_buildDominatedNodes:function() |
{var indexArray=this._firstDominatedNodeIndex=new Uint32Array(this.nodeCount+1);var dominatedNodes=this._dominatedNodes=new Uint32Array(this.nodeCount-1);var nodeFieldCount=this._nodeFieldCount;var dominatorsTree=this._dominatorsTree;var fromNodeOrdinal=0;var toNodeOrdinal=this.nodeCount;var rootNodeOrdinal=this._rootNodeIndex/nodeFieldCount;if(rootNodeOrdinal===fromNodeOrdinal) |
fromNodeOrdinal=1;else if(rootNodeOrdinal===toNodeOrdinal-1) |
toNodeOrdinal=toNodeOrdinal-1;else |
throw new Error("Root node is expected to be either first or last");for(var nodeOrdinal=fromNodeOrdinal;nodeOrdinal<toNodeOrdinal;++nodeOrdinal) |
++indexArray[dominatorsTree[nodeOrdinal]];var firstDominatedNodeIndex=0;for(var i=0,l=this.nodeCount;i<l;++i){var dominatedCount=dominatedNodes[firstDominatedNodeIndex]=indexArray[i];indexArray[i]=firstDominatedNodeIndex;firstDominatedNodeIndex+=dominatedCount;} |
-indexArray[this.nodeCount]=dominatedNodes.length;for(var nodeOrdinal=fromNodeOrdinal;nodeOrdinal<toNodeOrdinal;++nodeOrdinal){var dominatorOrdinal=dominatorsTree[nodeOrdinal];var dominatedRefIndex=indexArray[dominatorOrdinal];dominatedRefIndex+=(--dominatedNodes[dominatedRefIndex]);dominatedNodes[dominatedRefIndex]=nodeOrdinal*nodeFieldCount;}},_markInvisibleEdges:function() |
-{throw new Error("Not implemented");},_calculateFlags:function() |
+indexArray[this.nodeCount]=dominatedNodes.length;for(var nodeOrdinal=fromNodeOrdinal;nodeOrdinal<toNodeOrdinal;++nodeOrdinal){var dominatorOrdinal=dominatorsTree[nodeOrdinal];var dominatedRefIndex=indexArray[dominatorOrdinal];dominatedRefIndex+=(--dominatedNodes[dominatedRefIndex]);dominatedNodes[dominatedRefIndex]=nodeOrdinal*nodeFieldCount;}},_calculateFlags:function() |
+{throw new Error("Not implemented");},_calculateStatistics:function() |
{throw new Error("Not implemented");},userObjectsMapAndFlag:function() |
{throw new Error("Not implemented");},calculateSnapshotDiff:function(baseSnapshotId,baseSnapshotAggregates) |
{var snapshotDiff=this._snapshotDiffs[baseSnapshotId];if(snapshotDiff) |
return snapshotDiff;snapshotDiff={};var aggregates=this.aggregates(true,"allObjects");for(var className in baseSnapshotAggregates){var baseAggregate=baseSnapshotAggregates[className];var diff=this._calculateDiffForClass(baseAggregate,aggregates[className]);if(diff) |
snapshotDiff[className]=diff;} |
-var emptyBaseAggregate={ids:[],indexes:[],selfSizes:[]};for(var className in aggregates){if(className in baseSnapshotAggregates) |
+var emptyBaseAggregate=new WebInspector.HeapSnapshotCommon.AggregateForDiff();for(var className in aggregates){if(className in baseSnapshotAggregates) |
continue;snapshotDiff[className]=this._calculateDiffForClass(emptyBaseAggregate,aggregates[className]);} |
this._snapshotDiffs[baseSnapshotId]=snapshotDiff;return snapshotDiff;},_calculateDiffForClass:function(baseAggregate,aggregate) |
-{var baseIds=baseAggregate.ids;var baseIndexes=baseAggregate.indexes;var baseSelfSizes=baseAggregate.selfSizes;var indexes=aggregate?aggregate.idxs:[];var i=0,l=baseIds.length;var j=0,m=indexes.length;var diff={addedCount:0,removedCount:0,addedSize:0,removedSize:0,deletedIndexes:[],addedIndexes:[]};var nodeB=this.createNode(indexes[j]);while(i<l&&j<m){var nodeAId=baseIds[i];if(nodeAId<nodeB.id()){diff.deletedIndexes.push(baseIndexes[i]);diff.removedCount++;diff.removedSize+=baseSelfSizes[i];++i;}else if(nodeAId>nodeB.id()){diff.addedIndexes.push(indexes[j]);diff.addedCount++;diff.addedSize+=nodeB.selfSize();nodeB.nodeIndex=indexes[++j];}else{++i;nodeB.nodeIndex=indexes[++j];}} |
+{var baseIds=baseAggregate.ids;var baseIndexes=baseAggregate.indexes;var baseSelfSizes=baseAggregate.selfSizes;var indexes=aggregate?aggregate.idxs:[];var i=0,l=baseIds.length;var j=0,m=indexes.length;var diff=new WebInspector.HeapSnapshotCommon.Diff();var nodeB=this.createNode(indexes[j]);while(i<l&&j<m){var nodeAId=baseIds[i];if(nodeAId<nodeB.id()){diff.deletedIndexes.push(baseIndexes[i]);diff.removedCount++;diff.removedSize+=baseSelfSizes[i];++i;}else if(nodeAId>nodeB.id()){diff.addedIndexes.push(indexes[j]);diff.addedCount++;diff.addedSize+=nodeB.selfSize();nodeB.nodeIndex=indexes[++j];}else{++i;nodeB.nodeIndex=indexes[++j];}} |
while(i<l){diff.deletedIndexes.push(baseIndexes[i]);diff.removedCount++;diff.removedSize+=baseSelfSizes[i];++i;} |
while(j<m){diff.addedIndexes.push(indexes[j]);diff.addedCount++;diff.addedSize+=nodeB.selfSize();nodeB.nodeIndex=indexes[++j];} |
diff.countDelta=diff.addedCount-diff.removedCount;diff.sizeDelta=diff.addedSize-diff.removedSize;if(!diff.addedCount&&!diff.removedCount) |
@@ -242,53 +271,39 @@ |
return ids;},dominatorIdsForNode:function(snapshotObjectId) |
{var node=this._nodeForSnapshotObjectId(snapshotObjectId);if(!node) |
return null;var result=[];while(!node.isRoot()){result.push(node.id());node.nodeIndex=node.dominatorIndex();} |
-return result;},_parseFilter:function(filter) |
-{if(!filter) |
-return null;var parsedFilter=eval("(function(){return "+filter+"})()");return parsedFilter.bind(this);},createEdgesProvider:function(nodeIndex,showHiddenData) |
-{var node=this.createNode(nodeIndex);var filter=this.containmentEdgesFilter(showHiddenData);return new WebInspector.HeapSnapshotEdgesProvider(this,filter,node.edges());},createEdgesProviderForTest:function(nodeIndex,filter) |
-{var node=this.createNode(nodeIndex);return new WebInspector.HeapSnapshotEdgesProvider(this,filter,node.edges());},retainingEdgesFilter:function(showHiddenData) |
-{return null;},containmentEdgesFilter:function(showHiddenData) |
-{return null;},createRetainingEdgesProvider:function(nodeIndex,showHiddenData) |
-{var node=this.createNode(nodeIndex);var filter=this.retainingEdgesFilter(showHiddenData);return new WebInspector.HeapSnapshotEdgesProvider(this,filter,node.retainers());},createAddedNodesProvider:function(baseSnapshotId,className) |
+return result;},createEdgesProvider:function(nodeIndex) |
+{var node=this.createNode(nodeIndex);var filter=this.containmentEdgesFilter();var indexProvider=new WebInspector.HeapSnapshotEdgeIndexProvider(this);return new WebInspector.HeapSnapshotEdgesProvider(this,filter,node.edges(),indexProvider);},createEdgesProviderForTest:function(nodeIndex,filter) |
+{var node=this.createNode(nodeIndex);var indexProvider=new WebInspector.HeapSnapshotEdgeIndexProvider(this);return new WebInspector.HeapSnapshotEdgesProvider(this,filter,node.edges(),indexProvider);},retainingEdgesFilter:function() |
+{return null;},containmentEdgesFilter:function() |
+{return null;},createRetainingEdgesProvider:function(nodeIndex) |
+{var node=this.createNode(nodeIndex);var filter=this.retainingEdgesFilter();var indexProvider=new WebInspector.HeapSnapshotRetainerEdgeIndexProvider(this);return new WebInspector.HeapSnapshotEdgesProvider(this,filter,node.retainers(),indexProvider);},createAddedNodesProvider:function(baseSnapshotId,className) |
{var snapshotDiff=this._snapshotDiffs[baseSnapshotId];var diffForClass=snapshotDiff[className];return new WebInspector.HeapSnapshotNodesProvider(this,null,diffForClass.addedIndexes);},createDeletedNodesProvider:function(nodeIndexes) |
{return new WebInspector.HeapSnapshotNodesProvider(this,null,nodeIndexes);},classNodesFilter:function() |
-{return null;},createNodesProviderForClass:function(className,aggregatesKey) |
-{return new WebInspector.HeapSnapshotNodesProvider(this,this.classNodesFilter(),this.aggregates(false,aggregatesKey)[className].idxs);},createNodesProviderForDominator:function(nodeIndex) |
-{var node=this.createNode(nodeIndex);return new WebInspector.HeapSnapshotNodesProvider(this,null,this._dominatedNodesOfNode(node));},updateStaticData:function() |
-{return{nodeCount:this.nodeCount,rootNodeIndex:this._rootNodeIndex,totalSize:this.totalSize,uid:this.uid};}};WebInspector.HeapSnapshotFilteredOrderedIterator=function(iterator,filter,unfilteredIterationOrder) |
-{this._filter=filter;this._iterator=iterator;this._unfilteredIterationOrder=unfilteredIterationOrder;this._iterationOrder=null;this._position=0;this._currentComparator=null;this._sortedPrefixLength=0;this._sortedSuffixLength=0;} |
-WebInspector.HeapSnapshotFilteredOrderedIterator.prototype={_createIterationOrder:function() |
+{return null;},createNodesProviderForClass:function(className,nodeFilter) |
+{return new WebInspector.HeapSnapshotNodesProvider(this,this.classNodesFilter(),this.aggregatesWithFilter(nodeFilter)[className].idxs);},createNodesProviderForDominator:function(nodeIndex) |
+{var node=this.createNode(nodeIndex);return new WebInspector.HeapSnapshotNodesProvider(this,null,this._dominatedNodesOfNode(node));},_maxJsNodeId:function() |
+{var nodeFieldCount=this._nodeFieldCount;var nodes=this._nodes;var nodesLength=nodes.length;var id=0;for(var nodeIndex=this._nodeIdOffset;nodeIndex<nodesLength;nodeIndex+=nodeFieldCount){var nextId=nodes[nodeIndex];if(nextId%2===0) |
+continue;if(id<nextId) |
+id=nextId;} |
+return id;},updateStaticData:function() |
+{return new WebInspector.HeapSnapshotCommon.StaticData(this.nodeCount,this._rootNodeIndex,this.totalSize,this._maxJsNodeId());}};WebInspector.HeapSnapshotItemProvider=function(iterator,indexProvider) |
+{this._iterator=iterator;this._indexProvider=indexProvider;this._isEmpty=!iterator.hasNext();this._iterationOrder=null;this._currentComparator=null;this._sortedPrefixLength=0;this._sortedSuffixLength=0;} |
+WebInspector.HeapSnapshotItemProvider.prototype={_createIterationOrder:function() |
{if(this._iterationOrder) |
-return;if(this._unfilteredIterationOrder&&!this._filter){this._iterationOrder=this._unfilteredIterationOrder.slice(0);this._unfilteredIterationOrder=null;return;} |
-this._iterationOrder=[];var iterator=this._iterator;if(!this._unfilteredIterationOrder&&!this._filter){for(iterator.rewind();iterator.hasNext();iterator.next()) |
-this._iterationOrder.push(iterator.index());}else if(!this._unfilteredIterationOrder){for(iterator.rewind();iterator.hasNext();iterator.next()){if(this._filter(iterator.item())) |
-this._iterationOrder.push(iterator.index());}}else{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())) |
-this._iterationOrder.push(iterator.index());} |
-this._unfilteredIterationOrder=null;}},rewind:function() |
-{this._position=0;},hasNext:function() |
-{return this._position<this._iterationOrder.length;},isEmpty:function() |
-{if(this._iterationOrder) |
-return!this._iterationOrder.length;if(this._unfilteredIterationOrder&&!this._filter) |
-return!this._unfilteredIterationOrder.length;var iterator=this._iterator;if(!this._unfilteredIterationOrder&&!this._filter){iterator.rewind();return!iterator.hasNext();}else if(!this._unfilteredIterationOrder){for(iterator.rewind();iterator.hasNext();iterator.next()) |
-if(this._filter(iterator.item())) |
-return false;}else{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())) |
-return false;}} |
-return true;},item:function() |
-{this._iterator.setIndex(this._iterationOrder[this._position]);return this._iterator.item();},get length() |
-{this._createIterationOrder();return this._iterationOrder.length;},next:function() |
-{++this._position;},serializeItemsRange:function(begin,end) |
+return;this._iterationOrder=[];for(var iterator=this._iterator;iterator.hasNext();iterator.next()) |
+this._iterationOrder.push(iterator.item().itemIndex());},isEmpty:function() |
+{return this._isEmpty;},serializeItemsRange:function(begin,end) |
{this._createIterationOrder();if(begin>end) |
throw new Error("Start position > end position: "+begin+" > "+end);if(end>this._iterationOrder.length) |
end=this._iterationOrder.length;if(this._sortedPrefixLength<end&&begin<this._iterationOrder.length-this._sortedSuffixLength){this.sort(this._currentComparator,this._sortedPrefixLength,this._iterationOrder.length-1-this._sortedSuffixLength,begin,end-1);if(begin<=this._sortedPrefixLength) |
this._sortedPrefixLength=end;if(end>=this._iterationOrder.length-this._sortedSuffixLength) |
this._sortedSuffixLength=this._iterationOrder.length-begin;} |
-this._position=begin;var startPosition=this._position;var count=end-begin;var result=new Array(count);for(var i=0;i<count&&this.hasNext();++i,this.next()) |
-result[i]=this.item().serialize();result.length=i;result.totalLength=this._iterationOrder.length;result.startPosition=startPosition;result.endPosition=this._position;return result;},sortAll:function() |
-{this._createIterationOrder();if(this._sortedPrefixLength+this._sortedSuffixLength>=this._iterationOrder.length) |
-return;this.sort(this._currentComparator,this._sortedPrefixLength,this._iterationOrder.length-1-this._sortedSuffixLength,this._sortedPrefixLength,this._iterationOrder.length-1-this._sortedSuffixLength);this._sortedPrefixLength=this._iterationOrder.length;this._sortedSuffixLength=0;},sortAndRewind:function(comparator) |
-{this._currentComparator=comparator;this._sortedPrefixLength=0;this._sortedSuffixLength=0;this.rewind();}} |
-WebInspector.HeapSnapshotEdgesProvider=function(snapshot,filter,edgesIter) |
-{this.snapshot=snapshot;WebInspector.HeapSnapshotFilteredOrderedIterator.call(this,edgesIter,filter);} |
+var position=begin;var count=end-begin;var result=new Array(count);var iterator=this._iterator;for(var i=0;i<count;++i){var itemIndex=this._iterationOrder[position++];var item=this._indexProvider.itemForIndex(itemIndex);result[i]=item.serialize();} |
+return new WebInspector.HeapSnapshotCommon.ItemsRange(begin,end,this._iterationOrder.length,result);},sortAndRewind:function(comparator) |
+{this._currentComparator=comparator;this._sortedPrefixLength=0;this._sortedSuffixLength=0;}} |
+WebInspector.HeapSnapshotEdgesProvider=function(snapshot,filter,edgesIter,indexProvider) |
+{this.snapshot=snapshot;if(filter) |
+edgesIter=new WebInspector.HeapSnapshotFilteredIterator(edgesIter,filter);WebInspector.HeapSnapshotItemProvider.call(this,edgesIter,indexProvider);} |
WebInspector.HeapSnapshotEdgesProvider.prototype={sort:function(comparator,leftBound,rightBound,windowLeft,windowRight) |
{var fieldName1=comparator.fieldName1;var fieldName2=comparator.fieldName2;var ascending1=comparator.ascending1;var ascending2=comparator.ascending2;var edgeA=this._iterator.item().clone();var edgeB=edgeA.clone();var nodeA=this.snapshot.createNode();var nodeB=this.snapshot.createNode();function compareEdgeFieldName(ascending,indexA,indexB) |
{edgeA.edgeIndex=indexA;edgeB.edgeIndex=indexB;if(edgeB.name()==="__proto__")return-1;if(edgeA.name()==="__proto__")return 1;var result=edgeA.hasStringName()===edgeB.hasStringName()?(edgeA.name()<edgeB.name()?-1:(edgeA.name()>edgeB.name()?1:0)):(edgeA.hasStringName()?-1:1);return ascending?result:-result;} |
@@ -306,37 +321,56 @@ |
if(fieldName1==="!edgeName") |
this._iterationOrder.sortRange(compareEdgeAndNode,leftBound,rightBound,windowLeft,windowRight);else if(fieldName2==="!edgeName") |
this._iterationOrder.sortRange(compareNodeAndEdge,leftBound,rightBound,windowLeft,windowRight);else |
-this._iterationOrder.sortRange(compareNodeAndNode,leftBound,rightBound,windowLeft,windowRight);},__proto__:WebInspector.HeapSnapshotFilteredOrderedIterator.prototype} |
+this._iterationOrder.sortRange(compareNodeAndNode,leftBound,rightBound,windowLeft,windowRight);},__proto__:WebInspector.HeapSnapshotItemProvider.prototype} |
WebInspector.HeapSnapshotNodesProvider=function(snapshot,filter,nodeIndexes) |
-{this.snapshot=snapshot;WebInspector.HeapSnapshotFilteredOrderedIterator.call(this,snapshot._allNodes(),filter,nodeIndexes);} |
+{this.snapshot=snapshot;var indexProvider=new WebInspector.HeapSnapshotNodeIndexProvider(snapshot);var it=new WebInspector.HeapSnapshotIndexRangeIterator(indexProvider,nodeIndexes);if(filter) |
+it=new WebInspector.HeapSnapshotFilteredIterator(it,filter);WebInspector.HeapSnapshotItemProvider.call(this,it,indexProvider);} |
WebInspector.HeapSnapshotNodesProvider.prototype={nodePosition:function(snapshotObjectId) |
-{this._createIterationOrder();if(this.isEmpty()) |
-return-1;this.sortAll();var node=this.snapshot.createNode();for(var i=0;i<this._iterationOrder.length;i++){node.nodeIndex=this._iterationOrder[i];if(node.id()===snapshotObjectId) |
-return i;} |
-return-1;},sort:function(comparator,leftBound,rightBound,windowLeft,windowRight) |
-{var fieldName1=comparator.fieldName1;var fieldName2=comparator.fieldName2;var ascending1=comparator.ascending1;var ascending2=comparator.ascending2;var nodeA=this.snapshot.createNode();var nodeB=this.snapshot.createNode();function sortByNodeField(fieldName,ascending) |
-{var valueOrFunctionA=nodeA[fieldName];var valueA=typeof valueOrFunctionA!=="function"?valueOrFunctionA:valueOrFunctionA.call(nodeA);var valueOrFunctionB=nodeB[fieldName];var valueB=typeof valueOrFunctionB!=="function"?valueOrFunctionB:valueOrFunctionB.call(nodeB);var result=valueA<valueB?-1:(valueA>valueB?1:0);return ascending?result:-result;} |
-function sortByComparator(indexA,indexB){nodeA.nodeIndex=indexA;nodeB.nodeIndex=indexB;var result=sortByNodeField(fieldName1,ascending1);if(result===0) |
-result=sortByNodeField(fieldName2,ascending2);if(result===0) |
-return indexA-indexB;return result;} |
-this._iterationOrder.sortRange(sortByComparator,leftBound,rightBound,windowLeft,windowRight);},__proto__:WebInspector.HeapSnapshotFilteredOrderedIterator.prototype};WebInspector.HeapSnapshotProgressEvent={Update:"ProgressUpdate"};WebInspector.HeapSnapshotCommon={} |
-WebInspector.HeapSnapshotCommon.AllocationNodeCallers=function() |
-{this.nodesWithSingleCaller;this.branchingCallers;} |
+{this._createIterationOrder();var node=this.snapshot.createNode();for(var i=0;i<this._iterationOrder.length;i++){node.nodeIndex=this._iterationOrder[i];if(node.id()===snapshotObjectId) |
+break;} |
+if(i===this._iterationOrder.length) |
+return-1;var targetNodeIndex=this._iterationOrder[i];var smallerCount=0;var compare=this._buildCompareFunction(this._currentComparator);for(var i=0;i<this._iterationOrder.length;i++){if(compare(this._iterationOrder[i],targetNodeIndex)<0) |
+++smallerCount;} |
+return smallerCount;},_buildCompareFunction:function(comparator) |
+{var nodeA=this.snapshot.createNode();var nodeB=this.snapshot.createNode();var fieldAccessor1=nodeA[comparator.fieldName1];var fieldAccessor2=nodeA[comparator.fieldName2];var ascending1=comparator.ascending1?1:-1;var ascending2=comparator.ascending2?1:-1;function sortByNodeField(fieldAccessor,ascending) |
+{var valueA=fieldAccessor.call(nodeA);var valueB=fieldAccessor.call(nodeB);return valueA<valueB?-ascending:(valueA>valueB?ascending:0);} |
+function sortByComparator(indexA,indexB) |
+{nodeA.nodeIndex=indexA;nodeB.nodeIndex=indexB;var result=sortByNodeField(fieldAccessor1,ascending1);if(result===0) |
+result=sortByNodeField(fieldAccessor2,ascending2);return result||indexA-indexB;} |
+return sortByComparator;},sort:function(comparator,leftBound,rightBound,windowLeft,windowRight) |
+{this._iterationOrder.sortRange(this._buildCompareFunction(comparator),leftBound,rightBound,windowLeft,windowRight);},__proto__:WebInspector.HeapSnapshotItemProvider.prototype};WebInspector.HeapSnapshotProgressEvent={Update:"ProgressUpdate"};WebInspector.HeapSnapshotCommon={} |
+WebInspector.HeapSnapshotCommon.AllocationNodeCallers=function(nodesWithSingleCaller,branchingCallers) |
+{this.nodesWithSingleCaller=nodesWithSingleCaller;this.branchingCallers=branchingCallers;} |
+WebInspector.HeapSnapshotCommon.SerializedAllocationNode=function(nodeId,functionName,scriptName,line,column,count,size,liveCount,liveSize,hasChildren) |
+{this.id=nodeId;this.name=functionName;this.scriptName=scriptName;this.line=line;this.column=column;this.count=count;this.size=size;this.liveCount=liveCount;this.liveSize=liveSize;this.hasChildren=hasChildren;} |
WebInspector.HeapSnapshotCommon.Aggregate=function() |
{this.count;this.distance;this.self;this.maxRet;this.type;this.name;this.idxs;} |
+WebInspector.HeapSnapshotCommon.AggregateForDiff=function(){this.indexes=[];this.ids=[];this.selfSizes=[];} |
+WebInspector.HeapSnapshotCommon.Diff=function() |
+{this.addedCount=0;this.removedCount=0;this.addedSize=0;this.removedSize=0;this.deletedIndexes=[];this.addedIndexes=[];} |
WebInspector.HeapSnapshotCommon.DiffForClass=function() |
{this.addedCount;this.removedCount;this.addedSize;this.removedSize;this.deletedIndexes;this.addedIndexes;this.countDelta;this.sizeDelta;} |
WebInspector.HeapSnapshotCommon.ComparatorConfig=function() |
{this.fieldName1;this.ascending1;this.fieldName2;this.ascending2;} |
WebInspector.HeapSnapshotCommon.WorkerCommand=function() |
-{this.callId;this.disposition;this.objectId;this.newObjectId;this.methodName;this.methodArguments;this.source;};WebInspector.HeapSnapshotLoader=function(dispatcher) |
+{this.callId;this.disposition;this.objectId;this.newObjectId;this.methodName;this.methodArguments;this.source;} |
+WebInspector.HeapSnapshotCommon.ItemsRange=function(startPosition,endPosition,totalLength,items) |
+{this.startPosition=startPosition;this.endPosition=endPosition;this.totalLength=totalLength;this.items=items;} |
+WebInspector.HeapSnapshotCommon.StaticData=function(nodeCount,rootNodeIndex,totalSize,maxJSObjectId) |
+{this.nodeCount=nodeCount;this.rootNodeIndex=rootNodeIndex;this.totalSize=totalSize;this.maxJSObjectId=maxJSObjectId;} |
+WebInspector.HeapSnapshotCommon.Statistics=function() |
+{this.total;this.v8heap;this.native;this.code;this.jsArrays;this.strings;} |
+WebInspector.HeapSnapshotCommon.NodeFilter=function(minNodeId,maxNodeId) |
+{this.minNodeId=minNodeId;this.maxNodeId=maxNodeId;this.allocationNodeId;} |
+WebInspector.HeapSnapshotCommon.NodeFilter.prototype={equals:function(o) |
+{return this.minNodeId===o.minNodeId&&this.maxNodeId===o.maxNodeId&&this.allocationNodeId===o.allocationNodeId;}};WebInspector.HeapSnapshotLoader=function(dispatcher) |
{this._reset();this._progress=new WebInspector.HeapSnapshotProgress(dispatcher);} |
WebInspector.HeapSnapshotLoader.prototype={dispose:function() |
{this._reset();},_reset:function() |
{this._json="";this._state="find-snapshot-info";this._snapshot={};},close:function() |
{if(this._json) |
-this._parseStringsArray();},buildSnapshot:function(constructorName) |
-{this._progress.updateStatus("Processing snapshot\u2026");var constructor=WebInspector[constructorName];var result=new constructor(this._snapshot,this._progress);this._reset();return result;},_parseUintArray:function() |
+this._parseStringsArray();},buildSnapshot:function(showHiddenData) |
+{this._progress.updateStatus("Processing snapshot\u2026");var result=new WebInspector.JSHeapSnapshot(this._snapshot,this._progress,showHiddenData);this._reset();return result;},_parseUintArray:function() |
{var index=0;var char0="0".charCodeAt(0),char9="9".charCodeAt(0),closingBracket="]".charCodeAt(0);var length=this._json.length;while(true){while(index<length){var code=this._json.charCodeAt(index);if(char0<=code&&code<=char9) |
break;else if(code===closingBracket){this._json=this._json.slice(index+1);return false;} |
++index;} |
@@ -360,7 +394,7 @@ |
return;var bracketIndex=this._json.indexOf("[",edgesTokenIndex);if(bracketIndex===-1) |
return;this._json=this._json.slice(bracketIndex+1);var edge_fields_count=this._snapshot.snapshot.meta.edge_fields.length;var edges_length=this._snapshot.snapshot.edge_count*edge_fields_count;this._array=new Uint32Array(edges_length);this._arrayIndex=0;this._state="parse-edges";break;} |
case"parse-edges":{var hasMoreData=this._parseUintArray();this._progress.updateProgress("Loading edges\u2026 %d\%",this._arrayIndex,this._array.length);if(hasMoreData) |
-return;this._snapshot.edges=this._array;this._array=null;if(WebInspector.HeapSnapshot.enableAllocationProfiler) |
+return;this._snapshot.edges=this._array;this._array=null;if(this._snapshot.snapshot.trace_function_count) |
this._state="find-trace-function-infos";else |
this._state="find-strings";break;} |
case"find-trace-function-infos":{var tracesToken="\"trace_function_infos\"";var tracesTokenIndex=this._json.indexOf(tracesToken);if(tracesTokenIndex===-1) |
@@ -389,56 +423,40 @@ |
this._objects[data.newObjectId]=result;response.result=!!result;break;} |
case"method":{var object=this._objects[data.objectId];response.result=object[data.methodName].apply(object,data.methodArguments);break;} |
case"evaluateForTest":{try{response.result=eval(data.source)}catch(e){response.result=e.toString();} |
-break;} |
-case"enableAllocationProfiler":{WebInspector.HeapSnapshot.enableAllocationProfiler=true;return;}}}catch(e){response.error=e.toString();response.errorCallStack=e.stack;if(data.methodName) |
+break;}}}catch(e){response.error=e.toString();response.errorCallStack=e.stack;if(data.methodName) |
response.errorMethodName=data.methodName;} |
-this._postMessage(response);}};;WebInspector.JSHeapSnapshot=function(profile,progress) |
-{this._nodeFlags={canBeQueried:1,detachedDOMTreeNode:2,pageObject:4,visitedMarkerMask:0x0ffff,visitedMarker:0x10000};this._lazyStringCache={};WebInspector.HeapSnapshot.call(this,profile,progress);} |
-WebInspector.JSHeapSnapshot.prototype={maxJsNodeId:function() |
-{var nodeFieldCount=this._nodeFieldCount;var nodes=this._nodes;var nodesLength=nodes.length;var id=0;for(var nodeIndex=this._nodeIdOffset;nodeIndex<nodesLength;nodeIndex+=nodeFieldCount){var nextId=nodes[nodeIndex];if(nextId%2===0) |
-continue;if(id<nodes[nodeIndex]) |
-id=nodes[nodeIndex];} |
-return id;},createNode:function(nodeIndex) |
-{return new WebInspector.JSHeapSnapshotNode(this,nodeIndex);},createEdge:function(edges,edgeIndex) |
-{return new WebInspector.JSHeapSnapshotEdge(this,edges,edgeIndex);},createRetainingEdge:function(retainedNodeIndex,retainerIndex) |
-{return new WebInspector.JSHeapSnapshotRetainerEdge(this,retainedNodeIndex,retainerIndex);},classNodesFilter:function() |
+this._postMessage(response);}};;WebInspector.JSHeapSnapshot=function(profile,progress,showHiddenData) |
+{this._nodeFlags={canBeQueried:1,detachedDOMTreeNode:2,pageObject:4,visitedMarkerMask:0x0ffff,visitedMarker:0x10000};this._lazyStringCache={};WebInspector.HeapSnapshot.call(this,profile,progress,showHiddenData);} |
+WebInspector.JSHeapSnapshot.prototype={createNode:function(nodeIndex) |
+{return new WebInspector.JSHeapSnapshotNode(this,nodeIndex);},createEdge:function(edgeIndex) |
+{return new WebInspector.JSHeapSnapshotEdge(this,edgeIndex);},createRetainingEdge:function(retainerIndex) |
+{return new WebInspector.JSHeapSnapshotRetainerEdge(this,retainerIndex);},classNodesFilter:function() |
{function filter(node) |
{return node.isUserObject();} |
-return filter;},containmentEdgesFilter:function(showHiddenData) |
-{function filter(edge){if(edge.isInvisible()) |
+return this._showHiddenData?null:filter;},containmentEdgesFilter:function() |
+{var showHiddenData=this._showHiddenData;function filter(edge){if(edge.isInvisible()) |
return false;if(showHiddenData) |
return true;return!edge.isHidden()&&!edge.node().isHidden();} |
-return filter;},retainingEdgesFilter:function(showHiddenData) |
-{var containmentEdgesFilter=this.containmentEdgesFilter(showHiddenData);function filter(edge) |
+return filter;},retainingEdgesFilter:function() |
+{var containmentEdgesFilter=this.containmentEdgesFilter();function filter(edge) |
{return containmentEdgesFilter(edge)&&!edge.node().isRoot()&&!edge.isWeak();} |
return filter;},dispose:function() |
-{WebInspector.HeapSnapshot.prototype.dispose.call(this);delete this._flags;},_markInvisibleEdges:function() |
-{for(var iter=this.rootNode().edges();iter.hasNext();iter.next()){var edge=iter.edge;if(!edge.isShortcut()) |
-continue;var node=edge.node();var propNames={};for(var innerIter=node.edges();innerIter.hasNext();innerIter.next()){var globalObjEdge=innerIter.edge;if(globalObjEdge.isShortcut()) |
-propNames[globalObjEdge._nameOrIndex()]=true;} |
-for(innerIter.rewind();innerIter.hasNext();innerIter.next()){var globalObjEdge=innerIter.edge;if(!globalObjEdge.isShortcut()&&globalObjEdge.node().isHidden()&&globalObjEdge._hasStringName()&&(globalObjEdge._nameOrIndex()in propNames)) |
-this._containmentEdges[globalObjEdge._edges._start+globalObjEdge.edgeIndex+this._edgeTypeOffset]=this._edgeInvisibleType;}}},_calculateFlags:function() |
+{WebInspector.HeapSnapshot.prototype.dispose.call(this);delete this._flags;},_calculateFlags:function() |
{this._flags=new Uint32Array(this.nodeCount);this._markDetachedDOMTreeNodes();this._markQueriableHeapObjects();this._markPageOwnedNodes();},_isUserRoot:function(node) |
{return node.isUserRoot()||node.isDocumentDOMTreesRoot();},forEachRoot:function(action,userRootsOnly) |
{function getChildNodeByName(node,name) |
{for(var iter=node.edges();iter.hasNext();iter.next()){var child=iter.edge.node();if(child.name()===name) |
return child;} |
return null;} |
-function getChildNodeByLinkName(node,name) |
-{for(var iter=node.edges();iter.hasNext();iter.next()){var edge=iter.edge;if(edge.name()===name) |
-return edge.node();} |
-return null;} |
var visitedNodes={};function doAction(node) |
{var ordinal=node._ordinal();if(!visitedNodes[ordinal]){action(node);visitedNodes[ordinal]=true;}} |
var gcRoots=getChildNodeByName(this.rootNode(),"(GC roots)");if(!gcRoots) |
-return;if(userRootsOnly){for(var iter=this.rootNode().edges();iter.hasNext();iter.next()){var node=iter.edge.node();if(node.isDocumentDOMTreesRoot()) |
-doAction(node);else if(node.isUserRoot()){var nativeContextNode=getChildNodeByLinkName(node,"native_context");if(nativeContextNode) |
-doAction(nativeContextNode);else |
-doAction(node);}}}else{for(var iter=gcRoots.edges();iter.hasNext();iter.next()){var subRoot=iter.edge.node();for(var iter2=subRoot.edges();iter2.hasNext();iter2.next()) |
+return;if(userRootsOnly){for(var iter=this.rootNode().edges();iter.hasNext();iter.next()){var node=iter.edge.node();if(this._isUserRoot(node)) |
+doAction(node);}}else{for(var iter=gcRoots.edges();iter.hasNext();iter.next()){var subRoot=iter.edge.node();for(var iter2=subRoot.edges();iter2.hasNext();iter2.next()) |
doAction(iter2.edge.node());doAction(subRoot);} |
for(var iter=this.rootNode().edges();iter.hasNext();iter.next()) |
doAction(iter.edge.node())}},userObjectsMapAndFlag:function() |
-{return{map:this._flags,flag:this._nodeFlags.pageObject};},_flagsOfNode:function(node) |
+{return this._showHiddenData?null:{map:this._flags,flag:this._nodeFlags.pageObject};},_flagsOfNode:function(node) |
{return this._flags[node.nodeIndex/this._nodeFieldCount];},_markDetachedDOMTreeNodes:function() |
{var flag=this._nodeFlags.detachedDOMTreeNode;var detachedDOMTreesRoot;for(var iter=this.rootNode().edges();iter.hasNext();iter.next()){var node=iter.edge.node();if(node.name()==="(Detached DOM trees)"){detachedDOMTreesRoot=node;break;}} |
if(!detachedDOMTreesRoot) |
@@ -455,7 +473,19 @@ |
continue;var nodeOrdinal=nodeIndex/nodeFieldCount;nodesToVisit[nodesToVisitLength++]=nodeOrdinal;flags[nodeOrdinal]|=visitedMarker;} |
while(nodesToVisitLength){var nodeOrdinal=nodesToVisit[--nodesToVisitLength];flags[nodeOrdinal]|=flag;flags[nodeOrdinal]&=visitedMarkerMask;var beginEdgeIndex=firstEdgeIndexes[nodeOrdinal];var endEdgeIndex=firstEdgeIndexes[nodeOrdinal+1];for(var edgeIndex=beginEdgeIndex;edgeIndex<endEdgeIndex;edgeIndex+=edgeFieldsCount){var childNodeIndex=containmentEdges[edgeIndex+edgeToNodeOffset];var childNodeOrdinal=childNodeIndex/nodeFieldCount;if(flags[childNodeOrdinal]&markerAndFlag) |
continue;var type=containmentEdges[edgeIndex+edgeTypeOffset];if(type===edgeWeakType) |
-continue;nodesToVisit[nodesToVisitLength++]=childNodeOrdinal;flags[childNodeOrdinal]|=visitedMarker;}}},__proto__:WebInspector.HeapSnapshot.prototype};WebInspector.JSHeapSnapshotNode=function(snapshot,nodeIndex) |
+continue;nodesToVisit[nodesToVisitLength++]=childNodeOrdinal;flags[childNodeOrdinal]|=visitedMarker;}}},_calculateStatistics:function() |
+{var nodeFieldCount=this._nodeFieldCount;var nodes=this._nodes;var nodesLength=nodes.length;var nodeTypeOffset=this._nodeTypeOffset;var nodeSizeOffset=this._nodeSelfSizeOffset;;var nodeNativeType=this._nodeNativeType;var nodeCodeType=this._nodeCodeType;var nodeConsStringType=this._nodeConsStringType;var nodeSlicedStringType=this._nodeSlicedStringType;var sizeNative=0;var sizeCode=0;var sizeStrings=0;var sizeJSArrays=0;var node=this.rootNode();for(var nodeIndex=0;nodeIndex<nodesLength;nodeIndex+=nodeFieldCount){node.nodeIndex=nodeIndex;var nodeType=nodes[nodeIndex+nodeTypeOffset];var nodeSize=nodes[nodeIndex+nodeSizeOffset];if(nodeType===nodeNativeType) |
+sizeNative+=nodeSize;else if(nodeType===nodeCodeType) |
+sizeCode+=nodeSize;else if(nodeType===nodeConsStringType||nodeType===nodeSlicedStringType||node.type()==="string") |
+sizeStrings+=nodeSize;else if(node.name()==="Array") |
+sizeJSArrays+=this._calculateArraySize(node);} |
+this._statistics=new WebInspector.HeapSnapshotCommon.Statistics();this._statistics.total=this.totalSize;this._statistics.v8heap=this.totalSize-sizeNative;this._statistics.native=sizeNative;this._statistics.code=sizeCode;this._statistics.jsArrays=sizeJSArrays;this._statistics.strings=sizeStrings;},_calculateArraySize:function(node) |
+{var size=node.selfSize();var beginEdgeIndex=node._edgeIndexesStart();var endEdgeIndex=node._edgeIndexesEnd();var containmentEdges=this._containmentEdges;var strings=this._strings;var edgeToNodeOffset=this._edgeToNodeOffset;var edgeTypeOffset=this._edgeTypeOffset;var edgeNameOffset=this._edgeNameOffset;var edgeFieldsCount=this._edgeFieldsCount;var edgeInternalType=this._edgeInternalType;for(var edgeIndex=beginEdgeIndex;edgeIndex<endEdgeIndex;edgeIndex+=edgeFieldsCount){var edgeType=containmentEdges[edgeIndex+edgeTypeOffset];if(edgeType!==edgeInternalType) |
+continue;var edgeName=strings[containmentEdges[edgeIndex+edgeNameOffset]];if(edgeName!=="elements") |
+continue;var elementsNodeIndex=containmentEdges[edgeIndex+edgeToNodeOffset];node.nodeIndex=elementsNodeIndex;if(node.retainersCount()===1) |
+size+=node.selfSize();break;} |
+return size;},getStatistics:function() |
+{return this._statistics;},__proto__:WebInspector.HeapSnapshot.prototype};WebInspector.JSHeapSnapshotNode=function(snapshot,nodeIndex) |
{WebInspector.HeapSnapshotNode.call(this,snapshot,nodeIndex)} |
WebInspector.JSHeapSnapshotNode.prototype={canBeQueried:function() |
{var flags=this._snapshot._flagsOfNode(this);return!!(flags&this._snapshot._nodeFlags.canBeQueried);},isUserObject:function() |
@@ -478,10 +508,10 @@ |
{return this.isSynthetic()&&this.name()==="(Document DOM trees)";},serialize:function() |
{var result=WebInspector.HeapSnapshotNode.prototype.serialize.call(this);var flags=this._snapshot._flagsOfNode(this);if(flags&this._snapshot._nodeFlags.canBeQueried) |
result.canBeQueried=true;if(flags&this._snapshot._nodeFlags.detachedDOMTreeNode) |
-result.detachedDOMTreeNode=true;return result;},__proto__:WebInspector.HeapSnapshotNode.prototype};WebInspector.JSHeapSnapshotEdge=function(snapshot,edges,edgeIndex) |
-{WebInspector.HeapSnapshotEdge.call(this,snapshot,edges,edgeIndex);} |
+result.detachedDOMTreeNode=true;return result;},__proto__:WebInspector.HeapSnapshotNode.prototype};WebInspector.JSHeapSnapshotEdge=function(snapshot,edgeIndex) |
+{WebInspector.HeapSnapshotEdge.call(this,snapshot,edgeIndex);} |
WebInspector.JSHeapSnapshotEdge.prototype={clone:function() |
-{return new WebInspector.JSHeapSnapshotEdge(this._snapshot,this._edges,this.edgeIndex);},hasStringName:function() |
+{var snapshot=(this._snapshot);return new WebInspector.JSHeapSnapshotEdge(snapshot,this.edgeIndex);},hasStringName:function() |
{if(!this.isShortcut()) |
return this._hasStringName();return isNaN(parseInt(this._name(),10));},isElement:function() |
{return this._type()===this._snapshot._edgeElementType;},isHidden:function() |
@@ -495,13 +525,13 @@ |
{var name=this.name();switch(this.type()){case"context":return"->"+name;case"element":return"["+name+"]";case"weak":return"[["+name+"]]";case"property":return name.indexOf(" ")===-1?"."+name:"[\""+name+"\"]";case"shortcut":if(typeof name==="string") |
return name.indexOf(" ")===-1?"."+name:"[\""+name+"\"]";else |
return"["+name+"]";case"internal":case"hidden":case"invisible":return"{"+name+"}";};return"?"+name+"?";},_hasStringName:function() |
-{return!this.isElement()&&!this.isHidden()&&!this.isWeak();},_name:function() |
+{return!this.isElement()&&!this.isHidden();},_name:function() |
{return this._hasStringName()?this._snapshot._strings[this._nameOrIndex()]:this._nameOrIndex();},_nameOrIndex:function() |
-{return this._edges.item(this.edgeIndex+this._snapshot._edgeNameOffset);},_type:function() |
-{return this._edges.item(this.edgeIndex+this._snapshot._edgeTypeOffset);},__proto__:WebInspector.HeapSnapshotEdge.prototype};WebInspector.JSHeapSnapshotRetainerEdge=function(snapshot,retainedNodeIndex,retainerIndex) |
-{WebInspector.HeapSnapshotRetainerEdge.call(this,snapshot,retainedNodeIndex,retainerIndex);} |
+{return this._edges[this.edgeIndex+this._snapshot._edgeNameOffset];},_type:function() |
+{return this._edges[this.edgeIndex+this._snapshot._edgeTypeOffset];},__proto__:WebInspector.HeapSnapshotEdge.prototype};WebInspector.JSHeapSnapshotRetainerEdge=function(snapshot,retainerIndex) |
+{WebInspector.HeapSnapshotRetainerEdge.call(this,snapshot,retainerIndex);} |
WebInspector.JSHeapSnapshotRetainerEdge.prototype={clone:function() |
-{return new WebInspector.JSHeapSnapshotRetainerEdge(this._snapshot,this._retainedNodeIndex,this.retainerIndex());},isHidden:function() |
+{var snapshot=(this._snapshot);return new WebInspector.JSHeapSnapshotRetainerEdge(snapshot,this.retainerIndex());},isHidden:function() |
{return this._edge().isHidden();},isInternal:function() |
{return this._edge().isInternal();},isInvisible:function() |
{return this._edge().isInvisible();},isShortcut:function() |
@@ -540,6 +570,11 @@ |
String.prototype.lineEndings=function() |
{if(!this._lineEndings){this._lineEndings=this.findAll("\n");this._lineEndings.push(this.length);} |
return this._lineEndings;} |
+String.prototype.lineCount=function() |
+{var lineEndings=this.lineEndings();return lineEndings.length;} |
+String.prototype.lineAt=function(lineNumber) |
+{var lineEndings=this.lineEndings();var lineStart=lineNumber>0?lineEndings[lineNumber-1]+1:0;var lineEnd=lineEndings[lineNumber];var lineContent=this.substring(lineStart,lineEnd);if(lineContent.length>0&&lineContent.charAt(lineContent.length-1)==="\r") |
+lineContent=lineContent.substring(0,lineContent.length-1);return lineContent;} |
String.prototype.escapeCharacters=function(chars) |
{var foundChar=false;for(var i=0;i<chars.length;++i){if(this.indexOf(chars.charAt(i))!==-1){foundChar=true;break;}} |
if(!foundChar) |
@@ -547,7 +582,7 @@ |
result+="\\";result+=this.charAt(i);} |
return result;} |
String.regexSpecialCharacters=function() |
-{return"^[]{}()\\.$*+?|-,";} |
+{return"^[]{}()\\.^$*+?|-,";} |
String.prototype.escapeForRegExp=function() |
{return this.escapeCharacters(String.regexSpecialCharacters());} |
String.prototype.escapeHTML=function() |
@@ -613,11 +648,24 @@ |
leadZero(this.getHours())+ |
leadZero(this.getMinutes())+ |
leadZero(this.getSeconds());} |
-Object.defineProperty(Array.prototype,"remove",{value:function(value,onlyFirst) |
-{if(onlyFirst){var index=this.indexOf(value);if(index!==-1) |
-this.splice(index,1);return;} |
-var length=this.length;for(var i=0;i<length;++i){if(this[i]===value) |
-this.splice(i,1);}}});Object.defineProperty(Array.prototype,"keySet",{value:function() |
+Date.prototype.toConsoleTime=function() |
+{function leadZero2(x) |
+{return(x>9?"":"0")+x;} |
+function leadZero3(x) |
+{return(Array(4-x.toString().length)).join('0')+x;} |
+return this.getFullYear()+"-"+ |
+leadZero2(this.getMonth()+1)+"-"+ |
+leadZero2(this.getDate())+" "+ |
+leadZero2(this.getHours())+":"+ |
+leadZero2(this.getMinutes())+":"+ |
+leadZero2(this.getSeconds())+"."+ |
+leadZero3(this.getMilliseconds());} |
+Object.defineProperty(Array.prototype,"remove",{value:function(value,firstOnly) |
+{var index=this.indexOf(value);if(index===-1) |
+return;if(firstOnly){this.splice(index,1);return;} |
+for(var i=index+1,n=this.length;i<n;++i){if(this[i]!==value) |
+this[index++]=this[i];} |
+this.length=index;}});Object.defineProperty(Array.prototype,"keySet",{value:function() |
{var keys={};for(var i=0;i<this.length;++i) |
keys[this[i]]=true;return keys;}});Object.defineProperty(Array.prototype,"rotate",{value:function(index) |
{var result=[];for(var i=index;i<index+this.length;++i) |
@@ -649,16 +697,16 @@ |
var low=0;var high=this.length-1;for(;;){var pivotPosition=this.partition(comparator,low,high,Math.floor((high+low)/2));if(pivotPosition===k) |
return this[k];else if(pivotPosition>k) |
high=pivotPosition-1;else |
-low=pivotPosition+1;}}});Object.defineProperty(Array.prototype,"lowerBound",{value:function(object,comparator) |
+low=pivotPosition+1;}}});Object.defineProperty(Array.prototype,"lowerBound",{value:function(object,comparator,left,right) |
{function defaultComparator(a,b) |
{return a<b?-1:(a>b?1:0);} |
-comparator=comparator||defaultComparator;var l=0;var r=this.length;while(l<r){var m=(l+r)>>1;if(comparator(object,this[m])>0) |
+comparator=comparator||defaultComparator;var l=left||0;var r=right!==undefined?right:this.length;while(l<r){var m=(l+r)>>1;if(comparator(object,this[m])>0) |
l=m+1;else |
r=m;} |
-return r;}});Object.defineProperty(Array.prototype,"upperBound",{value:function(object,comparator) |
+return r;}});Object.defineProperty(Array.prototype,"upperBound",{value:function(object,comparator,left,right) |
{function defaultComparator(a,b) |
{return a<b?-1:(a>b?1:0);} |
-comparator=comparator||defaultComparator;var l=0;var r=this.length;while(l<r){var m=(l+r)>>1;if(comparator(object,this[m])>=0) |
+comparator=comparator||defaultComparator;var l=left||0;var r=right!==undefined?right:this.length;while(l<r){var m=(l+r)>>1;if(comparator(object,this[m])>=0) |
l=m+1;else |
r=m;} |
return r;}});Object.defineProperty(Array.prototype,"binaryIndexOf",{value:function(value,comparator) |
@@ -666,10 +714,13 @@ |
{var result=new Array(this.length);for(var i=0;i<this.length;++i) |
result[i]=this[i][field];return result;}});Object.defineProperty(Array.prototype,"peekLast",{value:function() |
{return this[this.length-1];}});(function(){function mergeOrIntersect(array1,array2,comparator,mergeNotIntersect) |
-{var result=[];var i=0;var j=0;while(i<array1.length||j<array2.length){if(i===array1.length){result=result.concat(array2.slice(j));j=array2.length;}else if(j===array2.length){result=result.concat(array1.slice(i));i=array1.length;}else{var compareValue=comparator(array1[i],array2[j]) |
-if(compareValue<0){if(mergeNotIntersect) |
-result.push(array1[i]);++i;}else if(compareValue>0){if(mergeNotIntersect) |
-result.push(array2[j]);++j;}else{result.push(array1[i]);++i;++j;}}} |
+{var result=[];var i=0;var j=0;while(i<array1.length&&j<array2.length){var compareValue=comparator(array1[i],array2[j]);if(mergeNotIntersect||!compareValue) |
+result.push(compareValue<=0?array1[i]:array2[j]);if(compareValue<=0) |
+i++;if(compareValue>=0) |
+j++;} |
+if(mergeNotIntersect){while(i<array1.length) |
+result.push(array1[i++]);while(j<array2.length) |
+result.push(array2[j++]);} |
return result;} |
Object.defineProperty(Array.prototype,"intersectOrdered",{value:function(array,comparator) |
{return mergeOrIntersect(this,array,comparator,false);}});Object.defineProperty(Array.prototype,"mergeOrdered",{value:function(array,comparator) |
@@ -784,6 +835,15 @@ |
return this._hasProtoKey;return Object.prototype.hasOwnProperty.call(this._map,key);},size:function() |
{return this._size;},clear:function() |
{this._map={};this._size=0;delete this._hasProtoKey;delete this._protoValue;}} |
+var StringSet=function() |
+{this._map=new StringMap();} |
+StringSet.prototype={put:function(value) |
+{this._map.put(value,true);},remove:function(value) |
+{return!!this._map.remove(value);},values:function() |
+{return this._map.keys();},contains:function(value) |
+{return this._map.contains(value);},size:function() |
+{return this._map.size();},clear:function() |
+{this._map.clear();}} |
function loadXHR(url,async,callback) |
{function onReadyStateChanged() |
{if(xhr.readyState!==XMLHttpRequest.DONE) |
@@ -793,20 +853,10 @@ |
xhr.onreadystatechange=onReadyStateChanged;xhr.send(null);if(!async){if(xhr.status===200) |
return xhr.responseText;return null;} |
return null;} |
-function StringPool() |
-{this.reset();} |
-StringPool.prototype={intern:function(string) |
-{if(string==="__proto__") |
-return"__proto__";var result=this._strings[string];if(result===undefined){this._strings[string]=string;result=string;} |
-return result;},reset:function() |
-{this._strings=Object.create(null);},internObjectStrings:function(obj,depthLimit) |
-{if(typeof depthLimit!=="number") |
-depthLimit=100;else if(--depthLimit<0) |
-throw"recursion depth limit reached in StringPool.deepIntern(), perhaps attempting to traverse cyclical references?";for(var field in obj){switch(typeof obj[field]){case"string":obj[field]=this.intern(obj[field]);break;case"object":this.internObjectStrings(obj[field],depthLimit);break;}}}} |
var _importedScripts={};function importScript(scriptName) |
{if(_importedScripts[scriptName]) |
return;var xhr=new XMLHttpRequest();_importedScripts[scriptName]=true;xhr.open("GET",scriptName,false);xhr.send(null);if(!xhr.responseText) |
-throw"empty response arrived for script '"+scriptName+"'";var baseUrl=location.href;baseUrl=baseUrl.substring(0,baseUrl.lastIndexOf("/"));var sourceURL=baseUrl+"/"+scriptName;eval(xhr.responseText+"\n//# sourceURL="+sourceURL);} |
+throw"empty response arrived for script '"+scriptName+"'";var baseUrl=location.origin+location.pathname;baseUrl=baseUrl.substring(0,baseUrl.lastIndexOf("/"));var sourceURL=baseUrl+"/"+scriptName;self.eval(xhr.responseText+"\n//# sourceURL="+sourceURL);} |
var loadScript=importScript;function CallbackBarrier() |
{this._pendingIncomingCallbacksCount=0;} |
CallbackBarrier.prototype={createCallback:function(userCallback) |
@@ -815,6 +865,8 @@ |
this._outgoingCallback();},_incomingCallback:function(userCallback) |
{console.assert(this._pendingIncomingCallbacksCount>0);if(userCallback){var args=Array.prototype.slice.call(arguments,1);userCallback.apply(null,args);} |
if(!--this._pendingIncomingCallbacksCount&&this._outgoingCallback) |
-this._outgoingCallback();}};function postMessageWrapper(message) |
+this._outgoingCallback();}} |
+function suppressUnused(value) |
+{};function postMessageWrapper(message) |
{postMessage(message);} |
var dispatcher=new WebInspector.HeapSnapshotWorkerDispatcher(this,postMessageWrapper);addEventListener("message",dispatcher.dispatchMessage.bind(dispatcher),false); |