Index: chrome_linux/resources/inspector/ProfilesPanel.js |
=================================================================== |
--- chrome_linux/resources/inspector/ProfilesPanel.js (revision 237140) |
+++ chrome_linux/resources/inspector/ProfilesPanel.js (working copy) |
@@ -1,4 +1,4 @@ |
-const UserInitiatedProfileName="org.webkit.profiles.user-initiated";WebInspector.ProfileType=function(id,name) |
+WebInspector.ProfileType=function(id,name) |
{this._id=id;this._name=name;this._profiles=[];this._profilesIdMap={};this.treeElement=null;} |
WebInspector.ProfileType.Events={AddProfileHeader:"add-profile-header",RemoveProfileHeader:"remove-profile-header",ProgressUpdated:"progress-updated",ViewUpdated:"view-updated"} |
WebInspector.ProfileType.prototype={hasTemporaryView:function() |
@@ -28,15 +28,10 @@ |
{var profiles=this._profiles.slice(0);for(var i=0;i<profiles.length;++i){var profile=profiles[i];var view=profile.existingView();if(view){view.detach();if("dispose"in view) |
view.dispose();} |
this.dispatchEventToListeners(WebInspector.ProfileType.Events.RemoveProfileHeader,profile);} |
-this.treeElement.removeChildren();this._profiles=[];this._profilesIdMap={};},_requestProfilesFromBackend:function(populateCallback) |
-{},_populateProfiles:function() |
-{function populateCallback(error,profileHeaders){if(error) |
-return;profileHeaders.sort(function(a,b){return a.uid-b.uid;});var count=profileHeaders.length;for(var i=0;i<count;++i) |
-this.addProfile(this.createProfile(profileHeaders[i]));} |
-this._requestProfilesFromBackend(populateCallback.bind(this));},__proto__:WebInspector.Object.prototype} |
+this.treeElement.removeChildren();this._profiles=[];this._profilesIdMap={};},__proto__:WebInspector.Object.prototype} |
WebInspector.ProfileHeader=function(profileType,title,uid) |
{this._profileType=profileType;this.title=title;this.isTemporary=uid===undefined;this.uid=this.isTemporary?-1:uid;this._fromFile=false;} |
-WebInspector.ProfileHeader.prototype={profileType:function() |
+WebInspector.ProfileHeader._nextProfileFromFileUid=1;WebInspector.ProfileHeader.prototype={profileType:function() |
{return this._profileType;},createSidebarTreeElement:function() |
{throw new Error("Needs implemented.");},existingView:function() |
{return this._view;},view:function(panel) |
@@ -49,11 +44,11 @@ |
{throw new Error("Needs implemented");},loadFromFile:function(file) |
{throw new Error("Needs implemented");},fromFile:function() |
{return this._fromFile;},setFromFile:function() |
-{this._fromFile=true;this.uid=-2;}} |
+{this._fromFile=true;this.uid="From file #"+WebInspector.ProfileHeader._nextProfileFromFileUid++;}} |
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()) |
+{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.splitView.mainElement.addStyleClass("vbox");this.splitView.sidebarElement.addStyleClass("vbox");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.profileViews.addStyleClass("vbox");this.splitView.mainElement.appendChild(this.profileViews);var statusBarContainer=this.splitView.mainElement.createChild("div","profiles-status-bar");this._statusBarElement=statusBarContainer.createChild("div","status-bar");var sidebarTreeBox=this.sidebarElement.createChild("div","profiles-sidebar-tree-box");sidebarTreeBox.appendChild(this.sidebarTreeElement);var statusBarContainerLeft=this.sidebarElement.createChild("div","profiles-status-bar");this._statusBarButtons=statusBarContainerLeft.createChild("div","status-bar");this.recordButton=new WebInspector.StatusBarButton("","record-profile-status-bar-item");this.recordButton.addEventListener("click",this.toggleRecordButton,this);this._statusBarButtons.appendChild(this.recordButton.element);this.clearResultsButton=new WebInspector.StatusBarButton(WebInspector.UIString("Clear all profiles."),"clear-status-bar-item");this.clearResultsButton.addEventListener("click",this._clearProfiles,this);this._statusBarButtons.appendChild(this.clearResultsButton.element);this._profileTypeStatusBarItemsContainer=this._statusBarElement.createChild("div");this._profileViewStatusBarItemsContainer=this._statusBarElement.createChild("div");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._configureCpuProfilerSamplingInterval();WebInspector.settings.highResolutionCpuProfiling.addChangeListener(this._configureCpuProfilerSamplingInterval,this);} |
+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() |
@@ -70,21 +65,16 @@ |
continue;extensions.push(extension);} |
WebInspector.log(WebInspector.UIString("Can't load file. Only files with extensions '%s' can be loaded.",extensions.join("', '")));return;} |
if(!!profileType.findTemporaryProfile()){WebInspector.log(WebInspector.UIString("Can't load profile when other profile is recording."));return;} |
-var temporaryProfile=profileType.createTemporaryProfile(WebInspector.ProfilesPanelDescriptor.UserInitiatedProfileName+"."+file.name);temporaryProfile.setFromFile();profileType.addProfile(temporaryProfile);temporaryProfile.loadFromFile(file);},get statusBarItems() |
-{return this._statusBarButtons.select("element").concat(this._profileTypeStatusBarItemsContainer,this._profileViewStatusBarItemsContainer);},toggleRecordButton:function(event) |
-{var isProfiling=this._selectedProfileType.buttonClicked();this.setRecordingProfile(this._selectedProfileType.id,isProfiling);return true;},_populateAllProfiles:function() |
-{if(this._profilesWereRequested) |
-return;this._profilesWereRequested=true;for(var typeId in this._profileTypesByIdMap) |
-this._profileTypesByIdMap[typeId]._populateProfiles();},wasShown:function() |
-{WebInspector.Panel.prototype.wasShown.call(this);this._populateAllProfiles();},_onProfileTypeSelected:function(event) |
+var name=file.name;if(name.endsWith(profileType.fileExtension())) |
+name=name.substr(0,name.length-profileType.fileExtension().length);var temporaryProfile=profileType.createTemporaryProfile(name);temporaryProfile.setFromFile();profileType.addProfile(temporaryProfile);temporaryProfile.loadFromFile(file);},toggleRecordButton:function(event) |
+{var isProfiling=this._selectedProfileType.buttonClicked();this.setRecordingProfile(this._selectedProfileType.id,isProfiling);return true;},_onProfileTypeSelected:function(event) |
{this._selectedProfileType=(event.data);this._updateProfileTypeSpecificUI();},_updateProfileTypeSpecificUI:function() |
{this.recordButton.title=this._selectedProfileType.buttonTooltip;this._launcherView.updateProfileType(this._selectedProfileType);this._profileTypeStatusBarItemsContainer.removeChildren();var statusBarItems=this._selectedProfileType.statusBarItems;if(statusBarItems){for(var i=0;i<statusBarItems.length;++i) |
-this._profileTypeStatusBarItemsContainer.appendChild(statusBarItems[i]);} |
-this._resize(this.splitView.sidebarWidth());},_reset:function() |
+this._profileTypeStatusBarItemsContainer.appendChild(statusBarItems[i]);}},_reset:function() |
{WebInspector.Panel.prototype.reset.call(this);for(var typeId in this._profileTypesByIdMap) |
this._profileTypesByIdMap[typeId]._reset();delete this.visibleView;delete this.currentQuery;this.searchCanceled();this._profileGroups={};this.recordButton.toggled=false;if(this._selectedProfileType) |
-this.recordButton.title=this._selectedProfileType.buttonTooltip;this._launcherView.profileFinished();this.sidebarTreeElement.removeStyleClass("some-expandable");this.profileViews.removeChildren();this._profileViewStatusBarItemsContainer.removeChildren();this.removeAllListeners();this.recordButton.visible=true;this._profileViewStatusBarItemsContainer.removeStyleClass("hidden");this.clearResultsButton.element.removeStyleClass("hidden");this.profilesItemTreeElement.select();this._showLauncherView();},_showLauncherView:function() |
-{this.closeVisibleView();this._profileViewStatusBarItemsContainer.removeChildren();this._launcherView.show(this.splitView.mainElement);this.visibleView=this._launcherView;},_clearProfiles:function() |
+this.recordButton.title=this._selectedProfileType.buttonTooltip;this._launcherView.profileFinished();this.sidebarTreeElement.removeStyleClass("some-expandable");this._launcherView.detach();this.profileViews.removeChildren();this._profileViewStatusBarItemsContainer.removeChildren();this.removeAllListeners();this.recordButton.visible=true;this._profileViewStatusBarItemsContainer.removeStyleClass("hidden");this.clearResultsButton.element.removeStyleClass("hidden");this.profilesItemTreeElement.select();this._showLauncherView();},_showLauncherView:function() |
+{this.closeVisibleView();this._profileViewStatusBarItemsContainer.removeChildren();this._launcherView.show(this.profileViews);this.visibleView=this._launcherView;},_clearProfiles:function() |
{ProfilerAgent.clearProfiles();HeapProfilerAgent.clearProfiles();this._reset();},_garbageCollectButtonClicked:function() |
{HeapProfilerAgent.collectGarbage();},_registerProfileType:function(profileType) |
{this._profileTypesByIdMap[profileType.id]=profileType;this._launcherView.addProfileType(profileType);profileType.treeElement=new WebInspector.SidebarSectionTreeElement(profileType.treeItemTitle,null,true);profileType.treeElement.hidden=!this._singleProfileMode;this.sidebarTree.appendChild(profileType.treeElement);profileType.treeElement.childrenListElement.addEventListener("contextmenu",this._handleContextMenuEvent.bind(this),true);function onAddProfileHeader(event) |
@@ -101,7 +91,7 @@ |
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)) |
+{var profileType=profile.profileType();var typeId=profileType.id;var sidebarParent=profileType.treeElement;sidebarParent.hidden=false;var small=false;var alternateTitle;if(!profile.fromFile()&&!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) |
group[0]._profilesTreeElement.revealAndSelect();group[0]._profilesTreeElement.small=true;group[0]._profilesTreeElement.mainTitle=WebInspector.UIString("Run %d",1);this.sidebarTreeElement.addStyleClass("some-expandable");} |
if(group.length>=2){sidebarParent=group._profilesTreeElement;alternateTitle=WebInspector.UIString("Run %d",group.length);small=true;}} |
@@ -174,10 +164,7 @@ |
view.searchCanceled();delete view.currentQuery;}} |
WebInspector.Panel.prototype.searchCanceled.call(this);if(this._currentSearchChunkIntervalIdentifier){clearInterval(this._currentSearchChunkIntervalIdentifier);delete this._currentSearchChunkIntervalIdentifier;} |
this._totalSearchMatches=0;this._currentSearchResultIndex=0;this._searchResults=[];var profiles=this._getAllProfiles();for(var i=0;i<profiles.length;++i) |
-profiles[i]._profilesTreeElement.searchMatches=0;},sidebarResized:function(event) |
-{var sidebarWidth=(event.data);this._resize(sidebarWidth);},onResize:function() |
-{this._resize(this.splitView.sidebarWidth());},_resize:function(sidebarWidth) |
-{var lastItemElement=this._statusBarButtons[this._statusBarButtons.length-1].element;var left=lastItemElement.totalOffsetLeft()+lastItemElement.offsetWidth;this._profileTypeStatusBarItemsContainer.style.left=left+"px";left+=this._profileTypeStatusBarItemsContainer.offsetWidth-1;this._profileViewStatusBarItemsContainer.style.left=Math.max(left,sidebarWidth)+"px";},setRecordingProfile:function(profileType,isProfiling) |
+profiles[i]._profilesTreeElement.searchMatches=0;},setRecordingProfile:function(profileType,isProfiling) |
{var profileTypeObject=this.getProfileType(profileType);this.recordButton.toggled=isProfiling;this.recordButton.title=profileTypeObject.buttonTooltip;if(isProfiling){this._launcherView.profileStarted();this._createTemporaryProfile(profileType);if(profileTypeObject.hasTemporaryView()) |
this._showProfile(profileTypeObject.findTemporaryProfile());}else |
this._launcherView.profileFinished();},_reportProfileProgress:function(profile,done,total) |
@@ -193,15 +180,13 @@ |
this.showObject(result,viewName);} |
contextMenu.appendItem(WebInspector.UIString(WebInspector.useLowerCaseMenuTitles()?"Reveal in Dominators view":"Reveal in Dominators View"),revealInView.bind(this,"Dominators"));contextMenu.appendItem(WebInspector.UIString(WebInspector.useLowerCaseMenuTitles()?"Reveal in Summary view":"Reveal in Summary View"),revealInView.bind(this,"Summary"));},__proto__:WebInspector.Panel.prototype} |
WebInspector.ProfileSidebarTreeElement=function(profile,titleFormat,className) |
-{this.profile=profile;this._titleFormat=titleFormat;if(WebInspector.ProfilesPanelDescriptor.isUserInitiatedProfile(this.profile.title)) |
-this._profileNumber=WebInspector.ProfilesPanelDescriptor.userInitiatedProfileIndex(this.profile.title);WebInspector.SidebarTreeElement.call(this,className,"","",profile,false);this.refreshTitles();} |
+{this.profile=profile;this._titleFormat=titleFormat;WebInspector.SidebarTreeElement.call(this,className,"","",profile,false);this.refreshTitles();} |
WebInspector.ProfileSidebarTreeElement.prototype={onselect:function() |
{if(!this._suppressOnSelect) |
this.treeOutline.panel._showProfile(this.profile);},ondelete:function() |
{this.treeOutline.panel._removeProfileHeader(this.profile);return true;},get mainTitle() |
{if(this._mainTitle) |
-return this._mainTitle;if(WebInspector.ProfilesPanelDescriptor.isUserInitiatedProfile(this.profile.title)) |
-return WebInspector.UIString(this._titleFormat,this._profileNumber);return this.profile.title;},set mainTitle(x) |
+return this._mainTitle;return this.profile.title;},set mainTitle(x) |
{this._mainTitle=x;this.refreshTitles();},set searchMatches(matches) |
{if(!matches){if(!this.bubbleElement) |
return;this.bubbleElement.removeStyleClass("search-matches");this.bubbleText="";return;} |
@@ -232,7 +217,7 @@ |
{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);} |
+{return WebInspector.UIString("%.1f\u2009ms",time);} |
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 |
@@ -244,7 +229,8 @@ |
cell.addStyleClass("highlight");if(columnIdentifier!=="function") |
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);} |
+cell.addStyleClass("highlight");if(this.profileNode.scriptId!=="0"){var lineNumber=this.profileNode.lineNumber?this.profileNode.lineNumber-1:0;var columnNumber=this.profileNode.columnNumber?this.profileNode.columnNumber-1:0;var location=new WebInspector.DebuggerModel.Location(this.profileNode.scriptId,lineNumber,columnNumber);var urlElement=this.tree.profileView._linkifier.linkifyRawLocation(location,"profile-node-file");if(!urlElement) |
+urlElement=this.tree.profileView._linkifier.linkifyLocation(this.profileNode.url,lineNumber,columnNumber,"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) |
{WebInspector.DataGridNode.prototype.deselect.call(this,supressDeselectedEvent);this.tree.profileView._dataGridNodeDeselected(this);},sort:function(comparator,force) |
@@ -261,8 +247,8 @@ |
{return this.totalTime/this.tree.totalTime*100.0;},get _parent() |
{return this.parent!==this.dataGrid?this.parent:this.tree;},populate:function() |
{if(this._populated) |
-return;this._populated=true;this._sharedPopulate();if(this._parent){var currentComparator=this._parent.lastComparator;if(currentComparator) |
-this.sort(currentComparator,true);}},_save:function() |
+return;this._populated=true;this._sharedPopulate();var currentComparator=this.tree.lastComparator;if(currentComparator) |
+this.sort(currentComparator,true);},_save:function() |
{if(this._savedChildren) |
return;this._savedSelfTime=this.selfTime;this._savedTotalTime=this.totalTime;this._savedChildren=this.children.slice();},_restore:function() |
{if(!this._savedChildren) |
@@ -295,21 +281,23 @@ |
return 1;return 0;}} |
WebInspector.ProfileDataGridTree.propertyComparators[(isAscending?1:0)][property]=comparator;} |
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) |
+{this._strings=profile.strings;this._nextNodeId=1;this._idToFunctionInfo={};this._idToNode={};this._collapsedTopNodeIdToFunctionInfo={};this._traceTops=null;this._buildAllocationFunctionInfos(profile);this._traceTree=this._buildInvertedAllocationTree(profile);} |
+WebInspector.AllocationProfile.prototype={_buildAllocationFunctionInfos:function(profile) |
+{var strings=this._strings;var functionInfoFields=profile.snapshot.meta.trace_function_info_fields;var functionIdOffset=functionInfoFields.indexOf("function_id");var functionNameOffset=functionInfoFields.indexOf("name");var scriptNameOffset=functionInfoFields.indexOf("script_name");var scriptIdOffset=functionInfoFields.indexOf("script_id");var lineOffset=functionInfoFields.indexOf("line");var columnOffset=functionInfoFields.indexOf("column");var functionInfoFieldCount=functionInfoFields.length;var map=this._idToFunctionInfo;map[0]=new WebInspector.FunctionAllocationInfo("(root)","<unknown>",0,-1,-1);var rawInfos=profile.trace_function_infos;var infoLength=rawInfos.length;for(var i=0;i<infoLength;i+=functionInfoFieldCount){map[rawInfos[i+functionIdOffset]]=new WebInspector.FunctionAllocationInfo(strings[rawInfos[i+functionNameOffset]],strings[rawInfos[i+scriptNameOffset]],rawInfos[i+scriptIdOffset],rawInfos[i+lineOffset],rawInfos[i+columnOffset]);}},_buildInvertedAllocationTree:function(profile) |
+{var traceTreeRaw=profile.trace_tree;var idToFunctionInfo=this._idToFunctionInfo;var traceNodeFields=profile.snapshot.meta.trace_node_fields;var nodeIdOffset=traceNodeFields.indexOf("id");var functionIdOffset=traceNodeFields.indexOf("function_id");var allocationCountOffset=traceNodeFields.indexOf("count");var allocationSizeOffset=traceNodeFields.indexOf("size");var childrenOffset=traceNodeFields.indexOf("children");var nodeFieldCount=traceNodeFields.length;function traverseNode(rawNodeArray,nodeOffset,parent) |
{var functionInfo=idToFunctionInfo[rawNodeArray[nodeOffset+functionIdOffset]];var result=new WebInspector.AllocationTraceNode(rawNodeArray[nodeOffset+nodeIdOffset],functionInfo,rawNodeArray[nodeOffset+allocationCountOffset],rawNodeArray[nodeOffset+allocationSizeOffset],parent);functionInfo.addTraceTopNode(result);var rawChildren=rawNodeArray[nodeOffset+childrenOffset];for(var i=0;i<rawChildren.length;i+=nodeFieldCount){result.children.push(traverseNode(rawChildren,i,result));} |
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) |
+continue;var nodeId=this._nextNodeId++;result.push(this._serializeNode(nodeId,info,info.totalCount,info.totalSize,true));this._collapsedTopNodeIdToFunctionInfo[nodeId]=info;} |
+result.sort(function(a,b){return b.size-a.size;});return result;},serializeCallers:function(nodeId) |
{var node=this._idToNode[nodeId];if(!node){var functionInfo=this._collapsedTopNodeIdToFunctionInfo[nodeId];node=functionInfo.tracesWithThisTop();delete this._collapsedTopNodeIdToFunctionInfo[nodeId];this._idToNode[nodeId]=node;} |
-var 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};}} |
+var nodesWithSingleCaller=[];while(node.callers().length===1){node=node.callers()[0];nodesWithSingleCaller.push(this._serializeCaller(node));} |
+var branchingCallers=[];var callers=node.callers();for(var i=0;i<callers.length;i++){branchingCallers.push(this._serializeCaller(callers[i]));} |
+return{nodesWithSingleCaller:nodesWithSingleCaller,branchingCallers:branchingCallers};},_serializeCaller:function(node) |
+{var callerId=this._nextNodeId++;this._idToNode[callerId]=node;return this._serializeNode(callerId,node.functionInfo,node.allocationCount,node.allocationSize,node.hasCallers());},_serializeNode:function(nodeId,functionInfo,count,size,hasChildren) |
+{return{id:nodeId,name:functionInfo.functionName,scriptName:functionInfo.scriptName,line:functionInfo.line,column:functionInfo.column,count:count,size:size,hasChildren:hasChildren};}} |
WebInspector.AllocationTraceNode=function(id,functionInfo,count,size,parent) |
{this.id=id;this.functionInfo=functionInfo;this.allocationCount=count;this.allocationSize=size;this.parent=parent;this.children=[];} |
WebInspector.AllocationBackTraceNode=function(functionInfo) |
@@ -320,8 +308,8 @@ |
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=function(functionName,scriptName,scriptId,line,column) |
+{this.functionName=functionName;this.scriptName=scriptName;this.scriptId=scriptId;this.line=line;this.column=column;this.totalCount=0;this.totalSize=0;this._traceTops=[];} |
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() |
@@ -441,7 +429,7 @@ |
return;var script=WebInspector.debuggerModel.scriptForId(node.scriptId) |
if(!script) |
return;var uiLocation=script.rawLocationToUILocation(node.lineNumber);if(!uiLocation) |
-return;WebInspector.showPanel("sources").showUILocation(uiLocation);},_changeView:function() |
+return;WebInspector.panel("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) |
@@ -489,11 +477,9 @@ |
{this._recording=isProfiling;},createTemporaryProfile:function(title) |
{title=title||WebInspector.UIString("Recording\u2026");return new WebInspector.CPUProfileHeader(this,title);},createProfile:function(profile) |
{return new WebInspector.CPUProfileHeader(this,profile.title,profile.uid);},removeProfile:function(profile) |
-{WebInspector.ProfileType.prototype.removeProfile.call(this,profile);if(!profile.isTemporary) |
-ProfilerAgent.removeProfile(this.id,profile.uid);},_requestProfilesFromBackend:function(populateCallback) |
-{ProfilerAgent.getProfileHeaders(populateCallback);},resetProfiles:function() |
+{WebInspector.ProfileType.prototype.removeProfile.call(this,profile);if(!profile.isTemporary&&!profile.fromFile()) |
+ProfilerAgent.removeProfile(this.id,profile.uid);},resetProfiles:function() |
{this._reset();},addHeapSnapshotChunk:function(uid,chunk) |
-{throw new Error("Never called");},finishHeapSnapshot:function(uid) |
{throw new Error("Never called");},reportHeapSnapshotProgress:function(done,total) |
{throw new Error("Never called");},__proto__:WebInspector.ProfileType.prototype} |
WebInspector.CPUProfileHeader=function(type,title,uid) |
@@ -514,15 +500,17 @@ |
function onOpen() |
{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._canvas.addEventListener("click",this._onClick.bind(this),false);this._linkifier=new WebInspector.Linkifier();this._highlightedEntryIndex=-1;if(!WebInspector.FlameChart._colorGenerator) |
+{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._entryInfo=this._chartContainer.createChild("div","entry-info");this._cpuProfileView=cpuProfileView;this._windowLeft=0.0;this._windowRight=1.0;this._barHeight=15;this._minWidth=1;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() |
{} |
WebInspector.FlameChart.Calculator.prototype={_updateBoundaries:function(flameChart) |
-{this._minimumBoundaries=flameChart._windowLeft*flameChart._timelineData.totalTime;this._maximumBoundaries=flameChart._windowRight*flameChart._timelineData.totalTime;this.paddingLeft=flameChart._paddingLeft;this._width=flameChart._canvas.width-this.paddingLeft;this._timeToPixel=this._width/this.boundarySpan();},computePosition:function(time) |
+{function log10(x) |
+{return Math.log(x)/Math.LN10;} |
+this._decimalDigits=Math.max(0,-Math.floor(log10(flameChart._timelineGrid.gridSliceTime*1.01)));this._minimumBoundaries=flameChart._windowLeft*flameChart._timelineData.totalTime;this._maximumBoundaries=flameChart._windowRight*flameChart._timelineData.totalTime;this.paddingLeft=flameChart._paddingLeft;this._width=flameChart._canvas.width-this.paddingLeft;this._timeToPixel=this._width/this.boundarySpan();},computePosition:function(time) |
{return(time-this._minimumBoundaries)*this._timeToPixel+this.paddingLeft;},formatTime:function(value) |
-{return WebInspector.UIString("%s\u2009ms",Number.withThousandsSeparator(Math.round(value+this._minimumBoundaries)));},maximumBoundary:function() |
+{var format="%."+this._decimalDigits+"f\u2009ms";return WebInspector.UIString(format,value+this._minimumBoundaries);},maximumBoundary:function() |
{return this._maximumBoundaries;},minimumBoundary:function() |
{return this._minimumBoundaries;},zeroTime:function() |
{return 0;},boundarySpan:function() |
@@ -539,12 +527,13 @@ |
{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(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) |
-{var hue=(index*7+12*(index%2))%360;if(typeof sat!=="number") |
-sat=100;return{index:index,highlighted:"hsla("+hue+", "+sat+"%, 33%, 0.7)",normal:"hsla("+hue+", "+sat+"%, 66%, 0.7)"}}} |
+{this._colorPairs={};this._colorIndexes=[];this._currentColorIndex=0;this._colorPairForID("(idle)::0",50);this._colorPairForID("(program)::0",50);this._colorPairForID("(garbage collector)::0",50);} |
+WebInspector.FlameChart.ColorGenerator.prototype={_colorPairForID:function(id,sat) |
+{if(typeof sat!=="number") |
+sat=100;var colorPairs=this._colorPairs;var colorPair=colorPairs[id];if(!colorPair){colorPairs[id]=colorPair=this._createPair(this._currentColorIndex++,sat);this._colorIndexes[colorPair.index]=colorPair;} |
+return colorPair;},_colorPairForIndex:function(index) |
+{return this._colorIndexes[index];},_createPair:function(index,sat) |
+{var hue=(index*7+12*(index%2))%360;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) |
@@ -556,29 +545,19 @@ |
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);this._wasDragged=true;},_endCanvasDragging:function() |
{this._isDragging=false;},_calculateTimelineData:function() |
-{if(this._cpuProfileView.samples) |
-return this._calculateTimelineDataForSamples();if(this._timelineData) |
-return this._timelineData;if(!this._cpuProfileView.profileHead) |
-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;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,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 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;} |
+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 colorEntryIndexes=[];var maxDepth=5;var depth=0;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();maxDepth=Math.max(maxDepth,depth);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+=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;} |
+while(node){var colorPair=colorGenerator._colorPairForID(node.functionName+":"+node.url+":"+node.lineNumber);var indexesForColor=colorEntryIndexes[colorPair.index];if(!indexesForColor) |
+indexesForColor=colorEntryIndexes[colorPair.index]=[];var entry=new WebInspector.FlameChart.Entry(colorPair,depth,samplingInterval,sampleIndex*samplingInterval,node);indexesForColor.push(entries.length);entries.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) |
+this._maxStackDepth=Math.max(maxDepth,depth);var entryColorIndexes=new Uint16Array(entries.length);var entryLevels=new Uint8Array(entries.length);var entryTotalTimes=new Float32Array(entries.length);var entryOffsets=new Float32Array(entries.length);var entryTitles=new Array(entries.length);var entryDeoptFlags=new Uint8Array(entries.length);for(var i=0;i<entries.length;++i){var entry=entries[i];entryColorIndexes[i]=colorPair.index;entryLevels[i]=entry.depth;entryTotalTimes[i]=entry.duration;entryOffsets[i]=entry.startTime;entryTitles[i]=entry.node.functionName;var reason=entry.node.deoptReason;entryDeoptFlags[i]=(reason&&reason!=="no reason");} |
+this._timelineData={entries:entries,totalTime:this._cpuProfileView.profileHead.totalTime,entryColorIndexes:entryColorIndexes,entryLevels:entryLevels,entryTotalTimes:entryTotalTimes,entryOffsets:entryOffsets,colorEntryIndexes:colorEntryIndexes,entryTitles:entryTitles,entryDeoptFlags:entryDeoptFlags};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") |
@@ -607,31 +586,29 @@ |
return-1;},onResize:function() |
{this._updateOverviewCanvas=true;this._scheduleUpdate();},_drawOverviewCanvas:function(width,height) |
{if(!this._timelineData) |
-return;var timelineEntries=this._timelineData.entries;var drawData=new Uint8Array(width);var scaleFactor=width/this._totalTime;var maxStackDepth=5;for(var entryIndex=0;entryIndex<timelineEntries.length;++entryIndex){var entry=timelineEntries[entryIndex];var start=Math.floor(entry.startTime*scaleFactor);var finish=Math.floor((entry.startTime+entry.duration)*scaleFactor);for(var x=start;x<finish;++x){drawData[x]=Math.max(drawData[x],entry.depth+1);maxStackDepth=Math.max(maxStackDepth,entry.depth+1);}} |
-var ratio=window.devicePixelRatio;var canvasWidth=width*ratio;var canvasHeight=height*ratio;this._overviewCanvas.width=canvasWidth;this._overviewCanvas.height=canvasHeight;this._overviewCanvas.style.width=width+"px";this._overviewCanvas.style.height=height+"px";var context=this._overviewCanvas.getContext("2d");var yScaleFactor=canvasHeight/(maxStackDepth*1.1);context.lineWidth=1;context.translate(0.5,0.5);context.strokeStyle="rgba(20,0,0,0.4)";context.fillStyle="rgba(214,225,254,0.8)";context.moveTo(-1,canvasHeight-1);if(drawData) |
+return;var timelineEntries=this._timelineData.entries;var drawData=new Uint8Array(width);var scaleFactor=width/this._totalTime;for(var entryIndex=0;entryIndex<timelineEntries.length;++entryIndex){var entry=timelineEntries[entryIndex];var start=Math.floor(entry.startTime*scaleFactor);var finish=Math.floor((entry.startTime+entry.duration)*scaleFactor);for(var x=start;x<finish;++x) |
+drawData[x]=Math.max(drawData[x],entry.depth+1);} |
+var ratio=window.devicePixelRatio;var canvasWidth=width*ratio;var canvasHeight=height*ratio;this._overviewCanvas.width=canvasWidth;this._overviewCanvas.height=canvasHeight;this._overviewCanvas.style.width=width+"px";this._overviewCanvas.style.height=height+"px";var context=this._overviewCanvas.getContext("2d");var yScaleFactor=canvasHeight/(this._maxStackDepth*1.1);context.lineWidth=1;context.translate(0.5,0.5);context.strokeStyle="rgba(20,0,0,0.4)";context.fillStyle="rgba(214,225,254,0.8)";context.moveTo(-1,canvasHeight-1);if(drawData) |
context.lineTo(-1,Math.round(height-drawData[0]*yScaleFactor-1));var value;for(var x=0;x<width;++x){value=Math.round(canvasHeight-drawData[x]*yScaleFactor-1);context.lineTo(x*ratio,value);} |
-context.lineTo(canvasWidth+1,value);context.lineTo(canvasWidth+1,canvasHeight-1);context.fill();context.stroke();context.closePath();},_entryToAnchorBox:function(entry,anchorBox) |
-{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) |
+context.lineTo(canvasWidth+1,value);context.lineTo(canvasWidth+1,canvasHeight-1);context.fill();context.stroke();context.closePath();},draw:function(width,height) |
{var timelineData=this._calculateTimelineData();if(!timelineData) |
-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;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;} |
+return;var ratio=window.devicePixelRatio;this._canvas.width=width*ratio;this._canvas.height=height*ratio;this._canvas.style.width=width+"px";this._canvas.style.height=height+"px";var context=this._canvas.getContext("2d");context.scale(ratio,ratio);var timeWindowRight=this._timeWindowRight;var timeToPixel=this._timeToPixel;var pixelWindowLeft=this._pixelWindowLeft;var paddingLeft=this._paddingLeft;var minWidth=this._minWidth;var entryTotalTimes=this._timelineData.entryTotalTimes;var entryOffsets=this._timelineData.entryOffsets;var entryLevels=this._timelineData.entryLevels;var colorEntryIndexes=this._timelineData.colorEntryIndexes;var entryTitles=this._timelineData.entryTitles;var entryDeoptFlags=this._timelineData.entryDeoptFlags;var colorGenerator=WebInspector.FlameChart._colorGenerator;var titleIndexes=new Uint32Array(this._timelineData.entryTotalTimes);var lastTitleIndex=0;var dotsWidth=context.measureText("\u2026").width;var textPaddingLeft=2;this._minTextWidth=context.measureText("\u2026").width+textPaddingLeft;var minTextWidth=this._minTextWidth;var marksField=[];for(var i=0;i<this._maxStackDepth;++i) |
+marksField.push(new Uint16Array(width));var barHeight=this._barHeight;var barX=0;var barWidth=0;var barRight=0;var barLevel=0;var bHeight=height-barHeight;context.strokeStyle="black";var colorPair;var entryIndex=0;var entryOffset=0;for(var colorIndex=0;colorIndex<colorEntryIndexes.length;++colorIndex){colorPair=colorGenerator._colorPairForIndex(colorIndex);context.fillStyle=colorPair.normal;var indexes=colorEntryIndexes[colorIndex];if(!indexes) |
+continue;context.beginPath();for(var i=0;i<indexes.length;++i){entryIndex=indexes[i];entryOffset=entryOffsets[entryIndex];if(entryOffset>timeWindowRight) |
+break;barX=Math.ceil(entryOffset*timeToPixel)-pixelWindowLeft+paddingLeft;barRight=Math.floor((entryOffset+entryTotalTimes[entryIndex])*timeToPixel)-pixelWindowLeft+paddingLeft;if(barRight<0) |
+continue;barWidth=(barRight-barX)||minWidth;barLevel=entryLevels[entryIndex];var marksRow=marksField[barLevel];if(barWidth<=marksRow[barX]) |
+continue;marksRow[barX]=barWidth;if(entryIndex===this._highlightedEntryIndex){context.fill();context.beginPath();context.fillStyle=colorPair.highlighted;} |
+context.rect(barX,bHeight-barLevel*barHeight,barWidth,barHeight);if(entryIndex===this._highlightedEntryIndex){context.fill();context.beginPath();context.fillStyle=colorPair.normal;} |
+if(barWidth>minTextWidth) |
+titleIndexes[lastTitleIndex++]=entryIndex;} |
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) |
-maxTextWidth=Math.max(maxTextWidth,context.measureText(entryInfo[i].text).width);maxTextWidth=Math.min(maxTextWidth,width-2*paddingLeft-maxTitleWidth);context.beginPath();context.rect(x,y,maxTitleWidth+maxTextWidth+5,lineHeight*entryInfo.length+5);context.strokeStyle="rgba(0,0,0,0)";context.fillStyle="rgba(254,254,254,0.8)";context.fill();context.stroke();context.fillStyle="#333";for(var i=0;i<entryInfo.length;++i) |
-context.fillText(entryInfo[i].title,x+paddingLeft,y+lineHeight*i);context.font=basicFont;for(var i=0;i<entryInfo.length;++i){var text=this._prepareText(context,entryInfo[i].text,maxTextWidth);context.fillText(text,x+paddingLeft+maxTitleWidth+paddingLeft,y+lineHeight*i);}},_prepareText:function(context,title,maxSize) |
+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 textBaseHeight=bHeight+barHeight-4;for(var i=0;i<lastTitleIndex;++i){entryIndex=titleIndexes[i];if(isBoldFontSelected){if(!entryDeoptFlags[entryIndex]){context.font=font;isBoldFontSelected=false;}}else{if(entryDeoptFlags[entryIndex]){context.font=boldFont;isBoldFontSelected=true;}} |
+entryOffset=entryOffsets[entryIndex];barX=Math.floor(entryOffset*timeToPixel)-pixelWindowLeft+paddingLeft;barRight=Math.ceil((entryOffset+entryTotalTimes[entryIndex])*timeToPixel)-pixelWindowLeft+paddingLeft;barWidth=(barRight-barX)||minWidth;var xText=Math.max(0,barX);var widthText=barWidth-textPaddingLeft+barX-xText;var title=this._prepareText(context,entryTitles[entryIndex],widthText);if(title) |
+context.fillText(title,xText+textPaddingLeft,textBaseHeight-entryLevels[entryIndex]*barHeight);} |
+var entryInfo=this._prepareHighlightedEntryInfo();this._entryInfo.removeChildren();if(entryInfo) |
+this._entryInfo.appendChild(this._buildEntryInfo(entryInfo));},_buildEntryInfo:function(entryInfo) |
+{var infoTable=document.createElement("table");infoTable.className="info-table";for(var i=0;i<entryInfo.length;++i){var row=infoTable.createChild("tr");var titleCell=row.createChild("td");titleCell.textContent=entryInfo[i].title;titleCell.className="title";var textCell=row.createChild("td");textCell.textContent=entryInfo[i].text;} |
+return infoTable;},_prepareText:function(context,title,maxSize) |
{if(maxSize<this._dotsWidth) |
return null;var titleWidth=context.measureText(title).width;if(maxSize>titleWidth) |
return title;maxSize-=this._dotsWidth;var dotRegExp=/[\.\$]/g;var match=dotRegExp.exec(title);if(!match){var visiblePartSize=maxSize/titleWidth;var newTextLength=Math.floor(title.length*visiblePartSize)+1;var minTextLength=4;if(newTextLength<minTextLength) |
@@ -739,13 +716,13 @@ |
{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=[];} |
+{this.node_fields=[];this.node_types=[];this.edge_fields=[];this.edge_types=[];this.trace_function_info_fields=[];this.trace_node_fields=[];this.type_strings={};} |
function HeapSnapshotHeader() |
{this.title="";this.uid=0;this.meta=new HeapSnapshotMetainfo();this.node_count=0;this.edge_count=0;} |
WebInspector.HeapSnapshot.prototype={_init:function() |
{var meta=this._metaNode;this._nodeTypeOffset=meta.node_fields.indexOf("type");this._nodeNameOffset=meta.node_fields.indexOf("name");this._nodeIdOffset=meta.node_fields.indexOf("id");this._nodeSelfSizeOffset=meta.node_fields.indexOf("self_size");this._nodeEdgeCountOffset=meta.node_fields.indexOf("edge_count");this._nodeFieldCount=meta.node_fields.length;this._nodeTypes=meta.node_types[this._nodeTypeOffset];this._nodeHiddenType=this._nodeTypes.indexOf("hidden");this._nodeObjectType=this._nodeTypes.indexOf("object");this._nodeNativeType=this._nodeTypes.indexOf("native");this._nodeConsStringType=this._nodeTypes.indexOf("concatenated string");this._nodeSlicedStringType=this._nodeTypes.indexOf("sliced string");this._nodeCodeType=this._nodeTypes.indexOf("code");this._nodeSyntheticType=this._nodeTypes.indexOf("synthetic");this._edgeFieldsCount=meta.edge_fields.length;this._edgeTypeOffset=meta.edge_fields.indexOf("type");this._edgeNameOffset=meta.edge_fields.indexOf("name_or_index");this._edgeToNodeOffset=meta.edge_fields.indexOf("to_node");this._edgeTypes=meta.edge_types[this._edgeTypeOffset];this._edgeTypes.push("invisible");this._edgeElementType=this._edgeTypes.indexOf("element");this._edgeHiddenType=this._edgeTypes.indexOf("hidden");this._edgeInternalType=this._edgeTypes.indexOf("internal");this._edgeShortcutType=this._edgeTypes.indexOf("shortcut");this._edgeWeakType=this._edgeTypes.indexOf("weak");this._edgeInvisibleType=this._edgeTypes.indexOf("invisible");this.nodeCount=this._nodes.length/this._nodeFieldCount;this._edgeCount=this._containmentEdges.length/this._edgeFieldsCount;this._progress.updateStatus("Building edge indexes\u2026");this._buildEdgeIndexes();this._progress.updateStatus("Marking invisible edges\u2026");this._markInvisibleEdges();this._progress.updateStatus("Building retainers\u2026");this._buildRetainers();this._progress.updateStatus("Calculating node flags\u2026");this._calculateFlags();this._progress.updateStatus("Calculating distances\u2026");this._calculateDistances();this._progress.updateStatus("Building postorder index\u2026");var result=this._buildPostOrderIndex();this._progress.updateStatus("Building dominator tree\u2026");this._dominatorsTree=this._buildDominatorTree(result.postOrderIndex2NodeOrdinal,result.nodeOrdinal2PostOrderIndex);this._progress.updateStatus("Calculating retained sizes\u2026");this._calculateRetainedSizes(result.postOrderIndex2NodeOrdinal);this._progress.updateStatus("Buiding dominated nodes\u2026");this._buildDominatedNodes();this._progress.updateStatus("Finished processing.");},_buildEdgeIndexes:function() |
{var 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) |
+{var retainingNodes=this._retainingNodes=new Uint32Array(this._edgeCount);var retainingEdges=this._retainingEdges=new Uint32Array(this._edgeCount);var firstRetainerIndex=this._firstRetainerIndex=new Uint32Array(this.nodeCount+1);var containmentEdges=this._containmentEdges;var edgeFieldsCount=this._edgeFieldsCount;var nodeFieldCount=this._nodeFieldCount;var edgeToNodeOffset=this._edgeToNodeOffset;var firstEdgeIndexes=this._firstEdgeIndexes;var nodeCount=this.nodeCount;for(var toNodeFieldIndex=edgeToNodeOffset,l=containmentEdges.length;toNodeFieldIndex<l;toNodeFieldIndex+=edgeFieldsCount){var toNodeIndex=containmentEdges[toNodeFieldIndex];if(toNodeIndex%nodeFieldCount) |
throw new Error("Invalid toNodeIndex "+toNodeIndex);++firstRetainerIndex[toNodeIndex/nodeFieldCount];} |
for(var i=0,firstUnusedRetainerSlot=0;i<nodeCount;i++){var retainersCount=firstRetainerIndex[i];firstRetainerIndex[i]=firstUnusedRetainerSlot;retainingNodes[firstUnusedRetainerSlot]=retainersCount;firstUnusedRetainerSlot+=retainersCount;} |
firstRetainerIndex[nodeCount]=retainingNodes.length;var nextNodeFirstEdgeIndex=firstEdgeIndexes[0];for(var srcNodeOrdinal=0;srcNodeOrdinal<nodeCount;++srcNodeOrdinal){var firstEdgeIndex=nextNodeFirstEdgeIndex;nextNodeFirstEdgeIndex=firstEdgeIndexes[srcNodeOrdinal+1];var srcNodeIndex=srcNodeOrdinal*nodeFieldCount;for(var edgeIndex=firstEdgeIndex;edgeIndex<nextNodeFirstEdgeIndex;edgeIndex+=edgeFieldsCount){var toNodeIndex=containmentEdges[edgeIndex+edgeToNodeOffset];if(toNodeIndex%nodeFieldCount) |
@@ -782,7 +759,7 @@ |
{var ordinal=node._ordinal();if(distances[ordinal]!==noDistance) |
return;distances[ordinal]=0;nodesToVisit[nodesToVisitLength++]=node.nodeIndex;} |
this.forEachRoot(enqueueNode,true);this._bfs(nodesToVisit,nodesToVisitLength,distances);nodesToVisitLength=0;this.forEachRoot(enqueueNode);this._bfs(nodesToVisit,nodesToVisitLength,distances);this._nodeDistances=distances;},_bfs:function(nodesToVisit,nodesToVisitLength,distances) |
-{var edgeFieldsCount=this._edgeFieldsCount;var nodeFieldCount=this._nodeFieldCount;var containmentEdges=this._containmentEdges;var firstEdgeIndexes=this._firstEdgeIndexes;var edgeToNodeOffset=this._edgeToNodeOffset;var edgeTypeOffset=this._edgeTypeOffset;var nodes=this._nodes;var nodeCount=this.nodeCount;var containmentEdgesLength=containmentEdges.length;var edgeWeakType=this._edgeWeakType;var noDistance=this._noDistance;var index=0;while(index<nodesToVisitLength){var nodeIndex=nodesToVisit[index++];var nodeOrdinal=nodeIndex/nodeFieldCount;var distance=distances[nodeOrdinal]+1;var firstEdgeIndex=firstEdgeIndexes[nodeOrdinal];var edgesEnd=firstEdgeIndexes[nodeOrdinal+1];for(var edgeIndex=firstEdgeIndex;edgeIndex<edgesEnd;edgeIndex+=edgeFieldsCount){var edgeType=containmentEdges[edgeIndex+edgeTypeOffset];if(edgeType==edgeWeakType) |
+{var edgeFieldsCount=this._edgeFieldsCount;var nodeFieldCount=this._nodeFieldCount;var containmentEdges=this._containmentEdges;var firstEdgeIndexes=this._firstEdgeIndexes;var edgeToNodeOffset=this._edgeToNodeOffset;var edgeTypeOffset=this._edgeTypeOffset;var nodeCount=this.nodeCount;var containmentEdgesLength=containmentEdges.length;var edgeWeakType=this._edgeWeakType;var noDistance=this._noDistance;var index=0;while(index<nodesToVisitLength){var nodeIndex=nodesToVisit[index++];var nodeOrdinal=nodeIndex/nodeFieldCount;var distance=distances[nodeOrdinal]+1;var firstEdgeIndex=firstEdgeIndexes[nodeOrdinal];var edgesEnd=firstEdgeIndexes[nodeOrdinal+1];for(var edgeIndex=firstEdgeIndex;edgeIndex<edgesEnd;edgeIndex+=edgeFieldsCount){var edgeType=containmentEdges[edgeIndex+edgeTypeOffset];if(edgeType==edgeWeakType) |
continue;var childNodeIndex=containmentEdges[edgeIndex+edgeToNodeOffset];var childNodeOrdinal=childNodeIndex/nodeFieldCount;if(distances[childNodeOrdinal]!==noDistance) |
continue;distances[childNodeOrdinal]=distance;nodesToVisit[nodesToVisitLength++]=childNodeIndex;}} |
if(nodesToVisitLength>nodeCount) |
@@ -1068,17 +1045,25 @@ |
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.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);} |
+{var columns=[{id:"count",title:WebInspector.UIString("Count"),width:"72px",sortable:true,sort:WebInspector.DataGrid.Order.Descending},{id:"size",title:WebInspector.UIString("Size"),width:"72px",sortable:true,sort:WebInspector.DataGrid.Order.Descending},{id:"name",title:WebInspector.UIString("Function"),disclosure:true,sortable:true},];WebInspector.DataGrid.call(this,columns);this._linkifier=new WebInspector.Linkifier();} |
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.DataGridNode.call(this,data,data.hasChildren);this._dataGrid=dataGrid;this._populated=false;} |
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) |
+{if(this._populated) |
+return;this._populated=true;this._dataGrid._snapshot.allocationNodeCallers(this.data.id,didReceiveCallers.bind(this));function didReceiveCallers(callers) |
+{var callersChain=callers.nodesWithSingleCaller;var parentNode=this;for(var i=0;i<callersChain.length;i++){var child=new WebInspector.AllocationGridNode(this._dataGrid,callersChain[i]);parentNode.appendChild(child);parentNode=child;parentNode._populated=true;if(this.expanded) |
+parentNode.expand();} |
+var callersBranch=callers.branchingCallers;for(var i=0;i<callersBranch.length;i++) |
+parentNode.appendChild(new WebInspector.AllocationGridNode(this._dataGrid,callersBranch[i]));}},expand:function() |
+{WebInspector.DataGridNode.prototype.expand.call(this);if(this.children.length===1) |
+this.children[0].expand();},createCell:function(columnIdentifier) |
+{var cell=WebInspector.DataGridNode.prototype.createCell.call(this,columnIdentifier);if(columnIdentifier!=="name") |
+return cell;var functionInfo=this.data;if(functionInfo.scriptName){var urlElement=this._dataGrid._linkifier.linkifyLocation(functionInfo.scriptName,functionInfo.line-1,functionInfo.column-1,"profile-node-file");urlElement.style.maxWidth="75%";cell.insertBefore(urlElement,cell.firstChild);} |
+return cell;},__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() |
@@ -1315,7 +1300,7 @@ |
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;} |
+return;this._json=this._json.slice(bracketIndex+1);var trace_function_info_field_count=this._snapshot.snapshot.meta.trace_function_info_fields.length;var trace_function_info_length=this._snapshot.snapshot.trace_function_count*trace_function_info_field_count;this._array=new Uint32Array(trace_function_info_length);this._arrayIndex=0;this._state="parse-trace-function-infos";break;} |
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) |
@@ -1420,7 +1405,8 @@ |
{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);},allocationTracesTops:function(callback) |
+{return this.callFactoryMethod(null,"createNodesProviderForDominator",WebInspector.HeapSnapshotProviderProxy,nodeIndex);},maxJsNodeId:function(callback) |
+{this.callMethod(callback,"maxJsNodeId");},allocationTracesTops:function(callback) |
{this.callMethod(callback,"allocationTracesTops");},allocationNodeCallers:function(nodeId,callback) |
{this.callMethod(callback,"allocationNodeCallers",nodeId);},dispose:function() |
{this.disposeWorker();},get nodeCount() |
@@ -1544,15 +1530,12 @@ |
{height=Number.constrain(height,Preferences.minConsoleHeight,this.element.clientHeight-Preferences.minConsoleHeight);this.viewsContainer.style.bottom=(height+this.retainmentViewHeader.clientHeight)+"px";if(this._trackingOverviewGrid&&this.currentView===this.constructorsView) |
this.viewsContainer.addStyleClass("reserve-80px-at-top");this.retainmentView.element.style.height=height+"px";this.retainmentViewHeader.style.bottom=height+"px";this.currentView.doResize();},_updateBaseOptions:function() |
{var list=this._profiles();if(this.baseSelect.size()===list.length) |
-return;for(var i=this.baseSelect.size(),n=list.length;i<n;++i){var title=list[i].title;if(WebInspector.ProfilesPanelDescriptor.isUserInitiatedProfile(title)) |
-title=WebInspector.UIString("Snapshot %d",WebInspector.ProfilesPanelDescriptor.userInitiatedProfileIndex(title));this.baseSelect.createOption(title);}},_updateFilterOptions:function() |
+return;for(var i=this.baseSelect.size(),n=list.length;i<n;++i){var title=list[i].title;this.baseSelect.createOption(title);}},_updateFilterOptions:function() |
{var list=this._profiles();if(this.filterSelect.size()-1===list.length) |
return;if(!this.filterSelect.size()) |
-this.filterSelect.createOption(WebInspector.UIString("All objects"));if(this.profile.fromFile()) |
-return;for(var i=this.filterSelect.size()-1,n=list.length;i<n;++i){var profile=list[i];var title=list[i].title;if(WebInspector.ProfilesPanelDescriptor.isUserInitiatedProfile(title)){var profileIndex=WebInspector.ProfilesPanelDescriptor.userInitiatedProfileIndex(title);if(!i) |
-title=WebInspector.UIString("Objects allocated before Snapshot %d",profileIndex);else |
-title=WebInspector.UIString("Objects allocated between Snapshots %d and %d",profileIndex-1,profileIndex);} |
-this.filterSelect.createOption(title);}},_onProfileHeaderAdded:function(event) |
+this.filterSelect.createOption(WebInspector.UIString("All objects"));for(var i=this.filterSelect.size()-1,n=list.length;i<n;++i){var title=list[i].title;if(!i) |
+title=WebInspector.UIString("Objects allocated before %s",title);else |
+title=WebInspector.UIString("Objects allocated between %s and %s",list[i-1].title,title);this.filterSelect.createOption(title);}},_onProfileHeaderAdded:function(event) |
{if(!event.data||event.data.type!==this._profileTypeId) |
return;this._updateBaseOptions();this._updateFilterOptions();},__proto__:WebInspector.View.prototype} |
WebInspector.HeapProfilerDispatcher=function() |
@@ -1564,8 +1547,7 @@ |
{this._genericCaller("heapStatsUpdate");},lastSeenObjectId:function(lastSeenObjectId,timestamp) |
{this._genericCaller("lastSeenObjectId");},addProfileHeader:function(profileHeader) |
{this._genericCaller("addProfileHeader");},addHeapSnapshotChunk:function(uid,chunk) |
-{this._genericCaller("addHeapSnapshotChunk");},finishHeapSnapshot:function(uid) |
-{this._genericCaller("finishHeapSnapshot");},reportHeapSnapshotProgress:function(done,total) |
+{this._genericCaller("addHeapSnapshotChunk");},reportHeapSnapshotProgress:function(done,total) |
{this._genericCaller("reportHeapSnapshotProgress");},resetProfiles:function() |
{this._genericCaller("resetProfiles");}} |
WebInspector.HeapProfilerDispatcher._dispatcher=new WebInspector.HeapProfilerDispatcher();WebInspector.HeapSnapshotProfileType=function() |
@@ -1586,15 +1568,12 @@ |
{if(!this.findTemporaryProfile()) |
return;var profile=this.createProfile(profileHeader);profile._profileSamples=this._profileSamples;this._profileSamples=null;this.addProfile(profile);},addHeapSnapshotChunk:function(uid,chunk) |
{var profile=this._profilesIdMap[this._makeKey(uid)];if(profile) |
-profile.transferChunk(chunk);},finishHeapSnapshot:function(uid) |
-{var profile=this._profilesIdMap[this._makeKey(uid)];if(profile) |
-profile.finishHeapSnapshot();},reportHeapSnapshotProgress:function(done,total) |
+profile.transferChunk(chunk);},reportHeapSnapshotProgress:function(done,total) |
{var profile=this.findTemporaryProfile();if(profile) |
this.dispatchEventToListeners(WebInspector.ProfileType.Events.ProgressUpdated,{"profile":profile,"done":done,"total":total});},resetProfiles:function() |
{this._reset();},removeProfile:function(profile) |
-{WebInspector.ProfileType.prototype.removeProfile.call(this,profile);if(!profile.isTemporary) |
-HeapProfilerAgent.removeProfile(profile.uid);},_requestProfilesFromBackend:function(populateCallback) |
-{HeapProfilerAgent.getProfileHeaders(populateCallback);},_snapshotReceived:function(profile) |
+{WebInspector.ProfileType.prototype.removeProfile.call(this,profile);if(!profile.isTemporary&&!profile.fromFile()) |
+HeapProfilerAgent.removeProfile(profile.uid);},_snapshotReceived:function(profile) |
{this.dispatchEventToListeners(WebInspector.HeapSnapshotProfileType.SnapshotReceived,profile);},__proto__:WebInspector.ProfileType.prototype} |
WebInspector.TrackingHeapSnapshotProfileType=function(profilesPanel) |
{WebInspector.ProfileType.call(this,WebInspector.TrackingHeapSnapshotProfileType.TypeId,WebInspector.UIString("Record Heap Allocations"));this._profilesPanel=profilesPanel;WebInspector.HeapProfilerDispatcher._dispatcher.register(this);} |
@@ -1621,8 +1600,7 @@ |
{return WebInspector.UIString("Record JavaScript object allocations over time. Use this profile type to isolate memory leaks.");},_reset:function() |
{WebInspector.HeapSnapshotProfileType.prototype._reset.call(this);if(this._recording) |
this._stopRecordingProfile();this._profileSamples=null;this._lastSeenIndex=-1;},createTemporaryProfile:function(title) |
-{title=title||WebInspector.UIString("Recording\u2026");return new WebInspector.HeapProfileHeader(this,title);},_requestProfilesFromBackend:function(populateCallback) |
-{},__proto__:WebInspector.HeapSnapshotProfileType.prototype} |
+{title=title||WebInspector.UIString("Recording\u2026");return new WebInspector.HeapProfileHeader(this,title);},__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;this._transferHandler=null;} |
WebInspector.HeapProfileHeader.prototype={createSidebarTreeElement:function() |
@@ -1630,9 +1608,11 @@ |
{return new WebInspector.HeapSnapshotView(profilesPanel,this);},load:function(callback) |
{if(this.uid===-1) |
return;if(this._snapshotProxy){callback(this._snapshotProxy);return;} |
-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() |
+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._transferSnapshot();} |
+var loaderProxy=(this._receiver);loaderProxy.addConsumer(callback);},_transferSnapshot:function() |
+{function finishTransfer() |
+{if(this._transferHandler){this._transferHandler.finishTransfer();this._totalNumberOfChunks=this._transferHandler._totalNumberOfChunks;}} |
+HeapProfilerAgent.getHeapSnapshot(this.uid,finishTransfer.bind(this));},snapshotConstructorName:function() |
{return"JSHeapSnapshot";},snapshotProxyConstructor:function() |
{return WebInspector.HeapSnapshotProxy;},_setupWorker:function() |
{function setProfileWait(event) |
@@ -1647,15 +1627,16 @@ |
{this.sidebarElement.subtitle=Number.bytesToString(this._snapshotProxy.totalSize);this.sidebarElement.wait=false;},transferChunk:function(chunk) |
{this._transferHandler.transferChunk(chunk);},_snapshotReceived:function(snapshotProxy) |
{this._receiver=null;if(snapshotProxy) |
-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() |
-{if(this._transferHandler){this._transferHandler.finishTransfer();this._totalNumberOfChunks=this._transferHandler._totalNumberOfChunks;}},_wasShown:function() |
+this._snapshotProxy=snapshotProxy;this._didCompleteSnapshotTransfer();var worker=(this._snapshotProxy.worker);this.isTemporary=false;worker.startCheckingForLongRunningCalls();this.notifySnapshotReceived();if(this.fromFile()){function didGetMaxNodeId(id) |
+{this.maxJSObjectId=id;} |
+snapshotProxy.maxJsNodeId(didGetMaxNodeId.bind(this));}},notifySnapshotReceived:function() |
+{this._profileType._snapshotReceived(this);},_wasShown:function() |
{},canSaveToFile:function() |
{return!this.fromFile()&&!!this._snapshotProxy&&!this._receiver;},saveToFile:function() |
{var fileOutputStream=new WebInspector.FileOutputStream();function onOpen() |
-{this._receiver=fileOutputStream;this._transferHandler=new WebInspector.SaveSnapshotHandler(this);HeapProfilerAgent.getHeapSnapshot(this.uid);} |
+{this._receiver=fileOutputStream;this._transferHandler=new WebInspector.SaveSnapshotHandler(this);this._transferSnapshot();} |
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) |
+{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;} |
@@ -1694,7 +1675,7 @@ |
callback(currentX,size);} |
function maxSizeCallback(x,size) |
{maxSize=Math.max(maxSize,size);} |
-aggregateAndCall(sizes,maxSizeCallback);var yScaleFactor=this._yScale.nextScale(maxSize?height/(maxSize*1.1):0.0);this._overviewCanvas.width=width*window.devicePixelRatio;this._overviewCanvas.height=height*window.devicePixelRatio;this._overviewCanvas.style.width=width+"px";this._overviewCanvas.style.height=height+"px";var context=this._overviewCanvas.getContext("2d");context.scale(window.devicePixelRatio,window.devicePixelRatio);context.beginPath();context.lineWidth=2;context.strokeStyle="rgba(192, 192, 192, 0.6)";var currentX=(endTime-startTime)*scaleFactor;context.moveTo(currentX,height-1);context.lineTo(currentX,0);context.stroke();context.closePath();var gridY;var gridValue;var gridLabelHeight=14;if(yScaleFactor){const maxGridValue=(height-gridLabelHeight)/yScaleFactor;gridValue=Math.pow(1024,Math.floor(Math.log(maxGridValue)/Math.log(1024)));gridValue*=Math.pow(10,Math.floor(Math.log(maxGridValue/gridValue)/Math.log(10)));if(gridValue*5<=maxGridValue) |
+aggregateAndCall(sizes,maxSizeCallback);var yScaleFactor=this._yScale.nextScale(maxSize?height/(maxSize*1.1):0.0);this._overviewCanvas.width=width*window.devicePixelRatio;this._overviewCanvas.height=height*window.devicePixelRatio;this._overviewCanvas.style.width=width+"px";this._overviewCanvas.style.height=height+"px";var context=this._overviewCanvas.getContext("2d");context.scale(window.devicePixelRatio,window.devicePixelRatio);context.beginPath();context.lineWidth=2;context.strokeStyle="rgba(192, 192, 192, 0.6)";var currentX=(endTime-startTime)*scaleFactor;context.moveTo(currentX,height-1);context.lineTo(currentX,0);context.stroke();context.closePath();var gridY;var gridValue;var gridLabelHeight=14;if(yScaleFactor){const maxGridValue=(height-gridLabelHeight)/yScaleFactor;gridValue=Math.pow(1024,Math.floor(Math.log(maxGridValue)/Math.log(1024)));gridValue*=Math.pow(10,Math.floor(Math.log(maxGridValue/gridValue)/Math.LN10));if(gridValue*5<=maxGridValue) |
gridValue*=5;gridY=Math.round(height-gridValue*yScaleFactor-0.5)+0.5;context.beginPath();context.lineWidth=1;context.strokeStyle="rgba(0, 0, 0, 0.2)";context.moveTo(0,gridY);context.lineTo(width,gridY);context.stroke();context.closePath();} |
function drawBarCallback(x,size) |
{context.moveTo(x,height-1);context.lineTo(x,Math.round(height-size*yScaleFactor-1));} |
@@ -1740,7 +1721,11 @@ |
response.errorMethodName=data.methodName;} |
this._postMessage(response);}};;WebInspector.JSHeapSnapshot=function(profile,progress) |
{this._nodeFlags={canBeQueried:1,detachedDOMTreeNode:2,pageObject:4,visitedMarkerMask:0x0ffff,visitedMarker:0x10000};this._lazyStringCache={};WebInspector.HeapSnapshot.call(this,profile,progress);} |
-WebInspector.JSHeapSnapshot.prototype={createNode:function(nodeIndex) |
+WebInspector.JSHeapSnapshot.prototype={maxJsNodeId:function() |
+{var nodeFieldCount=this._nodeFieldCount;var nodes=this._nodes;var nodesLength=nodes.length;var id=0;for(var nodeIndex=this._nodeIdOffset;nodeIndex<nodesLength;nodeIndex+=nodeFieldCount){var nextId=nodes[nodeIndex];if(nextId%2===0) |
+continue;if(id<nodes[nodeIndex]) |
+id=nodes[nodeIndex];} |
+return id;},createNode:function(nodeIndex) |
{return new WebInspector.JSHeapSnapshotNode(this,nodeIndex);},createEdge:function(edges,edgeIndex) |
{return new WebInspector.JSHeapSnapshotEdge(this,edges,edgeIndex);},createRetainingEdge:function(retainedNodeIndex,retainerIndex) |
{return new WebInspector.JSHeapSnapshotRetainerEdge(this,retainedNodeIndex,retainerIndex);},classNodesFilter:function() |
@@ -1852,14 +1837,14 @@ |
{WebInspector.View.call(this);this._panel=profilesPanel;this.element.addStyleClass("profile-launcher-view");this.element.addStyleClass("panel-enabler-view");this._contentElement=this.element.createChild("div","profile-launcher-view-content");this._innerContentElement=this._contentElement.createChild("div");this._controlButton=this._contentElement.createChild("button","control-profiling");this._controlButton.addEventListener("click",this._controlButtonClicked.bind(this),false);} |
WebInspector.ProfileLauncherView.prototype={addProfileType:function(profileType) |
{var descriptionElement=this._innerContentElement.createChild("h1");descriptionElement.textContent=profileType.description;var decorationElement=profileType.decorationElement();if(decorationElement) |
-this._innerContentElement.appendChild(decorationElement);this._isInstantProfile=profileType.isInstantProfile();this._isEnabled=profileType.isEnabled();},_controlButtonClicked:function() |
+this._innerContentElement.appendChild(decorationElement);this._isInstantProfile=profileType.isInstantProfile();this._isEnabled=profileType.isEnabled();this._profileTypeId=profileType.id;},_controlButtonClicked:function() |
{this._panel.toggleRecordButton();},_updateControls:function() |
{if(this._isEnabled) |
this._controlButton.removeAttribute("disabled");else |
this._controlButton.setAttribute("disabled","");if(this._isInstantProfile){this._controlButton.removeStyleClass("running");this._controlButton.textContent=WebInspector.UIString("Take Snapshot");}else if(this._isProfiling){this._controlButton.addStyleClass("running");this._controlButton.textContent=WebInspector.UIString("Stop");}else{this._controlButton.removeStyleClass("running");this._controlButton.textContent=WebInspector.UIString("Start");}},profileStarted:function() |
-{this._isProfiling=true;this._updateControls();},profileFinished:function() |
-{this._isProfiling=false;this._updateControls();},updateProfileType:function(profileType) |
-{this._isInstantProfile=profileType.isInstantProfile();this._isEnabled=profileType.isEnabled();this._updateControls();},__proto__:WebInspector.View.prototype} |
+{this._isProfiling=true;WebInspector.profileManager.notifyStarted(this._profileTypeId);this._updateControls();},profileFinished:function() |
+{this._isProfiling=false;WebInspector.profileManager.notifyStoped(this._profileTypeId);this._updateControls();},updateProfileType:function(profileType) |
+{this._isInstantProfile=profileType.isInstantProfile();this._isEnabled=profileType.isEnabled();this._profileTypeId=profileType.id;this._updateControls();},__proto__:WebInspector.View.prototype} |
WebInspector.MultiProfileLauncherView=function(profilesPanel) |
{WebInspector.ProfileLauncherView.call(this,profilesPanel);var header=this._innerContentElement.createChild("h1");header.textContent=WebInspector.UIString("Select profiling type");this._profileTypeSelectorForm=this._innerContentElement.createChild("form");this._innerContentElement.createChild("div","flexible-space");} |
WebInspector.MultiProfileLauncherView.EventTypes={ProfileTypeSelected:"profile-type-selected"} |
@@ -1870,9 +1855,9 @@ |
{this._panel.toggleRecordButton();},_updateControls:function() |
{WebInspector.ProfileLauncherView.prototype._updateControls.call(this);var items=this._profileTypeSelectorForm.elements;for(var i=0;i<items.length;++i){if(items[i].type==="radio") |
items[i].disabled=this._isProfiling;}},_profileTypeChanged:function(profileType,event) |
-{this.dispatchEventToListeners(WebInspector.MultiProfileLauncherView.EventTypes.ProfileTypeSelected,profileType);this._isInstantProfile=profileType.isInstantProfile();this._isEnabled=profileType.isEnabled();this._updateControls();},profileStarted:function() |
-{this._isProfiling=true;this._updateControls();},profileFinished:function() |
-{this._isProfiling=false;this._updateControls();},__proto__:WebInspector.ProfileLauncherView.prototype};WebInspector.TopDownProfileDataGridNode=function(profileNode,owningTree) |
+{this.dispatchEventToListeners(WebInspector.MultiProfileLauncherView.EventTypes.ProfileTypeSelected,profileType);this._isInstantProfile=profileType.isInstantProfile();this._isEnabled=profileType.isEnabled();this._profileTypeId=profileType.id;this._updateControls();},profileStarted:function() |
+{this._isProfiling=true;WebInspector.profileManager.notifyStarted(this._profileTypeId);this._updateControls();},profileFinished:function() |
+{this._isProfiling=false;WebInspector.profileManager.notifyStoped(this._profileTypeId);this._updateControls();},__proto__:WebInspector.ProfileLauncherView.prototype};WebInspector.TopDownProfileDataGridNode=function(profileNode,owningTree) |
{var hasChildren=!!(profileNode.children&&profileNode.children.length);WebInspector.ProfileDataGridNode.call(this,profileNode,owningTree,hasChildren);this._remainingChildren=profileNode.children;} |
WebInspector.TopDownProfileDataGridNode.prototype={_sharedPopulate:function() |
{var children=this._remainingChildren;var childrenLength=children.length;for(var i=0;i<childrenLength;++i) |
@@ -1891,7 +1876,7 @@ |
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.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.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("img","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() |