Upstream version 9.37.195.0
[platform/framework/web/crosswalk.git] / src / chrome / tools / test / reference_build / chrome_linux / resources / inspector / HeapSnapshotWorker.js
1 WebInspector={};WebInspector.AllocationProfile=function(profile,liveObjectStats)
2 {this._strings=profile.strings;this._liveObjectStats=liveObjectStats;this._nextNodeId=1;this._functionInfos=[]
3 this._idToNode={};this._collapsedTopNodeIdToFunctionInfo={};this._traceTops=null;this._buildFunctionAllocationInfos(profile);this._traceTree=this._buildAllocationTree(profile,liveObjectStats);}
4 WebInspector.AllocationProfile.prototype={_buildFunctionAllocationInfos:function(profile)
5 {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)
6 {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)
7 {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));}
8 return result;}
9 return traverseNode(traceTreeRaw,0,null);},serializeTraceTops:function()
10 {if(this._traceTops)
11 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)
12 continue;var nodeId=this._nextNodeId++;result.push(this._serializeNode(nodeId,info,info.totalCount,info.totalSize,info.totalLiveCount,info.totalLiveSize,true));this._collapsedTopNodeIdToFunctionInfo[nodeId]=info;}
13 result.sort(function(a,b){return b.size-a.size;});return result;},serializeCallers:function(nodeId)
14 {var node=this._ensureBottomUpNode(nodeId);var nodesWithSingleCaller=[];while(node.callers().length===1){node=node.callers()[0];nodesWithSingleCaller.push(this._serializeCaller(node));}
15 var branchingCallers=[];var callers=node.callers();for(var i=0;i<callers.length;i++){branchingCallers.push(this._serializeCaller(callers[i]));}
16 return new WebInspector.HeapSnapshotCommon.AllocationNodeCallers(nodesWithSingleCaller,branchingCallers);},traceIds:function(allocationNodeId)
17 {return this._ensureBottomUpNode(allocationNodeId).traceTopIds;},_ensureBottomUpNode:function(nodeId)
18 {var node=this._idToNode[nodeId];if(!node){var functionInfo=this._collapsedTopNodeIdToFunctionInfo[nodeId];node=functionInfo.bottomUpRoot();delete this._collapsedTopNodeIdToFunctionInfo[nodeId];this._idToNode[nodeId]=node;}
19 return node;},_serializeCaller:function(node)
20 {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)
21 {return new WebInspector.HeapSnapshotCommon.SerializedAllocationNode(nodeId,functionInfo.functionName,functionInfo.scriptName,functionInfo.line,functionInfo.column,count,size,liveCount,liveSize,hasChildren);}}
22 WebInspector.TopDownAllocationNode=function(id,functionInfo,count,size,liveCount,liveSize,parent)
23 {this.id=id;this.functionInfo=functionInfo;this.allocationCount=count;this.allocationSize=size;this.liveCount=liveCount;this.liveSize=liveSize;this.parent=parent;this.children=[];}
24 WebInspector.BottomUpAllocationNode=function(functionInfo)
25 {this.functionInfo=functionInfo;this.allocationCount=0;this.allocationSize=0;this.liveCount=0;this.liveSize=0;this.traceTopIds=[];this._callers=[];}
26 WebInspector.BottomUpAllocationNode.prototype={addCaller:function(traceNode)
27 {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;}}
28 if(!result){result=new WebInspector.BottomUpAllocationNode(functionInfo);this._callers.push(result);}
29 return result;},callers:function()
30 {return this._callers;},hasCallers:function()
31 {return this._callers.length>0;}}
32 WebInspector.FunctionAllocationInfo=function(functionName,scriptName,scriptId,line,column)
33 {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=[];}
34 WebInspector.FunctionAllocationInfo.prototype={addTraceTopNode:function(node)
35 {if(node.allocationCount===0)
36 return;this._traceTops.push(node);this.totalCount+=node.allocationCount;this.totalSize+=node.allocationSize;this.totalLiveCount+=node.liveCount;this.totalLiveSize+=node.liveSize;},bottomUpRoot:function()
37 {if(!this._traceTops.length)
38 return null;if(!this._bottomUpTree)
39 this._buildAllocationTraceTree();return this._bottomUpTree;},_buildAllocationTraceTree:function()
40 {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;}
41 bottomUpNode=bottomUpNode.addCaller(node);}}}};WebInspector.HeapSnapshotItem=function(){}
42 WebInspector.HeapSnapshotItem.prototype={itemIndex:function(){},serialize:function(){}};WebInspector.HeapSnapshotEdge=function(snapshot,edgeIndex)
43 {this._snapshot=snapshot;this._edges=snapshot._containmentEdges;this.edgeIndex=edgeIndex||0;}
44 WebInspector.HeapSnapshotEdge.Serialized=function(name,node,nodeIndex,type)
45 {this.name=name;this.node=node;this.nodeIndex=nodeIndex;this.type=type;};WebInspector.HeapSnapshotEdge.prototype={clone:function()
46 {return new WebInspector.HeapSnapshotEdge(this._snapshot,this.edgeIndex);},hasStringName:function()
47 {throw new Error("Not implemented");},name:function()
48 {throw new Error("Not implemented");},node:function()
49 {return this._snapshot.createNode(this.nodeIndex());},nodeIndex:function()
50 {return this._edges[this.edgeIndex+this._snapshot._edgeToNodeOffset];},toString:function()
51 {return"HeapSnapshotEdge: "+this.name();},type:function()
52 {return this._snapshot._edgeTypes[this._type()];},itemIndex:function()
53 {return this.edgeIndex;},serialize:function()
54 {var node=this.node();return new WebInspector.HeapSnapshotEdge.Serialized(this.name(),node.serialize(),this.nodeIndex(),this.type());},_type:function()
55 {return this._edges[this.edgeIndex+this._snapshot._edgeTypeOffset];}};WebInspector.HeapSnapshotItemIterator=function(){}
56 WebInspector.HeapSnapshotItemIterator.prototype={hasNext:function(){},item:function(){},next:function(){}};WebInspector.HeapSnapshotItemIndexProvider=function(){}
57 WebInspector.HeapSnapshotItemIndexProvider.prototype={itemForIndex:function(newIndex){},};WebInspector.HeapSnapshotNodeIndexProvider=function(snapshot)
58 {this._node=snapshot.createNode();}
59 WebInspector.HeapSnapshotNodeIndexProvider.prototype={itemForIndex:function(index)
60 {this._node.nodeIndex=index;return this._node;}};WebInspector.HeapSnapshotEdgeIndexProvider=function(snapshot)
61 {this._edge=snapshot.createEdge(0);}
62 WebInspector.HeapSnapshotEdgeIndexProvider.prototype={itemForIndex:function(index)
63 {this._edge.edgeIndex=index;return this._edge;}};WebInspector.HeapSnapshotRetainerEdgeIndexProvider=function(snapshot)
64 {this._retainerEdge=snapshot.createRetainingEdge(0);}
65 WebInspector.HeapSnapshotRetainerEdgeIndexProvider.prototype={itemForIndex:function(index)
66 {this._retainerEdge.setRetainerIndex(index);return this._retainerEdge;}};WebInspector.HeapSnapshotEdgeIterator=function(node)
67 {this._sourceNode=node;this.edge=node._snapshot.createEdge(node._edgeIndexesStart());}
68 WebInspector.HeapSnapshotEdgeIterator.prototype={hasNext:function()
69 {return this.edge.edgeIndex<this._sourceNode._edgeIndexesEnd();},item:function()
70 {return this.edge;},next:function()
71 {this.edge.edgeIndex+=this.edge._snapshot._edgeFieldsCount;}};WebInspector.HeapSnapshotRetainerEdge=function(snapshot,retainerIndex)
72 {this._snapshot=snapshot;this.setRetainerIndex(retainerIndex);}
73 WebInspector.HeapSnapshotRetainerEdge.Serialized=function(name,node,nodeIndex,type){this.name=name;this.node=node;this.nodeIndex=nodeIndex;this.type=type;}
74 WebInspector.HeapSnapshotRetainerEdge.prototype={clone:function()
75 {return new WebInspector.HeapSnapshotRetainerEdge(this._snapshot,this.retainerIndex());},hasStringName:function()
76 {return this._edge().hasStringName();},name:function()
77 {return this._edge().name();},node:function()
78 {return this._node();},nodeIndex:function()
79 {return this._retainingNodeIndex;},retainerIndex:function()
80 {return this._retainerIndex;},setRetainerIndex:function(retainerIndex)
81 {if(retainerIndex===this._retainerIndex)
82 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)
83 {this.setRetainerIndex(edgeIndex);},_node:function()
84 {if(!this._nodeInstance)
85 this._nodeInstance=this._snapshot.createNode(this._retainingNodeIndex);return this._nodeInstance;},_edge:function()
86 {if(!this._edgeInstance)
87 this._edgeInstance=this._snapshot.createEdge(this._globalEdgeIndex);return this._edgeInstance;},toString:function()
88 {return this._edge().toString();},itemIndex:function()
89 {return this._retainerIndex;},serialize:function()
90 {var node=this.node();return new WebInspector.HeapSnapshotRetainerEdge.Serialized(this.name(),node.serialize(),this.nodeIndex(),this.type());},type:function()
91 {return this._edge().type();}}
92 WebInspector.HeapSnapshotRetainerEdgeIterator=function(retainedNode)
93 {var snapshot=retainedNode._snapshot;var retainedNodeOrdinal=retainedNode._ordinal();var retainerIndex=snapshot._firstRetainerIndex[retainedNodeOrdinal];this._retainersEnd=snapshot._firstRetainerIndex[retainedNodeOrdinal+1];this.retainer=snapshot.createRetainingEdge(retainerIndex);}
94 WebInspector.HeapSnapshotRetainerEdgeIterator.prototype={hasNext:function()
95 {return this.retainer.retainerIndex()<this._retainersEnd;},item:function()
96 {return this.retainer;},next:function()
97 {this.retainer.setRetainerIndex(this.retainer.retainerIndex()+1);}};WebInspector.HeapSnapshotNode=function(snapshot,nodeIndex)
98 {this._snapshot=snapshot;this.nodeIndex=nodeIndex||0;}
99 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;}
100 WebInspector.HeapSnapshotNode.prototype={distance:function()
101 {return this._snapshot._nodeDistances[this.nodeIndex/this._snapshot._nodeFieldCount];},className:function()
102 {throw new Error("Not implemented");},classIndex:function()
103 {throw new Error("Not implemented");},dominatorIndex:function()
104 {var nodeFieldCount=this._snapshot._nodeFieldCount;return this._snapshot._dominatorsTree[this.nodeIndex/this._snapshot._nodeFieldCount]*nodeFieldCount;},edges:function()
105 {return new WebInspector.HeapSnapshotEdgeIterator(this);},edgesCount:function()
106 {return(this._edgeIndexesEnd()-this._edgeIndexesStart())/this._snapshot._edgeFieldsCount;},id:function()
107 {throw new Error("Not implemented");},isRoot:function()
108 {return this.nodeIndex===this._snapshot._rootNodeIndex;},name:function()
109 {return this._snapshot._strings[this._name()];},retainedSize:function()
110 {return this._snapshot._retainedSizes[this._ordinal()];},retainers:function()
111 {return new WebInspector.HeapSnapshotRetainerEdgeIterator(this);},retainersCount:function()
112 {var snapshot=this._snapshot;var ordinal=this._ordinal();return snapshot._firstRetainerIndex[ordinal+1]-snapshot._firstRetainerIndex[ordinal];},selfSize:function()
113 {var snapshot=this._snapshot;return snapshot._nodes[this.nodeIndex+snapshot._nodeSelfSizeOffset];},type:function()
114 {return this._snapshot._nodeTypes[this._type()];},traceNodeId:function()
115 {var snapshot=this._snapshot;return snapshot._nodes[this.nodeIndex+snapshot._nodeTraceNodeIdOffset];},itemIndex:function()
116 {return this.nodeIndex;},serialize:function()
117 {return new WebInspector.HeapSnapshotNode.Serialized(this.id(),this.name(),this.distance(),this.nodeIndex,this.retainedSize(),this.selfSize(),this.type());},_name:function()
118 {var snapshot=this._snapshot;return snapshot._nodes[this.nodeIndex+snapshot._nodeNameOffset];},_edgeIndexesStart:function()
119 {return this._snapshot._firstEdgeIndexes[this._ordinal()];},_edgeIndexesEnd:function()
120 {return this._snapshot._firstEdgeIndexes[this._ordinal()+1];},_ordinal:function()
121 {return this.nodeIndex/this._snapshot._nodeFieldCount;},_nextNodeIndex:function()
122 {return this.nodeIndex+this._snapshot._nodeFieldCount;},_type:function()
123 {var snapshot=this._snapshot;return snapshot._nodes[this.nodeIndex+snapshot._nodeTypeOffset];}};WebInspector.HeapSnapshotNodeIterator=function(node)
124 {this.node=node;this._nodesLength=node._snapshot._nodes.length;}
125 WebInspector.HeapSnapshotNodeIterator.prototype={hasNext:function()
126 {return this.node.nodeIndex<this._nodesLength;},item:function()
127 {return this.node;},next:function()
128 {this.node.nodeIndex=this.node._nextNodeIndex();}}
129 WebInspector.HeapSnapshotIndexRangeIterator=function(itemProvider,indexes)
130 {this._itemProvider=itemProvider;this._indexes=indexes;this._position=0;}
131 WebInspector.HeapSnapshotIndexRangeIterator.prototype={hasNext:function()
132 {return this._position<this._indexes.length},item:function()
133 {var index=this._indexes[this._position];return this._itemProvider.itemForIndex(index);},next:function()
134 {++this._position;}}
135 WebInspector.HeapSnapshotFilteredIterator=function(iterator,filter)
136 {this._iterator=iterator;this._filter=filter;this._skipFilteredItems();}
137 WebInspector.HeapSnapshotFilteredIterator.prototype={hasNext:function()
138 {return this._iterator.hasNext();},item:function()
139 {return this._iterator.item();},next:function()
140 {this._iterator.next();this._skipFilteredItems();},_skipFilteredItems:function()
141 {while(this._iterator.hasNext()&&!this._filter(this._iterator.item())){this._iterator.next();}}}
142 WebInspector.HeapSnapshotProgress=function(dispatcher)
143 {this._dispatcher=dispatcher;}
144 WebInspector.HeapSnapshotProgress.prototype={updateStatus:function(status)
145 {this._sendUpdateEvent(WebInspector.UIString(status));},updateProgress:function(title,value,total)
146 {var percentValue=((total?(value/total):0)*100).toFixed(0);this._sendUpdateEvent(WebInspector.UIString(title,percentValue));},_sendUpdateEvent:function(text)
147 {if(this._dispatcher)
148 this._dispatcher.sendEvent(WebInspector.HeapSnapshotProgressEvent.Update,text);}}
149 WebInspector.HeapSnapshot=function(profile,progress,showHiddenData)
150 {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)
151 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:[]};}
152 stats.count++;stats.size+=node.selfSize();stats.ids.push(node.id());}
153 this._allocationProfile=new WebInspector.AllocationProfile(profile,liveObjects);this._progress.updateStatus("Done");}}
154 function HeapSnapshotMetainfo()
155 {this.node_fields=[];this.node_types=[];this.edge_fields=[];this.edge_types=[];this.trace_function_info_fields=[];this.trace_node_fields=[];this.type_strings={};}
156 function HeapSnapshotHeader()
157 {this.title="";this.meta=new HeapSnapshotMetainfo();this.node_count=0;this.edge_count=0;}
158 WebInspector.HeapSnapshot.prototype={_init:function()
159 {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()
160 {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()
161 {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)
162 throw new Error("Invalid toNodeIndex "+toNodeIndex);++firstRetainerIndex[toNodeIndex/nodeFieldCount];}
163 for(var i=0,firstUnusedRetainerSlot=0;i<nodeCount;i++){var retainersCount=firstRetainerIndex[i];firstRetainerIndex[i]=firstUnusedRetainerSlot;retainingNodes[firstUnusedRetainerSlot]=retainersCount;firstUnusedRetainerSlot+=retainersCount;}
164 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)
165 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)
166 {throw new Error("Not implemented");},createEdge:function(edgeIndex)
167 {throw new Error("Not implemented");},createRetainingEdge:function(retainerIndex)
168 {throw new Error("Not implemented");},dispose:function()
169 {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()
170 {return new WebInspector.HeapSnapshotNodeIterator(this.rootNode());},rootNode:function()
171 {return this.createNode(this._rootNodeIndex);},get rootNodeIndex()
172 {return this._rootNodeIndex;},get totalSize()
173 {return this.rootNode().retainedSize();},_getDominatedIndex:function(nodeIndex)
174 {if(nodeIndex%this._nodeFieldCount)
175 throw new Error("Invalid nodeIndex: "+nodeIndex);return this._firstDominatedNodeIndex[nodeIndex/this._nodeFieldCount];},_dominatedNodesOfNode:function(node)
176 {var dominatedIndexFrom=this._getDominatedIndex(node.nodeIndex);var dominatedIndexTo=this._getDominatedIndex(node._nextNodeIndex());return this._dominatedNodes.subarray(dominatedIndexFrom,dominatedIndexTo);},aggregatesWithFilter:function(nodeFilter)
177 {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";}
178 return this.aggregates(false,key,filter);},_createNodeIdFilter:function(minNodeId,maxNodeId)
179 {function nodeIdFilter(node)
180 {var id=node.id();return id>minNodeId&&id<=maxNodeId;}
181 return nodeIdFilter;},_createAllocationStackFilter:function(bottomUpAllocationNodeId)
182 {var traceIds=this._allocationProfile.traceIds(bottomUpAllocationNodeId);if(!traceIds.length)
183 return undefined;var set={};for(var i=0;i<traceIds.length;i++)
184 set[traceIds[i]]=true;function traceIdFilter(node)
185 {return!!set[node.traceNodeId()];};return traceIdFilter;},aggregates:function(sortedIndexes,key,filter)
186 {var aggregatesByClassName=key&&this._aggregates[key];if(!aggregatesByClassName){var aggregates=this._buildAggregates(filter);this._calculateClassesRetainedSize(aggregates.aggregatesByClassIndex,filter);aggregatesByClassName=aggregates.aggregatesByClassName;if(key)
187 this._aggregates[key]=aggregatesByClassName;}
188 if(sortedIndexes&&(!key||!this._aggregatesSortedFlags[key])){this._sortAggregateIndexes(aggregatesByClassName);if(key)
189 this._aggregatesSortedFlags[key]=sortedIndexes;}
190 return aggregatesByClassName;},allocationTracesTops:function()
191 {return this._allocationProfile.serializeTraceTops();},allocationNodeCallers:function(nodeId)
192 {return this._allocationProfile.serializeCallers(nodeId);},aggregatesForDiff:function()
193 {if(this._aggregatesForDiff)
194 return this._aggregatesForDiff;var aggregatesByClassName=this.aggregates(true,"allObjects");this._aggregatesForDiff={};var node=this.createNode();for(var className in aggregatesByClassName){var aggregate=aggregatesByClassName[className];var indexes=aggregate.idxs;var ids=new Array(indexes.length);var selfSizes=new Array(indexes.length);for(var i=0;i<indexes.length;i++){node.nodeIndex=indexes[i];ids[i]=node.id();selfSizes[i]=node.selfSize();}
195 this._aggregatesForDiff[className]={indexes:indexes,ids:ids,selfSizes:selfSizes};}
196 return this._aggregatesForDiff;},_isUserRoot:function(node)
197 {return true;},forEachRoot:function(action,userRootsOnly)
198 {for(var iter=this.rootNode().edges();iter.hasNext();iter.next()){var node=iter.edge.node();if(!userRootsOnly||this._isUserRoot(node))
199 action(node);}},_calculateDistances:function()
200 {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)
201 distances[i]=noDistance;var nodesToVisit=new Uint32Array(this.nodeCount);var nodesToVisitLength=0;function enqueueNode(distance,node)
202 {var ordinal=node._ordinal();if(distances[ordinal]!==noDistance)
203 return;distances[ordinal]=distance;nodesToVisit[nodesToVisitLength++]=node.nodeIndex;}
204 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)
205 {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)
206 continue;var childNodeIndex=containmentEdges[edgeIndex+edgeToNodeOffset];var childNodeOrdinal=childNodeIndex/nodeFieldCount;if(distances[childNodeOrdinal]!==noDistance)
207 continue;distances[childNodeOrdinal]=distance;nodesToVisit[nodesToVisitLength++]=childNodeIndex;}}
208 if(nodesToVisitLength>nodeCount)
209 throw new Error("BFS failed. Nodes to visit ("+nodesToVisitLength+") is more than nodes count ("+nodeCount+")");},_buildAggregates:function(filter)
210 {var aggregates={};var aggregatesByClassName={};var classIndexes=[];var nodes=this._nodes;var mapAndFlag=this.userObjectsMapAndFlag();var flags=mapAndFlag?mapAndFlag.map:null;var flag=mapAndFlag?mapAndFlag.flag:0;var nodesLength=nodes.length;var nodeNativeType=this._nodeNativeType;var nodeFieldCount=this._nodeFieldCount;var selfSizeOffset=this._nodeSelfSizeOffset;var nodeTypeOffset=this._nodeTypeOffset;var node=this.rootNode();var nodeDistances=this._nodeDistances;for(var nodeIndex=0;nodeIndex<nodesLength;nodeIndex+=nodeFieldCount){var nodeOrdinal=nodeIndex/nodeFieldCount;if(flags&&!(flags[nodeOrdinal]&flag))
211 continue;node.nodeIndex=nodeIndex;if(filter&&!filter(node))
212 continue;var selfSize=nodes[nodeIndex+selfSizeOffset];if(!selfSize&&nodes[nodeIndex+nodeTypeOffset]!==nodeNativeType)
213 continue;var classIndex=node.classIndex();if(!(classIndex in aggregates)){var nodeType=node.type();var nameMatters=nodeType==="object"||nodeType==="native";var value={count:1,distance:nodeDistances[nodeOrdinal],self:selfSize,maxRet:0,type:nodeType,name:nameMatters?node.name():null,idxs:[nodeIndex]};aggregates[classIndex]=value;classIndexes.push(classIndex);aggregatesByClassName[node.className()]=value;}else{var clss=aggregates[classIndex];clss.distance=Math.min(clss.distance,nodeDistances[nodeOrdinal]);++clss.count;clss.self+=selfSize;clss.idxs.push(nodeIndex);}}
214 for(var i=0,l=classIndexes.length;i<l;++i){var classIndex=classIndexes[i];aggregates[classIndex].idxs=aggregates[classIndex].idxs.slice();}
215 return{aggregatesByClassName:aggregatesByClassName,aggregatesByClassIndex:aggregates};},_calculateClassesRetainedSize:function(aggregates,filter)
216 {var rootNodeIndex=this._rootNodeIndex;var node=this.createNode(rootNodeIndex);var list=[rootNodeIndex];var sizes=[-1];var classes=[];var seenClassNameIndexes={};var nodeFieldCount=this._nodeFieldCount;var nodeTypeOffset=this._nodeTypeOffset;var nodeNativeType=this._nodeNativeType;var dominatedNodes=this._dominatedNodes;var nodes=this._nodes;var mapAndFlag=this.userObjectsMapAndFlag();var flags=mapAndFlag?mapAndFlag.map:null;var flag=mapAndFlag?mapAndFlag.flag:0;var firstDominatedNodeIndex=this._firstDominatedNodeIndex;while(list.length){var nodeIndex=list.pop();node.nodeIndex=nodeIndex;var classIndex=node.classIndex();var seen=!!seenClassNameIndexes[classIndex];var nodeOrdinal=nodeIndex/nodeFieldCount;var dominatedIndexFrom=firstDominatedNodeIndex[nodeOrdinal];var dominatedIndexTo=firstDominatedNodeIndex[nodeOrdinal+1];if(!seen&&(!flags||(flags[nodeOrdinal]&flag))&&(!filter||filter(node))&&(node.selfSize()||nodes[nodeIndex+nodeTypeOffset]===nodeNativeType)){aggregates[classIndex].maxRet+=node.retainedSize();if(dominatedIndexFrom!==dominatedIndexTo){seenClassNameIndexes[classIndex]=true;sizes.push(list.length);classes.push(classIndex);}}
217 for(var i=dominatedIndexFrom;i<dominatedIndexTo;i++)
218 list.push(dominatedNodes[i]);var l=list.length;while(sizes[sizes.length-1]===l){sizes.pop();classIndex=classes.pop();seenClassNameIndexes[classIndex]=false;}}},_sortAggregateIndexes:function(aggregates)
219 {var nodeA=this.createNode();var nodeB=this.createNode();for(var clss in aggregates)
220 aggregates[clss].idxs.sort(function(idxA,idxB){nodeA.nodeIndex=idxA;nodeB.nodeIndex=idxB;return nodeA.id()<nodeB.id()?-1:1;});},_buildPostOrderIndex:function()
221 {var nodeFieldCount=this._nodeFieldCount;var nodes=this._nodes;var nodeCount=this.nodeCount;var rootNodeOrdinal=this._rootNodeIndex/nodeFieldCount;var edgeFieldsCount=this._edgeFieldsCount;var edgeTypeOffset=this._edgeTypeOffset;var edgeToNodeOffset=this._edgeToNodeOffset;var edgeShortcutType=this._edgeShortcutType;var firstEdgeIndexes=this._firstEdgeIndexes;var containmentEdges=this._containmentEdges;var containmentEdgesLength=this._containmentEdges.length;var mapAndFlag=this.userObjectsMapAndFlag();var flags=mapAndFlag?mapAndFlag.map:null;var flag=mapAndFlag?mapAndFlag.flag:0;var nodesToVisit=new Uint32Array(nodeCount);var postOrderIndex2NodeOrdinal=new Uint32Array(nodeCount);var nodeOrdinal2PostOrderIndex=new Uint32Array(nodeCount);var painted=new Uint8Array(nodeCount);var nodesToVisitLength=0;var postOrderIndex=0;var grey=1;var black=2;nodesToVisit[nodesToVisitLength++]=rootNodeOrdinal;painted[rootNodeOrdinal]=grey;while(nodesToVisitLength){var nodeOrdinal=nodesToVisit[nodesToVisitLength-1];if(painted[nodeOrdinal]===grey){painted[nodeOrdinal]=black;var nodeFlag=!flags||(flags[nodeOrdinal]&flag);var beginEdgeIndex=firstEdgeIndexes[nodeOrdinal];var endEdgeIndex=firstEdgeIndexes[nodeOrdinal+1];for(var edgeIndex=beginEdgeIndex;edgeIndex<endEdgeIndex;edgeIndex+=edgeFieldsCount){if(nodeOrdinal!==rootNodeOrdinal&&containmentEdges[edgeIndex+edgeTypeOffset]===edgeShortcutType)
222 continue;var childNodeIndex=containmentEdges[edgeIndex+edgeToNodeOffset];var childNodeOrdinal=childNodeIndex/nodeFieldCount;var childNodeFlag=!flags||(flags[childNodeOrdinal]&flag);if(nodeOrdinal!==rootNodeOrdinal&&childNodeFlag&&!nodeFlag)
223 continue;if(!painted[childNodeOrdinal]){painted[childNodeOrdinal]=grey;nodesToVisit[nodesToVisitLength++]=childNodeOrdinal;}}}else{nodeOrdinal2PostOrderIndex[nodeOrdinal]=postOrderIndex;postOrderIndex2NodeOrdinal[postOrderIndex++]=nodeOrdinal;--nodesToVisitLength;}}
224 if(postOrderIndex!==nodeCount){console.log("Error: Corrupted snapshot. "+(nodeCount-postOrderIndex)+" nodes are unreachable from the root:");var dumpNode=this.rootNode();for(var i=0;i<nodeCount;++i){if(painted[i]!==black){nodeOrdinal2PostOrderIndex[i]=postOrderIndex;postOrderIndex2NodeOrdinal[postOrderIndex++]=i;dumpNode.nodeIndex=i*nodeFieldCount;console.log(JSON.stringify(dumpNode.serialize()));for(var retainers=dumpNode.retainers();retainers.hasNext();retainers=retainers.item().node().retainers())
225 console.log("  edgeName: "+retainers.item().name()+" nodeClassName: "+retainers.item().node().className());}}}
226 return{postOrderIndex2NodeOrdinal:postOrderIndex2NodeOrdinal,nodeOrdinal2PostOrderIndex:nodeOrdinal2PostOrderIndex};},_buildDominatorTree:function(postOrderIndex2NodeOrdinal,nodeOrdinal2PostOrderIndex)
227 {var nodeFieldCount=this._nodeFieldCount;var nodes=this._nodes;var firstRetainerIndex=this._firstRetainerIndex;var retainingNodes=this._retainingNodes;var retainingEdges=this._retainingEdges;var edgeFieldsCount=this._edgeFieldsCount;var edgeTypeOffset=this._edgeTypeOffset;var edgeToNodeOffset=this._edgeToNodeOffset;var edgeShortcutType=this._edgeShortcutType;var firstEdgeIndexes=this._firstEdgeIndexes;var containmentEdges=this._containmentEdges;var containmentEdgesLength=this._containmentEdges.length;var rootNodeIndex=this._rootNodeIndex;var mapAndFlag=this.userObjectsMapAndFlag();var flags=mapAndFlag?mapAndFlag.map:null;var flag=mapAndFlag?mapAndFlag.flag:0;var nodesCount=postOrderIndex2NodeOrdinal.length;var rootPostOrderedIndex=nodesCount-1;var noEntry=nodesCount;var dominators=new Uint32Array(nodesCount);for(var i=0;i<rootPostOrderedIndex;++i)
228 dominators[i]=noEntry;dominators[rootPostOrderedIndex]=rootPostOrderedIndex;var affected=new Uint8Array(nodesCount);var nodeOrdinal;{nodeOrdinal=this._rootNodeIndex/nodeFieldCount;var beginEdgeToNodeFieldIndex=firstEdgeIndexes[nodeOrdinal]+edgeToNodeOffset;var endEdgeToNodeFieldIndex=firstEdgeIndexes[nodeOrdinal+1];for(var toNodeFieldIndex=beginEdgeToNodeFieldIndex;toNodeFieldIndex<endEdgeToNodeFieldIndex;toNodeFieldIndex+=edgeFieldsCount){var childNodeOrdinal=containmentEdges[toNodeFieldIndex]/nodeFieldCount;affected[nodeOrdinal2PostOrderIndex[childNodeOrdinal]]=1;}}
229 var changed=true;while(changed){changed=false;for(var postOrderIndex=rootPostOrderedIndex-1;postOrderIndex>=0;--postOrderIndex){if(affected[postOrderIndex]===0)
230 continue;affected[postOrderIndex]=0;if(dominators[postOrderIndex]===rootPostOrderedIndex)
231 continue;nodeOrdinal=postOrderIndex2NodeOrdinal[postOrderIndex];var nodeFlag=!flags||(flags[nodeOrdinal]&flag);var newDominatorIndex=noEntry;var beginRetainerIndex=firstRetainerIndex[nodeOrdinal];var endRetainerIndex=firstRetainerIndex[nodeOrdinal+1];for(var retainerIndex=beginRetainerIndex;retainerIndex<endRetainerIndex;++retainerIndex){var retainerEdgeIndex=retainingEdges[retainerIndex];var retainerEdgeType=containmentEdges[retainerEdgeIndex+edgeTypeOffset];var retainerNodeIndex=retainingNodes[retainerIndex];if(retainerNodeIndex!==rootNodeIndex&&retainerEdgeType===edgeShortcutType)
232 continue;var retainerNodeOrdinal=retainerNodeIndex/nodeFieldCount;var retainerNodeFlag=!flags||(flags[retainerNodeOrdinal]&flag);if(retainerNodeIndex!==rootNodeIndex&&nodeFlag&&!retainerNodeFlag)
233 continue;var retanerPostOrderIndex=nodeOrdinal2PostOrderIndex[retainerNodeOrdinal];if(dominators[retanerPostOrderIndex]!==noEntry){if(newDominatorIndex===noEntry)
234 newDominatorIndex=retanerPostOrderIndex;else{while(retanerPostOrderIndex!==newDominatorIndex){while(retanerPostOrderIndex<newDominatorIndex)
235 retanerPostOrderIndex=dominators[retanerPostOrderIndex];while(newDominatorIndex<retanerPostOrderIndex)
236 newDominatorIndex=dominators[newDominatorIndex];}}
237 if(newDominatorIndex===rootPostOrderedIndex)
238 break;}}
239 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;}}}}
240 var dominatorsTree=new Uint32Array(nodesCount);for(var postOrderIndex=0,l=dominators.length;postOrderIndex<l;++postOrderIndex){nodeOrdinal=postOrderIndex2NodeOrdinal[postOrderIndex];dominatorsTree[nodeOrdinal]=postOrderIndex2NodeOrdinal[dominators[postOrderIndex]];}
241 return dominatorsTree;},_calculateRetainedSizes:function(postOrderIndex2NodeOrdinal)
242 {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)
243 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()
244 {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)
245 fromNodeOrdinal=1;else if(rootNodeOrdinal===toNodeOrdinal-1)
246 toNodeOrdinal=toNodeOrdinal-1;else
247 throw new Error("Root node is expected to be either first or last");for(var nodeOrdinal=fromNodeOrdinal;nodeOrdinal<toNodeOrdinal;++nodeOrdinal)
248 ++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;}
249 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()
250 {throw new Error("Not implemented");},_calculateStatistics:function()
251 {throw new Error("Not implemented");},userObjectsMapAndFlag:function()
252 {throw new Error("Not implemented");},calculateSnapshotDiff:function(baseSnapshotId,baseSnapshotAggregates)
253 {var snapshotDiff=this._snapshotDiffs[baseSnapshotId];if(snapshotDiff)
254 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)
255 snapshotDiff[className]=diff;}
256 var emptyBaseAggregate=new WebInspector.HeapSnapshotCommon.AggregateForDiff();for(var className in aggregates){if(className in baseSnapshotAggregates)
257 continue;snapshotDiff[className]=this._calculateDiffForClass(emptyBaseAggregate,aggregates[className]);}
258 this._snapshotDiffs[baseSnapshotId]=snapshotDiff;return snapshotDiff;},_calculateDiffForClass:function(baseAggregate,aggregate)
259 {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];}}
260 while(i<l){diff.deletedIndexes.push(baseIndexes[i]);diff.removedCount++;diff.removedSize+=baseSelfSizes[i];++i;}
261 while(j<m){diff.addedIndexes.push(indexes[j]);diff.addedCount++;diff.addedSize+=nodeB.selfSize();nodeB.nodeIndex=indexes[++j];}
262 diff.countDelta=diff.addedCount-diff.removedCount;diff.sizeDelta=diff.addedSize-diff.removedSize;if(!diff.addedCount&&!diff.removedCount)
263 return null;return diff;},_nodeForSnapshotObjectId:function(snapshotObjectId)
264 {for(var it=this._allNodes();it.hasNext();it.next()){if(it.node.id()===snapshotObjectId)
265 return it.node;}
266 return null;},nodeClassName:function(snapshotObjectId)
267 {var node=this._nodeForSnapshotObjectId(snapshotObjectId);if(node)
268 return node.className();return null;},idsOfObjectsWithName:function(name)
269 {var ids=[];for(var it=this._allNodes();it.hasNext();it.next()){if(it.item().name()===name)
270 ids.push(it.item().id());}
271 return ids;},dominatorIdsForNode:function(snapshotObjectId)
272 {var node=this._nodeForSnapshotObjectId(snapshotObjectId);if(!node)
273 return null;var result=[];while(!node.isRoot()){result.push(node.id());node.nodeIndex=node.dominatorIndex();}
274 return result;},createEdgesProvider:function(nodeIndex)
275 {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)
276 {var node=this.createNode(nodeIndex);var indexProvider=new WebInspector.HeapSnapshotEdgeIndexProvider(this);return new WebInspector.HeapSnapshotEdgesProvider(this,filter,node.edges(),indexProvider);},retainingEdgesFilter:function()
277 {return null;},containmentEdgesFilter:function()
278 {return null;},createRetainingEdgesProvider:function(nodeIndex)
279 {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)
280 {var snapshotDiff=this._snapshotDiffs[baseSnapshotId];var diffForClass=snapshotDiff[className];return new WebInspector.HeapSnapshotNodesProvider(this,null,diffForClass.addedIndexes);},createDeletedNodesProvider:function(nodeIndexes)
281 {return new WebInspector.HeapSnapshotNodesProvider(this,null,nodeIndexes);},classNodesFilter:function()
282 {return null;},createNodesProviderForClass:function(className,nodeFilter)
283 {return new WebInspector.HeapSnapshotNodesProvider(this,this.classNodesFilter(),this.aggregatesWithFilter(nodeFilter)[className].idxs);},createNodesProviderForDominator:function(nodeIndex)
284 {var node=this.createNode(nodeIndex);return new WebInspector.HeapSnapshotNodesProvider(this,null,this._dominatedNodesOfNode(node));},_maxJsNodeId:function()
285 {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)
286 continue;if(id<nextId)
287 id=nextId;}
288 return id;},updateStaticData:function()
289 {return new WebInspector.HeapSnapshotCommon.StaticData(this.nodeCount,this._rootNodeIndex,this.totalSize,this._maxJsNodeId());}};WebInspector.HeapSnapshotItemProvider=function(iterator,indexProvider)
290 {this._iterator=iterator;this._indexProvider=indexProvider;this._isEmpty=!iterator.hasNext();this._iterationOrder=null;this._currentComparator=null;this._sortedPrefixLength=0;this._sortedSuffixLength=0;}
291 WebInspector.HeapSnapshotItemProvider.prototype={_createIterationOrder:function()
292 {if(this._iterationOrder)
293 return;this._iterationOrder=[];for(var iterator=this._iterator;iterator.hasNext();iterator.next())
294 this._iterationOrder.push(iterator.item().itemIndex());},isEmpty:function()
295 {return this._isEmpty;},serializeItemsRange:function(begin,end)
296 {this._createIterationOrder();if(begin>end)
297 throw new Error("Start position > end position: "+begin+" > "+end);if(end>this._iterationOrder.length)
298 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)
299 this._sortedPrefixLength=end;if(end>=this._iterationOrder.length-this._sortedSuffixLength)
300 this._sortedSuffixLength=this._iterationOrder.length-begin;}
301 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();}
302 return new WebInspector.HeapSnapshotCommon.ItemsRange(begin,end,this._iterationOrder.length,result);},sortAndRewind:function(comparator)
303 {this._currentComparator=comparator;this._sortedPrefixLength=0;this._sortedSuffixLength=0;}}
304 WebInspector.HeapSnapshotEdgesProvider=function(snapshot,filter,edgesIter,indexProvider)
305 {this.snapshot=snapshot;if(filter)
306 edgesIter=new WebInspector.HeapSnapshotFilteredIterator(edgesIter,filter);WebInspector.HeapSnapshotItemProvider.call(this,edgesIter,indexProvider);}
307 WebInspector.HeapSnapshotEdgesProvider.prototype={sort:function(comparator,leftBound,rightBound,windowLeft,windowRight)
308 {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)
309 {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;}
310 function compareNodeField(fieldName,ascending,indexA,indexB)
311 {edgeA.edgeIndex=indexA;nodeA.nodeIndex=edgeA.nodeIndex();var valueA=nodeA[fieldName]();edgeB.edgeIndex=indexB;nodeB.nodeIndex=edgeB.nodeIndex();var valueB=nodeB[fieldName]();var result=valueA<valueB?-1:(valueA>valueB?1:0);return ascending?result:-result;}
312 function compareEdgeAndNode(indexA,indexB){var result=compareEdgeFieldName(ascending1,indexA,indexB);if(result===0)
313 result=compareNodeField(fieldName2,ascending2,indexA,indexB);if(result===0)
314 return indexA-indexB;return result;}
315 function compareNodeAndEdge(indexA,indexB){var result=compareNodeField(fieldName1,ascending1,indexA,indexB);if(result===0)
316 result=compareEdgeFieldName(ascending2,indexA,indexB);if(result===0)
317 return indexA-indexB;return result;}
318 function compareNodeAndNode(indexA,indexB){var result=compareNodeField(fieldName1,ascending1,indexA,indexB);if(result===0)
319 result=compareNodeField(fieldName2,ascending2,indexA,indexB);if(result===0)
320 return indexA-indexB;return result;}
321 if(fieldName1==="!edgeName")
322 this._iterationOrder.sortRange(compareEdgeAndNode,leftBound,rightBound,windowLeft,windowRight);else if(fieldName2==="!edgeName")
323 this._iterationOrder.sortRange(compareNodeAndEdge,leftBound,rightBound,windowLeft,windowRight);else
324 this._iterationOrder.sortRange(compareNodeAndNode,leftBound,rightBound,windowLeft,windowRight);},__proto__:WebInspector.HeapSnapshotItemProvider.prototype}
325 WebInspector.HeapSnapshotNodesProvider=function(snapshot,filter,nodeIndexes)
326 {this.snapshot=snapshot;var indexProvider=new WebInspector.HeapSnapshotNodeIndexProvider(snapshot);var it=new WebInspector.HeapSnapshotIndexRangeIterator(indexProvider,nodeIndexes);if(filter)
327 it=new WebInspector.HeapSnapshotFilteredIterator(it,filter);WebInspector.HeapSnapshotItemProvider.call(this,it,indexProvider);}
328 WebInspector.HeapSnapshotNodesProvider.prototype={nodePosition:function(snapshotObjectId)
329 {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)
330 break;}
331 if(i===this._iterationOrder.length)
332 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)
333 ++smallerCount;}
334 return smallerCount;},_buildCompareFunction:function(comparator)
335 {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)
336 {var valueA=fieldAccessor.call(nodeA);var valueB=fieldAccessor.call(nodeB);return valueA<valueB?-ascending:(valueA>valueB?ascending:0);}
337 function sortByComparator(indexA,indexB)
338 {nodeA.nodeIndex=indexA;nodeB.nodeIndex=indexB;var result=sortByNodeField(fieldAccessor1,ascending1);if(result===0)
339 result=sortByNodeField(fieldAccessor2,ascending2);return result||indexA-indexB;}
340 return sortByComparator;},sort:function(comparator,leftBound,rightBound,windowLeft,windowRight)
341 {this._iterationOrder.sortRange(this._buildCompareFunction(comparator),leftBound,rightBound,windowLeft,windowRight);},__proto__:WebInspector.HeapSnapshotItemProvider.prototype};WebInspector.HeapSnapshotProgressEvent={Update:"ProgressUpdate"};WebInspector.HeapSnapshotCommon={}
342 WebInspector.HeapSnapshotCommon.AllocationNodeCallers=function(nodesWithSingleCaller,branchingCallers)
343 {this.nodesWithSingleCaller=nodesWithSingleCaller;this.branchingCallers=branchingCallers;}
344 WebInspector.HeapSnapshotCommon.SerializedAllocationNode=function(nodeId,functionName,scriptName,line,column,count,size,liveCount,liveSize,hasChildren)
345 {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;}
346 WebInspector.HeapSnapshotCommon.Aggregate=function()
347 {this.count;this.distance;this.self;this.maxRet;this.type;this.name;this.idxs;}
348 WebInspector.HeapSnapshotCommon.AggregateForDiff=function(){this.indexes=[];this.ids=[];this.selfSizes=[];}
349 WebInspector.HeapSnapshotCommon.Diff=function()
350 {this.addedCount=0;this.removedCount=0;this.addedSize=0;this.removedSize=0;this.deletedIndexes=[];this.addedIndexes=[];}
351 WebInspector.HeapSnapshotCommon.DiffForClass=function()
352 {this.addedCount;this.removedCount;this.addedSize;this.removedSize;this.deletedIndexes;this.addedIndexes;this.countDelta;this.sizeDelta;}
353 WebInspector.HeapSnapshotCommon.ComparatorConfig=function()
354 {this.fieldName1;this.ascending1;this.fieldName2;this.ascending2;}
355 WebInspector.HeapSnapshotCommon.WorkerCommand=function()
356 {this.callId;this.disposition;this.objectId;this.newObjectId;this.methodName;this.methodArguments;this.source;}
357 WebInspector.HeapSnapshotCommon.ItemsRange=function(startPosition,endPosition,totalLength,items)
358 {this.startPosition=startPosition;this.endPosition=endPosition;this.totalLength=totalLength;this.items=items;}
359 WebInspector.HeapSnapshotCommon.StaticData=function(nodeCount,rootNodeIndex,totalSize,maxJSObjectId)
360 {this.nodeCount=nodeCount;this.rootNodeIndex=rootNodeIndex;this.totalSize=totalSize;this.maxJSObjectId=maxJSObjectId;}
361 WebInspector.HeapSnapshotCommon.Statistics=function()
362 {this.total;this.v8heap;this.native;this.code;this.jsArrays;this.strings;}
363 WebInspector.HeapSnapshotCommon.NodeFilter=function(minNodeId,maxNodeId)
364 {this.minNodeId=minNodeId;this.maxNodeId=maxNodeId;this.allocationNodeId;}
365 WebInspector.HeapSnapshotCommon.NodeFilter.prototype={equals:function(o)
366 {return this.minNodeId===o.minNodeId&&this.maxNodeId===o.maxNodeId&&this.allocationNodeId===o.allocationNodeId;}};WebInspector.HeapSnapshotLoader=function(dispatcher)
367 {this._reset();this._progress=new WebInspector.HeapSnapshotProgress(dispatcher);}
368 WebInspector.HeapSnapshotLoader.prototype={dispose:function()
369 {this._reset();},_reset:function()
370 {this._json="";this._state="find-snapshot-info";this._snapshot={};},close:function()
371 {if(this._json)
372 this._parseStringsArray();},buildSnapshot:function(showHiddenData)
373 {this._progress.updateStatus("Processing snapshot\u2026");var result=new WebInspector.JSHeapSnapshot(this._snapshot,this._progress,showHiddenData);this._reset();return result;},_parseUintArray:function()
374 {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)
375 break;else if(code===closingBracket){this._json=this._json.slice(index+1);return false;}
376 ++index;}
377 if(index===length){this._json="";return true;}
378 var nextNumber=0;var startIndex=index;while(index<length){var code=this._json.charCodeAt(index);if(char0>code||code>char9)
379 break;nextNumber*=10;nextNumber+=(code-char0);++index;}
380 if(index===length){this._json=this._json.slice(startIndex);return true;}
381 this._array[this._arrayIndex++]=nextNumber;}},_parseStringsArray:function()
382 {this._progress.updateStatus("Parsing strings\u2026");var closingBracketIndex=this._json.lastIndexOf("]");if(closingBracketIndex===-1)
383 throw new Error("Incomplete JSON");this._json=this._json.slice(0,closingBracketIndex+1);this._snapshot.strings=JSON.parse(this._json);},write:function(chunk)
384 {this._json+=chunk;while(true){switch(this._state){case"find-snapshot-info":{var snapshotToken="\"snapshot\"";var snapshotTokenIndex=this._json.indexOf(snapshotToken);if(snapshotTokenIndex===-1)
385 throw new Error("Snapshot token not found");this._json=this._json.slice(snapshotTokenIndex+snapshotToken.length+1);this._state="parse-snapshot-info";this._progress.updateStatus("Loading snapshot info\u2026");break;}
386 case"parse-snapshot-info":{var closingBracketIndex=WebInspector.TextUtils.findBalancedCurlyBrackets(this._json);if(closingBracketIndex===-1)
387 return;this._snapshot.snapshot=(JSON.parse(this._json.slice(0,closingBracketIndex)));this._json=this._json.slice(closingBracketIndex);this._state="find-nodes";break;}
388 case"find-nodes":{var nodesToken="\"nodes\"";var nodesTokenIndex=this._json.indexOf(nodesToken);if(nodesTokenIndex===-1)
389 return;var bracketIndex=this._json.indexOf("[",nodesTokenIndex);if(bracketIndex===-1)
390 return;this._json=this._json.slice(bracketIndex+1);var node_fields_count=this._snapshot.snapshot.meta.node_fields.length;var nodes_length=this._snapshot.snapshot.node_count*node_fields_count;this._array=new Uint32Array(nodes_length);this._arrayIndex=0;this._state="parse-nodes";break;}
391 case"parse-nodes":{var hasMoreData=this._parseUintArray();this._progress.updateProgress("Loading nodes\u2026 %d\%",this._arrayIndex,this._array.length);if(hasMoreData)
392 return;this._snapshot.nodes=this._array;this._state="find-edges";this._array=null;break;}
393 case"find-edges":{var edgesToken="\"edges\"";var edgesTokenIndex=this._json.indexOf(edgesToken);if(edgesTokenIndex===-1)
394 return;var bracketIndex=this._json.indexOf("[",edgesTokenIndex);if(bracketIndex===-1)
395 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;}
396 case"parse-edges":{var hasMoreData=this._parseUintArray();this._progress.updateProgress("Loading edges\u2026 %d\%",this._arrayIndex,this._array.length);if(hasMoreData)
397 return;this._snapshot.edges=this._array;this._array=null;if(this._snapshot.snapshot.trace_function_count)
398 this._state="find-trace-function-infos";else
399 this._state="find-strings";break;}
400 case"find-trace-function-infos":{var tracesToken="\"trace_function_infos\"";var tracesTokenIndex=this._json.indexOf(tracesToken);if(tracesTokenIndex===-1)
401 return;var bracketIndex=this._json.indexOf("[",tracesTokenIndex);if(bracketIndex===-1)
402 return;this._json=this._json.slice(bracketIndex+1);var trace_function_info_field_count=this._snapshot.snapshot.meta.trace_function_info_fields.length;var trace_function_info_length=this._snapshot.snapshot.trace_function_count*trace_function_info_field_count;this._array=new Uint32Array(trace_function_info_length);this._arrayIndex=0;this._state="parse-trace-function-infos";break;}
403 case"parse-trace-function-infos":{if(this._parseUintArray())
404 return;this._snapshot.trace_function_infos=this._array;this._array=null;this._state="find-trace-tree";break;}
405 case"find-trace-tree":{var tracesToken="\"trace_tree\"";var tracesTokenIndex=this._json.indexOf(tracesToken);if(tracesTokenIndex===-1)
406 return;var bracketIndex=this._json.indexOf("[",tracesTokenIndex);if(bracketIndex===-1)
407 return;this._json=this._json.slice(bracketIndex);this._state="parse-trace-tree";break;}
408 case"parse-trace-tree":{var stringsToken="\"strings\"";var stringsTokenIndex=this._json.indexOf(stringsToken);if(stringsTokenIndex===-1)
409 return;var bracketIndex=this._json.lastIndexOf("]",stringsTokenIndex);this._snapshot.trace_tree=JSON.parse(this._json.substring(0,bracketIndex+1));this._json=this._json.slice(bracketIndex);this._state="find-strings";this._progress.updateStatus("Loading strings\u2026");break;}
410 case"find-strings":{var stringsToken="\"strings\"";var stringsTokenIndex=this._json.indexOf(stringsToken);if(stringsTokenIndex===-1)
411 return;var bracketIndex=this._json.indexOf("[",stringsTokenIndex);if(bracketIndex===-1)
412 return;this._json=this._json.slice(bracketIndex);this._state="accumulate-strings";break;}
413 case"accumulate-strings":return;}}}};;WebInspector.HeapSnapshotWorkerDispatcher=function(globalObject,postMessage)
414 {this._objects=[];this._global=globalObject;this._postMessage=postMessage;}
415 WebInspector.HeapSnapshotWorkerDispatcher.prototype={_findFunction:function(name)
416 {var path=name.split(".");var result=this._global;for(var i=0;i<path.length;++i)
417 result=result[path[i]];return result;},sendEvent:function(name,data)
418 {this._postMessage({eventName:name,data:data});},dispatchMessage:function(event)
419 {var data=(event.data);var response={callId:data.callId};try{switch(data.disposition){case"create":{var constructorFunction=this._findFunction(data.methodName);this._objects[data.objectId]=new constructorFunction(this);break;}
420 case"dispose":{delete this._objects[data.objectId];break;}
421 case"getter":{var object=this._objects[data.objectId];var result=object[data.methodName];response.result=result;break;}
422 case"factory":{var object=this._objects[data.objectId];var result=object[data.methodName].apply(object,data.methodArguments);if(result)
423 this._objects[data.newObjectId]=result;response.result=!!result;break;}
424 case"method":{var object=this._objects[data.objectId];response.result=object[data.methodName].apply(object,data.methodArguments);break;}
425 case"evaluateForTest":{try{response.result=eval(data.source)}catch(e){response.result=e.toString();}
426 break;}}}catch(e){response.error=e.toString();response.errorCallStack=e.stack;if(data.methodName)
427 response.errorMethodName=data.methodName;}
428 this._postMessage(response);}};;WebInspector.JSHeapSnapshot=function(profile,progress,showHiddenData)
429 {this._nodeFlags={canBeQueried:1,detachedDOMTreeNode:2,pageObject:4,visitedMarkerMask:0x0ffff,visitedMarker:0x10000};this._lazyStringCache={};WebInspector.HeapSnapshot.call(this,profile,progress,showHiddenData);}
430 WebInspector.JSHeapSnapshot.prototype={createNode:function(nodeIndex)
431 {return new WebInspector.JSHeapSnapshotNode(this,nodeIndex);},createEdge:function(edgeIndex)
432 {return new WebInspector.JSHeapSnapshotEdge(this,edgeIndex);},createRetainingEdge:function(retainerIndex)
433 {return new WebInspector.JSHeapSnapshotRetainerEdge(this,retainerIndex);},classNodesFilter:function()
434 {function filter(node)
435 {return node.isUserObject();}
436 return this._showHiddenData?null:filter;},containmentEdgesFilter:function()
437 {var showHiddenData=this._showHiddenData;function filter(edge){if(edge.isInvisible())
438 return false;if(showHiddenData)
439 return true;return!edge.isHidden()&&!edge.node().isHidden();}
440 return filter;},retainingEdgesFilter:function()
441 {var containmentEdgesFilter=this.containmentEdgesFilter();function filter(edge)
442 {return containmentEdgesFilter(edge)&&!edge.node().isRoot()&&!edge.isWeak();}
443 return filter;},dispose:function()
444 {WebInspector.HeapSnapshot.prototype.dispose.call(this);delete this._flags;},_calculateFlags:function()
445 {this._flags=new Uint32Array(this.nodeCount);this._markDetachedDOMTreeNodes();this._markQueriableHeapObjects();this._markPageOwnedNodes();},_isUserRoot:function(node)
446 {return node.isUserRoot()||node.isDocumentDOMTreesRoot();},forEachRoot:function(action,userRootsOnly)
447 {function getChildNodeByName(node,name)
448 {for(var iter=node.edges();iter.hasNext();iter.next()){var child=iter.edge.node();if(child.name()===name)
449 return child;}
450 return null;}
451 var visitedNodes={};function doAction(node)
452 {var ordinal=node._ordinal();if(!visitedNodes[ordinal]){action(node);visitedNodes[ordinal]=true;}}
453 var gcRoots=getChildNodeByName(this.rootNode(),"(GC roots)");if(!gcRoots)
454 return;if(userRootsOnly){for(var iter=this.rootNode().edges();iter.hasNext();iter.next()){var node=iter.edge.node();if(this._isUserRoot(node))
455 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())
456 doAction(iter2.edge.node());doAction(subRoot);}
457 for(var iter=this.rootNode().edges();iter.hasNext();iter.next())
458 doAction(iter.edge.node())}},userObjectsMapAndFlag:function()
459 {return this._showHiddenData?null:{map:this._flags,flag:this._nodeFlags.pageObject};},_flagsOfNode:function(node)
460 {return this._flags[node.nodeIndex/this._nodeFieldCount];},_markDetachedDOMTreeNodes:function()
461 {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;}}
462 if(!detachedDOMTreesRoot)
463 return;var detachedDOMTreeRE=/^Detached DOM tree/;for(var iter=detachedDOMTreesRoot.edges();iter.hasNext();iter.next()){var node=iter.edge.node();if(detachedDOMTreeRE.test(node.className())){for(var edgesIter=node.edges();edgesIter.hasNext();edgesIter.next())
464 this._flags[edgesIter.edge.node().nodeIndex/this._nodeFieldCount]|=flag;}}},_markQueriableHeapObjects:function()
465 {var flag=this._nodeFlags.canBeQueried;var hiddenEdgeType=this._edgeHiddenType;var internalEdgeType=this._edgeInternalType;var invisibleEdgeType=this._edgeInvisibleType;var weakEdgeType=this._edgeWeakType;var edgeToNodeOffset=this._edgeToNodeOffset;var edgeTypeOffset=this._edgeTypeOffset;var edgeFieldsCount=this._edgeFieldsCount;var containmentEdges=this._containmentEdges;var nodes=this._nodes;var nodeCount=this.nodeCount;var nodeFieldCount=this._nodeFieldCount;var firstEdgeIndexes=this._firstEdgeIndexes;var flags=this._flags;var list=[];for(var iter=this.rootNode().edges();iter.hasNext();iter.next()){if(iter.edge.node().isUserRoot())
466 list.push(iter.edge.node().nodeIndex/nodeFieldCount);}
467 while(list.length){var nodeOrdinal=list.pop();if(flags[nodeOrdinal]&flag)
468 continue;flags[nodeOrdinal]|=flag;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]&flag)
469 continue;var type=containmentEdges[edgeIndex+edgeTypeOffset];if(type===hiddenEdgeType||type===invisibleEdgeType||type===internalEdgeType||type===weakEdgeType)
470 continue;list.push(childNodeOrdinal);}}},_markPageOwnedNodes:function()
471 {var edgeShortcutType=this._edgeShortcutType;var edgeElementType=this._edgeElementType;var edgeToNodeOffset=this._edgeToNodeOffset;var edgeTypeOffset=this._edgeTypeOffset;var edgeFieldsCount=this._edgeFieldsCount;var edgeWeakType=this._edgeWeakType;var firstEdgeIndexes=this._firstEdgeIndexes;var containmentEdges=this._containmentEdges;var containmentEdgesLength=containmentEdges.length;var nodes=this._nodes;var nodeFieldCount=this._nodeFieldCount;var nodesCount=this.nodeCount;var flags=this._flags;var flag=this._nodeFlags.pageObject;var visitedMarker=this._nodeFlags.visitedMarker;var visitedMarkerMask=this._nodeFlags.visitedMarkerMask;var markerAndFlag=visitedMarker|flag;var nodesToVisit=new Uint32Array(nodesCount);var nodesToVisitLength=0;var rootNodeOrdinal=this._rootNodeIndex/nodeFieldCount;var node=this.rootNode();for(var edgeIndex=firstEdgeIndexes[rootNodeOrdinal],endEdgeIndex=firstEdgeIndexes[rootNodeOrdinal+1];edgeIndex<endEdgeIndex;edgeIndex+=edgeFieldsCount){var edgeType=containmentEdges[edgeIndex+edgeTypeOffset];var nodeIndex=containmentEdges[edgeIndex+edgeToNodeOffset];if(edgeType===edgeElementType){node.nodeIndex=nodeIndex;if(!node.isDocumentDOMTreesRoot())
472 continue;}else if(edgeType!==edgeShortcutType)
473 continue;var nodeOrdinal=nodeIndex/nodeFieldCount;nodesToVisit[nodesToVisitLength++]=nodeOrdinal;flags[nodeOrdinal]|=visitedMarker;}
474 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)
475 continue;var type=containmentEdges[edgeIndex+edgeTypeOffset];if(type===edgeWeakType)
476 continue;nodesToVisit[nodesToVisitLength++]=childNodeOrdinal;flags[childNodeOrdinal]|=visitedMarker;}}},_calculateStatistics:function()
477 {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)
478 sizeNative+=nodeSize;else if(nodeType===nodeCodeType)
479 sizeCode+=nodeSize;else if(nodeType===nodeConsStringType||nodeType===nodeSlicedStringType||node.type()==="string")
480 sizeStrings+=nodeSize;else if(node.name()==="Array")
481 sizeJSArrays+=this._calculateArraySize(node);}
482 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)
483 {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)
484 continue;var edgeName=strings[containmentEdges[edgeIndex+edgeNameOffset]];if(edgeName!=="elements")
485 continue;var elementsNodeIndex=containmentEdges[edgeIndex+edgeToNodeOffset];node.nodeIndex=elementsNodeIndex;if(node.retainersCount()===1)
486 size+=node.selfSize();break;}
487 return size;},getStatistics:function()
488 {return this._statistics;},__proto__:WebInspector.HeapSnapshot.prototype};WebInspector.JSHeapSnapshotNode=function(snapshot,nodeIndex)
489 {WebInspector.HeapSnapshotNode.call(this,snapshot,nodeIndex)}
490 WebInspector.JSHeapSnapshotNode.prototype={canBeQueried:function()
491 {var flags=this._snapshot._flagsOfNode(this);return!!(flags&this._snapshot._nodeFlags.canBeQueried);},isUserObject:function()
492 {var flags=this._snapshot._flagsOfNode(this);return!!(flags&this._snapshot._nodeFlags.pageObject);},name:function(){var snapshot=this._snapshot;if(this._type()===snapshot._nodeConsStringType){var string=snapshot._lazyStringCache[this.nodeIndex];if(typeof string==="undefined"){string=this._consStringName();snapshot._lazyStringCache[this.nodeIndex]=string;}
493 return string;}
494 return WebInspector.HeapSnapshotNode.prototype.name.call(this);},_consStringName:function()
495 {var snapshot=this._snapshot;var consStringType=snapshot._nodeConsStringType;var edgeInternalType=snapshot._edgeInternalType;var edgeFieldsCount=snapshot._edgeFieldsCount;var edgeToNodeOffset=snapshot._edgeToNodeOffset;var edgeTypeOffset=snapshot._edgeTypeOffset;var edgeNameOffset=snapshot._edgeNameOffset;var strings=snapshot._strings;var edges=snapshot._containmentEdges;var firstEdgeIndexes=snapshot._firstEdgeIndexes;var nodeFieldCount=snapshot._nodeFieldCount;var nodeTypeOffset=snapshot._nodeTypeOffset;var nodeNameOffset=snapshot._nodeNameOffset;var nodes=snapshot._nodes;var nodesStack=[];nodesStack.push(this.nodeIndex);var name="";while(nodesStack.length&&name.length<1024){var nodeIndex=nodesStack.pop();if(nodes[nodeIndex+nodeTypeOffset]!==consStringType){name+=strings[nodes[nodeIndex+nodeNameOffset]];continue;}
496 var nodeOrdinal=nodeIndex/nodeFieldCount;var beginEdgeIndex=firstEdgeIndexes[nodeOrdinal];var endEdgeIndex=firstEdgeIndexes[nodeOrdinal+1];var firstNodeIndex=0;var secondNodeIndex=0;for(var edgeIndex=beginEdgeIndex;edgeIndex<endEdgeIndex&&(!firstNodeIndex||!secondNodeIndex);edgeIndex+=edgeFieldsCount){var edgeType=edges[edgeIndex+edgeTypeOffset];if(edgeType===edgeInternalType){var edgeName=strings[edges[edgeIndex+edgeNameOffset]];if(edgeName==="first")
497 firstNodeIndex=edges[edgeIndex+edgeToNodeOffset];else if(edgeName==="second")
498 secondNodeIndex=edges[edgeIndex+edgeToNodeOffset];}}
499 nodesStack.push(secondNodeIndex);nodesStack.push(firstNodeIndex);}
500 return name;},className:function()
501 {var type=this.type();switch(type){case"hidden":return"(system)";case"object":case"native":return this.name();case"code":return"(compiled code)";default:return"("+type+")";}},classIndex:function()
502 {var snapshot=this._snapshot;var nodes=snapshot._nodes;var type=nodes[this.nodeIndex+snapshot._nodeTypeOffset];;if(type===snapshot._nodeObjectType||type===snapshot._nodeNativeType)
503 return nodes[this.nodeIndex+snapshot._nodeNameOffset];return-1-type;},id:function()
504 {var snapshot=this._snapshot;return snapshot._nodes[this.nodeIndex+snapshot._nodeIdOffset];},isHidden:function()
505 {return this._type()===this._snapshot._nodeHiddenType;},isSynthetic:function()
506 {return this._type()===this._snapshot._nodeSyntheticType;},isUserRoot:function()
507 {return!this.isSynthetic();},isDocumentDOMTreesRoot:function()
508 {return this.isSynthetic()&&this.name()==="(Document DOM trees)";},serialize:function()
509 {var result=WebInspector.HeapSnapshotNode.prototype.serialize.call(this);var flags=this._snapshot._flagsOfNode(this);if(flags&this._snapshot._nodeFlags.canBeQueried)
510 result.canBeQueried=true;if(flags&this._snapshot._nodeFlags.detachedDOMTreeNode)
511 result.detachedDOMTreeNode=true;return result;},__proto__:WebInspector.HeapSnapshotNode.prototype};WebInspector.JSHeapSnapshotEdge=function(snapshot,edgeIndex)
512 {WebInspector.HeapSnapshotEdge.call(this,snapshot,edgeIndex);}
513 WebInspector.JSHeapSnapshotEdge.prototype={clone:function()
514 {var snapshot=(this._snapshot);return new WebInspector.JSHeapSnapshotEdge(snapshot,this.edgeIndex);},hasStringName:function()
515 {if(!this.isShortcut())
516 return this._hasStringName();return isNaN(parseInt(this._name(),10));},isElement:function()
517 {return this._type()===this._snapshot._edgeElementType;},isHidden:function()
518 {return this._type()===this._snapshot._edgeHiddenType;},isWeak:function()
519 {return this._type()===this._snapshot._edgeWeakType;},isInternal:function()
520 {return this._type()===this._snapshot._edgeInternalType;},isInvisible:function()
521 {return this._type()===this._snapshot._edgeInvisibleType;},isShortcut:function()
522 {return this._type()===this._snapshot._edgeShortcutType;},name:function()
523 {if(!this.isShortcut())
524 return this._name();var numName=parseInt(this._name(),10);return isNaN(numName)?this._name():numName;},toString:function()
525 {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")
526 return name.indexOf(" ")===-1?"."+name:"[\""+name+"\"]";else
527 return"["+name+"]";case"internal":case"hidden":case"invisible":return"{"+name+"}";};return"?"+name+"?";},_hasStringName:function()
528 {return!this.isElement()&&!this.isHidden();},_name:function()
529 {return this._hasStringName()?this._snapshot._strings[this._nameOrIndex()]:this._nameOrIndex();},_nameOrIndex:function()
530 {return this._edges[this.edgeIndex+this._snapshot._edgeNameOffset];},_type:function()
531 {return this._edges[this.edgeIndex+this._snapshot._edgeTypeOffset];},__proto__:WebInspector.HeapSnapshotEdge.prototype};WebInspector.JSHeapSnapshotRetainerEdge=function(snapshot,retainerIndex)
532 {WebInspector.HeapSnapshotRetainerEdge.call(this,snapshot,retainerIndex);}
533 WebInspector.JSHeapSnapshotRetainerEdge.prototype={clone:function()
534 {var snapshot=(this._snapshot);return new WebInspector.JSHeapSnapshotRetainerEdge(snapshot,this.retainerIndex());},isHidden:function()
535 {return this._edge().isHidden();},isInternal:function()
536 {return this._edge().isInternal();},isInvisible:function()
537 {return this._edge().isInvisible();},isShortcut:function()
538 {return this._edge().isShortcut();},isWeak:function()
539 {return this._edge().isWeak();},__proto__:WebInspector.HeapSnapshotRetainerEdge.prototype};WebInspector.TextUtils={isStopChar:function(char)
540 {return(char>" "&&char<"0")||(char>"9"&&char<"A")||(char>"Z"&&char<"_")||(char>"_"&&char<"a")||(char>"z"&&char<="~");},isWordChar:function(char)
541 {return!WebInspector.TextUtils.isStopChar(char)&&!WebInspector.TextUtils.isSpaceChar(char);},isSpaceChar:function(char)
542 {return WebInspector.TextUtils._SpaceCharRegex.test(char);},isWord:function(word)
543 {for(var i=0;i<word.length;++i){if(!WebInspector.TextUtils.isWordChar(word.charAt(i)))
544 return false;}
545 return true;},isOpeningBraceChar:function(char)
546 {return char==="("||char==="{";},isClosingBraceChar:function(char)
547 {return char===")"||char==="}";},isBraceChar:function(char)
548 {return WebInspector.TextUtils.isOpeningBraceChar(char)||WebInspector.TextUtils.isClosingBraceChar(char);},textToWords:function(text)
549 {var words=[];var startWord=-1;for(var i=0;i<text.length;++i){if(!WebInspector.TextUtils.isWordChar(text.charAt(i))){if(startWord!==-1)
550 words.push(text.substring(startWord,i));startWord=-1;}else if(startWord===-1)
551 startWord=i;}
552 if(startWord!==-1)
553 words.push(text.substring(startWord));return words;},findBalancedCurlyBrackets:function(source,startIndex,lastIndex){lastIndex=lastIndex||source.length;startIndex=startIndex||0;var counter=0;var inString=false;for(var index=startIndex;index<lastIndex;++index){var character=source[index];if(inString){if(character==="\\")
554 ++index;else if(character==="\"")
555 inString=false;}else{if(character==="\"")
556 inString=true;else if(character==="{")
557 ++counter;else if(character==="}"){if(--counter===0)
558 return index+1;}}}
559 return-1;}}
560 WebInspector.TextUtils._SpaceCharRegex=/\s/;WebInspector.TextUtils.Indent={TwoSpaces:"  ",FourSpaces:"    ",EightSpaces:"        ",TabCharacter:"\t"};WebInspector.UIString=function(string,vararg)
561 {return String.vsprintf(string,Array.prototype.slice.call(arguments,1));};Object.isEmpty=function(obj)
562 {for(var i in obj)
563 return false;return true;}
564 Object.values=function(obj)
565 {var result=Object.keys(obj);var length=result.length;for(var i=0;i<length;++i)
566 result[i]=obj[result[i]];return result;}
567 String.prototype.findAll=function(string)
568 {var matches=[];var i=this.indexOf(string);while(i!==-1){matches.push(i);i=this.indexOf(string,i+string.length);}
569 return matches;}
570 String.prototype.lineEndings=function()
571 {if(!this._lineEndings){this._lineEndings=this.findAll("\n");this._lineEndings.push(this.length);}
572 return this._lineEndings;}
573 String.prototype.lineCount=function()
574 {var lineEndings=this.lineEndings();return lineEndings.length;}
575 String.prototype.lineAt=function(lineNumber)
576 {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")
577 lineContent=lineContent.substring(0,lineContent.length-1);return lineContent;}
578 String.prototype.escapeCharacters=function(chars)
579 {var foundChar=false;for(var i=0;i<chars.length;++i){if(this.indexOf(chars.charAt(i))!==-1){foundChar=true;break;}}
580 if(!foundChar)
581 return String(this);var result="";for(var i=0;i<this.length;++i){if(chars.indexOf(this.charAt(i))!==-1)
582 result+="\\";result+=this.charAt(i);}
583 return result;}
584 String.regexSpecialCharacters=function()
585 {return"^[]{}()\\.^$*+?|-,";}
586 String.prototype.escapeForRegExp=function()
587 {return this.escapeCharacters(String.regexSpecialCharacters());}
588 String.prototype.escapeHTML=function()
589 {return this.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;");}
590 String.prototype.collapseWhitespace=function()
591 {return this.replace(/[\s\xA0]+/g," ");}
592 String.prototype.trimMiddle=function(maxLength)
593 {if(this.length<=maxLength)
594 return String(this);var leftHalf=maxLength>>1;var rightHalf=maxLength-leftHalf-1;return this.substr(0,leftHalf)+"\u2026"+this.substr(this.length-rightHalf,rightHalf);}
595 String.prototype.trimEnd=function(maxLength)
596 {if(this.length<=maxLength)
597 return String(this);return this.substr(0,maxLength-1)+"\u2026";}
598 String.prototype.trimURL=function(baseURLDomain)
599 {var result=this.replace(/^(https|http|file):\/\//i,"");if(baseURLDomain)
600 result=result.replace(new RegExp("^"+baseURLDomain.escapeForRegExp(),"i"),"");return result;}
601 String.prototype.toTitleCase=function()
602 {return this.substring(0,1).toUpperCase()+this.substring(1);}
603 String.prototype.compareTo=function(other)
604 {if(this>other)
605 return 1;if(this<other)
606 return-1;return 0;}
607 function sanitizeHref(href)
608 {return href&&href.trim().toLowerCase().startsWith("javascript:")?null:href;}
609 String.prototype.removeURLFragment=function()
610 {var fragmentIndex=this.indexOf("#");if(fragmentIndex==-1)
611 fragmentIndex=this.length;return this.substring(0,fragmentIndex);}
612 String.prototype.startsWith=function(substring)
613 {return!this.lastIndexOf(substring,0);}
614 String.prototype.endsWith=function(substring)
615 {return this.indexOf(substring,this.length-substring.length)!==-1;}
616 String.prototype.hashCode=function()
617 {var result=0;for(var i=0;i<this.length;++i)
618 result=result*3+this.charCodeAt(i);return result;}
619 String.naturalOrderComparator=function(a,b)
620 {var chunk=/^\d+|^\D+/;var chunka,chunkb,anum,bnum;while(1){if(a){if(!b)
621 return 1;}else{if(b)
622 return-1;else
623 return 0;}
624 chunka=a.match(chunk)[0];chunkb=b.match(chunk)[0];anum=!isNaN(chunka);bnum=!isNaN(chunkb);if(anum&&!bnum)
625 return-1;if(bnum&&!anum)
626 return 1;if(anum&&bnum){var diff=chunka-chunkb;if(diff)
627 return diff;if(chunka.length!==chunkb.length){if(!+chunka&&!+chunkb)
628 return chunka.length-chunkb.length;else
629 return chunkb.length-chunka.length;}}else if(chunka!==chunkb)
630 return(chunka<chunkb)?-1:1;a=a.substring(chunka.length);b=b.substring(chunkb.length);}}
631 Number.constrain=function(num,min,max)
632 {if(num<min)
633 num=min;else if(num>max)
634 num=max;return num;}
635 Number.gcd=function(a,b)
636 {if(b===0)
637 return a;else
638 return Number.gcd(b,a%b);}
639 Number.toFixedIfFloating=function(value)
640 {if(!value||isNaN(value))
641 return value;var number=Number(value);return number%1?number.toFixed(3):String(number);}
642 Date.prototype.toISO8601Compact=function()
643 {function leadZero(x)
644 {return(x>9?"":"0")+x;}
645 return this.getFullYear()+
646 leadZero(this.getMonth()+1)+
647 leadZero(this.getDate())+"T"+
648 leadZero(this.getHours())+
649 leadZero(this.getMinutes())+
650 leadZero(this.getSeconds());}
651 Date.prototype.toConsoleTime=function()
652 {function leadZero2(x)
653 {return(x>9?"":"0")+x;}
654 function leadZero3(x)
655 {return(Array(4-x.toString().length)).join('0')+x;}
656 return this.getFullYear()+"-"+
657 leadZero2(this.getMonth()+1)+"-"+
658 leadZero2(this.getDate())+" "+
659 leadZero2(this.getHours())+":"+
660 leadZero2(this.getMinutes())+":"+
661 leadZero2(this.getSeconds())+"."+
662 leadZero3(this.getMilliseconds());}
663 Object.defineProperty(Array.prototype,"remove",{value:function(value,firstOnly)
664 {var index=this.indexOf(value);if(index===-1)
665 return;if(firstOnly){this.splice(index,1);return;}
666 for(var i=index+1,n=this.length;i<n;++i){if(this[i]!==value)
667 this[index++]=this[i];}
668 this.length=index;}});Object.defineProperty(Array.prototype,"keySet",{value:function()
669 {var keys={};for(var i=0;i<this.length;++i)
670 keys[this[i]]=true;return keys;}});Object.defineProperty(Array.prototype,"rotate",{value:function(index)
671 {var result=[];for(var i=index;i<index+this.length;++i)
672 result.push(this[i%this.length]);return result;}});Object.defineProperty(Uint32Array.prototype,"sort",{value:Array.prototype.sort});(function(){var partition={value:function(comparator,left,right,pivotIndex)
673 {function swap(array,i1,i2)
674 {var temp=array[i1];array[i1]=array[i2];array[i2]=temp;}
675 var pivotValue=this[pivotIndex];swap(this,right,pivotIndex);var storeIndex=left;for(var i=left;i<right;++i){if(comparator(this[i],pivotValue)<0){swap(this,storeIndex,i);++storeIndex;}}
676 swap(this,right,storeIndex);return storeIndex;}};Object.defineProperty(Array.prototype,"partition",partition);Object.defineProperty(Uint32Array.prototype,"partition",partition);var sortRange={value:function(comparator,leftBound,rightBound,sortWindowLeft,sortWindowRight)
677 {function quickSortRange(array,comparator,left,right,sortWindowLeft,sortWindowRight)
678 {if(right<=left)
679 return;var pivotIndex=Math.floor(Math.random()*(right-left))+left;var pivotNewIndex=array.partition(comparator,left,right,pivotIndex);if(sortWindowLeft<pivotNewIndex)
680 quickSortRange(array,comparator,left,pivotNewIndex-1,sortWindowLeft,sortWindowRight);if(pivotNewIndex<sortWindowRight)
681 quickSortRange(array,comparator,pivotNewIndex+1,right,sortWindowLeft,sortWindowRight);}
682 if(leftBound===0&&rightBound===(this.length-1)&&sortWindowLeft===0&&sortWindowRight>=rightBound)
683 this.sort(comparator);else
684 quickSortRange(this,comparator,leftBound,rightBound,sortWindowLeft,sortWindowRight);return this;}}
685 Object.defineProperty(Array.prototype,"sortRange",sortRange);Object.defineProperty(Uint32Array.prototype,"sortRange",sortRange);})();Object.defineProperty(Array.prototype,"stableSort",{value:function(comparator)
686 {function defaultComparator(a,b)
687 {return a<b?-1:(a>b?1:0);}
688 comparator=comparator||defaultComparator;var indices=new Array(this.length);for(var i=0;i<this.length;++i)
689 indices[i]=i;var self=this;function indexComparator(a,b)
690 {var result=comparator(self[a],self[b]);return result?result:a-b;}
691 indices.sort(indexComparator);for(var i=0;i<this.length;++i){if(indices[i]<0||i===indices[i])
692 continue;var cyclical=i;var saved=this[i];while(true){var next=indices[cyclical];indices[cyclical]=-1;if(next===i){this[cyclical]=saved;break;}else{this[cyclical]=this[next];cyclical=next;}}}
693 return this;}});Object.defineProperty(Array.prototype,"qselect",{value:function(k,comparator)
694 {if(k<0||k>=this.length)
695 return;if(!comparator)
696 comparator=function(a,b){return a-b;}
697 var low=0;var high=this.length-1;for(;;){var pivotPosition=this.partition(comparator,low,high,Math.floor((high+low)/2));if(pivotPosition===k)
698 return this[k];else if(pivotPosition>k)
699 high=pivotPosition-1;else
700 low=pivotPosition+1;}}});Object.defineProperty(Array.prototype,"lowerBound",{value:function(object,comparator,left,right)
701 {function defaultComparator(a,b)
702 {return a<b?-1:(a>b?1:0);}
703 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)
704 l=m+1;else
705 r=m;}
706 return r;}});Object.defineProperty(Array.prototype,"upperBound",{value:function(object,comparator,left,right)
707 {function defaultComparator(a,b)
708 {return a<b?-1:(a>b?1:0);}
709 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)
710 l=m+1;else
711 r=m;}
712 return r;}});Object.defineProperty(Array.prototype,"binaryIndexOf",{value:function(value,comparator)
713 {var index=this.lowerBound(value,comparator);return index<this.length&&comparator(value,this[index])===0?index:-1;}});Object.defineProperty(Array.prototype,"select",{value:function(field)
714 {var result=new Array(this.length);for(var i=0;i<this.length;++i)
715 result[i]=this[i][field];return result;}});Object.defineProperty(Array.prototype,"peekLast",{value:function()
716 {return this[this.length-1];}});(function(){function mergeOrIntersect(array1,array2,comparator,mergeNotIntersect)
717 {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)
718 result.push(compareValue<=0?array1[i]:array2[j]);if(compareValue<=0)
719 i++;if(compareValue>=0)
720 j++;}
721 if(mergeNotIntersect){while(i<array1.length)
722 result.push(array1[i++]);while(j<array2.length)
723 result.push(array2[j++]);}
724 return result;}
725 Object.defineProperty(Array.prototype,"intersectOrdered",{value:function(array,comparator)
726 {return mergeOrIntersect(this,array,comparator,false);}});Object.defineProperty(Array.prototype,"mergeOrdered",{value:function(array,comparator)
727 {return mergeOrIntersect(this,array,comparator,true);}});}());function insertionIndexForObjectInListSortedByFunction(object,list,comparator,insertionIndexAfter)
728 {if(insertionIndexAfter)
729 return list.upperBound(object,comparator);else
730 return list.lowerBound(object,comparator);}
731 String.sprintf=function(format,var_arg)
732 {return String.vsprintf(format,Array.prototype.slice.call(arguments,1));}
733 String.tokenizeFormatString=function(format,formatters)
734 {var tokens=[];var substitutionIndex=0;function addStringToken(str)
735 {tokens.push({type:"string",value:str});}
736 function addSpecifierToken(specifier,precision,substitutionIndex)
737 {tokens.push({type:"specifier",specifier:specifier,precision:precision,substitutionIndex:substitutionIndex});}
738 function isDigit(c)
739 {return!!/[0-9]/.exec(c);}
740 var index=0;for(var precentIndex=format.indexOf("%",index);precentIndex!==-1;precentIndex=format.indexOf("%",index)){addStringToken(format.substring(index,precentIndex));index=precentIndex+1;if(isDigit(format[index])){var number=parseInt(format.substring(index),10);while(isDigit(format[index]))
741 ++index;if(number>0&&format[index]==="$"){substitutionIndex=(number-1);++index;}}
742 var precision=-1;if(format[index]==="."){++index;precision=parseInt(format.substring(index),10);if(isNaN(precision))
743 precision=0;while(isDigit(format[index]))
744 ++index;}
745 if(!(format[index]in formatters)){addStringToken(format.substring(precentIndex,index+1));++index;continue;}
746 addSpecifierToken(format[index],precision,substitutionIndex);++substitutionIndex;++index;}
747 addStringToken(format.substring(index));return tokens;}
748 String.standardFormatters={d:function(substitution)
749 {return!isNaN(substitution)?substitution:0;},f:function(substitution,token)
750 {if(substitution&&token.precision>-1)
751 substitution=substitution.toFixed(token.precision);return!isNaN(substitution)?substitution:(token.precision>-1?Number(0).toFixed(token.precision):0);},s:function(substitution)
752 {return substitution;}}
753 String.vsprintf=function(format,substitutions)
754 {return String.format(format,substitutions,String.standardFormatters,"",function(a,b){return a+b;}).formattedResult;}
755 String.format=function(format,substitutions,formatters,initialValue,append)
756 {if(!format||!substitutions||!substitutions.length)
757 return{formattedResult:append(initialValue,format),unusedSubstitutions:substitutions};function prettyFunctionName()
758 {return"String.format(\""+format+"\", \""+substitutions.join("\", \"")+"\")";}
759 function warn(msg)
760 {console.warn(prettyFunctionName()+": "+msg);}
761 function error(msg)
762 {console.error(prettyFunctionName()+": "+msg);}
763 var result=initialValue;var tokens=String.tokenizeFormatString(format,formatters);var usedSubstitutionIndexes={};for(var i=0;i<tokens.length;++i){var token=tokens[i];if(token.type==="string"){result=append(result,token.value);continue;}
764 if(token.type!=="specifier"){error("Unknown token type \""+token.type+"\" found.");continue;}
765 if(token.substitutionIndex>=substitutions.length){error("not enough substitution arguments. Had "+substitutions.length+" but needed "+(token.substitutionIndex+1)+", so substitution was skipped.");result=append(result,"%"+(token.precision>-1?token.precision:"")+token.specifier);continue;}
766 usedSubstitutionIndexes[token.substitutionIndex]=true;if(!(token.specifier in formatters)){warn("unsupported format character \u201C"+token.specifier+"\u201D. Treating as a string.");result=append(result,substitutions[token.substitutionIndex]);continue;}
767 result=append(result,formatters[token.specifier](substitutions[token.substitutionIndex],token));}
768 var unusedSubstitutions=[];for(var i=0;i<substitutions.length;++i){if(i in usedSubstitutionIndexes)
769 continue;unusedSubstitutions.push(substitutions[i]);}
770 return{formattedResult:result,unusedSubstitutions:unusedSubstitutions};}
771 function createSearchRegex(query,caseSensitive,isRegex)
772 {var regexFlags=caseSensitive?"g":"gi";var regexObject;if(isRegex){try{regexObject=new RegExp(query,regexFlags);}catch(e){}}
773 if(!regexObject)
774 regexObject=createPlainTextSearchRegex(query,regexFlags);return regexObject;}
775 function createPlainTextSearchRegex(query,flags)
776 {var regexSpecialCharacters=String.regexSpecialCharacters();var regex="";for(var i=0;i<query.length;++i){var c=query.charAt(i);if(regexSpecialCharacters.indexOf(c)!=-1)
777 regex+="\\";regex+=c;}
778 return new RegExp(regex,flags||"");}
779 function countRegexMatches(regex,content)
780 {var text=content;var result=0;var match;while(text&&(match=regex.exec(text))){if(match[0].length>0)
781 ++result;text=text.substring(match.index+1);}
782 return result;}
783 function numberToStringWithSpacesPadding(value,symbolsCount)
784 {var numberString=value.toString();var paddingLength=Math.max(0,symbolsCount-numberString.length);var paddingString=Array(paddingLength+1).join("\u00a0");return paddingString+numberString;}
785 var createObjectIdentifier=function()
786 {return"_"+ ++createObjectIdentifier._last;}
787 createObjectIdentifier._last=0;var Set=function()
788 {this._set={};this._size=0;}
789 Set.prototype={add:function(item)
790 {var objectIdentifier=item.__identifier;if(!objectIdentifier){objectIdentifier=createObjectIdentifier();item.__identifier=objectIdentifier;}
791 if(!this._set[objectIdentifier])
792 ++this._size;this._set[objectIdentifier]=item;},remove:function(item)
793 {if(this._set[item.__identifier]){--this._size;delete this._set[item.__identifier];return true;}
794 return false;},items:function()
795 {var result=new Array(this._size);var i=0;for(var objectIdentifier in this._set)
796 result[i++]=this._set[objectIdentifier];return result;},hasItem:function(item)
797 {return!!this._set[item.__identifier];},size:function()
798 {return this._size;},clear:function()
799 {this._set={};this._size=0;}}
800 var Map=function()
801 {this._map={};this._size=0;}
802 Map.prototype={put:function(key,value)
803 {var objectIdentifier=key.__identifier;if(!objectIdentifier){objectIdentifier=createObjectIdentifier();key.__identifier=objectIdentifier;}
804 if(!this._map[objectIdentifier])
805 ++this._size;this._map[objectIdentifier]=[key,value];},remove:function(key)
806 {var result=this._map[key.__identifier];if(!result)
807 return undefined;--this._size;delete this._map[key.__identifier];return result[1];},keys:function()
808 {return this._list(0);},values:function()
809 {return this._list(1);},_list:function(index)
810 {var result=new Array(this._size);var i=0;for(var objectIdentifier in this._map)
811 result[i++]=this._map[objectIdentifier][index];return result;},get:function(key)
812 {var entry=this._map[key.__identifier];return entry?entry[1]:undefined;},contains:function(key)
813 {var entry=this._map[key.__identifier];return!!entry;},size:function()
814 {return this._size;},clear:function()
815 {this._map={};this._size=0;}}
816 var StringMap=function()
817 {this._map={};this._size=0;}
818 StringMap.prototype={put:function(key,value)
819 {if(key==="__proto__"){if(!this._hasProtoKey){++this._size;this._hasProtoKey=true;}
820 this._protoValue=value;return;}
821 if(!Object.prototype.hasOwnProperty.call(this._map,key))
822 ++this._size;this._map[key]=value;},remove:function(key)
823 {var result;if(key==="__proto__"){if(!this._hasProtoKey)
824 return undefined;--this._size;delete this._hasProtoKey;result=this._protoValue;delete this._protoValue;return result;}
825 if(!Object.prototype.hasOwnProperty.call(this._map,key))
826 return undefined;--this._size;result=this._map[key];delete this._map[key];return result;},keys:function()
827 {var result=Object.keys(this._map)||[];if(this._hasProtoKey)
828 result.push("__proto__");return result;},values:function()
829 {var result=Object.values(this._map);if(this._hasProtoKey)
830 result.push(this._protoValue);return result;},get:function(key)
831 {if(key==="__proto__")
832 return this._protoValue;if(!Object.prototype.hasOwnProperty.call(this._map,key))
833 return undefined;return this._map[key];},contains:function(key)
834 {var result;if(key==="__proto__")
835 return this._hasProtoKey;return Object.prototype.hasOwnProperty.call(this._map,key);},size:function()
836 {return this._size;},clear:function()
837 {this._map={};this._size=0;delete this._hasProtoKey;delete this._protoValue;}}
838 var StringSet=function()
839 {this._map=new StringMap();}
840 StringSet.prototype={put:function(value)
841 {this._map.put(value,true);},remove:function(value)
842 {return!!this._map.remove(value);},values:function()
843 {return this._map.keys();},contains:function(value)
844 {return this._map.contains(value);},size:function()
845 {return this._map.size();},clear:function()
846 {this._map.clear();}}
847 function loadXHR(url,async,callback)
848 {function onReadyStateChanged()
849 {if(xhr.readyState!==XMLHttpRequest.DONE)
850 return;if(xhr.status===200){callback(xhr.responseText);return;}
851 callback(null);}
852 var xhr=new XMLHttpRequest();xhr.open("GET",url,async);if(async)
853 xhr.onreadystatechange=onReadyStateChanged;xhr.send(null);if(!async){if(xhr.status===200)
854 return xhr.responseText;return null;}
855 return null;}
856 var _importedScripts={};function importScript(scriptName)
857 {if(_importedScripts[scriptName])
858 return;var xhr=new XMLHttpRequest();_importedScripts[scriptName]=true;xhr.open("GET",scriptName,false);xhr.send(null);if(!xhr.responseText)
859 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);}
860 var loadScript=importScript;function CallbackBarrier()
861 {this._pendingIncomingCallbacksCount=0;}
862 CallbackBarrier.prototype={createCallback:function(userCallback)
863 {console.assert(!this._outgoingCallback,"CallbackBarrier.createCallback() is called after CallbackBarrier.callWhenDone()");++this._pendingIncomingCallbacksCount;return this._incomingCallback.bind(this,userCallback);},callWhenDone:function(callback)
864 {console.assert(!this._outgoingCallback,"CallbackBarrier.callWhenDone() is called multiple times");this._outgoingCallback=callback;if(!this._pendingIncomingCallbacksCount)
865 this._outgoingCallback();},_incomingCallback:function(userCallback)
866 {console.assert(this._pendingIncomingCallbacksCount>0);if(userCallback){var args=Array.prototype.slice.call(arguments,1);userCallback.apply(null,args);}
867 if(!--this._pendingIncomingCallbacksCount&&this._outgoingCallback)
868 this._outgoingCallback();}}
869 function suppressUnused(value)
870 {};function postMessageWrapper(message)
871 {postMessage(message);}
872 var dispatcher=new WebInspector.HeapSnapshotWorkerDispatcher(this,postMessageWrapper);addEventListener("message",dispatcher.dispatchMessage.bind(dispatcher),false);