summaryrefslogtreecommitdiffstats
path: root/webkit/glue/devtools
diff options
context:
space:
mode:
authorpfeldman@chromium.org <pfeldman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-05-14 15:26:53 +0000
committerpfeldman@chromium.org <pfeldman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-05-14 15:26:53 +0000
commita68b966e94845efaa30dae71f4ca7c324eba57b9 (patch)
treef7d9d85bd5e541aa504a64e5338da84b81d4b889 /webkit/glue/devtools
parent96649a0f3cafe764eb191532f635d99c234ea005 (diff)
downloadchromium_src-a68b966e94845efaa30dae71f4ca7c324eba57b9.zip
chromium_src-a68b966e94845efaa30dae71f4ca7c324eba57b9.tar.gz
chromium_src-a68b966e94845efaa30dae71f4ca7c324eba57b9.tar.bz2
DevTools: save time on line lookup in l10n error report.
Review URL: http://codereview.chromium.org/113401 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@16057 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/glue/devtools')
-rw-r--r--webkit/glue/devtools/js/debugger_agent.js104
-rw-r--r--webkit/glue/devtools/js/devtools.html14
-rw-r--r--webkit/glue/devtools/js/devtools.js226
-rw-r--r--webkit/glue/devtools/js/devtools_host_stub.js60
-rw-r--r--webkit/glue/devtools/js/inspector_controller.js6
-rw-r--r--webkit/glue/devtools/js/inspector_controller_impl.js30
-rw-r--r--webkit/glue/devtools/js/profiler_processor.js402
7 files changed, 426 insertions, 416 deletions
diff --git a/webkit/glue/devtools/js/debugger_agent.js b/webkit/glue/devtools/js/debugger_agent.js
index 2f5bb3d..17308c4 100644
--- a/webkit/glue/devtools/js/debugger_agent.js
+++ b/webkit/glue/devtools/js/debugger_agent.js
@@ -17,8 +17,8 @@ devtools.DebuggerAgent = function() {
goog.bind(this.handleDebuggerOutput_, this);
RemoteDebuggerAgent.DidGetContextId =
goog.bind(this.didGetContextId_, this);
- RemoteDebuggerAgent.DidGetLogLines =
- goog.bind(this.didGetLogLines_, this);
+ RemoteDebuggerAgent.DidGetLogLines =
+ goog.bind(this.didGetLogLines_, this);
/**
* Id of the inspected page global context. It is used for filtering scripts.
@@ -71,18 +71,18 @@ devtools.DebuggerAgent = function() {
* profiler's log.
* @type {boolean}
*/
- this.isProcessingProfile_ = false;
-
- /**
- * The position in log file to read from.
- * @type {number}
- */
- this.lastProfileLogPosition_ = 0;
-
- /**
- * Profiler processor instance.
- * @type {devtools.profiler.Processor}
- */
+ this.isProcessingProfile_ = false;
+
+ /**
+ * The position in log file to read from.
+ * @type {number}
+ */
+ this.lastProfileLogPosition_ = 0;
+
+ /**
+ * Profiler processor instance.
+ * @type {devtools.profiler.Processor}
+ */
this.profilerProcessor_ = new devtools.profiler.Processor();
};
@@ -245,7 +245,7 @@ devtools.DebuggerAgent.prototype.pauseOnExceptions = function() {
* @param {boolean} value True iff execution should be stopped in the debugger
* on the exceptions.
*/
-devtools.DebuggerAgent.prototype.setPauseOnExceptions = function(value) {
+devtools.DebuggerAgent.prototype.setPauseOnExceptions = function(value) {
this.pauseOnExceptions_ = value;
};
@@ -310,24 +310,24 @@ devtools.DebuggerAgent.prototype.resolveChildren = function(object, callback) {
/**
* Starts (resumes) profiling.
*/
-devtools.DebuggerAgent.prototype.startProfiling = function() {
- if (this.isProcessingProfile_) {
- return;
- }
- RemoteDebuggerAgent.StartProfiling();
- RemoteDebuggerAgent.GetLogLines(this.lastProfileLogPosition_);
- WebInspector.setRecordingProfile(true);
-};
-
-
+devtools.DebuggerAgent.prototype.startProfiling = function() {
+ if (this.isProcessingProfile_) {
+ return;
+ }
+ RemoteDebuggerAgent.StartProfiling();
+ RemoteDebuggerAgent.GetLogLines(this.lastProfileLogPosition_);
+ WebInspector.setRecordingProfile(true);
+};
+
+
/**
* Stops (pauses) profiling.
*/
-devtools.DebuggerAgent.prototype.stopProfiling = function() {
- this.isProcessingProfile_ = true;
- RemoteDebuggerAgent.StopProfiling();
-};
-
+devtools.DebuggerAgent.prototype.stopProfiling = function() {
+ this.isProcessingProfile_ = true;
+ RemoteDebuggerAgent.StopProfiling();
+};
+
/**
* Removes specified breakpoint from the v8 debugger.
@@ -562,28 +562,28 @@ devtools.DebuggerAgent.prototype.handleAfterCompileEvent_ = function(msg) {
}
this.addScriptInfo_(script);
};
-
-
-/**
- * Handles a portion of a profiler log retrieved by GetLogLines call.
- * @param {string} log A portion of profiler log.
- * @param {number} newPosition The position in log file to read from
- * next time.
- */
-devtools.DebuggerAgent.prototype.didGetLogLines_ = function(
- log, newPosition) {
- if (log.length > 0) {
- this.profilerProcessor_.processLogChunk(log);
- this.lastProfileLogPosition_ = newPosition;
- } else if (this.isProcessingProfile_) {
- this.isProcessingProfile_ = false;
- WebInspector.setRecordingProfile(false);
- WebInspector.addProfile(this.profilerProcessor_.createProfileForView());
- return;
- }
- setTimeout(function() { RemoteDebuggerAgent.GetLogLines(newPosition); },
- this.isProcessingProfile_ ? 100 : 1000);
-};
+
+
+/**
+ * Handles a portion of a profiler log retrieved by GetLogLines call.
+ * @param {string} log A portion of profiler log.
+ * @param {number} newPosition The position in log file to read from
+ * next time.
+ */
+devtools.DebuggerAgent.prototype.didGetLogLines_ = function(
+ log, newPosition) {
+ if (log.length > 0) {
+ this.profilerProcessor_.processLogChunk(log);
+ this.lastProfileLogPosition_ = newPosition;
+ } else if (this.isProcessingProfile_) {
+ this.isProcessingProfile_ = false;
+ WebInspector.setRecordingProfile(false);
+ WebInspector.addProfile(this.profilerProcessor_.createProfileForView());
+ return;
+ }
+ setTimeout(function() { RemoteDebuggerAgent.GetLogLines(newPosition); },
+ this.isProcessingProfile_ ? 100 : 1000);
+};
/**
diff --git a/webkit/glue/devtools/js/devtools.html b/webkit/glue/devtools/js/devtools.html
index 24615d3..5fd2c60 100644
--- a/webkit/glue/devtools/js/devtools.html
+++ b/webkit/glue/devtools/js/devtools.html
@@ -54,13 +54,13 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
<script type="text/javascript" src="inspector_controller.js"></script>
<script type="text/javascript" src="inspector_controller_impl.js"></script>
<script type="text/javascript" src="inspector.js"></script>
- <script type="text/javascript" src="codemap.js"></script>
- <script type="text/javascript" src="consarray.js"></script>
- <script type="text/javascript" src="csvparser.js"></script>
- <script type="text/javascript" src="profile.js"></script>
- <script type="text/javascript" src="profile_view.js"></script>
- <script type="text/javascript" src="profiler_processor.js"></script>
- <script type="text/javascript" src="splaytree.js"></script>
+ <script type="text/javascript" src="codemap.js"></script>
+ <script type="text/javascript" src="consarray.js"></script>
+ <script type="text/javascript" src="csvparser.js"></script>
+ <script type="text/javascript" src="profile.js"></script>
+ <script type="text/javascript" src="profile_view.js"></script>
+ <script type="text/javascript" src="profiler_processor.js"></script>
+ <script type="text/javascript" src="splaytree.js"></script>
<script type="text/javascript" src="Object.js"></script>
<script type="text/javascript" src="TextPrompt.js"></script>
<script type="text/javascript" src="Placard.js"></script>
diff --git a/webkit/glue/devtools/js/devtools.js b/webkit/glue/devtools/js/devtools.js
index 22d639a..70b8bba 100644
--- a/webkit/glue/devtools/js/devtools.js
+++ b/webkit/glue/devtools/js/devtools.js
@@ -615,7 +615,7 @@ WebInspector.ScopeChainSidebarPane.TreeElement.prototype.didResolveChildren_ =
};
-/**
+/**
* @override
*/
WebInspector.StylePropertyTreeElement.prototype.toggleEnabled =
@@ -715,110 +715,120 @@ WebInspector.Console.prototype._evalInInspectedWindow = function(expression) {
})();
-/**
- * We don't use WebKit's BottomUpProfileDataGridTree, instead using
- * our own (because BottomUpProfileDataGridTree's functionality is
- * implemented in profile_view.js for V8's Tick Processor).
- *
- * @param {WebInspector.ProfileView} profileView Profile view.
- * @param {devtools.profiler.ProfileView} profile Profile.
- */
-WebInspector.BottomUpProfileDataGridTree = function(profileView, profile) {
- return WebInspector.buildProfileDataGridTree_(
- profileView, profile.heavyProfile);
-};
-
-
-/**
- * We don't use WebKit's TopDownProfileDataGridTree, instead using
- * our own (because TopDownProfileDataGridTree's functionality is
- * implemented in profile_view.js for V8's Tick Processor).
- *
- * @param {WebInspector.ProfileView} profileView Profile view.
- * @param {devtools.profiler.ProfileView} profile Profile.
- */
-WebInspector.TopDownProfileDataGridTree = function(profileView, profile) {
- return WebInspector.buildProfileDataGridTree_(
- profileView, profile.treeProfile);
-};
-
-
-/**
- * A helper function, checks whether a profile node has visible children.
- *
- * @param {devtools.profiler.ProfileView.Node} profileNode Profile node.
- * @return {boolean} Whether a profile node has visible children.
- */
-WebInspector.nodeHasChildren_ = function(profileNode) {
- var children = profileNode.children;
- for (var i = 0, n = children.length; i < n; ++i) {
- if (children[i].visible) {
- return true;
- }
- }
- return false;
-};
-
-
-/**
- * Common code for populating a profiler grid node or a tree with
- * given profile nodes.
- *
- * @param {WebInspector.ProfileDataGridNode|
- * WebInspector.ProfileDataGridTree} viewNode Grid node or a tree.
- * @param {WebInspector.ProfileView} profileView Profile view.
- * @param {Array<devtools.profiler.ProfileView.Node>} children Profile nodes.
- * @param {WebInspector.ProfileDataGridTree} owningTree Grid tree.
- */
-WebInspector.populateNode_ = function(
- viewNode, profileView, children, owningTree) {
- for (var i = 0, n = children.length; i < n; ++i) {
- var child = children[i];
- if (child.visible) {
- viewNode.appendChild(
- new WebInspector.ProfileDataGridNode(
- profileView, child, owningTree,
- WebInspector.nodeHasChildren_(child)));
- }
- }
-};
-
-
-/**
- * A helper function for building a profile grid tree.
- *
- * @param {WebInspector.ProfileView} profileview Profile view.
- * @param {devtools.profiler.ProfileView} profile Profile.
- * @return {WebInspector.ProfileDataGridTree} Profile grid tree.
- */
-WebInspector.buildProfileDataGridTree_ = function(profileView, profile) {
- var children = profile.head.children;
- var dataGridTree = new WebInspector.ProfileDataGridTree(
- profileView, profile.head);
- WebInspector.populateNode_(dataGridTree, profileView, children, dataGridTree);
- return dataGridTree;
-};
-
-
-/**
- * @override
- */
-WebInspector.ProfileDataGridNode.prototype._populate = function(event) {
- var children = this.profileNode.children;
- WebInspector.populateNode_(this, this.profileView, children, this.tree);
- this.removeEventListener("populate", this._populate, this);
-};
-
-
-// As columns in data grid can't be changed after initialization,
-// we need to intercept the constructor and modify columns upon creation.
-(function InterceptDataGridForProfiler() {
- var originalDataGrid = WebInspector.DataGrid;
- WebInspector.DataGrid = function(columns) {
- if (('average' in columns) && ('calls' in columns)) {
- delete columns['average'];
- delete columns['calls'];
- }
- return new originalDataGrid(columns);
- };
-})();
+/**
+ * We don't use WebKit's BottomUpProfileDataGridTree, instead using
+ * our own (because BottomUpProfileDataGridTree's functionality is
+ * implemented in profile_view.js for V8's Tick Processor).
+ *
+ * @param {WebInspector.ProfileView} profileView Profile view.
+ * @param {devtools.profiler.ProfileView} profile Profile.
+ */
+WebInspector.BottomUpProfileDataGridTree = function(profileView, profile) {
+ return WebInspector.buildProfileDataGridTree_(
+ profileView, profile.heavyProfile);
+};
+
+
+/**
+ * We don't use WebKit's TopDownProfileDataGridTree, instead using
+ * our own (because TopDownProfileDataGridTree's functionality is
+ * implemented in profile_view.js for V8's Tick Processor).
+ *
+ * @param {WebInspector.ProfileView} profileView Profile view.
+ * @param {devtools.profiler.ProfileView} profile Profile.
+ */
+WebInspector.TopDownProfileDataGridTree = function(profileView, profile) {
+ return WebInspector.buildProfileDataGridTree_(
+ profileView, profile.treeProfile);
+};
+
+
+/**
+ * A helper function, checks whether a profile node has visible children.
+ *
+ * @param {devtools.profiler.ProfileView.Node} profileNode Profile node.
+ * @return {boolean} Whether a profile node has visible children.
+ */
+WebInspector.nodeHasChildren_ = function(profileNode) {
+ var children = profileNode.children;
+ for (var i = 0, n = children.length; i < n; ++i) {
+ if (children[i].visible) {
+ return true;
+ }
+ }
+ return false;
+};
+
+
+/**
+ * Common code for populating a profiler grid node or a tree with
+ * given profile nodes.
+ *
+ * @param {WebInspector.ProfileDataGridNode|
+ * WebInspector.ProfileDataGridTree} viewNode Grid node or a tree.
+ * @param {WebInspector.ProfileView} profileView Profile view.
+ * @param {Array<devtools.profiler.ProfileView.Node>} children Profile nodes.
+ * @param {WebInspector.ProfileDataGridTree} owningTree Grid tree.
+ */
+WebInspector.populateNode_ = function(
+ viewNode, profileView, children, owningTree) {
+ for (var i = 0, n = children.length; i < n; ++i) {
+ var child = children[i];
+ if (child.visible) {
+ viewNode.appendChild(
+ new WebInspector.ProfileDataGridNode(
+ profileView, child, owningTree,
+ WebInspector.nodeHasChildren_(child)));
+ }
+ }
+};
+
+
+/**
+ * A helper function for building a profile grid tree.
+ *
+ * @param {WebInspector.ProfileView} profileview Profile view.
+ * @param {devtools.profiler.ProfileView} profile Profile.
+ * @return {WebInspector.ProfileDataGridTree} Profile grid tree.
+ */
+WebInspector.buildProfileDataGridTree_ = function(profileView, profile) {
+ var children = profile.head.children;
+ var dataGridTree = new WebInspector.ProfileDataGridTree(
+ profileView, profile.head);
+ WebInspector.populateNode_(dataGridTree, profileView, children, dataGridTree);
+ return dataGridTree;
+};
+
+
+/**
+ * @override
+ */
+WebInspector.ProfileDataGridNode.prototype._populate = function(event) {
+ var children = this.profileNode.children;
+ WebInspector.populateNode_(this, this.profileView, children, this.tree);
+ this.removeEventListener("populate", this._populate, this);
+};
+
+
+// As columns in data grid can't be changed after initialization,
+// we need to intercept the constructor and modify columns upon creation.
+(function InterceptDataGridForProfiler() {
+ var originalDataGrid = WebInspector.DataGrid;
+ WebInspector.DataGrid = function(columns) {
+ if (('average' in columns) && ('calls' in columns)) {
+ delete columns['average'];
+ delete columns['calls'];
+ }
+ return new originalDataGrid(columns);
+ };
+})();
+
+
+/**
+ * @override
+ * TODO(pfeldman): Add l10n.
+ */
+WebInspector.UIString = function(string)
+{
+ return string;
+}
diff --git a/webkit/glue/devtools/js/devtools_host_stub.js b/webkit/glue/devtools/js/devtools_host_stub.js
index 35e89a3..b8dae47 100644
--- a/webkit/glue/devtools/js/devtools_host_stub.js
+++ b/webkit/glue/devtools/js/devtools_host_stub.js
@@ -20,24 +20,24 @@ RemoteDebuggerAgentStub.prototype.GetContextId = function() {
RemoteDebuggerAgent.DidGetContextId(3);
};
-RemoteDebuggerAgentStub.prototype.StopProfiling = function() {
-};
-
-RemoteDebuggerAgentStub.prototype.StartProfiling = function() {
-};
-
-RemoteDebuggerAgentStub.prototype.GetLogLines = function(pos) {
- if (pos < RemoteDebuggerAgentStub.ProfilerLogBuffer.length) {
- setTimeout(function() {
- RemoteDebuggerAgent.DidGetLogLines(
- RemoteDebuggerAgentStub.ProfilerLogBuffer,
- pos + RemoteDebuggerAgentStub.ProfilerLogBuffer.length);
- },
- 100);
- } else {
- setTimeout(function() { RemoteDebuggerAgent.DidGetLogLines('', pos); }, 100);
- }
-};
+RemoteDebuggerAgentStub.prototype.StopProfiling = function() {
+};
+
+RemoteDebuggerAgentStub.prototype.StartProfiling = function() {
+};
+
+RemoteDebuggerAgentStub.prototype.GetLogLines = function(pos) {
+ if (pos < RemoteDebuggerAgentStub.ProfilerLogBuffer.length) {
+ setTimeout(function() {
+ RemoteDebuggerAgent.DidGetLogLines(
+ RemoteDebuggerAgentStub.ProfilerLogBuffer,
+ pos + RemoteDebuggerAgentStub.ProfilerLogBuffer.length);
+ },
+ 100);
+ } else {
+ setTimeout(function() { RemoteDebuggerAgent.DidGetLogLines('', pos); }, 100);
+ }
+};
/**
* @constructor
@@ -223,18 +223,18 @@ RemoteToolsAgentStub.prototype.ClearConsoleMessages = function() {
};
-RemoteDebuggerAgentStub.ProfilerLogBuffer =
- 'code-creation,LazyCompile,0x1000,256,"test1 http://aaa.js:1"\n' +
- 'code-creation,LazyCompile,0x2000,256,"test2 http://bbb.js:2"\n' +
- 'code-creation,LazyCompile,0x3000,256,"test3 http://ccc.js:3"\n' +
- 'tick,0x1010,0x0,3\n' +
- 'tick,0x2020,0x0,3,0x1010\n' +
- 'tick,0x2020,0x0,3,0x1010\n' +
- 'tick,0x3010,0x0,3,0x2020, 0x1010\n' +
- 'tick,0x2020,0x0,3,0x1010\n' +
- 'tick,0x2030,0x0,3,0x2020, 0x1010\n' +
- 'tick,0x2020,0x0,3,0x1010\n' +
- 'tick,0x1010,0x0,3\n';
+RemoteDebuggerAgentStub.ProfilerLogBuffer =
+ 'code-creation,LazyCompile,0x1000,256,"test1 http://aaa.js:1"\n' +
+ 'code-creation,LazyCompile,0x2000,256,"test2 http://bbb.js:2"\n' +
+ 'code-creation,LazyCompile,0x3000,256,"test3 http://ccc.js:3"\n' +
+ 'tick,0x1010,0x0,3\n' +
+ 'tick,0x2020,0x0,3,0x1010\n' +
+ 'tick,0x2020,0x0,3,0x1010\n' +
+ 'tick,0x3010,0x0,3,0x2020, 0x1010\n' +
+ 'tick,0x2020,0x0,3,0x1010\n' +
+ 'tick,0x2030,0x0,3,0x2020, 0x1010\n' +
+ 'tick,0x2020,0x0,3,0x1010\n' +
+ 'tick,0x1010,0x0,3\n';
/**
diff --git a/webkit/glue/devtools/js/inspector_controller.js b/webkit/glue/devtools/js/inspector_controller.js
index 09238e2..dd4193c 100644
--- a/webkit/glue/devtools/js/inspector_controller.js
+++ b/webkit/glue/devtools/js/inspector_controller.js
@@ -302,9 +302,9 @@ devtools.InspectorController.prototype.pauseOnExceptions = function() {
* @param {boolean} value True iff execution should be stopped in the debugger
* on the exceptions.
*/
-devtools.InspectorController.prototype.setPauseOnExceptions = function(value) {
-};
-
+devtools.InspectorController.prototype.setPauseOnExceptions = function(value) {
+};
+
/**
* Tells backend to resume execution.
diff --git a/webkit/glue/devtools/js/inspector_controller_impl.js b/webkit/glue/devtools/js/inspector_controller_impl.js
index 3d349df..2f6f65e7 100644
--- a/webkit/glue/devtools/js/inspector_controller_impl.js
+++ b/webkit/glue/devtools/js/inspector_controller_impl.js
@@ -144,21 +144,21 @@ devtools.InspectorControllerImpl.prototype.setPauseOnExceptions = function(
return devtools.tools.getDebuggerAgent().setPauseOnExceptions(value);
};
-
-/**
- * @override
- */
-devtools.InspectorControllerImpl.prototype.startProfiling = function() {
- devtools.tools.getDebuggerAgent().startProfiling();
-};
-
-
-/**
- * @override
- */
-devtools.InspectorControllerImpl.prototype.stopProfiling = function() {
- devtools.tools.getDebuggerAgent().stopProfiling();
-};
+
+/**
+ * @override
+ */
+devtools.InspectorControllerImpl.prototype.startProfiling = function() {
+ devtools.tools.getDebuggerAgent().startProfiling();
+};
+
+
+/**
+ * @override
+ */
+devtools.InspectorControllerImpl.prototype.stopProfiling = function() {
+ devtools.tools.getDebuggerAgent().stopProfiling();
+};
var InspectorController = new devtools.InspectorControllerImpl();
diff --git a/webkit/glue/devtools/js/profiler_processor.js b/webkit/glue/devtools/js/profiler_processor.js
index 0f8a9ad..e290350 100644
--- a/webkit/glue/devtools/js/profiler_processor.js
+++ b/webkit/glue/devtools/js/profiler_processor.js
@@ -1,201 +1,201 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-/**
- * @fileoverview Profiler processor is used to process log file produced
- * by V8 and produce an internal profile representation which is used
- * for building profile views in 'Profiles' tab.
- */
-goog.provide('devtools.profiler.Processor');
-
-
-/**
- * Ancestor of a profile object that leaves out only JS-related functions.
- * @constructor
- */
-devtools.profiler.JsProfile = function() {
- devtools.profiler.Profile.call(this);
-};
-goog.inherits(devtools.profiler.JsProfile, devtools.profiler.Profile);
-
-
-/**
- * @type {RegExp}
- */
-devtools.profiler.JsProfile.JS_FUNC_RE = /^(LazyCompile|Function|Script):/;
-
-
-/**
- * @override
- */
-devtools.profiler.JsProfile.prototype.skipThisFunction = function(name) {
- return !devtools.profiler.JsProfile.JS_FUNC_RE.test(name);
-};
-
-
-/**
- * Profiler processor. Consumes profiler log and builds profile views.
- * @constructor
- */
-devtools.profiler.Processor = function() {
- /**
- * Current profile.
- * @type {devtools.profiler.JsProfile}
- */
- this.profile_ = new devtools.profiler.JsProfile();
-
- /**
- * Builder of profile views.
- * @type {devtools.profiler.ViewBuilder}
- */
- this.viewBuilder_ = new devtools.profiler.ViewBuilder(1);
-
- /**
- * Next profile id.
- * @type {number}
- */
- this.profileId_ = 1;
-};
-
-
-/**
- * A dispatch table for V8 profiler event log records.
- * @private
- */
-devtools.profiler.Processor.RecordsDispatch_ = {
- 'code-creation': { parsers: [null, parseInt, parseInt, null],
- processor: 'processCodeCreation_' },
- 'code-move': { parsers: [parseInt, parseInt],
- processor: 'processCodeMove_' },
- 'code-delete': { parsers: [parseInt], processor: 'processCodeDelete_' },
- 'tick': { parsers: [parseInt, parseInt, parseInt, 'var-args'],
- processor: 'processTick_' },
- // Not used in DevTools Profiler.
- 'profiler': null,
- 'shared-library': null,
- // Obsolete row types.
- 'code-allocate': null,
- 'begin-code-region': null,
- 'end-code-region': null
-};
-
-
-/**
- * Processes a portion of V8 profiler event log.
- *
- * @param {string} chunk A portion of log.
- */
-devtools.profiler.Processor.prototype.processLogChunk = function(chunk) {
- this.processLog_(chunk.split('\n'));
-};
-
-
-/**
- * Processes a log lines.
- *
- * @param {Array<string>} lines Log lines.
- * @private
- */
-devtools.profiler.Processor.prototype.processLog_ = function(lines) {
- var csvParser = new devtools.profiler.CsvParser();
- try {
- for (var i = 0, n = lines.length; i < n; ++i) {
- var line = lines[i];
- if (!line) {
- continue;
- }
- var fields = csvParser.parseLine(line);
- this.dispatchLogRow_(fields);
- }
- } catch (e) {
- debugPrint('line ' + (i + 1) + ': ' + (e.message || e));
- throw e;
- }
-};
-
-
-/**
- * Does a dispatch of a log record.
- *
- * @param {Array<string>} fields Log record.
- * @private
- */
-devtools.profiler.Processor.prototype.dispatchLogRow_ = function(fields) {
- // Obtain the dispatch.
- var command = fields[0];
- if (!(command in devtools.profiler.Processor.RecordsDispatch_)) {
- throw new Error('unknown command: ' + command);
- }
- var dispatch = devtools.profiler.Processor.RecordsDispatch_[command];
-
- if (dispatch === null) {
- return;
- }
-
- // Parse fields.
- var parsedFields = [];
- for (var i = 0; i < dispatch.parsers.length; ++i) {
- var parser = dispatch.parsers[i];
- if (parser === null) {
- parsedFields.push(fields[1 + i]);
- } else if (typeof parser == 'function') {
- parsedFields.push(parser(fields[1 + i]));
- } else {
- // var-args
- parsedFields.push(fields.slice(1 + i));
- break;
- }
- }
-
- // Run the processor.
- this[dispatch.processor].apply(this, parsedFields);
-};
-
-
-devtools.profiler.Processor.prototype.processCodeCreation_ = function(
- type, start, size, name) {
- this.profile_.addCode(type, name, start, size);
-};
-
-
-devtools.profiler.Processor.prototype.processCodeMove_ = function(from, to) {
- this.profile_.moveCode(from, to);
-};
-
-
-devtools.profiler.Processor.prototype.processCodeDelete_ = function(start) {
- this.profile_.deleteCode(start);
-};
-
-
-devtools.profiler.Processor.prototype.processTick_ = function(
- pc, sp, vmState, stack) {
- var fullStack = [pc];
- for (var i = 0, n = stack.length; i < n; ++i) {
- var frame = stack[i];
- // Leave only numbers starting with 0x. Filter possible 'overflow' string.
- if (frame.charAt(0) == '0') {
- fullStack.push(parseInt(frame, 16));
- }
- }
- this.profile_.recordTick(fullStack);
-};
-
-
-/**
- * Creates a profile for further displaying in ProfileView.
- */
-devtools.profiler.Processor.prototype.createProfileForView = function() {
- var profile = new devtools.profiler.ProfileView();
- profile.uid = this.profileId_++;
- profile.title = UserInitiatedProfileName + '.' + profile.uid;
- // A trick to cope with ProfileView.bottomUpProfileDataGridTree and
- // ProfileView.topDownProfileDataGridTree behavior.
- profile.head = profile;
- profile.heavyProfile = this.viewBuilder_.buildView(
- this.profile_.getBottomUpProfile(), true);
- profile.treeProfile = this.viewBuilder_.buildView(
- this.profile_.getTopDownProfile());
- return profile;
-};
+// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+/**
+ * @fileoverview Profiler processor is used to process log file produced
+ * by V8 and produce an internal profile representation which is used
+ * for building profile views in 'Profiles' tab.
+ */
+goog.provide('devtools.profiler.Processor');
+
+
+/**
+ * Ancestor of a profile object that leaves out only JS-related functions.
+ * @constructor
+ */
+devtools.profiler.JsProfile = function() {
+ devtools.profiler.Profile.call(this);
+};
+goog.inherits(devtools.profiler.JsProfile, devtools.profiler.Profile);
+
+
+/**
+ * @type {RegExp}
+ */
+devtools.profiler.JsProfile.JS_FUNC_RE = /^(LazyCompile|Function|Script):/;
+
+
+/**
+ * @override
+ */
+devtools.profiler.JsProfile.prototype.skipThisFunction = function(name) {
+ return !devtools.profiler.JsProfile.JS_FUNC_RE.test(name);
+};
+
+
+/**
+ * Profiler processor. Consumes profiler log and builds profile views.
+ * @constructor
+ */
+devtools.profiler.Processor = function() {
+ /**
+ * Current profile.
+ * @type {devtools.profiler.JsProfile}
+ */
+ this.profile_ = new devtools.profiler.JsProfile();
+
+ /**
+ * Builder of profile views.
+ * @type {devtools.profiler.ViewBuilder}
+ */
+ this.viewBuilder_ = new devtools.profiler.ViewBuilder(1);
+
+ /**
+ * Next profile id.
+ * @type {number}
+ */
+ this.profileId_ = 1;
+};
+
+
+/**
+ * A dispatch table for V8 profiler event log records.
+ * @private
+ */
+devtools.profiler.Processor.RecordsDispatch_ = {
+ 'code-creation': { parsers: [null, parseInt, parseInt, null],
+ processor: 'processCodeCreation_' },
+ 'code-move': { parsers: [parseInt, parseInt],
+ processor: 'processCodeMove_' },
+ 'code-delete': { parsers: [parseInt], processor: 'processCodeDelete_' },
+ 'tick': { parsers: [parseInt, parseInt, parseInt, 'var-args'],
+ processor: 'processTick_' },
+ // Not used in DevTools Profiler.
+ 'profiler': null,
+ 'shared-library': null,
+ // Obsolete row types.
+ 'code-allocate': null,
+ 'begin-code-region': null,
+ 'end-code-region': null
+};
+
+
+/**
+ * Processes a portion of V8 profiler event log.
+ *
+ * @param {string} chunk A portion of log.
+ */
+devtools.profiler.Processor.prototype.processLogChunk = function(chunk) {
+ this.processLog_(chunk.split('\n'));
+};
+
+
+/**
+ * Processes a log lines.
+ *
+ * @param {Array<string>} lines Log lines.
+ * @private
+ */
+devtools.profiler.Processor.prototype.processLog_ = function(lines) {
+ var csvParser = new devtools.profiler.CsvParser();
+ try {
+ for (var i = 0, n = lines.length; i < n; ++i) {
+ var line = lines[i];
+ if (!line) {
+ continue;
+ }
+ var fields = csvParser.parseLine(line);
+ this.dispatchLogRow_(fields);
+ }
+ } catch (e) {
+ debugPrint('line ' + (i + 1) + ': ' + (e.message || e));
+ throw e;
+ }
+};
+
+
+/**
+ * Does a dispatch of a log record.
+ *
+ * @param {Array<string>} fields Log record.
+ * @private
+ */
+devtools.profiler.Processor.prototype.dispatchLogRow_ = function(fields) {
+ // Obtain the dispatch.
+ var command = fields[0];
+ if (!(command in devtools.profiler.Processor.RecordsDispatch_)) {
+ throw new Error('unknown command: ' + command);
+ }
+ var dispatch = devtools.profiler.Processor.RecordsDispatch_[command];
+
+ if (dispatch === null) {
+ return;
+ }
+
+ // Parse fields.
+ var parsedFields = [];
+ for (var i = 0; i < dispatch.parsers.length; ++i) {
+ var parser = dispatch.parsers[i];
+ if (parser === null) {
+ parsedFields.push(fields[1 + i]);
+ } else if (typeof parser == 'function') {
+ parsedFields.push(parser(fields[1 + i]));
+ } else {
+ // var-args
+ parsedFields.push(fields.slice(1 + i));
+ break;
+ }
+ }
+
+ // Run the processor.
+ this[dispatch.processor].apply(this, parsedFields);
+};
+
+
+devtools.profiler.Processor.prototype.processCodeCreation_ = function(
+ type, start, size, name) {
+ this.profile_.addCode(type, name, start, size);
+};
+
+
+devtools.profiler.Processor.prototype.processCodeMove_ = function(from, to) {
+ this.profile_.moveCode(from, to);
+};
+
+
+devtools.profiler.Processor.prototype.processCodeDelete_ = function(start) {
+ this.profile_.deleteCode(start);
+};
+
+
+devtools.profiler.Processor.prototype.processTick_ = function(
+ pc, sp, vmState, stack) {
+ var fullStack = [pc];
+ for (var i = 0, n = stack.length; i < n; ++i) {
+ var frame = stack[i];
+ // Leave only numbers starting with 0x. Filter possible 'overflow' string.
+ if (frame.charAt(0) == '0') {
+ fullStack.push(parseInt(frame, 16));
+ }
+ }
+ this.profile_.recordTick(fullStack);
+};
+
+
+/**
+ * Creates a profile for further displaying in ProfileView.
+ */
+devtools.profiler.Processor.prototype.createProfileForView = function() {
+ var profile = new devtools.profiler.ProfileView();
+ profile.uid = this.profileId_++;
+ profile.title = UserInitiatedProfileName + '.' + profile.uid;
+ // A trick to cope with ProfileView.bottomUpProfileDataGridTree and
+ // ProfileView.topDownProfileDataGridTree behavior.
+ profile.head = profile;
+ profile.heavyProfile = this.viewBuilder_.buildView(
+ this.profile_.getBottomUpProfile(), true);
+ profile.treeProfile = this.viewBuilder_.buildView(
+ this.profile_.getTopDownProfile());
+ return profile;
+};