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

Unified Diff: chrome_linux/resources/inspector/ProfilesPanel.js

Issue 42163002: Roll Linux reference build to official build 31.0.1650.34 (trunk r224845, branch r230433) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/deps/reference_builds/
Patch Set: Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome_linux/resources/inspector/ProfilesPanel.js
===================================================================
--- chrome_linux/resources/inspector/ProfilesPanel.js (revision 230844)
+++ chrome_linux/resources/inspector/ProfilesPanel.js (working copy)
@@ -53,7 +53,7 @@
WebInspector.ProfilesPanel=function(name,type)
{var singleProfileMode=typeof name!=="undefined";name=name||"profiles";WebInspector.Panel.call(this,name);this.registerRequiredCSS("panelEnablerView.css");this.registerRequiredCSS("heapProfiler.css");this.registerRequiredCSS("profilesPanel.css");this.createSidebarViewWithTree();this.profilesItemTreeElement=new WebInspector.ProfilesSidebarTreeElement(this);this.sidebarTree.appendChild(this.profilesItemTreeElement);this._singleProfileMode=singleProfileMode;this._profileTypesByIdMap={};this.profileViews=document.createElement("div");this.profileViews.id="profile-views";this.splitView.mainElement.appendChild(this.profileViews);this._statusBarButtons=[];this.recordButton=new WebInspector.StatusBarButton("","record-profile-status-bar-item");this.recordButton.addEventListener("click",this.toggleRecordButton,this);this._statusBarButtons.push(this.recordButton);this.clearResultsButton=new WebInspector.StatusBarButton(WebInspector.UIString("Clear all profiles."),"clear-status-bar-item");this.clearResultsButton.addEventListener("click",this._clearProfiles,this);this._statusBarButtons.push(this.clearResultsButton);this._profileTypeStatusBarItemsContainer=document.createElement("div");this._profileTypeStatusBarItemsContainer.className="status-bar-items";this._profileViewStatusBarItemsContainer=document.createElement("div");this._profileViewStatusBarItemsContainer.className="status-bar-items";if(singleProfileMode){this._launcherView=this._createLauncherView();this._registerProfileType((type));this._selectedProfileType=type;this._updateProfileTypeSpecificUI();}else{this._launcherView=new WebInspector.MultiProfileLauncherView(this);this._launcherView.addEventListener(WebInspector.MultiProfileLauncherView.EventTypes.ProfileTypeSelected,this._onProfileTypeSelected,this);this._registerProfileType(new WebInspector.CPUProfileType());this._registerProfileType(new WebInspector.HeapSnapshotProfileType());this._registerProfileType(new WebInspector.TrackingHeapSnapshotProfileType(this));if(!WebInspector.WorkerManager.isWorkerFrontend()&&WebInspector.experimentsSettings.canvasInspection.isEnabled())
this._registerProfileType(new WebInspector.CanvasProfileType());}
-this._profilesWereRequested=false;this._reset();this._createFileSelectorElement();this.element.addEventListener("contextmenu",this._handleContextMenuEvent.bind(this),true);this._registerShortcuts();WebInspector.ContextMenu.registerProvider(this);}
+this._profilesWereRequested=false;this._reset();this._createFileSelectorElement();this.element.addEventListener("contextmenu",this._handleContextMenuEvent.bind(this),true);this._registerShortcuts();WebInspector.ContextMenu.registerProvider(this);this._configureCpuProfilerSamplingInterval();WebInspector.settings.highResolutionCpuProfiling.addChangeListener(this._configureCpuProfilerSamplingInterval,this);}
WebInspector.ProfilesPanel.prototype={_createFileSelectorElement:function()
{if(this._fileSelectorElement)
this.element.removeChild(this._fileSelectorElement);this._fileSelectorElement=WebInspector.createFileSelectorElement(this._loadFromFile.bind(this));this.element.appendChild(this._fileSelectorElement);},_createLauncherView:function()
@@ -62,7 +62,10 @@
continue;if(fileName.endsWith(type.fileExtension()))
return type;}
return null;},_registerShortcuts:function()
-{this.registerShortcuts(WebInspector.ProfilesPanelDescriptor.ShortcutKeys.StartStopRecording,this.toggleRecordButton.bind(this));},_loadFromFile:function(file)
+{this.registerShortcuts(WebInspector.ProfilesPanelDescriptor.ShortcutKeys.StartStopRecording,this.toggleRecordButton.bind(this));},_configureCpuProfilerSamplingInterval:function()
+{var intervalUs=WebInspector.settings.highResolutionCpuProfiling.get()?100:1000;ProfilerAgent.setSamplingInterval(intervalUs,didChangeInterval.bind(this));function didChangeInterval(error)
+{if(error)
+WebInspector.showErrorMessage(error)}},_loadFromFile:function(file)
{this._createFileSelectorElement();var profileType=this._findProfileTypeByExtension(file.name);if(!profileType){var extensions=[];for(var id in this._profileTypesByIdMap){var extension=this._profileTypesByIdMap[id].fileExtension();if(!extension)
continue;extensions.push(extension);}
WebInspector.log(WebInspector.UIString("Can't load file. Only files with extensions '%s' can be loaded.",extensions.join("', '")));return;}
@@ -94,8 +97,9 @@
{var element=event.srcElement;while(element&&!element.treeElement&&element!==this.element)
element=element.parentElement;if(!element)
return;if(element.treeElement&&element.treeElement.handleContextMenuEvent){element.treeElement.handleContextMenuEvent(event,this);return;}
-if(element!==this.element||event.srcElement===this.sidebarElement){var contextMenu=new WebInspector.ContextMenu(event);if(this.visibleView instanceof WebInspector.HeapSnapshotView)
-this.visibleView.populateContextMenu(contextMenu,event);contextMenu.appendItem(WebInspector.UIString("Load\u2026"),this._fileSelectorElement.click.bind(this._fileSelectorElement));contextMenu.show();}},_makeTitleKey:function(text,profileTypeId)
+var contextMenu=new WebInspector.ContextMenu(event);if(this.visibleView instanceof WebInspector.HeapSnapshotView){this.visibleView.populateContextMenu(contextMenu,event);}
+if(element!==this.element||event.srcElement===this.sidebarElement){contextMenu.appendItem(WebInspector.UIString("Load\u2026"),this._fileSelectorElement.click.bind(this._fileSelectorElement));}
+contextMenu.show();},_makeTitleKey:function(text,profileTypeId)
{return escape(text)+'/'+escape(profileTypeId);},_addProfileHeader:function(profile)
{var profileType=profile.profileType();var typeId=profileType.id;var sidebarParent=profileType.treeElement;sidebarParent.hidden=false;var small=false;var alternateTitle;if(!WebInspector.ProfilesPanelDescriptor.isUserInitiatedProfile(profile.title)&&!profile.isTemporary){var profileTitleKey=this._makeTitleKey(profile.title,typeId);if(!(profileTitleKey in this._profileGroups))
this._profileGroups[profileTitleKey]=[];var group=this._profileGroups[profileTitleKey];group.push(profile);if(group.length===2){group._profilesTreeElement=new WebInspector.ProfileGroupSidebarTreeElement(this,profile.title);var index=sidebarParent.children.indexOf(group[0]._profilesTreeElement);sidebarParent.insertChild(group._profilesTreeElement,index);var selected=group[0]._profilesTreeElement.selected;sidebarParent.removeChild(group[0]._profilesTreeElement);group._profilesTreeElement.appendChild(group[0]._profilesTreeElement);if(selected)
@@ -225,11 +229,12 @@
{WebInspector.ProfilesPanel.call(this,"canvas-profiler",new WebInspector.CanvasProfileType());}
WebInspector.CanvasProfilerPanel.prototype={__proto__:WebInspector.ProfilesPanel.prototype}
WebInspector.ProfileDataGridNode=function(profileNode,owningTree,hasChildren)
-{this.profileNode=profileNode;WebInspector.DataGridNode.call(this,null,hasChildren);this.tree=owningTree;this.childrenByCallUID={};this.lastComparator=null;this.callUID=profileNode.callUID;this.selfTime=profileNode.selfTime;this.totalTime=profileNode.totalTime;this.functionName=profileNode.functionName;this.url=profileNode.url;}
+{this.profileNode=profileNode;WebInspector.DataGridNode.call(this,null,hasChildren);this.tree=owningTree;this.childrenByCallUID={};this.lastComparator=null;this.callUID=profileNode.callUID;this.selfTime=profileNode.selfTime;this.totalTime=profileNode.totalTime;this.functionName=profileNode.functionName;this._deoptReason=(!profileNode.deoptReason||profileNode.deoptReason==="no reason")?"":profileNode.deoptReason;this.url=profileNode.url;}
WebInspector.ProfileDataGridNode.prototype={get data()
{function formatMilliseconds(time)
{return WebInspector.UIString("%.0f\u2009ms",time);}
-var data={};data["function"]=this.functionName;if(this.tree.profileView.showSelfTimeAsPercent.get())
+var data={};if(this._deoptReason){var div=document.createElement("div");var marker=div.createChild("span");marker.className="profile-warn-marker";marker.title=WebInspector.UIString("Not optimized: %s",this._deoptReason);var functionName=div.createChild("span");functionName.textContent=this.functionName;data["function"]=div;}else
+data["function"]=this.functionName;if(this.tree.profileView.showSelfTimeAsPercent.get())
data["self"]=WebInspector.UIString("%.2f%",this.selfPercent);else
data["self"]=formatMilliseconds(this.selfTime);if(this.tree.profileView.showTotalTimeAsPercent.get())
data["total"]=WebInspector.UIString("%.2f%",this.totalPercent);else
@@ -237,7 +242,8 @@
{var cell=WebInspector.DataGridNode.prototype.createCell.call(this,columnIdentifier);if(columnIdentifier==="self"&&this._searchMatchedSelfColumn)
cell.addStyleClass("highlight");else if(columnIdentifier==="total"&&this._searchMatchedTotalColumn)
cell.addStyleClass("highlight");if(columnIdentifier!=="function")
-return cell;if(this.profileNode._searchMatchedFunctionColumn)
+return cell;if(this._deoptReason)
+cell.addStyleClass("not-optimized");if(this.profileNode._searchMatchedFunctionColumn)
cell.addStyleClass("highlight");if(this.profileNode.url){var lineNumber=this.profileNode.lineNumber?this.profileNode.lineNumber-1:0;var urlElement=this.tree.profileView._linkifier.linkifyLocation(this.profileNode.url,lineNumber,0,"profile-node-file");urlElement.style.maxWidth="75%";cell.insertBefore(urlElement,cell.firstChild);}
return cell;},select:function(supressSelectedEvent)
{WebInspector.DataGridNode.prototype.select.call(this,supressSelectedEvent);this.tree.profileView._dataGridNodeSelected(this);},deselect:function(supressDeselectedEvent)
@@ -288,7 +294,42 @@
return-1;if(lhs[property]<rhs[property])
return 1;return 0;}}
WebInspector.ProfileDataGridTree.propertyComparators[(isAscending?1:0)][property]=comparator;}
-return comparator;};WebInspector.BottomUpProfileDataGridNode=function(profileNode,owningTree)
+return comparator;};WebInspector.AllocationProfile=function(profile)
+{this._strings=profile.strings;this._nextNodeId=1;this._idToFunctionInfo={};this._idToNode={};this._collapsedTopNodeIdToFunctionInfo={};this._traceTops=null;this._buildAllocationFunctionInfos(profile.trace_function_infos);this._traceTree=this._buildInvertedAllocationTree(profile.trace_tree);}
+WebInspector.AllocationProfile.prototype={_buildAllocationFunctionInfos:function(rawInfos)
+{var strings=this._strings;var functionIdOffset=0;var functionNameOffset=1;var scriptNameOffset=2;var functionInfoFieldCount=3;var map=this._idToFunctionInfo;map[0]=new WebInspector.FunctionAllocationInfo("(root)","<unknown>");var infoLength=rawInfos.length;for(var i=0;i<infoLength;i+=functionInfoFieldCount){map[rawInfos[i+functionIdOffset]]=new WebInspector.FunctionAllocationInfo(strings[rawInfos[i+functionNameOffset]],strings[rawInfos[i+scriptNameOffset]]);}},_buildInvertedAllocationTree:function(traceTreeRaw)
+{var idToFunctionInfo=this._idToFunctionInfo;var nodeIdOffset=0;var functionIdOffset=1;var allocationCountOffset=2;var allocationSizeOffset=3;var childrenOffset=4;var nodeFieldCount=5;function traverseNode(rawNodeArray,nodeOffset,parent)
+{var functionInfo=idToFunctionInfo[rawNodeArray[nodeOffset+functionIdOffset]];var result=new WebInspector.AllocationTraceNode(rawNodeArray[nodeOffset+nodeIdOffset],functionInfo,rawNodeArray[nodeOffset+allocationCountOffset],rawNodeArray[nodeOffset+allocationSizeOffset],parent);functionInfo.addTraceTopNode(result);var rawChildren=rawNodeArray[nodeOffset+childrenOffset];for(var i=0;i<rawChildren.length;i+=nodeFieldCount){result.children.push(traverseNode(rawChildren,i,result));}
+return result;}
+return traverseNode(traceTreeRaw,0,null);},serializeTraceTops:function()
+{if(this._traceTops)
+return this._traceTops;var result=this._traceTops=[];var idToFunctionInfo=this._idToFunctionInfo;for(var id in idToFunctionInfo){var info=idToFunctionInfo[id];if(info.totalCount===0)
+continue;var nodeId=this._nextNodeId++;result.push(this._serializeNode(nodeId,info.functionName,info.totalCount,info.totalSize,true));this._collapsedTopNodeIdToFunctionInfo[nodeId]=info;}
+return result;},serializeCallers:function(nodeId)
+{var node=this._idToNode[nodeId];if(!node){var functionInfo=this._collapsedTopNodeIdToFunctionInfo[nodeId];node=functionInfo.tracesWithThisTop();delete this._collapsedTopNodeIdToFunctionInfo[nodeId];this._idToNode[nodeId]=node;}
+var result=[];var callers=node.callers();for(var i=0;i<callers.length;i++){var callerNode=callers[i];var callerId=this._nextNodeId++;this._idToNode[callerId]=callerNode;result.push(this._serializeNode(callerId,callerNode.functionInfo.functionName,callerNode.allocationCount,callerNode.allocationSize,callerNode.hasCallers()));}
+return result;},_serializeNode:function(nodeId,functionName,count,size,hasChildren)
+{return{id:nodeId,name:functionName,count:count,size:size,hasChildren:hasChildren};}}
+WebInspector.AllocationTraceNode=function(id,functionInfo,count,size,parent)
+{this.id=id;this.functionInfo=functionInfo;this.allocationCount=count;this.allocationSize=size;this.parent=parent;this.children=[];}
+WebInspector.AllocationBackTraceNode=function(functionInfo)
+{this.functionInfo=functionInfo;this.allocationCount=0;this.allocationSize=0;this._callers=[];}
+WebInspector.AllocationBackTraceNode.prototype={addCaller:function(traceNode)
+{var functionInfo=traceNode.functionInfo;var result;for(var i=0;i<this._callers.length;i++){var caller=this._callers[i];if(caller.functionInfo===functionInfo){result=caller;break;}}
+if(!result){result=new WebInspector.AllocationBackTraceNode(functionInfo);this._callers.push(result);}
+return result;},callers:function()
+{return this._callers;},hasCallers:function()
+{return this._callers.length>0;}}
+WebInspector.FunctionAllocationInfo=function(functionName,scriptName)
+{this.functionName=functionName;this.scriptName=scriptName;this.totalCount=0;this.totalSize=0;this._traceTops=[];}
+WebInspector.FunctionAllocationInfo.prototype={addTraceTopNode:function(node)
+{if(node.allocationCount===0)
+return;this._traceTops.push(node);this.totalCount+=node.allocationCount;this.totalSize+=node.allocationSize;},tracesWithThisTop:function()
+{if(!this._traceTops.length)
+return null;if(!this._backTraceTree)
+this._buildAllocationTraceTree();return this._backTraceTree;},_buildAllocationTraceTree:function()
+{this._backTraceTree=new WebInspector.AllocationBackTraceNode(this._traceTops[0].functionInfo);for(var i=0;i<this._traceTops.length;i++){var node=this._traceTops[i];var backTraceNode=this._backTraceTree;var count=node.allocationCount;var size=node.allocationSize;while(true){backTraceNode.allocationCount+=count;backTraceNode.allocationSize+=size;node=node.parent;if(node===null){break;}
+backTraceNode=backTraceNode.addCaller(node);}}}};WebInspector.BottomUpProfileDataGridNode=function(profileNode,owningTree)
{WebInspector.ProfileDataGridNode.call(this,profileNode,owningTree,this._willHaveChildren(profileNode));this._remainingNodeInfos=[];}
WebInspector.BottomUpProfileDataGridNode.prototype={_takePropertiesFromProfileDataGridNode:function(profileDataGridNode)
{this._save();this.selfTime=profileDataGridNode.selfTime;this.totalTime=profileDataGridNode.totalTime;},_keepOnlyChild:function(child)
@@ -336,8 +377,7 @@
{if(error)
return;if(!profile.head){return;}
this._processProfileData(profile);},_processProfileData:function(profile)
-{this.profileHead=profile.head;this.samples=profile.samples;this._calculateTimes(profile);if(profile.idleTime)
-this._injectIdleTimeNode(profile);this._assignParentsInProfile();if(this.samples)
+{this.profileHead=profile.head;this.samples=profile.samples;this._calculateTimes(profile);this._assignParentsInProfile();if(this.samples)
this._buildIdToNodeMap();this._changeView();this._updatePercentButton();if(this._flameChart)
this._flameChart.update();},get statusBarItems()
{return[this.viewSelectComboBox.element,this._statusBarButtonsElement];},_getBottomUpProfileDataGridTree:function()
@@ -401,7 +441,7 @@
return;var script=WebInspector.debuggerModel.scriptForId(node.scriptId)
if(!script)
return;var uiLocation=script.rawLocationToUILocation(node.lineNumber);if(!uiLocation)
-return;WebInspector.showPanel("scripts").showUISourceCode(uiLocation.uiSourceCode,uiLocation.lineNumber,uiLocation.columnNumber);},_changeView:function()
+return;WebInspector.showPanel("sources").showUILocation(uiLocation);},_changeView:function()
{if(!this.profile)
return;switch(this.viewSelectComboBox.selectedOption().value){case WebInspector.CPUProfileView._TypeFlame:this._ensureFlameChartCreated();this.dataGrid.detach();this._flameChart.show(this.element);this._viewType.set(WebInspector.CPUProfileView._TypeFlame);this._statusBarButtonsElement.enableStyleClass("hidden",true);return;case WebInspector.CPUProfileView._TypeTree:this.profileDataGridTree=this._getTopDownProfileDataGridTree();this._sortProfile();this._viewType.set(WebInspector.CPUProfileView._TypeTree);break;case WebInspector.CPUProfileView._TypeHeavy:this.profileDataGridTree=this._getBottomUpProfileDataGridTree();this._sortProfile();this._viewType.set(WebInspector.CPUProfileView._TypeHeavy);break;}
this._statusBarButtonsElement.enableStyleClass("hidden",false);if(this._flameChart)
@@ -426,17 +466,14 @@
this.showAverageTimeAsPercent.set(!this.showAverageTimeAsPercent.get());this.refreshShowAsPercents();event.consume(true);},_calculateTimes:function(profile)
{function totalHitCount(node){var result=node.hitCount;for(var i=0;i<node.children.length;i++)
result+=totalHitCount(node.children[i]);return result;}
-profile.totalHitCount=totalHitCount(profile.head);var durationMs=1000*profile.endTime-1000*profile.startTime;var samplingRate=profile.totalHitCount/durationMs;function calculateTimesForNode(node){node.selfTime=node.hitCount*samplingRate;var totalTime=node.selfTime;for(var i=0;i<node.children.length;i++)
-totalTime+=calculateTimesForNode(node.children[i]);node.totalTime=totalTime;return totalTime;}
+profile.totalHitCount=totalHitCount(profile.head);var durationMs=1000*(profile.endTime-profile.startTime);var samplingInterval=durationMs/profile.totalHitCount;this.samplingIntervalMs=samplingInterval;function calculateTimesForNode(node){node.selfTime=node.hitCount*samplingInterval;var totalHitCount=node.hitCount;for(var i=0;i<node.children.length;i++)
+totalHitCount+=calculateTimesForNode(node.children[i]);node.totalTime=totalHitCount*samplingInterval;return totalHitCount;}
calculateTimesForNode(profile.head);},_assignParentsInProfile:function()
{var head=this.profileHead;head.parent=null;head.head=null;var nodesToTraverse=[{parent:head,children:head.children}];while(nodesToTraverse.length>0){var pair=nodesToTraverse.pop();var parent=pair.parent;var children=pair.children;var length=children.length;for(var i=0;i<length;++i){children[i].head=head;children[i].parent=parent;if(children[i].children.length>0)
nodesToTraverse.push({parent:children[i],children:children[i].children});}}},_buildIdToNodeMap:function()
{var idToNode=this._idToNode={};var stack=[this.profileHead];while(stack.length){var node=stack.pop();idToNode[node.id]=node;for(var i=0;i<node.children.length;i++)
stack.push(node.children[i]);}
-var topLevelNodes=this.profileHead.children;for(var i=0;i<topLevelNodes.length;i++){var node=topLevelNodes[i];if(node.functionName=="(garbage collector)"){this._gcNode=node;break;}}},_injectIdleTimeNode:function(profile)
-{var idleTime=profile.idleTime;var nodes=profile.head.children;var programNode={selfTime:0};for(var i=nodes.length-1;i>=0;--i){if(nodes[i].functionName==="(program)"){programNode=nodes[i];break;}}
-var programTime=programNode.selfTime;if(idleTime>programTime)
-idleTime=programTime;programTime=programTime-idleTime;programNode.selfTime=programTime;programNode.totalTime=programTime;var idleNode={functionName:"(idle)",url:null,lineNumber:0,totalTime:idleTime,selfTime:idleTime,callUID:0,children:[]};nodes.push(idleNode);},__proto__:WebInspector.View.prototype}
+var topLevelNodes=this.profileHead.children;for(var i=0;i<topLevelNodes.length;i++){var node=topLevelNodes[i];if(node.functionName=="(garbage collector)"){this._gcNode=node;break;}}},__proto__:WebInspector.View.prototype}
WebInspector.CPUProfileType=function()
{WebInspector.ProfileType.call(this,WebInspector.CPUProfileType.TypeId,WebInspector.UIString("Collect JavaScript CPU Profile"));InspectorBackend.registerProfilerDispatcher(this);this._recording=false;WebInspector.CPUProfileType.instance=this;}
WebInspector.CPUProfileType.TypeId="CPU";WebInspector.CPUProfileType.prototype={fileExtension:function()
@@ -478,7 +515,7 @@
{ProfilerAgent.getCPUProfile(this.uid,getCPUProfileCallback.bind(this));}
this._fileName=this._fileName||"CPU-"+new Date().toISO8601Compact()+this._profileType.fileExtension();fileOutputStream.open(this._fileName,onOpen.bind(this));},loadFromFile:function(file)
{this.title=file.name;this.sidebarElement.subtitle=WebInspector.UIString("Loading\u2026");this.sidebarElement.wait=true;var fileReader=new WebInspector.ChunkedFileReader(file,10000000,this);fileReader.start(this);},__proto__:WebInspector.ProfileHeader.prototype};WebInspector.FlameChart=function(cpuProfileView)
-{WebInspector.View.call(this);this.registerRequiredCSS("flameChart.css");this.element.className="fill";this.element.id="cpu-flame-chart";this._overviewContainer=this.element.createChild("div","overview-container");this._overviewGrid=new WebInspector.OverviewGrid("flame-chart");this._overviewCanvas=this._overviewContainer.createChild("canvas","flame-chart-overview-canvas");this._overviewContainer.appendChild(this._overviewGrid.element);this._overviewCalculator=new WebInspector.FlameChart.OverviewCalculator();this._overviewGrid.addEventListener(WebInspector.OverviewGrid.Events.WindowChanged,this._onWindowChanged,this);this._chartContainer=this.element.createChild("div","chart-container");this._timelineGrid=new WebInspector.TimelineGrid();this._chartContainer.appendChild(this._timelineGrid.element);this._calculator=new WebInspector.FlameChart.Calculator();this._canvas=this._chartContainer.createChild("canvas");this._canvas.addEventListener("mousemove",this._onMouseMove.bind(this));WebInspector.installDragHandle(this._canvas,this._startCanvasDragging.bind(this),this._canvasDragging.bind(this),this._endCanvasDragging.bind(this),"col-resize");this._cpuProfileView=cpuProfileView;this._windowLeft=0.0;this._windowRight=1.0;this._barHeight=15;this._minWidth=2;this._paddingLeft=15;this._canvas.addEventListener("mousewheel",this._onMouseWheel.bind(this),false);this.element.addEventListener("click",this._onClick.bind(this),false);this._linkifier=new WebInspector.Linkifier();this._highlightedEntryIndex=-1;if(!WebInspector.FlameChart._colorGenerator)
+{WebInspector.View.call(this);this.registerRequiredCSS("flameChart.css");this.element.className="fill";this.element.id="cpu-flame-chart";this._overviewContainer=this.element.createChild("div","overview-container");this._overviewGrid=new WebInspector.OverviewGrid("flame-chart");this._overviewCanvas=this._overviewContainer.createChild("canvas","flame-chart-overview-canvas");this._overviewContainer.appendChild(this._overviewGrid.element);this._overviewCalculator=new WebInspector.FlameChart.OverviewCalculator();this._overviewGrid.addEventListener(WebInspector.OverviewGrid.Events.WindowChanged,this._onWindowChanged,this);this._chartContainer=this.element.createChild("div","chart-container");this._timelineGrid=new WebInspector.TimelineGrid();this._chartContainer.appendChild(this._timelineGrid.element);this._calculator=new WebInspector.FlameChart.Calculator();this._canvas=this._chartContainer.createChild("canvas");this._canvas.addEventListener("mousemove",this._onMouseMove.bind(this));WebInspector.installDragHandle(this._canvas,this._startCanvasDragging.bind(this),this._canvasDragging.bind(this),this._endCanvasDragging.bind(this),"col-resize");this._cpuProfileView=cpuProfileView;this._windowLeft=0.0;this._windowRight=1.0;this._barHeight=15;this._minWidth=2;this._paddingLeft=15;this._canvas.addEventListener("mousewheel",this._onMouseWheel.bind(this),false);this._canvas.addEventListener("click",this._onClick.bind(this),false);this._linkifier=new WebInspector.Linkifier();this._highlightedEntryIndex=-1;if(!WebInspector.FlameChart._colorGenerator)
WebInspector.FlameChart._colorGenerator=new WebInspector.FlameChart.ColorGenerator();}
WebInspector.FlameChart.Calculator=function()
{}
@@ -502,22 +539,22 @@
{return this._maximumBoundaries-this._minimumBoundaries;}}
WebInspector.FlameChart.Events={SelectedNode:"SelectedNode"}
WebInspector.FlameChart.ColorGenerator=function()
-{this._colorPairs={};this._currentColorIndex=0;this._colorPairs["(idle)::0"]=this._createPair(0,50);this._colorPairs["(program)::0"]=this._createPair(5,50);this._colorPairs["(garbage collector)::0"]=this._createPair(10,50);}
+{this._colorPairs={};this._currentColorIndex=0;this._colorPairs["(idle)::0"]=this._createPair(this._currentColorIndex++,50);this._colorPairs["(program)::0"]=this._createPair(this._currentColorIndex++,50);this._colorPairs["(garbage collector)::0"]=this._createPair(this._currentColorIndex++,50);}
WebInspector.FlameChart.ColorGenerator.prototype={_colorPairForID:function(id)
{var colorPairs=this._colorPairs;var colorPair=colorPairs[id];if(!colorPair)
-colorPairs[id]=colorPair=this._createPair(++this._currentColorIndex);return colorPair;},_createPair:function(index,sat)
+colorPairs[id]=colorPair=this._createPair(this._currentColorIndex++);return colorPair;},_createPair:function(index,sat)
{var hue=(index*7+12*(index%2))%360;if(typeof sat!=="number")
-sat=100;return{highlighted:"hsla("+hue+", "+sat+"%, 33%, 0.7)",normal:"hsla("+hue+", "+sat+"%, 66%, 0.7)"}}}
+sat=100;return{index:index,highlighted:"hsla("+hue+", "+sat+"%, 33%, 0.7)",normal:"hsla("+hue+", "+sat+"%, 66%, 0.7)"}}}
WebInspector.FlameChart.Entry=function(colorPair,depth,duration,startTime,node)
{this.colorPair=colorPair;this.depth=depth;this.duration=duration;this.startTime=startTime;this.node=node;this.selfTime=0;}
WebInspector.FlameChart.prototype={selectRange:function(timeLeft,timeRight)
{this._overviewGrid.setWindow(timeLeft/this._totalTime,timeRight/this._totalTime);},_onWindowChanged:function(event)
{this._scheduleUpdate();},_startCanvasDragging:function(event)
{if(!this._timelineData)
-return false;this._isDragging=true;this._dragStartPoint=event.pageX;this._dragStartWindowLeft=this._windowLeft;this._dragStartWindowRight=this._windowRight;return true;},_canvasDragging:function(event)
+return false;this._isDragging=true;this._wasDragged=false;this._dragStartPoint=event.pageX;this._dragStartWindowLeft=this._windowLeft;this._dragStartWindowRight=this._windowRight;return true;},_canvasDragging:function(event)
{var pixelShift=this._dragStartPoint-event.pageX;var windowShift=pixelShift/this._totalPixels;var windowLeft=Math.max(0,this._dragStartWindowLeft+windowShift);if(windowLeft===this._windowLeft)
return;windowShift=windowLeft-this._dragStartWindowLeft;var windowRight=Math.min(1,this._dragStartWindowRight+windowShift);if(windowRight===this._windowRight)
-return;windowShift=windowRight-this._dragStartWindowRight;this._overviewGrid.setWindow(this._dragStartWindowLeft+windowShift,this._dragStartWindowRight+windowShift);},_endCanvasDragging:function()
+return;windowShift=windowRight-this._dragStartWindowRight;this._overviewGrid.setWindow(this._dragStartWindowLeft+windowShift,this._dragStartWindowRight+windowShift);this._wasDragged=true;},_endCanvasDragging:function()
{this._isDragging=false;},_calculateTimelineData:function()
{if(this._cpuProfileView.samples)
return this._calculateTimelineDataForSamples();if(this._timelineData)
@@ -525,35 +562,42 @@
return null;var index=0;var entries=[];function appendReversedArray(toArray,fromArray)
{for(var i=fromArray.length-1;i>=0;--i)
toArray.push(fromArray[i]);}
-var stack=[];appendReversedArray(stack,this._cpuProfileView.profileHead.children);var levelOffsets=([0]);var levelExitIndexes=([0]);var colorGenerator=WebInspector.FlameChart._colorGenerator;while(stack.length){var level=levelOffsets.length-1;var node=stack.pop();var offset=levelOffsets[level];var colorPair=colorGenerator._colorPairForID(node.functionName+":"+node.url+":"+node.lineNumber);entries.push(new WebInspector.FlameChart.Entry(colorPair,level,node.totalTime,offset,node));++index;levelOffsets[level]+=node.totalTime;if(node.children.length){levelExitIndexes.push(stack.length);levelOffsets.push(offset+node.selfTime/2);appendReversedArray(stack,node.children);}
+var stack=[];appendReversedArray(stack,this._cpuProfileView.profileHead.children);var levelOffsets=([0]);var levelExitIndexes=([0]);var colorGenerator=WebInspector.FlameChart._colorGenerator;var colorIndexEntryChains=[[],[],[]];while(stack.length){var level=levelOffsets.length-1;var node=stack.pop();var offset=levelOffsets[level];var id=node.functionName+":"+node.url+":"+node.lineNumber;var colorPair=colorGenerator._colorPairForID(id);var colorIndexEntries=colorIndexEntryChains[colorPair.index];if(!colorIndexEntries)
+colorIndexEntries=colorIndexEntryChains[colorPair.index]=[];var entry=new WebInspector.FlameChart.Entry(colorPair,level,node.totalTime,offset,node);entries.push(entry);colorIndexEntries.push(entry);++index;levelOffsets[level]+=node.totalTime;if(node.children.length){levelExitIndexes.push(stack.length);levelOffsets.push(offset+node.selfTime/2);appendReversedArray(stack,node.children);}
while(stack.length===levelExitIndexes[levelExitIndexes.length-1]){levelOffsets.pop();levelExitIndexes.pop();}}
-this._timelineData={entries:entries,totalTime:this._cpuProfileView.profileHead.totalTime,}
+this._timelineData={entries:entries,colorIndexEntryChains:colorIndexEntryChains,totalTime:this._cpuProfileView.profileHead.totalTime,}
return this._timelineData;},_calculateTimelineDataForSamples:function()
{if(this._timelineData)
return this._timelineData;if(!this._cpuProfileView.profileHead)
-return null;var samples=this._cpuProfileView.samples;var idToNode=this._cpuProfileView._idToNode;var gcNode=this._cpuProfileView._gcNode;var samplesCount=samples.length;var index=0;var entries=([]);var openIntervals=[];var stackTrace=[];var colorGenerator=WebInspector.FlameChart._colorGenerator;for(var sampleIndex=0;sampleIndex<samplesCount;sampleIndex++){var node=idToNode[samples[sampleIndex]];stackTrace.length=0;while(node){stackTrace.push(node);node=node.parent;}
-stackTrace.pop();var depth=0;node=stackTrace.pop();var intervalIndex;if(node===gcNode){while(depth<openIntervals.length){intervalIndex=openIntervals[depth].index;entries[intervalIndex].duration+=1;++depth;}
-if(openIntervals.length>0&&openIntervals.peekLast().node===node){entries[intervalIndex].selfTime+=1;continue;}}
-while(node&&depth<openIntervals.length&&node===openIntervals[depth].node){intervalIndex=openIntervals[depth].index;entries[intervalIndex].duration+=1;node=stackTrace.pop();++depth;}
+return null;var samples=this._cpuProfileView.samples;var idToNode=this._cpuProfileView._idToNode;var gcNode=this._cpuProfileView._gcNode;var samplesCount=samples.length;var samplingInterval=this._cpuProfileView.samplingIntervalMs;var index=0;var entries=([]);var openIntervals=[];var stackTrace=[];var colorGenerator=WebInspector.FlameChart._colorGenerator;var colorIndexEntryChains=[[],[],[]];for(var sampleIndex=0;sampleIndex<samplesCount;sampleIndex++){var node=idToNode[samples[sampleIndex]];stackTrace.length=0;while(node){stackTrace.push(node);node=node.parent;}
+stackTrace.pop();var depth=0;node=stackTrace.pop();var intervalIndex;if(node===gcNode){while(depth<openIntervals.length){intervalIndex=openIntervals[depth].index;entries[intervalIndex].duration+=samplingInterval;++depth;}
+if(openIntervals.length>0&&openIntervals.peekLast().node===node){entries[intervalIndex].selfTime+=samplingInterval;continue;}}
+while(node&&depth<openIntervals.length&&node===openIntervals[depth].node){intervalIndex=openIntervals[depth].index;entries[intervalIndex].duration+=samplingInterval;node=stackTrace.pop();++depth;}
if(depth<openIntervals.length)
-openIntervals.length=depth;if(!node){entries[intervalIndex].selfTime+=1;continue;}
-while(node){var colorPair=colorGenerator._colorPairForID(node.functionName+":"+node.url+":"+node.lineNumber);entries.push(new WebInspector.FlameChart.Entry(colorPair,depth,1,sampleIndex,node));openIntervals.push({node:node,index:index});++index;node=stackTrace.pop();++depth;}
-entries[entries.length-1].selfTime+=1;}
-this._timelineData={entries:entries,totalTime:samplesCount,};return this._timelineData;},_onMouseMove:function(event)
+openIntervals.length=depth;if(!node){entries[intervalIndex].selfTime+=samplingInterval;continue;}
+while(node){var colorPair=colorGenerator._colorPairForID(node.functionName+":"+node.url+":"+node.lineNumber);var colorIndexEntries=colorIndexEntryChains[colorPair.index];if(!colorIndexEntries)
+colorIndexEntries=colorIndexEntryChains[colorPair.index]=[];var entry=new WebInspector.FlameChart.Entry(colorPair,depth,samplingInterval,sampleIndex*samplingInterval,node);entries.push(entry);colorIndexEntries.push(entry);openIntervals.push({node:node,index:index});++index;node=stackTrace.pop();++depth;}
+entries[entries.length-1].selfTime+=samplingInterval;}
+this._timelineData={entries:entries,colorIndexEntryChains:colorIndexEntryChains,totalTime:this._cpuProfileView.profileHead.totalTime};return this._timelineData;},_onMouseMove:function(event)
{if(this._isDragging)
return;var entryIndex=this._coordinatesToEntryIndex(event.offsetX,event.offsetY);if(this._highlightedEntryIndex===entryIndex)
return;if(entryIndex===-1||this._timelineData.entries[entryIndex].node.scriptId==="0")
this._canvas.style.cursor="default";else
-this._canvas.style.cursor="pointer";this._highlightedEntryIndex=entryIndex;this._scheduleUpdate();},_prepareHighlightedEntryInfo:function()
+this._canvas.style.cursor="pointer";this._highlightedEntryIndex=entryIndex;this._scheduleUpdate();},_millisecondsToString:function(ms)
+{if(ms===0)
+return"0";if(ms<1000)
+return WebInspector.UIString("%.1f\u2009ms",ms);return Number.secondsToString(ms/1000,true);},_prepareHighlightedEntryInfo:function()
{if(this._isDragging)
return null;var entry=this._timelineData.entries[this._highlightedEntryIndex];if(!entry)
return null;var node=entry.node;if(!node)
return null;var entryInfo=[];function pushEntryInfoRow(title,text)
{var row={};row.title=title;row.text=text;entryInfo.push(row);}
-pushEntryInfoRow(WebInspector.UIString("Name"),node.functionName);if(this._cpuProfileView.samples){pushEntryInfoRow(WebInspector.UIString("Self time"),Number.secondsToString(entry.selfTime/1000,true));pushEntryInfoRow(WebInspector.UIString("Total time"),Number.secondsToString(entry.duration/1000,true));}
+pushEntryInfoRow(WebInspector.UIString("Name"),node.functionName);if(this._cpuProfileView.samples){var selfTime=this._millisecondsToString(entry.selfTime);var totalTime=this._millisecondsToString(entry.duration);pushEntryInfoRow(WebInspector.UIString("Self time"),selfTime);pushEntryInfoRow(WebInspector.UIString("Total time"),totalTime);}
if(node.url)
-pushEntryInfoRow(WebInspector.UIString("URL"),node.url+":"+node.lineNumber);pushEntryInfoRow(WebInspector.UIString("Aggregated self time"),Number.secondsToString(node.selfTime/1000,true));pushEntryInfoRow(WebInspector.UIString("Aggregated total time"),Number.secondsToString(node.totalTime/1000,true));return entryInfo;},_onClick:function(e)
-{if(this._highlightedEntryIndex===-1)
+pushEntryInfoRow(WebInspector.UIString("URL"),node.url+":"+node.lineNumber);pushEntryInfoRow(WebInspector.UIString("Aggregated self time"),Number.secondsToString(node.selfTime/1000,true));pushEntryInfoRow(WebInspector.UIString("Aggregated total time"),Number.secondsToString(node.totalTime/1000,true));if(node.deoptReason&&node.deoptReason!=="no reason")
+pushEntryInfoRow(WebInspector.UIString("Not optimized"),node.deoptReason);return entryInfo;},_onClick:function(e)
+{if(this._wasDragged)
+return;if(this._highlightedEntryIndex===-1)
return;var node=this._timelineData.entries[this._highlightedEntryIndex].node;this.dispatchEventToListeners(WebInspector.FlameChart.Events.SelectedNode,node);},_onMouseWheel:function(e)
{if(e.wheelDeltaY){const zoomFactor=1.1;const mouseWheelZoomSpeed=1/120;var zoom=Math.pow(zoomFactor,-e.wheelDeltaY*mouseWheelZoomSpeed);var overviewReference=(this._pixelWindowLeft+e.offsetX-this._paddingLeft)/this._totalPixels;this._overviewGrid.zoom(zoom,overviewReference);}else{var shift=Number.constrain(-1*this._windowWidth/4*e.wheelDeltaX/120,-this._windowLeft,1-this._windowRight);this._overviewGrid.setWindow(this._windowLeft+shift,this._windowRight+shift);}},_coordinatesToEntryIndex:function(x,y)
{var timelineData=this._timelineData;if(!timelineData)
@@ -570,12 +614,19 @@
{anchorBox.x=Math.floor(entry.startTime*this._timeToPixel)-this._pixelWindowLeft+this._paddingLeft;anchorBox.y=this._canvas.height/window.devicePixelRatio-(entry.depth+1)*this._barHeight;anchorBox.width=Math.max(Math.ceil(entry.duration*this._timeToPixel),this._minWidth);anchorBox.height=this._barHeight;if(anchorBox.x<0){anchorBox.width+=anchorBox.x;anchorBox.x=0;}
anchorBox.width=Number.constrain(anchorBox.width,0,this._canvas.width-anchorBox.x);},draw:function(width,height)
{var timelineData=this._calculateTimelineData();if(!timelineData)
-return;var timelineEntries=timelineData.entries;var ratio=window.devicePixelRatio;var canvasWidth=width*ratio;var canvasHeight=height*ratio;this._canvas.width=canvasWidth;this._canvas.height=canvasHeight;this._canvas.style.width=width+"px";this._canvas.style.height=height+"px";var barHeight=this._barHeight;var context=this._canvas.getContext("2d");var textPaddingLeft=2;context.scale(ratio,ratio);context.font=(barHeight-4)+"px "+window.getComputedStyle(this.element,null).getPropertyValue("font-family");context.textBaseline="alphabetic";this._dotsWidth=context.measureText("\u2026").width;var visibleTimeLeft=this._timeWindowLeft-this._paddingLeftTime;var anchorBox=new AnchorBox();for(var i=0;i<timelineEntries.length;++i){var entry=timelineEntries[i];var startTime=entry.startTime;if(startTime>this._timeWindowRight)
+return;var colorIndexEntryChains=timelineData.colorIndexEntryChains;var ratio=window.devicePixelRatio;var canvasWidth=width*ratio;var canvasHeight=height*ratio;this._canvas.width=canvasWidth;this._canvas.height=canvasHeight;this._canvas.style.width=width+"px";this._canvas.style.height=height+"px";var barHeight=this._barHeight;var context=this._canvas.getContext("2d");context.scale(ratio,ratio);var visibleTimeLeft=this._timeWindowLeft-this._paddingLeftTime;var timeWindowRight=this._timeWindowRight;var lastUsedColor="";function forEachEntry(flameChart,callback)
+{var anchorBox=new AnchorBox();for(var j=0;j<colorIndexEntryChains.length;++j){var entries=colorIndexEntryChains[j];if(!entries)
+continue;for(var i=0;i<entries.length;++i){var entry=entries[i];var startTime=entry.startTime;if(startTime>timeWindowRight)
break;if((startTime+entry.duration)<visibleTimeLeft)
-continue;this._entryToAnchorBox(entry,anchorBox);var colorPair=entry.colorPair;var color;if(this._highlightedEntryIndex===i)
-color=colorPair.highlighted;else
-color=colorPair.normal;context.beginPath();context.rect(anchorBox.x,anchorBox.y,anchorBox.width-1,anchorBox.height-1);context.fillStyle=color;context.fill();var xText=Math.max(0,anchorBox.x);var widthText=anchorBox.width-textPaddingLeft+anchorBox.x-xText;var title=this._prepareText(context,entry.node.functionName,widthText);if(title){context.fillStyle="#333";context.fillText(title,xText+textPaddingLeft,anchorBox.y+barHeight-4);}}
-var entryInfo=this._prepareHighlightedEntryInfo();if(entryInfo)
+continue;flameChart._entryToAnchorBox(entry,anchorBox);callback(flameChart,context,entry,anchorBox,flameChart._highlightedEntryIndex===i);}}}
+function drawBar(flameChart,context,entry,anchorBox,highlighted)
+{context.beginPath();context.rect(anchorBox.x,anchorBox.y,anchorBox.width-1,anchorBox.height-1);var color=highlighted?entry.colorPair.highlighted:entry.colorPair.normal;if(lastUsedColor!==color){lastUsedColor=color;context.fillStyle=color;}
+context.fill();}
+forEachEntry(this,drawBar);var font=(barHeight-4)+"px "+window.getComputedStyle(this.element,null).getPropertyValue("font-family");var boldFont="bold "+font;var isBoldFontSelected=false;context.font=font;context.textBaseline="alphabetic";context.fillStyle="#333";this._dotsWidth=context.measureText("\u2026").width;var textPaddingLeft=2;function drawText(flameChart,context,entry,anchorBox,highlighted)
+{var deoptReason=entry.node.deoptReason;if(isBoldFontSelected){if(!deoptReason||deoptReason==="no reason"){context.font=font;isBoldFontSelected=false;}}else{if(deoptReason&&deoptReason!=="no reason"){context.font=boldFont;isBoldFontSelected=true;}}
+var xText=Math.max(0,anchorBox.x);var widthText=anchorBox.width-textPaddingLeft+anchorBox.x-xText;var title=flameChart._prepareText(context,entry.node.functionName,widthText);if(title)
+context.fillText(title,xText+textPaddingLeft,anchorBox.y+barHeight-4);}
+forEachEntry(this,drawText);var entryInfo=this._prepareHighlightedEntryInfo();if(entryInfo)
this._printEntryInfo(context,entryInfo,0,25,width);},_printEntryInfo:function(context,entryInfo,x,y,width)
{const lineHeight=18;const paddingLeft=10;const paddingTop=5;var maxTitleWidth=0;var basicFont="100% "+window.getComputedStyle(this.element,null).getPropertyValue("font-family");context.font="bold "+basicFont;context.textBaseline="top";for(var i=0;i<entryInfo.length;++i)
maxTitleWidth=Math.max(maxTitleWidth,context.measureText(entryInfo[i].title).width);var maxTextWidth=0;for(var i=0;i<entryInfo.length;++i)
@@ -677,15 +728,22 @@
{this.node.nodeIndex=newIndex;},item:function()
{return this.node;},next:function()
{this.node.nodeIndex=this.node._nextNodeIndex();}}
-WebInspector.HeapSnapshot=function(profile)
-{this.uid=profile.snapshot.uid;this._nodes=profile.nodes;this._containmentEdges=profile.edges;this._metaNode=profile.snapshot.meta;this._strings=profile.strings;this._noDistance=-5;this._rootNodeIndex=0;if(profile.snapshot.root_index)
-this._rootNodeIndex=profile.snapshot.root_index;this._snapshotDiffs={};this._aggregatesForDiff=null;this._init();}
-function HeapSnapshotMetainfo()
+WebInspector.HeapSnapshotProgress=function(dispatcher)
+{this._dispatcher=dispatcher;}
+WebInspector.HeapSnapshotProgress.Event={Update:"ProgressUpdate"};WebInspector.HeapSnapshotProgress.prototype={updateStatus:function(status)
+{this._sendUpdateEvent(WebInspector.UIString(status));},updateProgress:function(title,value,total)
+{var percentValue=((total?(value/total):0)*100).toFixed(0);this._sendUpdateEvent(WebInspector.UIString(title,percentValue));},_sendUpdateEvent:function(text)
+{if(this._dispatcher)
+this._dispatcher.sendEvent(WebInspector.HeapSnapshotProgress.Event.Update,text);}}
+WebInspector.HeapSnapshot=function(profile,progress)
+{this.uid=profile.snapshot.uid;this._nodes=profile.nodes;this._containmentEdges=profile.edges;this._metaNode=profile.snapshot.meta;this._strings=profile.strings;this._progress=progress;this._noDistance=-5;this._rootNodeIndex=0;if(profile.snapshot.root_index)
+this._rootNodeIndex=profile.snapshot.root_index;this._snapshotDiffs={};this._aggregatesForDiff=null;this._init();if(WebInspector.HeapSnapshot.enableAllocationProfiler){this._progress.updateStatus("Buiding allocation statistics\u2026");this._allocationProfile=new WebInspector.AllocationProfile(profile);this._progress.updateStatus("Done");}}
+WebInspector.HeapSnapshot.enableAllocationProfiler=false;function HeapSnapshotMetainfo()
{this.node_fields=[];this.node_types=[];this.edge_fields=[];this.edge_types=[];this.type_strings={};this.fields=[];this.types=[];}
function HeapSnapshotHeader()
{this.title="";this.uid=0;this.meta=new HeapSnapshotMetainfo();this.node_count=0;this.edge_count=0;}
WebInspector.HeapSnapshot.prototype={_init:function()
-{var meta=this._metaNode;this._nodeTypeOffset=meta.node_fields.indexOf("type");this._nodeNameOffset=meta.node_fields.indexOf("name");this._nodeIdOffset=meta.node_fields.indexOf("id");this._nodeSelfSizeOffset=meta.node_fields.indexOf("self_size");this._nodeEdgeCountOffset=meta.node_fields.indexOf("edge_count");this._nodeFieldCount=meta.node_fields.length;this._nodeTypes=meta.node_types[this._nodeTypeOffset];this._nodeHiddenType=this._nodeTypes.indexOf("hidden");this._nodeObjectType=this._nodeTypes.indexOf("object");this._nodeNativeType=this._nodeTypes.indexOf("native");this._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._buildEdgeIndexes();this._markInvisibleEdges();this._buildRetainers();this._calculateFlags();this._calculateDistances();var result=this._buildPostOrderIndex();this._dominatorsTree=this._buildDominatorTree(result.postOrderIndex2NodeOrdinal,result.nodeOrdinal2PostOrderIndex);this._calculateRetainedSizes(result.postOrderIndex2NodeOrdinal);this._buildDominatedNodes();},_buildEdgeIndexes:function()
+{var meta=this._metaNode;this._nodeTypeOffset=meta.node_fields.indexOf("type");this._nodeNameOffset=meta.node_fields.indexOf("name");this._nodeIdOffset=meta.node_fields.indexOf("id");this._nodeSelfSizeOffset=meta.node_fields.indexOf("self_size");this._nodeEdgeCountOffset=meta.node_fields.indexOf("edge_count");this._nodeFieldCount=meta.node_fields.length;this._nodeTypes=meta.node_types[this._nodeTypeOffset];this._nodeHiddenType=this._nodeTypes.indexOf("hidden");this._nodeObjectType=this._nodeTypes.indexOf("object");this._nodeNativeType=this._nodeTypes.indexOf("native");this._nodeConsStringType=this._nodeTypes.indexOf("concatenated string");this._nodeSlicedStringType=this._nodeTypes.indexOf("sliced string");this._nodeCodeType=this._nodeTypes.indexOf("code");this._nodeSyntheticType=this._nodeTypes.indexOf("synthetic");this._edgeFieldsCount=meta.edge_fields.length;this._edgeTypeOffset=meta.edge_fields.indexOf("type");this._edgeNameOffset=meta.edge_fields.indexOf("name_or_index");this._edgeToNodeOffset=meta.edge_fields.indexOf("to_node");this._edgeTypes=meta.edge_types[this._edgeTypeOffset];this._edgeTypes.push("invisible");this._edgeElementType=this._edgeTypes.indexOf("element");this._edgeHiddenType=this._edgeTypes.indexOf("hidden");this._edgeInternalType=this._edgeTypes.indexOf("internal");this._edgeShortcutType=this._edgeTypes.indexOf("shortcut");this._edgeWeakType=this._edgeTypes.indexOf("weak");this._edgeInvisibleType=this._edgeTypes.indexOf("invisible");this.nodeCount=this._nodes.length/this._nodeFieldCount;this._edgeCount=this._containmentEdges.length/this._edgeFieldsCount;this._progress.updateStatus("Building edge indexes\u2026");this._buildEdgeIndexes();this._progress.updateStatus("Marking invisible edges\u2026");this._markInvisibleEdges();this._progress.updateStatus("Building retainers\u2026");this._buildRetainers();this._progress.updateStatus("Calculating node flags\u2026");this._calculateFlags();this._progress.updateStatus("Calculating distances\u2026");this._calculateDistances();this._progress.updateStatus("Building postorder index\u2026");var result=this._buildPostOrderIndex();this._progress.updateStatus("Building dominator tree\u2026");this._dominatorsTree=this._buildDominatorTree(result.postOrderIndex2NodeOrdinal,result.nodeOrdinal2PostOrderIndex);this._progress.updateStatus("Calculating retained sizes\u2026");this._calculateRetainedSizes(result.postOrderIndex2NodeOrdinal);this._progress.updateStatus("Buiding dominated nodes\u2026");this._buildDominatedNodes();this._progress.updateStatus("Finished processing.");},_buildEdgeIndexes:function()
{var nodes=this._nodes;var nodeCount=this.nodeCount;var firstEdgeIndexes=this._firstEdgeIndexes=new Uint32Array(nodeCount+1);var nodeFieldCount=this._nodeFieldCount;var edgeFieldsCount=this._edgeFieldsCount;var nodeEdgeCountOffset=this._nodeEdgeCountOffset;firstEdgeIndexes[nodeCount]=this._containmentEdges.length;for(var nodeOrdinal=0,edgeIndex=0;nodeOrdinal<nodeCount;++nodeOrdinal){firstEdgeIndexes[nodeOrdinal]=edgeIndex;edgeIndex+=nodes[nodeOrdinal*nodeFieldCount+nodeEdgeCountOffset]*edgeFieldsCount;}},_buildRetainers:function()
{var retainingNodes=this._retainingNodes=new Uint32Array(this._edgeCount);var retainingEdges=this._retainingEdges=new Uint32Array(this._edgeCount);var firstRetainerIndex=this._firstRetainerIndex=new Uint32Array(this.nodeCount+1);var containmentEdges=this._containmentEdges;var edgeFieldsCount=this._edgeFieldsCount;var nodeFieldCount=this._nodeFieldCount;var edgeToNodeOffset=this._edgeToNodeOffset;var nodes=this._nodes;var firstEdgeIndexes=this._firstEdgeIndexes;var nodeCount=this.nodeCount;for(var toNodeFieldIndex=edgeToNodeOffset,l=containmentEdges.length;toNodeFieldIndex<l;toNodeFieldIndex+=edgeFieldsCount){var toNodeIndex=containmentEdges[toNodeFieldIndex];if(toNodeIndex%nodeFieldCount)
throw new Error("Invalid toNodeIndex "+toNodeIndex);++firstRetainerIndex[toNodeIndex/nodeFieldCount];}
@@ -709,7 +767,9 @@
return aggregatesByClassName;}
var filter;if(filterString)
filter=this._parseFilter(filterString);var aggregates=this._buildAggregates(filter);this._calculateClassesRetainedSize(aggregates.aggregatesByClassIndex,filter);aggregatesByClassName=aggregates.aggregatesByClassName;if(sortedIndexes)
-this._sortAggregateIndexes(aggregatesByClassName);this._aggregatesSortedFlags[key]=sortedIndexes;this._aggregates[key]=aggregatesByClassName;return aggregatesByClassName;},aggregatesForDiff:function()
+this._sortAggregateIndexes(aggregatesByClassName);this._aggregatesSortedFlags[key]=sortedIndexes;this._aggregates[key]=aggregatesByClassName;return aggregatesByClassName;},allocationTracesTops:function()
+{return this._allocationProfile.serializeTraceTops();},allocationNodeCallers:function(nodeId)
+{return this._allocationProfile.serializeCallers(nodeId);},aggregatesForDiff:function()
{if(this._aggregatesForDiff)
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();}
this._aggregatesForDiff[className]={indexes:indexes,ids:ids,selfSizes:selfSizes};}
@@ -802,7 +862,7 @@
{return new WebInspector.HeapSnapshotNodesProvider(this,this.classNodesFilter(),this.aggregates(false,aggregatesKey)[className].idxs);},createNodesProviderForDominator:function(nodeIndex)
{var node=this.createNode(nodeIndex);return new WebInspector.HeapSnapshotNodesProvider(this,null,this._dominatedNodesOfNode(node));},updateStaticData:function()
{return{nodeCount:this.nodeCount,rootNodeIndex:this._rootNodeIndex,totalSize:this.totalSize,uid:this.uid};}};WebInspector.HeapSnapshotFilteredOrderedIterator=function(iterator,filter,unfilteredIterationOrder)
-{this._filter=filter;this._iterator=iterator;this._unfilteredIterationOrder=unfilteredIterationOrder;this._iterationOrder=null;this._position=0;this._currentComparator=null;this._sortedPrefixLength=0;}
+{this._filter=filter;this._iterator=iterator;this._unfilteredIterationOrder=unfilteredIterationOrder;this._iterationOrder=null;this._position=0;this._currentComparator=null;this._sortedPrefixLength=0;this._sortedSuffixLength=0;}
WebInspector.HeapSnapshotFilteredOrderedIterator.prototype={_createIterationOrder:function()
{if(this._iterationOrder)
return;if(this._unfilteredIterationOrder&&!this._filter){this._iterationOrder=this._unfilteredIterationOrder.slice(0);this._unfilteredIterationOrder=null;return;}
@@ -824,44 +884,50 @@
{this._createIterationOrder();return this._iterationOrder.length;},next:function()
{++this._position;},serializeItemsRange:function(begin,end)
{this._createIterationOrder();if(begin>end)
-throw new Error("Start position > end position: "+begin+" > "+end);if(end>=this._iterationOrder.length)
-end=this._iterationOrder.length;if(this._sortedPrefixLength<end){this.sort(this._currentComparator,this._sortedPrefixLength,this._iterationOrder.length-1,end-this._sortedPrefixLength);this._sortedPrefixLength=end;}
+throw new Error("Start position > end position: "+begin+" > "+end);if(end>this._iterationOrder.length)
+end=this._iterationOrder.length;if(this._sortedPrefixLength<end&&begin<this._iterationOrder.length-this._sortedSuffixLength){this.sort(this._currentComparator,this._sortedPrefixLength,this._iterationOrder.length-1-this._sortedSuffixLength,begin,end-1);if(begin<=this._sortedPrefixLength)
+this._sortedPrefixLength=end;if(end>=this._iterationOrder.length-this._sortedSuffixLength)
+this._sortedSuffixLength=this._iterationOrder.length-begin;}
this._position=begin;var startPosition=this._position;var count=end-begin;var result=new Array(count);for(var i=0;i<count&&this.hasNext();++i,this.next())
result[i]=this.item().serialize();result.length=i;result.totalLength=this._iterationOrder.length;result.startPosition=startPosition;result.endPosition=this._position;return result;},sortAll:function()
-{this._createIterationOrder();if(this._sortedPrefixLength===this._iterationOrder.length)
-return;this.sort(this._currentComparator,this._sortedPrefixLength,this._iterationOrder.length-1,this._iterationOrder.length);this._sortedPrefixLength=this._iterationOrder.length;},sortAndRewind:function(comparator)
-{this._currentComparator=comparator;this._sortedPrefixLength=0;this.rewind();}}
+{this._createIterationOrder();if(this._sortedPrefixLength+this._sortedSuffixLength>=this._iterationOrder.length)
+return;this.sort(this._currentComparator,this._sortedPrefixLength,this._iterationOrder.length-1-this._sortedSuffixLength,this._sortedPrefixLength,this._iterationOrder.length-1-this._sortedSuffixLength);this._sortedPrefixLength=this._iterationOrder.length;this._sortedSuffixLength=0;},sortAndRewind:function(comparator)
+{this._currentComparator=comparator;this._sortedPrefixLength=0;this._sortedSuffixLength=0;this.rewind();}}
WebInspector.HeapSnapshotFilteredOrderedIterator.prototype.createComparator=function(fieldNames)
{return{fieldName1:fieldNames[0],ascending1:fieldNames[1],fieldName2:fieldNames[2],ascending2:fieldNames[3]};}
WebInspector.HeapSnapshotEdgesProvider=function(snapshot,filter,edgesIter)
{this.snapshot=snapshot;WebInspector.HeapSnapshotFilteredOrderedIterator.call(this,edgesIter,filter);}
-WebInspector.HeapSnapshotEdgesProvider.prototype={sort:function(comparator,leftBound,rightBound,count)
+WebInspector.HeapSnapshotEdgesProvider.prototype={sort:function(comparator,leftBound,rightBound,windowLeft,windowRight)
{var fieldName1=comparator.fieldName1;var fieldName2=comparator.fieldName2;var ascending1=comparator.ascending1;var ascending2=comparator.ascending2;var edgeA=this._iterator.item().clone();var edgeB=edgeA.clone();var nodeA=this.snapshot.createNode();var nodeB=this.snapshot.createNode();function compareEdgeFieldName(ascending,indexA,indexB)
{edgeA.edgeIndex=indexA;edgeB.edgeIndex=indexB;if(edgeB.name()==="__proto__")return-1;if(edgeA.name()==="__proto__")return 1;var result=edgeA.hasStringName()===edgeB.hasStringName()?(edgeA.name()<edgeB.name()?-1:(edgeA.name()>edgeB.name()?1:0)):(edgeA.hasStringName()?-1:1);return ascending?result:-result;}
function compareNodeField(fieldName,ascending,indexA,indexB)
{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;}
function compareEdgeAndNode(indexA,indexB){var result=compareEdgeFieldName(ascending1,indexA,indexB);if(result===0)
-result=compareNodeField(fieldName2,ascending2,indexA,indexB);return result;}
+result=compareNodeField(fieldName2,ascending2,indexA,indexB);if(result===0)
+return indexA-indexB;return result;}
function compareNodeAndEdge(indexA,indexB){var result=compareNodeField(fieldName1,ascending1,indexA,indexB);if(result===0)
-result=compareEdgeFieldName(ascending2,indexA,indexB);return result;}
+result=compareEdgeFieldName(ascending2,indexA,indexB);if(result===0)
+return indexA-indexB;return result;}
function compareNodeAndNode(indexA,indexB){var result=compareNodeField(fieldName1,ascending1,indexA,indexB);if(result===0)
-result=compareNodeField(fieldName2,ascending2,indexA,indexB);return result;}
+result=compareNodeField(fieldName2,ascending2,indexA,indexB);if(result===0)
+return indexA-indexB;return result;}
if(fieldName1==="!edgeName")
-this._iterationOrder.sortRange(compareEdgeAndNode,leftBound,rightBound,count);else if(fieldName2==="!edgeName")
-this._iterationOrder.sortRange(compareNodeAndEdge,leftBound,rightBound,count);else
-this._iterationOrder.sortRange(compareNodeAndNode,leftBound,rightBound,count);},__proto__:WebInspector.HeapSnapshotFilteredOrderedIterator.prototype}
+this._iterationOrder.sortRange(compareEdgeAndNode,leftBound,rightBound,windowLeft,windowRight);else if(fieldName2==="!edgeName")
+this._iterationOrder.sortRange(compareNodeAndEdge,leftBound,rightBound,windowLeft,windowRight);else
+this._iterationOrder.sortRange(compareNodeAndNode,leftBound,rightBound,windowLeft,windowRight);},__proto__:WebInspector.HeapSnapshotFilteredOrderedIterator.prototype}
WebInspector.HeapSnapshotNodesProvider=function(snapshot,filter,nodeIndexes)
{this.snapshot=snapshot;WebInspector.HeapSnapshotFilteredOrderedIterator.call(this,snapshot._allNodes(),filter,nodeIndexes);}
WebInspector.HeapSnapshotNodesProvider.prototype={nodePosition:function(snapshotObjectId)
{this._createIterationOrder();if(this.isEmpty())
return-1;this.sortAll();var node=this.snapshot.createNode();for(var i=0;i<this._iterationOrder.length;i++){node.nodeIndex=this._iterationOrder[i];if(node.id()===snapshotObjectId)
return i;}
-return-1;},sort:function(comparator,leftBound,rightBound,count)
+return-1;},sort:function(comparator,leftBound,rightBound,windowLeft,windowRight)
{var fieldName1=comparator.fieldName1;var fieldName2=comparator.fieldName2;var ascending1=comparator.ascending1;var ascending2=comparator.ascending2;var nodeA=this.snapshot.createNode();var nodeB=this.snapshot.createNode();function sortByNodeField(fieldName,ascending)
{var valueOrFunctionA=nodeA[fieldName];var valueA=typeof valueOrFunctionA!=="function"?valueOrFunctionA:valueOrFunctionA.call(nodeA);var valueOrFunctionB=nodeB[fieldName];var valueB=typeof valueOrFunctionB!=="function"?valueOrFunctionB:valueOrFunctionB.call(nodeB);var result=valueA<valueB?-1:(valueA>valueB?1:0);return ascending?result:-result;}
function sortByComparator(indexA,indexB){nodeA.nodeIndex=indexA;nodeB.nodeIndex=indexB;var result=sortByNodeField(fieldName1,ascending1);if(result===0)
-result=sortByNodeField(fieldName2,ascending2);return result;}
-this._iterationOrder.sortRange(sortByComparator,leftBound,rightBound,count);},__proto__:WebInspector.HeapSnapshotFilteredOrderedIterator.prototype};WebInspector.HeapSnapshotSortableDataGrid=function(columns)
+result=sortByNodeField(fieldName2,ascending2);if(result===0)
+return indexA-indexB;return result;}
+this._iterationOrder.sortRange(sortByComparator,leftBound,rightBound,windowLeft,windowRight);},__proto__:WebInspector.HeapSnapshotFilteredOrderedIterator.prototype};WebInspector.HeapSnapshotSortableDataGrid=function(columns)
{WebInspector.DataGrid.call(this,columns);this._recursiveSortingDepth=0;this._highlightedNode=null;this._populatedAndSorted=false;this.addEventListener("sorting complete",this._sortingComplete,this);this.addEventListener(WebInspector.DataGrid.Events.SortingChanged,this.sortingChanged,this);}
WebInspector.HeapSnapshotSortableDataGrid.Events={ContentShown:"ContentShown"}
WebInspector.HeapSnapshotSortableDataGrid.prototype={defaultPopulateCount:function()
@@ -873,11 +939,12 @@
{this.removeEventListener("sorting complete",this._sortingComplete,this);this._populatedAndSorted=true;this.dispatchEventToListeners(WebInspector.HeapSnapshotSortableDataGrid.Events.ContentShown,this);},willHide:function()
{this._clearCurrentHighlight();},populateContextMenu:function(profilesPanel,contextMenu,event)
{var td=event.target.enclosingNodeOrSelfWithNodeName("td");if(!td)
-return;var node=td.heapSnapshotNode;if(node instanceof WebInspector.HeapSnapshotInstanceNode||node instanceof WebInspector.HeapSnapshotObjectNode){function revealInDominatorsView()
+return;var node=td.heapSnapshotNode;function revealInDominatorsView()
{profilesPanel.showObject(node.snapshotNodeId,"Dominators");}
-contextMenu.appendItem(WebInspector.UIString(WebInspector.useLowerCaseMenuTitles()?"Reveal in Dominators view":"Reveal in Dominators View"),revealInDominatorsView.bind(this));}else if(node instanceof WebInspector.HeapSnapshotDominatorObjectNode){function revealInSummaryView()
+function revealInSummaryView()
{profilesPanel.showObject(node.snapshotNodeId,"Summary");}
-contextMenu.appendItem(WebInspector.UIString(WebInspector.useLowerCaseMenuTitles()?"Reveal in Summary view":"Reveal in Summary View"),revealInSummaryView.bind(this));}},resetSortingCache:function()
+if(node&&node.showRetainingEdges){contextMenu.appendItem(WebInspector.UIString(WebInspector.useLowerCaseMenuTitles()?"Reveal in Summary view":"Reveal in Summary View"),revealInSummaryView.bind(this));contextMenu.appendItem(WebInspector.UIString(WebInspector.useLowerCaseMenuTitles()?"Reveal in Dominators view":"Reveal in Dominators View"),revealInDominatorsView.bind(this));}
+else if(node instanceof WebInspector.HeapSnapshotInstanceNode||node instanceof WebInspector.HeapSnapshotObjectNode){contextMenu.appendItem(WebInspector.UIString(WebInspector.useLowerCaseMenuTitles()?"Reveal in Dominators view":"Reveal in Dominators View"),revealInDominatorsView.bind(this));}else if(node instanceof WebInspector.HeapSnapshotDominatorObjectNode){contextMenu.appendItem(WebInspector.UIString(WebInspector.useLowerCaseMenuTitles()?"Reveal in Summary view":"Reveal in Summary View"),revealInSummaryView.bind(this));}},resetSortingCache:function()
{delete this._lastSortColumnIdentifier;delete this._lastSortAscending;},topLevelNodes:function()
{return this.rootNode().children;},highlightObjectByHeapSnapshotId:function(heapSnapshotObjectId)
{},highlightNode:function(node)
@@ -999,7 +1066,19 @@
{if(!dominatorNode){console.error("Cannot find dominator node");return;}
if(!dominatorIds.length){this.highlightNode(dominatorNode);dominatorNode.element.scrollIntoViewIfNeeded(true);return;}
var snapshotObjectId=dominatorIds.pop();dominatorNode.retrieveChildBySnapshotObjectId(snapshotObjectId,expandNextDominator.bind(this,dominatorIds));}
-this.snapshot.dominatorIdsForNode(parseInt(id,10),didGetDominators.bind(this));},__proto__:WebInspector.HeapSnapshotSortableDataGrid.prototype};WebInspector.HeapSnapshotGridNode=function(tree,hasChildren)
+this.snapshot.dominatorIdsForNode(parseInt(id,10),didGetDominators.bind(this));},__proto__:WebInspector.HeapSnapshotSortableDataGrid.prototype}
+WebInspector.AllocationDataGrid=function()
+{var columns=[{id:"name",title:WebInspector.UIString("Function"),width:"200px",disclosure:true,sortable:true},{id:"count",title:WebInspector.UIString("Count"),sortable:true,sort:WebInspector.DataGrid.Order.Descending},{id:"size",title:WebInspector.UIString("Size"),sortable:true,sort:WebInspector.DataGrid.Order.Descending},];WebInspector.DataGrid.call(this,columns);}
+WebInspector.AllocationDataGrid.prototype={setDataSource:function(snapshot)
+{this._snapshot=snapshot;this._snapshot.allocationTracesTops(didReceiveAllocationTracesTops.bind(this));function didReceiveAllocationTracesTops(tops)
+{var root=this.rootNode();for(var i=0;i<tops.length;i++)
+root.appendChild(new WebInspector.AllocationGridNode(this,tops[i]));}},__proto__:WebInspector.DataGrid.prototype}
+WebInspector.AllocationGridNode=function(dataGrid,data)
+{WebInspector.DataGridNode.call(this,data,data.hasChildren);this._dataGrid=dataGrid;}
+WebInspector.AllocationGridNode.prototype={populate:function()
+{this._dataGrid._snapshot.allocationNodeCallers(this.data.id,didReceiveCallers.bind(this));function didReceiveCallers(callers)
+{for(var i=0;i<callers.length;i++)
+this.appendChild(new WebInspector.AllocationGridNode(this._dataGrid,callers[i]));}},__proto__:WebInspector.DataGridNode.prototype};WebInspector.HeapSnapshotGridNode=function(tree,hasChildren)
{WebInspector.DataGridNode.call(this,null,hasChildren);this._dataGrid=tree;this._instanceCount=0;this._savedChildren=null;this._retrievedChildrenRanges=[];}
WebInspector.HeapSnapshotGridNode.Events={PopulateComplete:"PopulateComplete"}
WebInspector.HeapSnapshotGridNode.prototype={createProvider:function()
@@ -1076,7 +1155,7 @@
var idSpan=document.createElement("span");idSpan.className="console-formatted-id";idSpan.textContent=" @"+data["nodeId"];div.appendChild(idSpan);if(this._postfixObjectCell)
this._postfixObjectCell(div,data);cell.appendChild(div);cell.addStyleClass("disclosure");if(this.depth)
cell.style.setProperty("padding-left",(this.depth*this.dataGrid.indentWidth)+"px");cell.heapSnapshotNode=this;return cell;},get data()
-{var data=this._emptyData();var value=this._name;var valueStyle="object";switch(this._type){case"string":value="\""+value+"\"";valueStyle="string";break;case"regexp":value="/"+value+"/";valueStyle="string";break;case"closure":value="function"+(value?" ":"")+value+"()";valueStyle="function";break;case"number":valueStyle="number";break;case"hidden":valueStyle="null";break;case"array":if(!value)
+{var data=this._emptyData();var value=this._name;var valueStyle="object";switch(this._type){case"concatenated string":case"string":value="\""+value+"\"";valueStyle="string";break;case"regexp":value="/"+value+"/";valueStyle="string";break;case"closure":value="function"+(value?" ":"")+value+"()";valueStyle="function";break;case"number":valueStyle="number";break;case"hidden":valueStyle="null";break;case"array":if(!value)
value="[]";else
value+="[]";break;};if(this._reachableFromWindow)
valueStyle+=" highlight";if(value==="Object")
@@ -1143,7 +1222,7 @@
{var cell=columnIdentifier!=="object"?this._createValueCell(columnIdentifier):WebInspector.HeapSnapshotGridNode.prototype.createCell.call(this,columnIdentifier);if(this._searchMatched)
cell.addStyleClass("highlight");return cell;},_createChildNode:function(item)
{return new WebInspector.HeapSnapshotInstanceNode(this._dataGrid,null,this._dataGrid.snapshot,item);},comparator:function()
-{var sortAscending=this._dataGrid.isSortOrderAscending();var sortColumnIdentifier=this._dataGrid.sortColumnIdentifier();var sortFields={object:["id",sortAscending,"retainedSize",false],distance:["distance",true,"retainedSize",false],count:["id",true,"retainedSize",false],shallowSize:["selfSize",sortAscending,"id",true],retainedSize:["retainedSize",sortAscending,"id",true]}[sortColumnIdentifier];return WebInspector.HeapSnapshotFilteredOrderedIterator.prototype.createComparator(sortFields);},_childHashForEntity:function(node)
+{var sortAscending=this._dataGrid.isSortOrderAscending();var sortColumnIdentifier=this._dataGrid.sortColumnIdentifier();var sortFields={object:["id",sortAscending,"retainedSize",false],distance:["distance",sortAscending,"retainedSize",false],count:["id",true,"retainedSize",false],shallowSize:["selfSize",sortAscending,"id",true],retainedSize:["retainedSize",sortAscending,"id",true]}[sortColumnIdentifier];return WebInspector.HeapSnapshotFilteredOrderedIterator.prototype.createComparator(sortFields);},_childHashForEntity:function(node)
{return node.id;},_childHashForNode:function(childNode)
{return childNode.snapshotNodeId;},get data()
{var data={object:this._name};data["count"]=Number.withThousandsSeparator(this._count);data["distance"]=this._distance;data["shallowSize"]=Number.withThousandsSeparator(this._shallowSize);data["retainedSize"]=Number.withThousandsSeparator(this._retainedSize);data["count-percent"]=this._toPercentString(this._countPercent);data["shallowSize-percent"]=this._toPercentString(this._shallowSizePercent);data["retainedSize-percent"]=this._toPercentString(this._retainedSizePercent);return data;},get _countPercent()
@@ -1200,14 +1279,14 @@
{return node.id;},_childHashForNode:function(childNode)
{return childNode.snapshotNodeId;},comparator:function()
{var sortAscending=this._dataGrid.isSortOrderAscending();var sortColumnIdentifier=this._dataGrid.sortColumnIdentifier();var sortFields={object:["id",sortAscending,"retainedSize",false],shallowSize:["selfSize",sortAscending,"id",true],retainedSize:["retainedSize",sortAscending,"id",true]}[sortColumnIdentifier];return WebInspector.HeapSnapshotFilteredOrderedIterator.prototype.createComparator(sortFields);},_emptyData:function()
-{return{};},__proto__:WebInspector.HeapSnapshotGenericObjectNode.prototype};WebInspector.HeapSnapshotLoader=function()
-{this._reset();}
+{return{};},__proto__:WebInspector.HeapSnapshotGenericObjectNode.prototype};WebInspector.HeapSnapshotLoader=function(dispatcher)
+{this._reset();this._progress=new WebInspector.HeapSnapshotProgress(dispatcher);}
WebInspector.HeapSnapshotLoader.prototype={dispose:function()
{this._reset();},_reset:function()
{this._json="";this._state="find-snapshot-info";this._snapshot={};},close:function()
{if(this._json)
this._parseStringsArray();},buildSnapshot:function(constructorName)
-{var constructor=WebInspector[constructorName];var result=new constructor(this._snapshot);this._reset();return result;},_parseUintArray:function()
+{this._progress.updateStatus("Processing snapshot\u2026");var constructor=WebInspector[constructorName];var result=new constructor(this._snapshot,this._progress);this._reset();return result;},_parseUintArray:function()
{var index=0;var char0="0".charCodeAt(0),char9="9".charCodeAt(0),closingBracket="]".charCodeAt(0);var length=this._json.length;while(true){while(index<length){var code=this._json.charCodeAt(index);if(char0<=code&&code<=char9)
break;else if(code===closingBracket){this._json=this._json.slice(index+1);return false;}
++index;}
@@ -1216,26 +1295,38 @@
break;nextNumber*=10;nextNumber+=(code-char0);++index;}
if(index===length){this._json=this._json.slice(startIndex);return true;}
this._array[this._arrayIndex++]=nextNumber;}},_parseStringsArray:function()
-{var closingBracketIndex=this._json.lastIndexOf("]");if(closingBracketIndex===-1)
+{this._progress.updateStatus("Parsing strings\u2026");var closingBracketIndex=this._json.lastIndexOf("]");if(closingBracketIndex===-1)
throw new Error("Incomplete JSON");this._json=this._json.slice(0,closingBracketIndex+1);this._snapshot.strings=JSON.parse(this._json);},write:function(chunk)
-{this._json+=chunk;switch(this._state){case"find-snapshot-info":{var snapshotToken="\"snapshot\"";var snapshotTokenIndex=this._json.indexOf(snapshotToken);if(snapshotTokenIndex===-1)
-throw new Error("Snapshot token not found");this._json=this._json.slice(snapshotTokenIndex+snapshotToken.length+1);this._state="parse-snapshot-info";}
+{this._json+=chunk;while(true){switch(this._state){case"find-snapshot-info":{var snapshotToken="\"snapshot\"";var snapshotTokenIndex=this._json.indexOf(snapshotToken);if(snapshotTokenIndex===-1)
+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;}
case"parse-snapshot-info":{var closingBracketIndex=WebInspector.findBalancedCurlyBrackets(this._json);if(closingBracketIndex===-1)
-return;this._snapshot.snapshot=(JSON.parse(this._json.slice(0,closingBracketIndex)));this._json=this._json.slice(closingBracketIndex);this._state="find-nodes";}
+return;this._snapshot.snapshot=(JSON.parse(this._json.slice(0,closingBracketIndex)));this._json=this._json.slice(closingBracketIndex);this._state="find-nodes";break;}
case"find-nodes":{var nodesToken="\"nodes\"";var nodesTokenIndex=this._json.indexOf(nodesToken);if(nodesTokenIndex===-1)
return;var bracketIndex=this._json.indexOf("[",nodesTokenIndex);if(bracketIndex===-1)
-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";}
-case"parse-nodes":{if(this._parseUintArray())
-return;this._snapshot.nodes=this._array;this._state="find-edges";this._array=null;}
+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;}
+case"parse-nodes":{var hasMoreData=this._parseUintArray();this._progress.updateProgress("Loading nodes\u2026 %d\%",this._arrayIndex,this._array.length);if(hasMoreData)
+return;this._snapshot.nodes=this._array;this._state="find-edges";this._array=null;break;}
case"find-edges":{var edgesToken="\"edges\"";var edgesTokenIndex=this._json.indexOf(edgesToken);if(edgesTokenIndex===-1)
return;var bracketIndex=this._json.indexOf("[",edgesTokenIndex);if(bracketIndex===-1)
-return;this._json=this._json.slice(bracketIndex+1);var edge_fields_count=this._snapshot.snapshot.meta.edge_fields.length;var edges_length=this._snapshot.snapshot.edge_count*edge_fields_count;this._array=new Uint32Array(edges_length);this._arrayIndex=0;this._state="parse-edges";}
-case"parse-edges":{if(this._parseUintArray())
-return;this._snapshot.edges=this._array;this._array=null;this._state="find-strings";}
+return;this._json=this._json.slice(bracketIndex+1);var edge_fields_count=this._snapshot.snapshot.meta.edge_fields.length;var edges_length=this._snapshot.snapshot.edge_count*edge_fields_count;this._array=new Uint32Array(edges_length);this._arrayIndex=0;this._state="parse-edges";break;}
+case"parse-edges":{var hasMoreData=this._parseUintArray();this._progress.updateProgress("Loading edges\u2026 %d\%",this._arrayIndex,this._array.length);if(hasMoreData)
+return;this._snapshot.edges=this._array;this._array=null;if(WebInspector.HeapSnapshot.enableAllocationProfiler)
+this._state="find-trace-function-infos";else
+this._state="find-strings";break;}
+case"find-trace-function-infos":{var tracesToken="\"trace_function_infos\"";var tracesTokenIndex=this._json.indexOf(tracesToken);if(tracesTokenIndex===-1)
+return;var bracketIndex=this._json.indexOf("[",tracesTokenIndex);if(bracketIndex===-1)
+return;this._json=this._json.slice(bracketIndex+1);var trace_function_info_field_count=3;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;}
+case"parse-trace-function-infos":{if(this._parseUintArray())
+return;this._snapshot.trace_function_infos=this._array;this._array=null;this._state="find-trace-tree";break;}
+case"find-trace-tree":{var tracesToken="\"trace_tree\"";var tracesTokenIndex=this._json.indexOf(tracesToken);if(tracesTokenIndex===-1)
+return;var bracketIndex=this._json.indexOf("[",tracesTokenIndex);if(bracketIndex===-1)
+return;this._json=this._json.slice(bracketIndex);this._state="parse-trace-tree";break;}
+case"parse-trace-tree":{var stringsToken="\"strings\"";var stringsTokenIndex=this._json.indexOf(stringsToken);if(stringsTokenIndex===-1)
+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;}
case"find-strings":{var stringsToken="\"strings\"";var stringsTokenIndex=this._json.indexOf(stringsToken);if(stringsTokenIndex===-1)
return;var bracketIndex=this._json.indexOf("[",stringsTokenIndex);if(bracketIndex===-1)
return;this._json=this._json.slice(bracketIndex);this._state="accumulate-strings";break;}
-case"accumulate-strings":break;}}};;WebInspector.HeapSnapshotWorkerWrapper=function()
+case"accumulate-strings":return;}}}};;WebInspector.HeapSnapshotWorkerWrapper=function()
{}
WebInspector.HeapSnapshotWorkerWrapper.prototype={postMessage:function(message)
{},terminate:function()
@@ -1243,10 +1334,7 @@
WebInspector.HeapSnapshotRealWorker=function()
{this._worker=new Worker("HeapSnapshotWorker.js");this._worker.addEventListener("message",this._messageReceived.bind(this),false);}
WebInspector.HeapSnapshotRealWorker.prototype={_messageReceived:function(event)
-{var message=event.data;if("callId"in message)
-this.dispatchEventToListeners("message",message);else{if(message.object!=="console"){console.log(WebInspector.UIString("Worker asks to call a method '%s' on an unsupported object '%s'.",message.method,message.object));return;}
-if(message.method!=="log"&&message.method!=="info"&&message.method!=="error"){console.log(WebInspector.UIString("Worker asks to call an unsupported method '%s' on the console object.",message.method));return;}
-console[message.method].apply(window[message.object],message.arguments);}},postMessage:function(message)
+{var message=event.data;this.dispatchEventToListeners("message",message);},postMessage:function(message)
{this._worker.postMessage(message);},terminate:function()
{this._worker.terminate();},__proto__:WebInspector.HeapSnapshotWorkerWrapper.prototype}
WebInspector.AsyncTaskQueue=function()
@@ -1267,9 +1355,9 @@
{function send()
{this.dispatchEventToListeners("message",message);}
this._asyncTaskQueue.addTask(send.bind(this));},__proto__:WebInspector.HeapSnapshotWorkerWrapper.prototype}
-WebInspector.HeapSnapshotWorker=function()
-{this._nextObjectId=1;this._nextCallId=1;this._callbacks=[];this._previousCallbacks=[];this._worker=typeof InspectorTest==="undefined"?new WebInspector.HeapSnapshotRealWorker():new WebInspector.HeapSnapshotFakeWorker();this._worker.addEventListener("message",this._messageReceived,this);}
-WebInspector.HeapSnapshotWorker.prototype={createLoader:function(snapshotConstructorName,proxyConstructor)
+WebInspector.HeapSnapshotWorkerProxy=function(eventHandler)
+{this._eventHandler=eventHandler;this._nextObjectId=1;this._nextCallId=1;this._callbacks=[];this._previousCallbacks=[];this._worker=typeof InspectorTest==="undefined"?new WebInspector.HeapSnapshotRealWorker():new WebInspector.HeapSnapshotFakeWorker();this._worker.addEventListener("message",this._messageReceived,this);}
+WebInspector.HeapSnapshotWorkerProxy.prototype={createLoader:function(snapshotConstructorName,proxyConstructor)
{var objectId=this._nextObjectId++;var proxy=new WebInspector.HeapSnapshotLoaderProxy(this,objectId,snapshotConstructorName,proxyConstructor);this._postMessage({callId:this._nextCallId++,disposition:"create",objectId:objectId,methodName:"WebInspector.HeapSnapshotLoader"});return proxy;},dispose:function()
{this._worker.terminate();if(this._interval)
clearInterval(this._interval);},disposeObject:function(objectId)
@@ -1289,8 +1377,10 @@
this._previousCallbacks[callId]=true;},_findFunction:function(name)
{var path=name.split(".");var result=window;for(var i=0;i<path.length;++i)
result=result[path[i]];return result;},_messageReceived:function(event)
-{var data=event.data;if(event.data.error){if(event.data.errorMethodName)
-WebInspector.log(WebInspector.UIString("An error happened when a call for method '%s' was requested",event.data.errorMethodName));WebInspector.log(event.data.errorCallStack);delete this._callbacks[data.callId];return;}
+{var data=event.data;if(data.eventName){if(this._eventHandler)
+this._eventHandler(data.eventName,data.data);return;}
+if(data.error){if(data.errorMethodName)
+WebInspector.log(WebInspector.UIString("An error happened when a call for method '%s' was requested",data.errorMethodName));WebInspector.log(data.errorCallStack);delete this._callbacks[data.callId];return;}
if(!this._callbacks[data.callId])
return;var callback=this._callbacks[data.callId];delete this._callbacks[data.callId];callback(data.result);},_postMessage:function(message)
{this._worker.postMessage(message);},__proto__:WebInspector.Object.prototype}
@@ -1306,9 +1396,10 @@
{WebInspector.HeapSnapshotProxyObject.call(this,worker,objectId);this._snapshotConstructorName=snapshotConstructorName;this._proxyConstructor=proxyConstructor;this._pendingSnapshotConsumers=[];}
WebInspector.HeapSnapshotLoaderProxy.prototype={addConsumer:function(callback)
{this._pendingSnapshotConsumers.push(callback);},write:function(chunk,callback)
-{this.callMethod(callback,"write",chunk);},close:function()
+{this.callMethod(callback,"write",chunk);},close:function(callback)
{function buildSnapshot()
-{this.callFactoryMethod(updateStaticData.bind(this),"buildSnapshot",this._proxyConstructor,this._snapshotConstructorName);}
+{if(callback)
+callback();this.callFactoryMethod(updateStaticData.bind(this),"buildSnapshot",this._proxyConstructor,this._snapshotConstructorName);}
function updateStaticData(snapshotProxy)
{this.dispose();snapshotProxy.updateStaticData(notifyPendingConsumers.bind(this));}
function notifyPendingConsumers(snapshotProxy)
@@ -1329,7 +1420,9 @@
{return this.callFactoryMethod(null,"createDeletedNodesProvider",WebInspector.HeapSnapshotProviderProxy,nodeIndexes);},createNodesProvider:function(filter)
{return this.callFactoryMethod(null,"createNodesProvider",WebInspector.HeapSnapshotProviderProxy,filter);},createNodesProviderForClass:function(className,aggregatesKey)
{return this.callFactoryMethod(null,"createNodesProviderForClass",WebInspector.HeapSnapshotProviderProxy,className,aggregatesKey);},createNodesProviderForDominator:function(nodeIndex)
-{return this.callFactoryMethod(null,"createNodesProviderForDominator",WebInspector.HeapSnapshotProviderProxy,nodeIndex);},dispose:function()
+{return this.callFactoryMethod(null,"createNodesProviderForDominator",WebInspector.HeapSnapshotProviderProxy,nodeIndex);},allocationTracesTops:function(callback)
+{this.callMethod(callback,"allocationTracesTops");},allocationNodeCallers:function(nodeId,callback)
+{this.callMethod(callback,"allocationNodeCallers",nodeId);},dispose:function()
{this.disposeWorker();},get nodeCount()
{return this._staticData.nodeCount;},get rootNodeIndex()
{return this._staticData.rootNodeIndex;},updateStaticData:function(callback)
@@ -1338,10 +1431,6 @@
this.callMethod(dataReceived.bind(this),"updateStaticData");},get totalSize()
{return this._staticData.totalSize;},get uid()
{return this._staticData.uid;},__proto__:WebInspector.HeapSnapshotProxyObject.prototype}
-WebInspector.NativeHeapSnapshotProxy=function(worker,objectId)
-{WebInspector.HeapSnapshotProxy.call(this,worker,objectId);}
-WebInspector.NativeHeapSnapshotProxy.prototype={images:function(callback)
-{this.callMethod(callback,"images");},__proto__:WebInspector.HeapSnapshotProxy.prototype}
WebInspector.HeapSnapshotProviderProxy=function(worker,objectId)
{WebInspector.HeapSnapshotProxyObject.call(this,worker,objectId);}
WebInspector.HeapSnapshotProviderProxy.prototype={nodePosition:function(snapshotObjectId,callback)
@@ -1350,9 +1439,11 @@
{this.callMethod(callback,"serializeItemsRange",startPosition,endPosition);},sortAndRewind:function(comparator,callback)
{this.callMethod(callback,"sortAndRewind",comparator);},__proto__:WebInspector.HeapSnapshotProxyObject.prototype};WebInspector.HeapSnapshotView=function(parent,profile)
{WebInspector.View.call(this);this.element.addStyleClass("heap-snapshot-view");this.parent=parent;this.parent.addEventListener("profile added",this._onProfileHeaderAdded,this);if(profile._profileType.id===WebInspector.TrackingHeapSnapshotProfileType.TypeId){this._trackingOverviewGrid=new WebInspector.HeapTrackingOverviewGrid(profile);this._trackingOverviewGrid.addEventListener(WebInspector.HeapTrackingOverviewGrid.IdsRangeChanged,this._onIdsRangeChanged.bind(this));this._trackingOverviewGrid.show(this.element);}
-this.viewsContainer=document.createElement("div");this.viewsContainer.addStyleClass("views-container");this.element.appendChild(this.viewsContainer);this.containmentView=new WebInspector.View();this.containmentView.element.addStyleClass("view");this.containmentDataGrid=new WebInspector.HeapSnapshotContainmentDataGrid();this.containmentDataGrid.element.addEventListener("mousedown",this._mouseDownInContentsGrid.bind(this),true);this.containmentDataGrid.show(this.containmentView.element);this.containmentDataGrid.addEventListener(WebInspector.DataGrid.Events.SelectedNode,this._selectionChanged,this);this.constructorsView=new WebInspector.View();this.constructorsView.element.addStyleClass("view");this.constructorsView.element.appendChild(this._createToolbarWithClassNameFilter());this.constructorsDataGrid=new WebInspector.HeapSnapshotConstructorsDataGrid();this.constructorsDataGrid.element.addStyleClass("class-view-grid");this.constructorsDataGrid.element.addEventListener("mousedown",this._mouseDownInContentsGrid.bind(this),true);this.constructorsDataGrid.show(this.constructorsView.element);this.constructorsDataGrid.addEventListener(WebInspector.DataGrid.Events.SelectedNode,this._selectionChanged,this);this.dataGrid=(this.constructorsDataGrid);this.currentView=this.constructorsView;this.currentView.show(this.viewsContainer);this.diffView=new WebInspector.View();this.diffView.element.addStyleClass("view");this.diffView.element.appendChild(this._createToolbarWithClassNameFilter());this.diffDataGrid=new WebInspector.HeapSnapshotDiffDataGrid();this.diffDataGrid.element.addStyleClass("class-view-grid");this.diffDataGrid.show(this.diffView.element);this.diffDataGrid.addEventListener(WebInspector.DataGrid.Events.SelectedNode,this._selectionChanged,this);this.dominatorView=new WebInspector.View();this.dominatorView.element.addStyleClass("view");this.dominatorDataGrid=new WebInspector.HeapSnapshotDominatorsDataGrid();this.dominatorDataGrid.element.addEventListener("mousedown",this._mouseDownInContentsGrid.bind(this),true);this.dominatorDataGrid.show(this.dominatorView.element);this.dominatorDataGrid.addEventListener(WebInspector.DataGrid.Events.SelectedNode,this._selectionChanged,this);this.retainmentViewHeader=document.createElement("div");this.retainmentViewHeader.addStyleClass("retainers-view-header");WebInspector.installDragHandle(this.retainmentViewHeader,this._startRetainersHeaderDragging.bind(this),this._retainersHeaderDragging.bind(this),this._endRetainersHeaderDragging.bind(this),"row-resize");var retainingPathsTitleDiv=document.createElement("div");retainingPathsTitleDiv.className="title";var retainingPathsTitle=document.createElement("span");retainingPathsTitle.textContent=WebInspector.UIString("Object's retaining tree");retainingPathsTitleDiv.appendChild(retainingPathsTitle);this.retainmentViewHeader.appendChild(retainingPathsTitleDiv);this.element.appendChild(this.retainmentViewHeader);this.retainmentView=new WebInspector.View();this.retainmentView.element.addStyleClass("view");this.retainmentView.element.addStyleClass("retaining-paths-view");this.retainmentDataGrid=new WebInspector.HeapSnapshotRetainmentDataGrid();this.retainmentDataGrid.show(this.retainmentView.element);this.retainmentDataGrid.addEventListener(WebInspector.DataGrid.Events.SelectedNode,this._inspectedObjectChanged,this);this.retainmentView.show(this.element);this.retainmentDataGrid.reset();this.viewSelect=new WebInspector.StatusBarComboBox(this._onSelectedViewChanged.bind(this));this.views=[{title:"Summary",view:this.constructorsView,grid:this.constructorsDataGrid},{title:"Comparison",view:this.diffView,grid:this.diffDataGrid},{title:"Containment",view:this.containmentView,grid:this.containmentDataGrid}];if(WebInspector.settings.showAdvancedHeapSnapshotProperties.get())
-this.views.push({title:"Dominators",view:this.dominatorView,grid:this.dominatorDataGrid});this.views.current=0;for(var i=0;i<this.views.length;++i)
-this.viewSelect.createOption(WebInspector.UIString(this.views[i].title));this._profileUid=profile.uid;this._profileTypeId=profile.profileType().id;this.baseSelect=new WebInspector.StatusBarComboBox(this._changeBase.bind(this));this.baseSelect.element.addStyleClass("hidden");this._updateBaseOptions();this.filterSelect=new WebInspector.StatusBarComboBox(this._changeFilter.bind(this));this._updateFilterOptions();this.helpButton=new WebInspector.StatusBarButton("","heap-snapshot-help-status-bar-item status-bar-item");this.helpButton.addEventListener("click",this._helpClicked,this);this.selectedSizeText=new WebInspector.StatusBarText("");this._popoverHelper=new WebInspector.ObjectPopoverHelper(this.element,this._getHoverAnchor.bind(this),this._resolveObjectForPopover.bind(this),undefined,true);this.profile.load(profileCallback.bind(this));function profileCallback(heapSnapshotProxy)
+this.viewsContainer=document.createElement("div");this.viewsContainer.addStyleClass("views-container");this.element.appendChild(this.viewsContainer);this.containmentView=new WebInspector.View();this.containmentView.element.addStyleClass("view");this.containmentDataGrid=new WebInspector.HeapSnapshotContainmentDataGrid();this.containmentDataGrid.element.addEventListener("mousedown",this._mouseDownInContentsGrid.bind(this),true);this.containmentDataGrid.show(this.containmentView.element);this.containmentDataGrid.addEventListener(WebInspector.DataGrid.Events.SelectedNode,this._selectionChanged,this);this.constructorsView=new WebInspector.View();this.constructorsView.element.addStyleClass("view");this.constructorsView.element.appendChild(this._createToolbarWithClassNameFilter());this.constructorsDataGrid=new WebInspector.HeapSnapshotConstructorsDataGrid();this.constructorsDataGrid.element.addStyleClass("class-view-grid");this.constructorsDataGrid.element.addEventListener("mousedown",this._mouseDownInContentsGrid.bind(this),true);this.constructorsDataGrid.show(this.constructorsView.element);this.constructorsDataGrid.addEventListener(WebInspector.DataGrid.Events.SelectedNode,this._selectionChanged,this);this.dataGrid=(this.constructorsDataGrid);this.currentView=this.constructorsView;this.currentView.show(this.viewsContainer);this.diffView=new WebInspector.View();this.diffView.element.addStyleClass("view");this.diffView.element.appendChild(this._createToolbarWithClassNameFilter());this.diffDataGrid=new WebInspector.HeapSnapshotDiffDataGrid();this.diffDataGrid.element.addStyleClass("class-view-grid");this.diffDataGrid.show(this.diffView.element);this.diffDataGrid.addEventListener(WebInspector.DataGrid.Events.SelectedNode,this._selectionChanged,this);this.dominatorView=new WebInspector.View();this.dominatorView.element.addStyleClass("view");this.dominatorDataGrid=new WebInspector.HeapSnapshotDominatorsDataGrid();this.dominatorDataGrid.element.addEventListener("mousedown",this._mouseDownInContentsGrid.bind(this),true);this.dominatorDataGrid.show(this.dominatorView.element);this.dominatorDataGrid.addEventListener(WebInspector.DataGrid.Events.SelectedNode,this._selectionChanged,this);if(WebInspector.HeapSnapshot.enableAllocationProfiler){this.allocationView=new WebInspector.View();this.allocationView.element.addStyleClass("view");this.allocationDataGrid=new WebInspector.AllocationDataGrid();this.allocationDataGrid.element.addEventListener("mousedown",this._mouseDownInContentsGrid.bind(this),true);this.allocationDataGrid.show(this.allocationView.element);this.allocationDataGrid.addEventListener(WebInspector.DataGrid.Events.SelectedNode,this._selectionChanged,this);}
+this.retainmentViewHeader=document.createElement("div");this.retainmentViewHeader.addStyleClass("retainers-view-header");WebInspector.installDragHandle(this.retainmentViewHeader,this._startRetainersHeaderDragging.bind(this),this._retainersHeaderDragging.bind(this),this._endRetainersHeaderDragging.bind(this),"row-resize");var retainingPathsTitleDiv=document.createElement("div");retainingPathsTitleDiv.className="title";var retainingPathsTitle=document.createElement("span");retainingPathsTitle.textContent=WebInspector.UIString("Object's retaining tree");retainingPathsTitleDiv.appendChild(retainingPathsTitle);this.retainmentViewHeader.appendChild(retainingPathsTitleDiv);this.element.appendChild(this.retainmentViewHeader);this.retainmentView=new WebInspector.View();this.retainmentView.element.addStyleClass("view");this.retainmentView.element.addStyleClass("retaining-paths-view");this.retainmentDataGrid=new WebInspector.HeapSnapshotRetainmentDataGrid();this.retainmentDataGrid.show(this.retainmentView.element);this.retainmentDataGrid.addEventListener(WebInspector.DataGrid.Events.SelectedNode,this._inspectedObjectChanged,this);this.retainmentView.show(this.element);this.retainmentDataGrid.reset();this.viewSelect=new WebInspector.StatusBarComboBox(this._onSelectedViewChanged.bind(this));this.views=[{title:"Summary",view:this.constructorsView,grid:this.constructorsDataGrid},{title:"Comparison",view:this.diffView,grid:this.diffDataGrid},{title:"Containment",view:this.containmentView,grid:this.containmentDataGrid}];if(WebInspector.settings.showAdvancedHeapSnapshotProperties.get())
+this.views.push({title:"Dominators",view:this.dominatorView,grid:this.dominatorDataGrid});if(WebInspector.HeapSnapshot.enableAllocationProfiler)
+this.views.push({title:"Allocation",view:this.allocationView,grid:this.allocationDataGrid});this.views.current=0;for(var i=0;i<this.views.length;++i)
+this.viewSelect.createOption(WebInspector.UIString(this.views[i].title));this._profileUid=profile.uid;this._profileTypeId=profile.profileType().id;this.baseSelect=new WebInspector.StatusBarComboBox(this._changeBase.bind(this));this.baseSelect.element.addStyleClass("hidden");this._updateBaseOptions();this.filterSelect=new WebInspector.StatusBarComboBox(this._changeFilter.bind(this));this._updateFilterOptions();this.selectedSizeText=new WebInspector.StatusBarText("");this._popoverHelper=new WebInspector.ObjectPopoverHelper(this.element,this._getHoverAnchor.bind(this),this._resolveObjectForPopover.bind(this),undefined,true);this.profile.load(profileCallback.bind(this));function profileCallback(heapSnapshotProxy)
{var list=this._profiles();var profileIndex;for(var i=0;i<list.length;++i){if(list[i].uid===this._profileUid){profileIndex=i;break;}}
if(profileIndex>0)
this.baseSelect.setSelectedIndex(profileIndex-1);else
@@ -1362,7 +1453,7 @@
this.constructorsDataGrid.setSelectionRange(minId,maxId);},dispose:function()
{this.parent.removeEventListener("profile added",this._onProfileHeaderAdded,this);this.profile.dispose();if(this.baseProfile)
this.baseProfile.dispose();this.containmentDataGrid.dispose();this.constructorsDataGrid.dispose();this.diffDataGrid.dispose();this.dominatorDataGrid.dispose();this.retainmentDataGrid.dispose();},get statusBarItems()
-{return[this.viewSelect.element,this.baseSelect.element,this.filterSelect.element,this.helpButton.element,this.selectedSizeText.element];},get profile()
+{return[this.viewSelect.element,this.baseSelect.element,this.filterSelect.element,this.selectedSizeText.element];},get profile()
{return this.parent.getProfile(this._profileTypeId,this._profileUid);},get baseProfile()
{return this.parent.getProfile(this._profileTypeId,this._baseProfileUid);},wasShown:function()
{this.profile.load(profileCallback.bind(this));function profileCallback(){this.profile._wasShown();if(this.baseProfile)
@@ -1445,16 +1536,7 @@
return;var row=target.enclosingNodeOrSelfWithNodeName("tr");if(!row)
return;span.node=row._dataGridNode;return span;},_resolveObjectForPopover:function(element,showCallback,objectGroupName)
{if(this.profile.fromFile())
-return;element.node.queryObjectContent(showCallback,objectGroupName);},_helpClicked:function(event)
-{if(!this._helpPopoverContentElement){var refTypes=["a:","console-formatted-name",WebInspector.UIString("property"),"0:","console-formatted-name",WebInspector.UIString("element"),"a:","console-formatted-number",WebInspector.UIString("context var"),"a:","console-formatted-null",WebInspector.UIString("system prop")];var objTypes=[" a ","console-formatted-object","Object","\"a\"","console-formatted-string","String","/a/","console-formatted-string","RegExp","a()","console-formatted-function","Function","a[]","console-formatted-object","Array","num","console-formatted-number","Number"," a ","console-formatted-null","System"];var contentElement=document.createElement("table");contentElement.className="heap-snapshot-help";var headerRow=document.createElement("tr");var propsHeader=document.createElement("th");propsHeader.textContent=WebInspector.UIString("Property types:");headerRow.appendChild(propsHeader);var objsHeader=document.createElement("th");objsHeader.textContent=WebInspector.UIString("Object types:");headerRow.appendChild(objsHeader);contentElement.appendChild(headerRow);function appendHelp(help,index,cell)
-{var div=document.createElement("div");div.className="source-code event-properties";var name=document.createElement("span");name.textContent=help[index];name.className=help[index+1];div.appendChild(name);var desc=document.createElement("span");desc.textContent=" "+help[index+2];div.appendChild(desc);cell.appendChild(div);}
-var len=Math.max(refTypes.length,objTypes.length);for(var i=0;i<len;i+=3){var row=document.createElement("tr");var refCell=document.createElement("td");if(refTypes[i])
-appendHelp(refTypes,i,refCell);row.appendChild(refCell);var objCell=document.createElement("td");if(objTypes[i])
-appendHelp(objTypes,i,objCell);row.appendChild(objCell);contentElement.appendChild(row);}
-this._helpPopoverContentElement=contentElement;this.helpPopover=new WebInspector.Popover();}
-if(this.helpPopover.isShowing())
-this.helpPopover.hide();else
-this.helpPopover.show(this._helpPopoverContentElement,this.helpButton.element);},_startRetainersHeaderDragging:function(event)
+return;element.node.queryObjectContent(showCallback,objectGroupName);},_startRetainersHeaderDragging:function(event)
{if(!this.isShowing())
return false;this._previousDragPosition=event.pageY;return true;},_retainersHeaderDragging:function(event)
{var height=this.retainmentView.element.clientHeight;height+=this._previousDragPosition-event.pageY;this._previousDragPosition=event.pageY;this._updateRetainmentViewHeight(height);event.consume(true);},_endRetainersHeaderDragging:function(event)
@@ -1542,49 +1624,62 @@
{title=title||WebInspector.UIString("Recording\u2026");return new WebInspector.HeapProfileHeader(this,title);},_requestProfilesFromBackend:function(populateCallback)
{},__proto__:WebInspector.HeapSnapshotProfileType.prototype}
WebInspector.HeapProfileHeader=function(type,title,uid,maxJSObjectId)
-{WebInspector.ProfileHeader.call(this,type,title,uid);this.maxJSObjectId=maxJSObjectId;this._receiver=null;this._snapshotProxy=null;this._totalNumberOfChunks=0;}
+{WebInspector.ProfileHeader.call(this,type,title,uid);this.maxJSObjectId=maxJSObjectId;this._receiver=null;this._snapshotProxy=null;this._totalNumberOfChunks=0;this._transferHandler=null;}
WebInspector.HeapProfileHeader.prototype={createSidebarTreeElement:function()
{return new WebInspector.ProfileSidebarTreeElement(this,WebInspector.UIString("Snapshot %d"),"heap-snapshot-sidebar-tree-item");},createView:function(profilesPanel)
{return new WebInspector.HeapSnapshotView(profilesPanel,this);},load:function(callback)
{if(this.uid===-1)
return;if(this._snapshotProxy){callback(this._snapshotProxy);return;}
-this._numberOfChunks=0;this._savedChunks=0;this._savingToFile=false;if(!this._receiver){this._setupWorker();this.sidebarElement.subtitle=WebInspector.UIString("Loading\u2026");this.sidebarElement.wait=true;this.startSnapshotTransfer();}
+this._numberOfChunks=0;if(!this._receiver){this._setupWorker();this._transferHandler=new WebInspector.BackendSnapshotLoader(this);this.sidebarElement.subtitle=WebInspector.UIString("Loading\u2026");this.sidebarElement.wait=true;this.startSnapshotTransfer();}
var loaderProxy=(this._receiver);loaderProxy.addConsumer(callback);},startSnapshotTransfer:function()
{HeapProfilerAgent.getHeapSnapshot(this.uid);},snapshotConstructorName:function()
{return"JSHeapSnapshot";},snapshotProxyConstructor:function()
{return WebInspector.HeapSnapshotProxy;},_setupWorker:function()
{function setProfileWait(event)
{this.sidebarElement.wait=event.data;}
-var worker=new WebInspector.HeapSnapshotWorker();worker.addEventListener("wait",setProfileWait,this);var loaderProxy=worker.createLoader(this.snapshotConstructorName(),this.snapshotProxyConstructor());loaderProxy.addConsumer(this._snapshotReceived.bind(this));this._receiver=loaderProxy;},dispose:function()
+var worker=new WebInspector.HeapSnapshotWorkerProxy(this._handleWorkerEvent.bind(this));worker.addEventListener("wait",setProfileWait,this);var loaderProxy=worker.createLoader(this.snapshotConstructorName(),this.snapshotProxyConstructor());loaderProxy.addConsumer(this._snapshotReceived.bind(this));this._receiver=loaderProxy;},_handleWorkerEvent:function(eventName,data)
+{if(WebInspector.HeapSnapshotProgress.Event.Update!==eventName)
+return;this._updateSubtitle(data);},dispose:function()
{if(this._receiver)
this._receiver.close();else if(this._snapshotProxy)
-this._snapshotProxy.dispose();if(this._view){var view=this._view;this._view=null;view.dispose();}},_updateTransferProgress:function(value,maxValue)
-{var percentValue=((maxValue?(value/maxValue):0)*100).toFixed(0);if(this._savingToFile)
-this.sidebarElement.subtitle=WebInspector.UIString("Saving\u2026 %d\%",percentValue);else
-this.sidebarElement.subtitle=WebInspector.UIString("Loading\u2026 %d\%",percentValue);},_updateSnapshotStatus:function()
+this._snapshotProxy.dispose();if(this._view){var view=this._view;this._view=null;view.dispose();}},_updateSubtitle:function(value)
+{this.sidebarElement.subtitle=value;},_didCompleteSnapshotTransfer:function()
{this.sidebarElement.subtitle=Number.bytesToString(this._snapshotProxy.totalSize);this.sidebarElement.wait=false;},transferChunk:function(chunk)
-{++this._numberOfChunks;this._receiver.write(chunk,callback.bind(this));function callback()
-{this._updateTransferProgress(++this._savedChunks,this._totalNumberOfChunks);if(this._totalNumberOfChunks===this._savedChunks){if(this._savingToFile)
-this._updateSnapshotStatus();else
-this.sidebarElement.subtitle=WebInspector.UIString("Parsing\u2026");this._receiver.close();}}},_snapshotReceived:function(snapshotProxy)
+{this._transferHandler.transferChunk(chunk);},_snapshotReceived:function(snapshotProxy)
{this._receiver=null;if(snapshotProxy)
-this._snapshotProxy=snapshotProxy;this._updateSnapshotStatus();var worker=(this._snapshotProxy.worker);this.isTemporary=false;worker.startCheckingForLongRunningCalls();this.notifySnapshotReceived();},notifySnapshotReceived:function()
+this._snapshotProxy=snapshotProxy;this._didCompleteSnapshotTransfer();var worker=(this._snapshotProxy.worker);this.isTemporary=false;worker.startCheckingForLongRunningCalls();this.notifySnapshotReceived();},notifySnapshotReceived:function()
{this._profileType._snapshotReceived(this);},finishHeapSnapshot:function()
-{this._totalNumberOfChunks=this._numberOfChunks;},_wasShown:function()
+{if(this._transferHandler){this._transferHandler.finishTransfer();this._totalNumberOfChunks=this._transferHandler._totalNumberOfChunks;}},_wasShown:function()
{},canSaveToFile:function()
{return!this.fromFile()&&!!this._snapshotProxy&&!this._receiver;},saveToFile:function()
-{this._numberOfChunks=0;var fileOutputStream=new WebInspector.FileOutputStream();function onOpen()
-{this._receiver=fileOutputStream;this._savedChunks=0;this._updateTransferProgress(0,this._totalNumberOfChunks);HeapProfilerAgent.getHeapSnapshot(this.uid);}
-this._savingToFile=true;this._fileName=this._fileName||"Heap-"+new Date().toISO8601Compact()+this._profileType.fileExtension();fileOutputStream.open(this._fileName,onOpen.bind(this));},loadFromFile:function(file)
-{this.title=file.name;this.sidebarElement.subtitle=WebInspector.UIString("Loading\u2026");this.sidebarElement.wait=true;this._setupWorker();this._numberOfChunks=0;this._savingToFile=false;var delegate=new WebInspector.HeapSnapshotLoadFromFileDelegate(this);var fileReader=this._createFileReader(file,delegate);fileReader.start(this._receiver);},_createFileReader:function(file,delegate)
+{var fileOutputStream=new WebInspector.FileOutputStream();function onOpen()
+{this._receiver=fileOutputStream;this._transferHandler=new WebInspector.SaveSnapshotHandler(this);HeapProfilerAgent.getHeapSnapshot(this.uid);}
+this._fileName=this._fileName||"Heap-"+new Date().toISO8601Compact()+this._profileType.fileExtension();fileOutputStream.open(this._fileName,onOpen.bind(this));},loadFromFile:function(file)
+{this.title=file.name;this.sidebarElement.subtitle=WebInspector.UIString("Loading\u2026");this.sidebarElement.wait=true;this._setupWorker();var delegate=new WebInspector.HeapSnapshotLoadFromFileDelegate(this);var fileReader=this._createFileReader(file,delegate);fileReader.start(this._receiver);},_createFileReader:function(file,delegate)
{return new WebInspector.ChunkedFileReader(file,10000000,delegate);},__proto__:WebInspector.ProfileHeader.prototype}
+WebInspector.SnapshotTransferHandler=function(header,title)
+{this._numberOfChunks=0;this._savedChunks=0;this._header=header;this._totalNumberOfChunks=0;this._title=title;}
+WebInspector.SnapshotTransferHandler.prototype={transferChunk:function(chunk)
+{++this._numberOfChunks;this._header._receiver.write(chunk,this._didTransferChunk.bind(this));},finishTransfer:function()
+{},_didTransferChunk:function()
+{this._updateProgress(++this._savedChunks,this._totalNumberOfChunks);},_updateProgress:function(value,total)
+{}}
+WebInspector.SaveSnapshotHandler=function(header)
+{WebInspector.SnapshotTransferHandler.call(this,header,"Saving\u2026 %d\%");this._totalNumberOfChunks=header._totalNumberOfChunks;this._updateProgress(0,this._totalNumberOfChunks);}
+WebInspector.SaveSnapshotHandler.prototype={_updateProgress:function(value,total)
+{var percentValue=((total?(value/total):0)*100).toFixed(0);this._header._updateSubtitle(WebInspector.UIString(this._title,percentValue));if(value===total){this._header._receiver.close();this._header._didCompleteSnapshotTransfer();}},__proto__:WebInspector.SnapshotTransferHandler.prototype}
+WebInspector.BackendSnapshotLoader=function(header)
+{WebInspector.SnapshotTransferHandler.call(this,header,"Loading\u2026 %d\%");}
+WebInspector.BackendSnapshotLoader.prototype={finishTransfer:function()
+{this._header._receiver.close(this._didFinishTransfer.bind(this));this._totalNumberOfChunks=this._numberOfChunks;},_didFinishTransfer:function()
+{console.assert(this._totalNumberOfChunks===this._savedChunks,"Not all chunks were transfered.");},__proto__:WebInspector.SnapshotTransferHandler.prototype}
WebInspector.HeapSnapshotLoadFromFileDelegate=function(snapshotHeader)
{this._snapshotHeader=snapshotHeader;}
WebInspector.HeapSnapshotLoadFromFileDelegate.prototype={onTransferStarted:function()
{},onChunkTransferred:function(reader)
-{this._snapshotHeader._updateTransferProgress(reader.loadedSize(),reader.fileSize());},onTransferFinished:function()
-{this._snapshotHeader.finishHeapSnapshot();},onError:function(reader,e)
-{switch(e.target.error.code){case e.target.error.NOT_FOUND_ERR:this._snapshotHeader.sidebarElement.subtitle=WebInspector.UIString("'%s' not found.",reader.fileName());break;case e.target.error.NOT_READABLE_ERR:this._snapshotHeader.sidebarElement.subtitle=WebInspector.UIString("'%s' is not readable",reader.fileName());break;case e.target.error.ABORT_ERR:break;default:this._snapshotHeader.sidebarElement.subtitle=WebInspector.UIString("'%s' error %d",reader.fileName(),e.target.error.code);}}}
+{},onTransferFinished:function()
+{},onError:function(reader,e)
+{switch(e.target.error.code){case e.target.error.NOT_FOUND_ERR:this._snapshotHeader._updateSubtitle(WebInspector.UIString("'%s' not found.",reader.fileName()));break;case e.target.error.NOT_READABLE_ERR:this._snapshotHeader._updateSubtitle(WebInspector.UIString("'%s' is not readable",reader.fileName()));break;case e.target.error.ABORT_ERR:break;default:this._snapshotHeader._updateSubtitle(WebInspector.UIString("'%s' error %d",reader.fileName(),e.target.error.code));}}}
WebInspector.HeapTrackingOverviewGrid=function(heapProfileHeader)
{WebInspector.View.call(this);this.registerRequiredCSS("flameChart.css");this.element.id="heap-recording-view";this._overviewContainer=this.element.createChild("div","overview-container");this._overviewGrid=new WebInspector.OverviewGrid("heap-recording");this._overviewCanvas=this._overviewContainer.createChild("canvas","heap-recording-overview-canvas");this._overviewContainer.appendChild(this._overviewGrid.element);this._overviewCalculator=new WebInspector.HeapTrackingOverviewGrid.OverviewCalculator();this._overviewGrid.addEventListener(WebInspector.OverviewGrid.Events.WindowChanged,this._onWindowChanged,this);this._profileSamples=heapProfileHeader._profileSamples||heapProfileHeader._profileType._profileSamples;if(heapProfileHeader.isTemporary){this._profileType=heapProfileHeader._profileType;this._profileType.addEventListener(WebInspector.TrackingHeapSnapshotProfileType.HeapStatsUpdate,this._onHeapStatsUpdate,this);this._profileType.addEventListener(WebInspector.TrackingHeapSnapshotProfileType.TrackingStopped,this._onStopTracking,this);}
var timestamps=this._profileSamples.timestamps;var totalTime=this._profileSamples.totalTime;this._windowLeft=0.0;this._windowRight=totalTime&&timestamps.length?(timestamps[timestamps.length-1]-timestamps[0])/totalTime:1.0;this._overviewGrid.setWindow(this._windowLeft,this._windowRight);this._yScale=new WebInspector.HeapTrackingOverviewGrid.SmoothScale();this._xScale=new WebInspector.HeapTrackingOverviewGrid.SmoothScale();}
@@ -1634,16 +1729,17 @@
{this._objects=[];this._global=globalObject;this._postMessage=postMessage;}
WebInspector.HeapSnapshotWorkerDispatcher.prototype={_findFunction:function(name)
{var path=name.split(".");var result=this._global;for(var i=0;i<path.length;++i)
-result=result[path[i]];return result;},dispatchMessage:function(event)
-{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();break;}
+result=result[path[i]];return result;},sendEvent:function(name,data)
+{this._postMessage({eventName:name,data:data});},dispatchMessage:function(event)
+{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;}
case"dispose":{delete this._objects[data.objectId];break;}
case"getter":{var object=this._objects[data.objectId];var result=object[data.methodName];response.result=result;break;}
case"factory":{var object=this._objects[data.objectId];var result=object[data.methodName].apply(object,data.methodArguments);if(result)
this._objects[data.newObjectId]=result;response.result=!!result;break;}
case"method":{var object=this._objects[data.objectId];response.result=object[data.methodName].apply(object,data.methodArguments);break;}}}catch(e){response.error=e.toString();response.errorCallStack=e.stack;if(data.methodName)
response.errorMethodName=data.methodName;}
-this._postMessage(response);}};;WebInspector.JSHeapSnapshot=function(profile)
-{this._nodeFlags={canBeQueried:1,detachedDOMTreeNode:2,pageObject:4,visitedMarkerMask:0x0ffff,visitedMarker:0x10000};WebInspector.HeapSnapshot.call(this,profile);}
+this._postMessage(response);}};;WebInspector.JSHeapSnapshot=function(profile,progress)
+{this._nodeFlags={canBeQueried:1,detachedDOMTreeNode:2,pageObject:4,visitedMarkerMask:0x0ffff,visitedMarker:0x10000};this._lazyStringCache={};WebInspector.HeapSnapshot.call(this,profile,progress);}
WebInspector.JSHeapSnapshot.prototype={createNode:function(nodeIndex)
{return new WebInspector.JSHeapSnapshotNode(this,nodeIndex);},createEdge:function(edges,edgeIndex)
{return new WebInspector.JSHeapSnapshotEdge(this,edges,edgeIndex);},createRetainingEdge:function(retainedNodeIndex,retainerIndex)
@@ -1705,7 +1801,15 @@
{WebInspector.HeapSnapshotNode.call(this,snapshot,nodeIndex)}
WebInspector.JSHeapSnapshotNode.prototype={canBeQueried:function()
{var flags=this._snapshot._flagsOfNode(this);return!!(flags&this._snapshot._nodeFlags.canBeQueried);},isUserObject:function()
-{var flags=this._snapshot._flagsOfNode(this);return!!(flags&this._snapshot._nodeFlags.pageObject);},className:function()
+{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;}
+return string;}
+return WebInspector.HeapSnapshotNode.prototype.name.call(this);},_consStringName:function()
+{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;}
+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")
+firstNodeIndex=edges[edgeIndex+edgeToNodeOffset];else if(edgeName==="second")
+secondNodeIndex=edges[edgeIndex+edgeToNodeOffset];}}
+nodesStack.push(secondNodeIndex);nodesStack.push(firstNodeIndex);}
+return name;},className:function()
{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()
{var snapshot=this._snapshot;var nodes=snapshot._nodes;var type=nodes[this.nodeIndex+snapshot._nodeTypeOffset];;if(type===snapshot._nodeObjectType||type===snapshot._nodeNativeType)
return nodes[this.nodeIndex+snapshot._nodeNameOffset];return-1-type;},id:function()
@@ -1787,19 +1891,24 @@
this.sort(this.lastComparator,true);},restore:function()
{if(!this._savedChildren)
return;this.children[0].restorePosition();WebInspector.ProfileDataGridTree.prototype.restore.call(this);},_merge:WebInspector.TopDownProfileDataGridNode.prototype._merge,_sharedPopulate:WebInspector.TopDownProfileDataGridNode.prototype._sharedPopulate,__proto__:WebInspector.ProfileDataGridTree.prototype};WebInspector.CanvasProfileView=function(profile)
-{WebInspector.View.call(this);this.registerRequiredCSS("canvasProfiler.css");this._profile=profile;this._traceLogId=profile.traceLogId();this.element.addStyleClass("canvas-profile-view");this._linkifier=new WebInspector.Linkifier();this._splitView=new WebInspector.SplitView(false,"canvasProfileViewSplitLocation",300);var replayImageContainer=this._splitView.firstElement();replayImageContainer.id="canvas-replay-image-container";this._replayImageElement=replayImageContainer.createChild("image","canvas-replay-image");this._debugInfoElement=replayImageContainer.createChild("div","canvas-debug-info hidden");this._spinnerIcon=replayImageContainer.createChild("img","canvas-spinner-icon hidden");var replayInfoContainer=this._splitView.secondElement();var controlsContainer=replayInfoContainer.createChild("div","status-bar");var logGridContainer=replayInfoContainer.createChild("div","canvas-replay-log");this._createControlButton(controlsContainer,"canvas-replay-first-step",WebInspector.UIString("First call."),this._onReplayFirstStepClick.bind(this));this._createControlButton(controlsContainer,"canvas-replay-prev-step",WebInspector.UIString("Previous call."),this._onReplayStepClick.bind(this,false));this._createControlButton(controlsContainer,"canvas-replay-next-step",WebInspector.UIString("Next call."),this._onReplayStepClick.bind(this,true));this._createControlButton(controlsContainer,"canvas-replay-prev-draw",WebInspector.UIString("Previous drawing call."),this._onReplayDrawingCallClick.bind(this,false));this._createControlButton(controlsContainer,"canvas-replay-next-draw",WebInspector.UIString("Next drawing call."),this._onReplayDrawingCallClick.bind(this,true));this._createControlButton(controlsContainer,"canvas-replay-last-step",WebInspector.UIString("Last call."),this._onReplayLastStepClick.bind(this));this._replayContextSelector=new WebInspector.StatusBarComboBox(this._onReplayContextChanged.bind(this));this._replayContextSelector.createOption("<screenshot auto>",WebInspector.UIString("Show screenshot of the last replayed resource."),"");controlsContainer.appendChild(this._replayContextSelector.element);this._replayContexts={};this._currentResourceStates={};var columns=[{title:"#",sortable:true,width:"5%"},{title:WebInspector.UIString("Call"),sortable:true,width:"75%",disclosure:true},{title:WebInspector.UIString("Location"),sortable:true,width:"20%"}];this._logGrid=new WebInspector.DataGrid(columns);this._logGrid.element.addStyleClass("fill");this._logGrid.show(logGridContainer);this._logGrid.addEventListener(WebInspector.DataGrid.Events.SelectedNode,this._replayTraceLog.bind(this));this._popoverHelper=new WebInspector.ObjectPopoverHelper(this.element,this._popoverAnchor.bind(this),this._resolveObjectForPopover.bind(this),this._onHidePopover.bind(this),true);this._splitView.show(this.element);this._requestTraceLog(0);}
+{WebInspector.View.call(this);this.registerRequiredCSS("canvasProfiler.css");this.element.addStyleClass("canvas-profile-view");this._profile=profile;this._traceLogId=profile.traceLogId();this._traceLogPlayer=profile.traceLogPlayer();this._linkifier=new WebInspector.Linkifier();const defaultReplayLogWidthPercent=0.34;this._replayInfoSplitView=new WebInspector.SplitView(true,"canvasProfileViewReplaySplitLocation",defaultReplayLogWidthPercent);this._replayInfoSplitView.setMainElementConstraints(defaultReplayLogWidthPercent,defaultReplayLogWidthPercent);this._replayInfoSplitView.show(this.element);this._imageSplitView=new WebInspector.SplitView(false,"canvasProfileViewSplitLocation",300);this._imageSplitView.show(this._replayInfoSplitView.firstElement());var replayImageContainer=this._imageSplitView.firstElement();replayImageContainer.id="canvas-replay-image-container";this._replayImageElement=replayImageContainer.createChild("image","canvas-replay-image");this._debugInfoElement=replayImageContainer.createChild("div","canvas-debug-info hidden");this._spinnerIcon=replayImageContainer.createChild("img","canvas-spinner-icon hidden");var replayLogContainer=this._imageSplitView.secondElement();var controlsContainer=replayLogContainer.createChild("div","status-bar");var logGridContainer=replayLogContainer.createChild("div","canvas-replay-log");this._createControlButton(controlsContainer,"canvas-replay-first-step",WebInspector.UIString("First call."),this._onReplayFirstStepClick.bind(this));this._createControlButton(controlsContainer,"canvas-replay-prev-step",WebInspector.UIString("Previous call."),this._onReplayStepClick.bind(this,false));this._createControlButton(controlsContainer,"canvas-replay-next-step",WebInspector.UIString("Next call."),this._onReplayStepClick.bind(this,true));this._createControlButton(controlsContainer,"canvas-replay-prev-draw",WebInspector.UIString("Previous drawing call."),this._onReplayDrawingCallClick.bind(this,false));this._createControlButton(controlsContainer,"canvas-replay-next-draw",WebInspector.UIString("Next drawing call."),this._onReplayDrawingCallClick.bind(this,true));this._createControlButton(controlsContainer,"canvas-replay-last-step",WebInspector.UIString("Last call."),this._onReplayLastStepClick.bind(this));this._replayContextSelector=new WebInspector.StatusBarComboBox(this._onReplayContextChanged.bind(this));this._replayContextSelector.createOption(WebInspector.UIString("<screenshot auto>"),WebInspector.UIString("Show screenshot of the last replayed resource."),"");controlsContainer.appendChild(this._replayContextSelector.element);this._installReplayInfoSidebarWidgets(controlsContainer);this._replayStateView=new WebInspector.CanvasReplayStateView(this._traceLogPlayer);this._replayStateView.show(this._replayInfoSplitView.secondElement());this._replayContexts={};var columns=[{title:"#",sortable:false,width:"5%"},{title:WebInspector.UIString("Call"),sortable:false,width:"75%",disclosure:true},{title:WebInspector.UIString("Location"),sortable:false,width:"20%"}];this._logGrid=new WebInspector.DataGrid(columns);this._logGrid.element.addStyleClass("fill");this._logGrid.show(logGridContainer);this._logGrid.addEventListener(WebInspector.DataGrid.Events.SelectedNode,this._replayTraceLog,this);this.element.addEventListener("mousedown",this._onMouseClick.bind(this),true);this._popoverHelper=new WebInspector.ObjectPopoverHelper(this.element,this._popoverAnchor.bind(this),this._resolveObjectForPopover.bind(this),this._onHidePopover.bind(this),true);this._popoverHelper.setRemoteObjectFormatter(this._hexNumbersFormatter.bind(this));this._requestTraceLog(0);}
WebInspector.CanvasProfileView.TraceLogPollingInterval=500;WebInspector.CanvasProfileView.prototype={dispose:function()
{this._linkifier.reset();},get statusBarItems()
{return[];},get profile()
{return this._profile;},elementsToRestoreScrollPositionsFor:function()
-{return[this._logGrid.scrollContainer];},_createControlButton:function(parent,className,title,clickCallback)
-{var button=new WebInspector.StatusBarButton(title,className);parent.appendChild(button.element);button.makeLongClickEnabled();button.addEventListener("click",clickCallback,this);button.addEventListener("longClickDown",clickCallback,this);button.addEventListener("longClickPress",clickCallback,this);},_onReplayContextChanged:function()
-{function didReceiveResourceState(error,resourceState)
-{const emptyTransparentImageURL="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==";this._enableWaitIcon(false);if(error)
-return;this._currentResourceStates[resourceState.id]=resourceState;var selectedContextId=this._replayContextSelector.selectedOption().value;if(selectedContextId===resourceState.id)
-this._replayImageElement.src=resourceState.imageURL||emptyTransparentImageURL;}
-var selectedContextId=this._replayContextSelector.selectedOption().value||"auto";var resourceState=this._currentResourceStates[selectedContextId];if(resourceState)
-this._replayImageElement.src=resourceState.imageURL;else{this._enableWaitIcon(true);CanvasAgent.getResourceState(this._traceLogId,selectedContextId,didReceiveResourceState.bind(this));}},_onReplayStepClick:function(forward)
+{return[this._logGrid.scrollContainer];},_installReplayInfoSidebarWidgets:function(controlsContainer)
+{this._replayInfoResizeWidgetElement=controlsContainer.createChild("div","resizer-widget");this._replayInfoSplitView.installResizer(this._replayInfoResizeWidgetElement);this._toggleReplayStateSidebarButton=new WebInspector.StatusBarButton("","right-sidebar-show-hide-button canvas-sidebar-show-hide-button",3);this._toggleReplayStateSidebarButton.addEventListener("click",clickHandler,this);controlsContainer.appendChild(this._toggleReplayStateSidebarButton.element);this._enableReplayInfoSidebar(false);function clickHandler()
+{this._enableReplayInfoSidebar(this._toggleReplayStateSidebarButton.state==="left");}},_enableReplayInfoSidebar:function(show)
+{if(show){this._toggleReplayStateSidebarButton.state="right";this._toggleReplayStateSidebarButton.title=WebInspector.UIString("Hide sidebar.");this._replayInfoSplitView.showBoth();}else{this._toggleReplayStateSidebarButton.state="left";this._toggleReplayStateSidebarButton.title=WebInspector.UIString("Show sidebar.");this._replayInfoSplitView.showOnlyFirst();}
+this._replayInfoResizeWidgetElement.enableStyleClass("hidden",!show);},_onMouseClick:function(event)
+{var resourceLinkElement=event.target.enclosingNodeOrSelfWithClass("canvas-formatted-resource");if(resourceLinkElement){this._enableReplayInfoSidebar(true);this._replayStateView.selectResource(resourceLinkElement.__resourceId);event.consume(true);return;}
+if(event.target.enclosingNodeOrSelfWithClass("webkit-html-resource-link"))
+event.consume(false);},_createControlButton:function(parent,className,title,clickCallback)
+{var button=new WebInspector.StatusBarButton(title,className+" canvas-replay-button");parent.appendChild(button.element);button.makeLongClickEnabled();button.addEventListener("click",clickCallback,this);button.addEventListener("longClickDown",clickCallback,this);button.addEventListener("longClickPress",clickCallback,this);},_onReplayContextChanged:function()
+{var selectedContextId=this._replayContextSelector.selectedOption().value;function didReceiveResourceState(resourceState)
+{this._enableWaitIcon(false);if(selectedContextId!==this._replayContextSelector.selectedOption().value)
+return;var imageURL=(resourceState&&resourceState.imageURL)||"";this._replayImageElement.src=imageURL;this._replayImageElement.style.visibility=imageURL?"":"hidden";}
+this._enableWaitIcon(true);this._traceLogPlayer.getResourceState(selectedContextId,didReceiveResourceState.bind(this));},_onReplayStepClick:function(forward)
{var selectedNode=this._logGrid.selectedNode;if(!selectedNode)
return;var nextNode=selectedNode;do{nextNode=forward?nextNode.traverseNextNode(false):nextNode.traversePreviousNode(false);}while(nextNode&&typeof nextNode.index!=="number");(nextNode||selectedNode).revealAndSelect();},_onReplayDrawingCallClick:function(forward)
{var selectedNode=this._logGrid.selectedNode;if(!selectedNode)
@@ -1818,19 +1927,19 @@
{this._spinnerIcon.enableStyleClass("hidden",!enable);this._debugInfoElement.enableStyleClass("hidden",enable);},_replayTraceLog:function()
{if(this._pendingReplayTraceLogEvent)
return;var index=this._selectedCallIndex();if(index===-1||index===this._lastReplayCallIndex)
-return;this._lastReplayCallIndex=index;this._pendingReplayTraceLogEvent=true;function didReplayTraceLog(error,resourceState,replayTime)
-{delete this._pendingReplayTraceLogEvent;this._enableWaitIcon(false);if(!error){this._currentResourceStates={};this._currentResourceStates["auto"]=resourceState;this._currentResourceStates[resourceState.id]=resourceState;this._debugInfoElement.textContent="Replay time: "+Number(replayTime).toFixed()+"ms";this._onReplayContextChanged();}
-if(index!==this._selectedCallIndex())
+return;this._lastReplayCallIndex=index;this._pendingReplayTraceLogEvent=true;function didReplayTraceLog(resourceState,replayTime)
+{delete this._pendingReplayTraceLogEvent;this._enableWaitIcon(false);this._debugInfoElement.textContent="Replay time: "+Number.secondsToString(replayTime/1000,true);this._onReplayContextChanged();if(index!==this._selectedCallIndex())
this._replayTraceLog();}
-this._enableWaitIcon(true);CanvasAgent.replayTraceLog(this._traceLogId,index,didReplayTraceLog.bind(this));},_didReceiveTraceLog:function(error,traceLog)
-{this._enableWaitIcon(false);if(error||!traceLog)
+this._enableWaitIcon(true);this._traceLogPlayer.replayTraceLog(index,didReplayTraceLog.bind(this));},_requestTraceLog:function(offset)
+{function didReceiveTraceLog(traceLog)
+{this._enableWaitIcon(false);if(!traceLog)
return;var callNodes=[];var calls=traceLog.calls;var index=traceLog.startOffset;for(var i=0,n=calls.length;i<n;++i)
callNodes.push(this._createCallNode(index++,calls[i]));var contexts=traceLog.contexts;for(var i=0,n=contexts.length;i<n;++i){var contextId=contexts[i].resourceId||"";var description=contexts[i].description||"";if(this._replayContexts[contextId])
continue;this._replayContexts[contextId]=true;this._replayContextSelector.createOption(description,WebInspector.UIString("Show screenshot of this context's canvas."),contextId);}
this._appendCallNodes(callNodes);if(traceLog.alive)
setTimeout(this._requestTraceLog.bind(this,index),WebInspector.CanvasProfileView.TraceLogPollingInterval);else
-this._flattenSingleFrameNode();this._profile._updateCapturingStatus(traceLog);this._onReplayLastStepClick();},_requestTraceLog:function(offset)
-{this._enableWaitIcon(true);CanvasAgent.getTraceLog(this._traceLogId,offset,undefined,this._didReceiveTraceLog.bind(this));},_selectedCallIndex:function()
+this._flattenSingleFrameNode();this._profile._updateCapturingStatus(traceLog);this._onReplayLastStepClick();}
+this._enableWaitIcon(true);this._traceLogPlayer.getTraceLog(offset,undefined,didReceiveTraceLog.bind(this));},_selectedCallIndex:function()
{var node=this._logGrid.selectedNode;return node?this._peekLastRecursively(node).index:-1;},_peekLastRecursively:function(node)
{var lastChild;while((lastChild=node.children.peekLast()))
node=lastChild;return node;},_appendCallNodes:function(callNodes)
@@ -1850,24 +1959,23 @@
drawCallGroup=splitDrawCallGroup(drawCallGroup);else
groupHasDrawCall=true;}}},_createCallNode:function(index,call)
{var callViewElement=document.createElement("div");var data={};data[0]=index+1;data[1]=callViewElement;data[2]="";if(call.sourceURL){var lineNumber=Math.max(0,call.lineNumber-1)||0;var columnNumber=Math.max(0,call.columnNumber-1)||0;data[2]=this._linkifier.linkifyLocation(call.sourceURL,lineNumber,columnNumber);}
-callViewElement.createChild("span","canvas-function-name").textContent=call.functionName||"context."+call.property;if(call.arguments){callViewElement.createTextChild("(");for(var i=0,n=call.arguments.length;i<n;++i){var argument=call.arguments[i];if(i)
-callViewElement.createTextChild(", ");this._createCallArgumentChild(callViewElement,argument)._argumentIndex=i;}
-callViewElement.createTextChild(")");}else if(typeof call.value!=="undefined"){callViewElement.createTextChild(" = ");this._createCallArgumentChild(callViewElement,call.value);}
-if(typeof call.result!=="undefined"){callViewElement.createTextChild(" => ");this._createCallArgumentChild(callViewElement,call.result);}
-var node=new WebInspector.DataGridNode(data);node.index=index;node.selectable=true;node.call=call;return node;},_createCallArgumentChild:function(parentElement,callArgument)
-{var element=parentElement.createChild("span","canvas-call-argument");element._argumentIndex=-1;if(callArgument.type==="string"){const maxStringLength=150;element.createTextChild("\"");element.createChild("span","canvas-formatted-string").textContent=callArgument.description.trimMiddle(maxStringLength);element.createTextChild("\"");element._suppressPopover=(callArgument.description.length<=maxStringLength&&!/[\r\n]/.test(callArgument.description));}else{var type=callArgument.subtype||callArgument.type;if(type){element.addStyleClass("canvas-formatted-"+type);switch(type){case"null":case"undefined":case"boolean":element._suppressPopover=true;break;case"number":element._suppressPopover=!isNaN(callArgument.description);break;}}
-element.textContent=callArgument.description;}
-if(callArgument.resourceId){element.addStyleClass("canvas-formatted-resource");element.resourceId=callArgument.resourceId;}
-return element;},_popoverAnchor:function(element,event)
-{var argumentElement=element.enclosingNodeOrSelfWithClass("canvas-call-argument");if(!argumentElement||argumentElement._suppressPopover)
+callViewElement.createChild("span","canvas-function-name").textContent=call.functionName||"context."+call.property;if(call.arguments){callViewElement.createTextChild("(");for(var i=0,n=call.arguments.length;i<n;++i){var argument=(call.arguments[i]);if(i)
+callViewElement.createTextChild(", ");var element=WebInspector.CanvasProfileDataGridHelper.createCallArgumentElement(argument);element.__argumentIndex=i;callViewElement.appendChild(element);}
+callViewElement.createTextChild(")");}else if(call.value){callViewElement.createTextChild(" = ");callViewElement.appendChild(WebInspector.CanvasProfileDataGridHelper.createCallArgumentElement(call.value));}
+if(call.result){callViewElement.createTextChild(" => ");callViewElement.appendChild(WebInspector.CanvasProfileDataGridHelper.createCallArgumentElement(call.result));}
+var node=new WebInspector.DataGridNode(data);node.index=index;node.selectable=true;node.call=call;return node;},_popoverAnchor:function(element,event)
+{var argumentElement=element.enclosingNodeOrSelfWithClass("canvas-call-argument");if(!argumentElement||argumentElement.__suppressPopover)
return null;return argumentElement;},_resolveObjectForPopover:function(argumentElement,showCallback,objectGroupName)
-{var dataGridNode=this._logGrid.dataGridNodeFromNode(argumentElement);if(!dataGridNode){this._popoverHelper.hidePopover();return;}
-var callIndex=dataGridNode.index;var argumentIndex=argumentElement._argumentIndex;function showObjectPopover(error,result,resourceState)
+{function showObjectPopover(error,result,resourceState)
{if(error)
return;if(!result)
-return;if(result&&result.type==="number"){var str="0000"+Number(result.description).toString(16).toUpperCase();str=str.replace(/^0+(.{4,})$/,"$1");result.description="0x"+str;}
-this._popoverAnchorElement=argumentElement.cloneNode(true);this._popoverAnchorElement.addStyleClass("canvas-popover-anchor");this._popoverAnchorElement.addStyleClass("source-frame-eval-expression");argumentElement.parentElement.appendChild(this._popoverAnchorElement);var diffLeft=this._popoverAnchorElement.boxInWindow().x-argumentElement.boxInWindow().x;this._popoverAnchorElement.style.left=this._popoverAnchorElement.offsetLeft-diffLeft+"px";showCallback(WebInspector.RemoteObject.fromPayload(result),false,this._popoverAnchorElement);}
-CanvasAgent.evaluateTraceLogCallArgument(this._traceLogId,callIndex,argumentIndex,objectGroupName,showObjectPopover.bind(this));},_onHidePopover:function()
+return;this._popoverAnchorElement=argumentElement.cloneNode(true);this._popoverAnchorElement.addStyleClass("canvas-popover-anchor");this._popoverAnchorElement.addStyleClass("source-frame-eval-expression");argumentElement.parentElement.appendChild(this._popoverAnchorElement);var diffLeft=this._popoverAnchorElement.boxInWindow().x-argumentElement.boxInWindow().x;this._popoverAnchorElement.style.left=this._popoverAnchorElement.offsetLeft-diffLeft+"px";showCallback(WebInspector.RemoteObject.fromPayload(result),false,this._popoverAnchorElement);}
+var evalResult=argumentElement.__evalResult;if(evalResult)
+showObjectPopover.call(this,null,evalResult);else{var dataGridNode=this._logGrid.dataGridNodeFromNode(argumentElement);if(!dataGridNode||typeof dataGridNode.index!=="number"){this._popoverHelper.hidePopover();return;}
+var callIndex=dataGridNode.index;var argumentIndex=argumentElement.__argumentIndex;if(typeof argumentIndex!=="number")
+argumentIndex=-1;CanvasAgent.evaluateTraceLogCallArgument(this._traceLogId,callIndex,argumentIndex,objectGroupName,showObjectPopover.bind(this));}},_hexNumbersFormatter:function(object)
+{if(object.type==="number"){var str="0000"+Number(object.description).toString(16).toUpperCase();str=str.replace(/^0+(.{4,})$/,"$1");return"0x"+str;}
+return object.description||"";},_onHidePopover:function()
{if(this._popoverAnchorElement){this._popoverAnchorElement.remove()
delete this._popoverAnchorElement;}},_flattenSingleFrameNode:function()
{var rootNode=this._logGrid.rootNode();if(rootNode.children.length!==1)
@@ -1934,17 +2042,124 @@
{this._profileType._contextCreated(frameId);},traceLogsRemoved:function(frameId,traceLogId)
{this._profileType._traceLogsRemoved(frameId,traceLogId);}}
WebInspector.CanvasProfileHeader=function(type,title,uid,traceLogId,frameId)
-{WebInspector.ProfileHeader.call(this,type,title,uid);this._traceLogId=traceLogId||"";this._frameId=frameId;this._alive=true;this._traceLogSize=0;}
+{WebInspector.ProfileHeader.call(this,type,title,uid);this._traceLogId=traceLogId||"";this._frameId=frameId;this._alive=true;this._traceLogSize=0;this._traceLogPlayer=traceLogId?new WebInspector.CanvasTraceLogPlayerProxy(traceLogId):null;}
WebInspector.CanvasProfileHeader.prototype={traceLogId:function()
-{return this._traceLogId;},frameId:function()
+{return this._traceLogId;},traceLogPlayer:function()
+{return this._traceLogPlayer;},frameId:function()
{return this._frameId;},createSidebarTreeElement:function()
{return new WebInspector.ProfileSidebarTreeElement(this,WebInspector.UIString("Trace Log %d"),"profile-sidebar-tree-item");},createView:function(profilesPanel)
{return new WebInspector.CanvasProfileView(this);},dispose:function()
-{if(this._traceLogId){CanvasAgent.dropTraceLog(this._traceLogId);clearTimeout(this._requestStatusTimer);this._alive=false;}},_updateCapturingStatus:function(traceLog)
+{if(this._traceLogPlayer)
+this._traceLogPlayer.dispose();clearTimeout(this._requestStatusTimer);this._alive=false;},_updateCapturingStatus:function(traceLog)
{if(!this.sidebarElement||!this._traceLogId)
return;if(traceLog){this._alive=traceLog.alive;this._traceLogSize=traceLog.totalAvailableCalls;}
this.sidebarElement.subtitle=this._alive?WebInspector.UIString("Capturing\u2026 %d calls",this._traceLogSize):WebInspector.UIString("Captured %d calls",this._traceLogSize);this.sidebarElement.wait=this._alive;if(this._alive){clearTimeout(this._requestStatusTimer);this._requestStatusTimer=setTimeout(this._requestCapturingStatus.bind(this),WebInspector.CanvasProfileView.TraceLogPollingInterval);}},_requestCapturingStatus:function()
-{function didReceiveTraceLog(error,traceLog)
-{if(error)
+{function didReceiveTraceLog(traceLog)
+{if(!traceLog)
return;this._alive=traceLog.alive;this._traceLogSize=traceLog.totalAvailableCalls;this._updateCapturingStatus();}
-CanvasAgent.getTraceLog(this._traceLogId,0,0,didReceiveTraceLog.bind(this));},__proto__:WebInspector.ProfileHeader.prototype};
+this._traceLogPlayer.getTraceLog(0,0,didReceiveTraceLog.bind(this));},__proto__:WebInspector.ProfileHeader.prototype}
+WebInspector.CanvasProfileDataGridHelper={createCallArgumentElement:function(callArgument)
+{if(callArgument.enumName)
+return WebInspector.CanvasProfileDataGridHelper.createEnumValueElement(callArgument.enumName,+callArgument.description);var element=document.createElement("span");element.className="canvas-call-argument";var description=callArgument.description;if(callArgument.type==="string"){const maxStringLength=150;element.createTextChild("\"");element.createChild("span","canvas-formatted-string").textContent=description.trimMiddle(maxStringLength);element.createTextChild("\"");element.__suppressPopover=(description.length<=maxStringLength&&!/[\r\n]/.test(description));if(!element.__suppressPopover)
+element.__evalResult=WebInspector.RemoteObject.fromPrimitiveValue(description);}else{var type=callArgument.subtype||callArgument.type;if(type){element.addStyleClass("canvas-formatted-"+type);if(["null","undefined","boolean","number"].indexOf(type)>=0)
+element.__suppressPopover=true;}
+element.textContent=description;if(callArgument.remoteObject)
+element.__evalResult=WebInspector.RemoteObject.fromPayload(callArgument.remoteObject);}
+if(callArgument.resourceId){element.addStyleClass("canvas-formatted-resource");element.__resourceId=callArgument.resourceId;}
+return element;},createEnumValueElement:function(enumName,enumValue)
+{var element=document.createElement("span");element.className="canvas-call-argument canvas-formatted-number";element.textContent=enumName;element.__evalResult=WebInspector.RemoteObject.fromPrimitiveValue(enumValue);return element;}}
+WebInspector.CanvasTraceLogPlayerProxy=function(traceLogId)
+{this._traceLogId=traceLogId;this._currentResourceStates={};this._defaultResourceId=null;}
+WebInspector.CanvasTraceLogPlayerProxy.Events={CanvasTraceLogReceived:"CanvasTraceLogReceived",CanvasReplayStateChanged:"CanvasReplayStateChanged",CanvasResourceStateReceived:"CanvasResourceStateReceived",}
+WebInspector.CanvasTraceLogPlayerProxy.prototype={getTraceLog:function(startOffset,maxLength,userCallback)
+{function callback(error,traceLog)
+{if(error||!traceLog){userCallback(null);return;}
+userCallback(traceLog);this.dispatchEventToListeners(WebInspector.CanvasTraceLogPlayerProxy.Events.CanvasTraceLogReceived,traceLog);}
+CanvasAgent.getTraceLog(this._traceLogId,startOffset,maxLength,callback.bind(this));},dispose:function()
+{this._currentResourceStates={};CanvasAgent.dropTraceLog(this._traceLogId);this.dispatchEventToListeners(WebInspector.CanvasTraceLogPlayerProxy.Events.CanvasReplayStateChanged);},getResourceState:function(resourceId,userCallback)
+{resourceId=resourceId||this._defaultResourceId;if(!resourceId){userCallback(null);return;}
+if(this._currentResourceStates[resourceId]){userCallback(this._currentResourceStates[resourceId]);return;}
+function callback(error,resourceState)
+{if(error||!resourceState){userCallback(null);return;}
+this._currentResourceStates[resourceId]=resourceState;userCallback(resourceState);this.dispatchEventToListeners(WebInspector.CanvasTraceLogPlayerProxy.Events.CanvasResourceStateReceived,resourceState);}
+CanvasAgent.getResourceState(this._traceLogId,resourceId,callback.bind(this));},replayTraceLog:function(index,userCallback)
+{function callback(error,resourceState,replayTime)
+{this._currentResourceStates={};if(error||!resourceState){resourceState=null;userCallback(null,replayTime);}else{this._defaultResourceId=resourceState.id;this._currentResourceStates[resourceState.id]=resourceState;userCallback(resourceState,replayTime);}
+this.dispatchEventToListeners(WebInspector.CanvasTraceLogPlayerProxy.Events.CanvasReplayStateChanged);if(resourceState)
+this.dispatchEventToListeners(WebInspector.CanvasTraceLogPlayerProxy.Events.CanvasResourceStateReceived,resourceState);}
+CanvasAgent.replayTraceLog(this._traceLogId,index,callback.bind(this));},clearResourceStates:function()
+{this._currentResourceStates={};this.dispatchEventToListeners(WebInspector.CanvasTraceLogPlayerProxy.Events.CanvasReplayStateChanged);},__proto__:WebInspector.Object.prototype};WebInspector.CanvasReplayStateView=function(traceLogPlayer)
+{WebInspector.View.call(this);this.registerRequiredCSS("canvasProfiler.css");this.element.addStyleClass("canvas-replay-state-view");this._traceLogPlayer=traceLogPlayer;var controlsContainer=this.element.createChild("div","status-bar");this._prevButton=this._createControlButton(controlsContainer,"canvas-replay-state-prev",WebInspector.UIString("Previous resource."),this._onResourceNavigationClick.bind(this,false));this._nextButton=this._createControlButton(controlsContainer,"canvas-replay-state-next",WebInspector.UIString("Next resource."),this._onResourceNavigationClick.bind(this,true));this._createControlButton(controlsContainer,"canvas-replay-state-refresh",WebInspector.UIString("Refresh."),this._onStateRefreshClick.bind(this));this._resourceSelector=new WebInspector.StatusBarComboBox(this._onReplayResourceChanged.bind(this));this._currentOption=this._resourceSelector.createOption(WebInspector.UIString("<auto>"),WebInspector.UIString("Show state of the last replayed resource."),"");controlsContainer.appendChild(this._resourceSelector.element);this._resourceIdToDescription={};this._gridNodesExpandedState={};this._gridScrollPositions={};this._currentResourceId=null;this._prevOptionsStack=[];this._nextOptionsStack=[];this._highlightedGridNodes=[];var columns=[{title:WebInspector.UIString("Name"),sortable:false,width:"50%",disclosure:true},{title:WebInspector.UIString("Value"),sortable:false,width:"50%"}];this._stateGrid=new WebInspector.DataGrid(columns);this._stateGrid.element.addStyleClass("fill");this._stateGrid.show(this.element);this._traceLogPlayer.addEventListener(WebInspector.CanvasTraceLogPlayerProxy.Events.CanvasReplayStateChanged,this._onReplayResourceChanged,this);this._traceLogPlayer.addEventListener(WebInspector.CanvasTraceLogPlayerProxy.Events.CanvasTraceLogReceived,this._onCanvasTraceLogReceived,this);this._traceLogPlayer.addEventListener(WebInspector.CanvasTraceLogPlayerProxy.Events.CanvasResourceStateReceived,this._onCanvasResourceStateReceived,this);this._updateButtonsEnabledState();}
+WebInspector.CanvasReplayStateView.prototype={selectResource:function(resourceId)
+{if(resourceId===this._resourceSelector.selectedOption().value)
+return;var option=this._resourceSelector.selectElement().firstChild;for(var index=0;option;++index,option=option.nextSibling){if(resourceId===option.value){this._resourceSelector.setSelectedIndex(index);this._onReplayResourceChanged();break;}}},_createControlButton:function(parent,className,title,clickCallback)
+{var button=new WebInspector.StatusBarButton(title,className+" canvas-replay-button");parent.appendChild(button.element);button.makeLongClickEnabled();button.addEventListener("click",clickCallback,this);button.addEventListener("longClickDown",clickCallback,this);button.addEventListener("longClickPress",clickCallback,this);return button;},_onResourceNavigationClick:function(forward)
+{var newOption=forward?this._nextOptionsStack.pop():this._prevOptionsStack.pop();if(!newOption)
+return;(forward?this._prevOptionsStack:this._nextOptionsStack).push(this._currentOption);this._isNavigationButton=true;this.selectResource(newOption.value);delete this._isNavigationButton;this._updateButtonsEnabledState();},_onStateRefreshClick:function()
+{this._traceLogPlayer.clearResourceStates();},_updateButtonsEnabledState:function()
+{this._prevButton.setEnabled(this._prevOptionsStack.length>0);this._nextButton.setEnabled(this._nextOptionsStack.length>0);},_updateCurrentOption:function()
+{const maxStackSize=256;var selectedOption=this._resourceSelector.selectedOption();if(this._currentOption===selectedOption)
+return;if(!this._isNavigationButton){this._prevOptionsStack.push(this._currentOption);this._nextOptionsStack=[];if(this._prevOptionsStack.length>maxStackSize)
+this._prevOptionsStack.shift();this._updateButtonsEnabledState();}
+this._currentOption=selectedOption;},_collectResourcesFromTraceLog:function(traceLog)
+{var collectedResources=[];var calls=traceLog.calls;for(var i=0,n=calls.length;i<n;++i){var call=calls[i];var args=call.arguments||[];for(var j=0;j<args.length;++j)
+this._collectResourceFromCallArgument(args[j],collectedResources);this._collectResourceFromCallArgument(call.result,collectedResources);this._collectResourceFromCallArgument(call.value,collectedResources);}
+var contexts=traceLog.contexts;for(var i=0,n=contexts.length;i<n;++i)
+this._collectResourceFromCallArgument(contexts[i],collectedResources);this._addCollectedResourcesToSelector(collectedResources);},_collectResourcesFromResourceState:function(resourceState)
+{var collectedResources=[];this._collectResourceFromResourceStateDescriptors(resourceState.descriptors,collectedResources);this._addCollectedResourcesToSelector(collectedResources);},_collectResourceFromResourceStateDescriptors:function(descriptors,output)
+{if(!descriptors)
+return;for(var i=0,n=descriptors.length;i<n;++i){var descriptor=descriptors[i];this._collectResourceFromCallArgument(descriptor.value,output);this._collectResourceFromResourceStateDescriptors(descriptor.values,output);}},_collectResourceFromCallArgument:function(argument,output)
+{if(!argument)
+return;var resourceId=argument.resourceId;if(!resourceId||this._resourceIdToDescription[resourceId])
+return;this._resourceIdToDescription[resourceId]=argument.description;output.push(argument);},_addCollectedResourcesToSelector:function(collectedResources)
+{if(!collectedResources.length)
+return;function comparator(arg1,arg2)
+{var a=arg1.description;var b=arg2.description;return String.naturalOrderComparator(a,b);}
+collectedResources.sort(comparator);var selectElement=this._resourceSelector.selectElement();var currentOption=selectElement.firstChild;currentOption=currentOption.nextSibling;for(var i=0,n=collectedResources.length;i<n;++i){var argument=collectedResources[i];while(currentOption&&String.naturalOrderComparator(currentOption.text,argument.description)<0)
+currentOption=currentOption.nextSibling;var option=this._resourceSelector.createOption(argument.description,WebInspector.UIString("Show state of this resource."),argument.resourceId);if(currentOption)
+selectElement.insertBefore(option,currentOption);}},_onReplayResourceChanged:function()
+{this._updateCurrentOption();var selectedResourceId=this._resourceSelector.selectedOption().value;function didReceiveResourceState(resourceState)
+{if(selectedResourceId!==this._resourceSelector.selectedOption().value)
+return;this._showResourceState(resourceState);}
+this._traceLogPlayer.getResourceState(selectedResourceId,didReceiveResourceState.bind(this));},_onCanvasTraceLogReceived:function(event)
+{var traceLog=(event.data);if(traceLog)
+this._collectResourcesFromTraceLog(traceLog);},_onCanvasResourceStateReceived:function(event)
+{var resourceState=(event.data);if(resourceState)
+this._collectResourcesFromResourceState(resourceState);},_showResourceState:function(resourceState)
+{this._saveExpandedState();this._saveScrollState();var rootNode=this._stateGrid.rootNode();if(!resourceState){this._currentResourceId=null;this._updateDataGridHighlights([]);rootNode.removeChildren();return;}
+var nodesToHighlight=[];var nameToOldGridNodes={};function populateNameToNodesMap(map,node)
+{if(!node)
+return;for(var i=0,child;child=node.children[i];++i){var item={node:child,children:{}};map[child.name]=item;populateNameToNodesMap(item.children,child);}}
+populateNameToNodesMap(nameToOldGridNodes,rootNode);rootNode.removeChildren();function comparator(d1,d2)
+{var hasChildren1=!!d1.values;var hasChildren2=!!d2.values;if(hasChildren1!==hasChildren2)
+return hasChildren1?1:-1;return String.naturalOrderComparator(d1.name,d2.name);}
+function appendResourceStateDescriptors(descriptors,parent,nameToOldChildren)
+{descriptors=descriptors||[];descriptors.sort(comparator);var oldChildren=nameToOldChildren||{};for(var i=0,n=descriptors.length;i<n;++i){var descriptor=descriptors[i];var childNode=this._createDataGridNode(descriptor);parent.appendChild(childNode);var oldChildrenItem=oldChildren[childNode.name]||{};var oldChildNode=oldChildrenItem.node;if(!oldChildNode||oldChildNode.element.textContent!==childNode.element.textContent)
+nodesToHighlight.push(childNode);appendResourceStateDescriptors.call(this,descriptor.values,childNode,oldChildrenItem.children);}}
+appendResourceStateDescriptors.call(this,resourceState.descriptors,rootNode,nameToOldGridNodes);var shouldHighlightChanges=(this._resourceKindId(this._currentResourceId)===this._resourceKindId(resourceState.id));this._currentResourceId=resourceState.id;this._restoreExpandedState();this._updateDataGridHighlights(shouldHighlightChanges?nodesToHighlight:[]);this._restoreScrollState();},_updateDataGridHighlights:function(nodes)
+{for(var i=0,n=this._highlightedGridNodes.length;i<n;++i){var node=this._highlightedGridNodes[i];node.element.removeStyleClass("canvas-grid-node-highlighted");}
+this._highlightedGridNodes=nodes;for(var i=0,n=this._highlightedGridNodes.length;i<n;++i){var node=this._highlightedGridNodes[i];node.element.addStyleClass("canvas-grid-node-highlighted");node.reveal();}},_resourceKindId:function(resourceId)
+{var description=(resourceId&&this._resourceIdToDescription[resourceId])||"";return description.replace(/\d+/g,"");},_forEachGridNode:function(callback)
+{function processRecursively(node,key)
+{for(var i=0,child;child=node.children[i];++i){var childKey=key+"#"+child.name;callback(child,childKey);processRecursively(child,childKey);}}
+processRecursively(this._stateGrid.rootNode(),"");},_saveExpandedState:function()
+{if(!this._currentResourceId)
+return;var expandedState={};var key=this._resourceKindId(this._currentResourceId);this._gridNodesExpandedState[key]=expandedState;function callback(node,key)
+{if(node.expanded)
+expandedState[key]=true;}
+this._forEachGridNode(callback);},_restoreExpandedState:function()
+{if(!this._currentResourceId)
+return;var key=this._resourceKindId(this._currentResourceId);var expandedState=this._gridNodesExpandedState[key];if(!expandedState)
+return;function callback(node,key)
+{if(expandedState[key])
+node.expand();}
+this._forEachGridNode(callback);},_saveScrollState:function()
+{if(!this._currentResourceId)
+return;var key=this._resourceKindId(this._currentResourceId);this._gridScrollPositions[key]={scrollTop:this._stateGrid.scrollContainer.scrollTop,scrollLeft:this._stateGrid.scrollContainer.scrollLeft};},_restoreScrollState:function()
+{if(!this._currentResourceId)
+return;var key=this._resourceKindId(this._currentResourceId);var scrollState=this._gridScrollPositions[key];if(!scrollState)
+return;this._stateGrid.scrollContainer.scrollTop=scrollState.scrollTop;this._stateGrid.scrollContainer.scrollLeft=scrollState.scrollLeft;},_createDataGridNode:function(descriptor)
+{var name=descriptor.name;var callArgument=descriptor.value;var valueElement=callArgument?WebInspector.CanvasProfileDataGridHelper.createCallArgumentElement(callArgument):"";var nameElement=name;if(typeof descriptor.enumValueForName!=="undefined")
+nameElement=WebInspector.CanvasProfileDataGridHelper.createEnumValueElement(name,+descriptor.enumValueForName);if(descriptor.isArray&&descriptor.values){if(typeof nameElement==="string")
+nameElement+="["+descriptor.values.length+"]";else{var element=document.createElement("span");element.appendChild(nameElement);element.createTextChild("["+descriptor.values.length+"]");nameElement=element;}}
+var data={};data[0]=nameElement;data[1]=valueElement;var node=new WebInspector.DataGridNode(data);node.selectable=false;node.name=name;return node;},__proto__:WebInspector.View.prototype};
« no previous file with comments | « chrome_linux/resources/inspector/NetworkPanel.js ('k') | chrome_linux/resources/inspector/ResourcesPanel.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698