summaryrefslogtreecommitdiff
path: root/deps/v8/tools/tickprocessor.js
diff options
context:
space:
mode:
authorTimothy J Fontaine <tjfontaine@gmail.com>2013-10-22 15:14:25 -0700
committerTimothy J Fontaine <tjfontaine@gmail.com>2013-10-23 09:17:31 -0700
commita53c763c16eeabb0901a05dbcf38a72fa96d2f26 (patch)
tree309bf250e1521cedf0e945d7a7629db511e64498 /deps/v8/tools/tickprocessor.js
parent54910044b33a6405c72ad085915a55c575c027fc (diff)
downloadnode-new-a53c763c16eeabb0901a05dbcf38a72fa96d2f26.tar.gz
v8: upgrade 3.21.18.3
Diffstat (limited to 'deps/v8/tools/tickprocessor.js')
-rw-r--r--deps/v8/tools/tickprocessor.js50
1 files changed, 45 insertions, 5 deletions
diff --git a/deps/v8/tools/tickprocessor.js b/deps/v8/tools/tickprocessor.js
index f1a11ccc94..ff5254172f 100644
--- a/deps/v8/tools/tickprocessor.js
+++ b/deps/v8/tools/tickprocessor.js
@@ -153,7 +153,8 @@ function TickProcessor(
stateFilter,
snapshotLogProcessor,
distortion,
- range) {
+ range,
+ sourceMap) {
LogReader.call(this, {
'shared-library': { parsers: [null, parseInt, parseInt],
processor: this.processSharedLibrary },
@@ -196,6 +197,7 @@ function TickProcessor(
this.ignoreUnknown_ = ignoreUnknown;
this.stateFilter_ = stateFilter;
this.snapshotLogProcessor_ = snapshotLogProcessor;
+ this.sourceMap = sourceMap;
this.deserializedEntriesNames_ = [];
var ticks = this.ticks_ =
{ total: 0, unaccounted: 0, excluded: 0, gc: 0 };
@@ -544,17 +546,52 @@ TickProcessor.prototype.processProfile = function(
}
};
+TickProcessor.prototype.getLineAndColumn = function(name) {
+ var re = /:([0-9]+):([0-9]+)$/;
+ var array = re.exec(name);
+ if (!array) {
+ return null;
+ }
+ return {line: array[1], column: array[2]};
+}
+
+TickProcessor.prototype.hasSourceMap = function() {
+ return this.sourceMap != null;
+};
+
+
+TickProcessor.prototype.formatFunctionName = function(funcName) {
+ if (!this.hasSourceMap()) {
+ return funcName;
+ }
+ var lc = this.getLineAndColumn(funcName);
+ if (lc == null) {
+ return funcName;
+ }
+ // in source maps lines and columns are zero based
+ var lineNumber = lc.line - 1;
+ var column = lc.column - 1;
+ var entry = this.sourceMap.findEntry(lineNumber, column);
+ var sourceFile = entry[2];
+ var sourceLine = entry[3] + 1;
+ var sourceColumn = entry[4] + 1;
+
+ return sourceFile + ':' + sourceLine + ':' + sourceColumn + ' -> ' + funcName;
+};
TickProcessor.prototype.printEntries = function(
profile, nonLibTicks, filterP) {
+ var that = this;
this.processProfile(profile, filterP, function (rec) {
if (rec.selfTime == 0) return;
var nonLibPct = nonLibTicks != null ?
rec.selfTime * 100.0 / nonLibTicks : 0.0;
+ var funcName = that.formatFunctionName(rec.internalFuncName);
+
print(' ' + padLeft(rec.selfTime, 5) + ' ' +
padLeft(rec.selfPercent.toFixed(1), 5) + '% ' +
padLeft(nonLibPct.toFixed(1), 5) + '% ' +
- rec.internalFuncName);
+ funcName);
});
};
@@ -566,9 +603,10 @@ TickProcessor.prototype.printHeavyProfile = function(profile, opt_indent) {
this.processProfile(profile, function() { return true; }, function (rec) {
// Cut off too infrequent callers.
if (rec.parentTotalPercent < TickProcessor.CALL_PROFILE_CUTOFF_PCT) return;
+ var funcName = self.formatFunctionName(rec.internalFuncName);
print(' ' + padLeft(rec.totalTime, 5) + ' ' +
padLeft(rec.parentTotalPercent.toFixed(1), 5) + '% ' +
- indentStr + rec.internalFuncName);
+ indentStr + funcName);
// Limit backtrace depth.
if (indent < 2 * self.callGraphSize_) {
self.printHeavyProfile(rec.children, indent + 2);
@@ -823,9 +861,11 @@ function ArgumentsProcessor(args) {
'--snapshot-log': ['snapshotLogFileName', 'snapshot.log',
'Specify snapshot log file to use (e.g. --snapshot-log=snapshot.log)'],
'--range': ['range', 'auto,auto',
- 'Specify the range limit as [start],[end]'],
+ 'Specify the range limit as [start],[end]'],
'--distortion': ['distortion', 0,
- 'Specify the logging overhead in picoseconds']
+ 'Specify the logging overhead in picoseconds'],
+ '--source-map': ['sourceMap', null,
+ 'Specify the source map that should be used for output']
};
this.argsDispatch_['--js'] = this.argsDispatch_['-j'];
this.argsDispatch_['--gc'] = this.argsDispatch_['-g'];