Upgrade to 3.29
Update V8 to 3.29.88.17 and update makefiles to support building on
all the relevant platforms.
Bug: 17370214
Change-Id: Ia3407c157fd8d72a93e23d8318ccaf6ecf77fa4e
diff --git a/tools/tickprocessor.js b/tools/tickprocessor.js
index 05a3369..acd7a71 100644
--- a/tools/tickprocessor.js
+++ b/tools/tickprocessor.js
@@ -1,4 +1,4 @@
-// Copyright 2009 the V8 project authors. All rights reserved.
+// Copyright 2012 the V8 project authors. All rights reserved.
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
@@ -73,7 +73,7 @@
function SnapshotLogProcessor() {
LogReader.call(this, {
'code-creation': {
- parsers: [null, parseInt, parseInt, null, 'var-args'],
+ parsers: [null, parseInt, parseInt, parseInt, null, 'var-args'],
processor: this.processCodeCreation },
'code-move': { parsers: [parseInt, parseInt],
processor: this.processCodeMove },
@@ -107,7 +107,7 @@
SnapshotLogProcessor.prototype.processCodeCreation = function(
- type, start, size, name, maybe_func) {
+ type, kind, start, size, name, maybe_func) {
if (maybe_func.length) {
var funcAddr = parseInt(maybe_func[0]);
var state = parseState(maybe_func[1]);
@@ -151,12 +151,15 @@
callGraphSize,
ignoreUnknown,
stateFilter,
- snapshotLogProcessor) {
+ snapshotLogProcessor,
+ distortion,
+ range,
+ sourceMap) {
LogReader.call(this, {
'shared-library': { parsers: [null, parseInt, parseInt],
processor: this.processSharedLibrary },
'code-creation': {
- parsers: [null, parseInt, parseInt, null, 'var-args'],
+ parsers: [null, parseInt, parseInt, parseInt, null, 'var-args'],
processor: this.processCodeCreation },
'code-move': { parsers: [parseInt, parseInt],
processor: this.processCodeMove },
@@ -174,6 +177,10 @@
processor: this.processHeapSampleBegin },
'heap-sample-end': { parsers: [null, null],
processor: this.processHeapSampleEnd },
+ 'timer-event-start' : { parsers: [null, null, null],
+ processor: this.advanceDistortion },
+ 'timer-event-end' : { parsers: [null, null, null],
+ processor: this.advanceDistortion },
// Ignored events.
'profiler': null,
'function-creation': null,
@@ -190,10 +197,22 @@
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 };
+ distortion = parseInt(distortion);
+ // Convert picoseconds to nanoseconds.
+ this.distortion_per_entry = isNaN(distortion) ? 0 : (distortion / 1000);
+ this.distortion = 0;
+ var rangelimits = range ? range.split(",") : [];
+ var range_start = parseInt(rangelimits[0]);
+ var range_end = parseInt(rangelimits[1]);
+ // Convert milliseconds to nanoseconds.
+ this.range_start = isNaN(range_start) ? -Infinity : (range_start * 1000);
+ this.range_end = isNaN(range_end) ? Infinity : (range_end * 1000)
+
V8Profile.prototype.handleUnknownCode = function(
operation, addr, opt_stackPos) {
var op = Profile.Operation;
@@ -232,7 +251,8 @@
GC: 1,
COMPILER: 2,
OTHER: 3,
- EXTERNAL: 4
+ EXTERNAL: 4,
+ IDLE: 5
};
@@ -308,7 +328,7 @@
TickProcessor.prototype.processCodeCreation = function(
- type, start, size, name, maybe_func) {
+ type, kind, start, size, name, maybe_func) {
name = this.deserializedEntriesNames_[start] || name;
if (maybe_func.length) {
var funcAddr = parseInt(maybe_func[0]);
@@ -348,11 +368,16 @@
};
TickProcessor.prototype.processTick = function(pc,
- sp,
+ ns_since_start,
is_external_callback,
tos_or_external_callback,
vmState,
stack) {
+ this.distortion += this.distortion_per_entry;
+ ns_since_start -= this.distortion;
+ if (ns_since_start < this.range_start || ns_since_start > this.range_end) {
+ return;
+ }
this.ticks_.total++;
if (vmState == TickProcessor.VmStates.GC) this.ticks_.gc++;
if (!this.includeTick(vmState)) {
@@ -379,6 +404,11 @@
};
+TickProcessor.prototype.advanceDistortion = function() {
+ this.distortion += this.distortion_per_entry;
+}
+
+
TickProcessor.prototype.processHeapSampleBegin = function(space, state, ticks) {
if (space != 'Heap') return;
this.currentProducerProfile_ = new CallTree();
@@ -411,12 +441,6 @@
if (this.ticks_.total == 0) return;
- // Print the unknown ticks percentage if they are not ignored.
- if (!this.ignoreUnknown_ && this.ticks_.unaccounted > 0) {
- this.printHeader('Unknown');
- this.printCounter(this.ticks_.unaccounted, this.ticks_.total);
- }
-
var flatProfile = this.profile_.getFlatProfile();
var flatView = this.viewBuilder_.buildView(flatProfile);
// Sort by self time, desc, then by name, desc.
@@ -427,33 +451,39 @@
if (this.ignoreUnknown_) {
totalTicks -= this.ticks_.unaccounted;
}
- // Our total time contains all the ticks encountered,
- // while profile only knows about the filtered ticks.
- flatView.head.totalTime = totalTicks;
// Count library ticks
var flatViewNodes = flatView.head.children;
var self = this;
+
var libraryTicks = 0;
- this.processProfile(flatViewNodes,
+ this.printHeader('Shared libraries');
+ this.printEntries(flatViewNodes, totalTicks, null,
function(name) { return self.isSharedLibrary(name); },
function(rec) { libraryTicks += rec.selfTime; });
var nonLibraryTicks = totalTicks - libraryTicks;
- this.printHeader('Shared libraries');
- this.printEntries(flatViewNodes, null,
- function(name) { return self.isSharedLibrary(name); });
-
+ var jsTicks = 0;
this.printHeader('JavaScript');
- this.printEntries(flatViewNodes, nonLibraryTicks,
- function(name) { return self.isJsCode(name); });
+ this.printEntries(flatViewNodes, totalTicks, nonLibraryTicks,
+ function(name) { return self.isJsCode(name); },
+ function(rec) { jsTicks += rec.selfTime; });
+ var cppTicks = 0;
this.printHeader('C++');
- this.printEntries(flatViewNodes, nonLibraryTicks,
- function(name) { return self.isCppCode(name); });
+ this.printEntries(flatViewNodes, totalTicks, nonLibraryTicks,
+ function(name) { return self.isCppCode(name); },
+ function(rec) { cppTicks += rec.selfTime; });
- this.printHeader('GC');
- this.printCounter(this.ticks_.gc, totalTicks);
+ this.printHeader('Summary');
+ this.printLine('JavaScript', jsTicks, totalTicks, nonLibraryTicks);
+ this.printLine('C++', cppTicks, totalTicks, nonLibraryTicks);
+ this.printLine('GC', this.ticks_.gc, totalTicks, nonLibraryTicks);
+ this.printLine('Shared libraries', libraryTicks, totalTicks, null);
+ if (!this.ignoreUnknown_ && this.ticks_.unaccounted > 0) {
+ this.printLine('Unaccounted', this.ticks_.unaccounted,
+ this.ticks_.total, null);
+ }
this.printHeavyProfHeader();
var heavyProfile = this.profile_.getBottomUpProfile();
@@ -487,6 +517,18 @@
};
+TickProcessor.prototype.printLine = function(
+ entry, ticks, totalTicks, nonLibTicks) {
+ var pct = ticks * 100 / totalTicks;
+ var nonLibPct = nonLibTicks != null
+ ? padLeft((ticks * 100 / nonLibTicks).toFixed(1), 5) + '% '
+ : ' ';
+ print(' ' + padLeft(ticks, 5) + ' ' +
+ padLeft(pct.toFixed(1), 5) + '% ' +
+ nonLibPct +
+ entry);
+}
+
TickProcessor.prototype.printHeavyProfHeader = function() {
print('\n [Bottom up (heavy) profile]:');
print(' Note: percentage shows a share of a particular caller in the ' +
@@ -499,12 +541,6 @@
};
-TickProcessor.prototype.printCounter = function(ticksCount, totalTicksCount) {
- var pct = ticksCount * 100.0 / totalTicksCount;
- print(' ' + padLeft(ticksCount, 5) + ' ' + padLeft(pct.toFixed(1), 5) + '%');
-};
-
-
TickProcessor.prototype.processProfile = function(
profile, filterP, func) {
for (var i = 0, n = profile.length; i < n; ++i) {
@@ -516,17 +552,47 @@
}
};
+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) {
+ profile, totalTicks, nonLibTicks, filterP, callback) {
+ 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;
- print(' ' + padLeft(rec.selfTime, 5) + ' ' +
- padLeft(rec.selfPercent.toFixed(1), 5) + '% ' +
- padLeft(nonLibPct.toFixed(1), 5) + '% ' +
- rec.internalFuncName);
+ callback(rec);
+ var funcName = that.formatFunctionName(rec.internalFuncName);
+ that.printLine(funcName, rec.selfTime, totalTicks, nonLibTicks);
});
};
@@ -538,9 +604,10 @@
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);
@@ -608,10 +675,11 @@
};
-function UnixCppEntriesProvider(nmExec) {
+function UnixCppEntriesProvider(nmExec, targetRootFS) {
this.symbols = [];
this.parsePos = 0;
this.nmExec = nmExec;
+ this.targetRootFS = targetRootFS;
this.FUNC_RE = /^([0-9a-fA-F]{8,16}) ([0-9a-fA-F]{8,16} )?[tTwW] (.*)$/;
};
inherits(UnixCppEntriesProvider, CppEntriesProvider);
@@ -619,6 +687,7 @@
UnixCppEntriesProvider.prototype.loadSymbols = function(libName) {
this.parsePos = 0;
+ libName = this.targetRootFS + libName;
try {
this.symbols = [
os.system(this.nmExec, ['-C', '-n', '-S', libName], -1, -1),
@@ -656,8 +725,8 @@
};
-function MacCppEntriesProvider(nmExec) {
- UnixCppEntriesProvider.call(this, nmExec);
+function MacCppEntriesProvider(nmExec, targetRootFS) {
+ UnixCppEntriesProvider.call(this, nmExec, targetRootFS);
// Note an empty group. It is required, as UnixCppEntriesProvider expects 3 groups.
this.FUNC_RE = /^([0-9a-fA-F]{8,16}) ()[iItT] (.*)$/;
};
@@ -666,6 +735,7 @@
MacCppEntriesProvider.prototype.loadSymbols = function(libName) {
this.parsePos = 0;
+ libName = this.targetRootFS + libName;
try {
this.symbols = [os.system(this.nmExec, ['-n', '-f', libName], -1, -1), ''];
} catch (e) {
@@ -675,7 +745,8 @@
};
-function WindowsCppEntriesProvider() {
+function WindowsCppEntriesProvider(_ignored_nmExec, targetRootFS) {
+ this.targetRootFS = targetRootFS;
this.symbols = '';
this.parsePos = 0;
};
@@ -698,6 +769,7 @@
WindowsCppEntriesProvider.prototype.loadSymbols = function(libName) {
+ libName = this.targetRootFS + libName;
var fileNameFields = libName.match(WindowsCppEntriesProvider.FILENAME_RE);
if (!fileNameFields) return;
var mapFileName = fileNameFields[1] + '.map';
@@ -785,8 +857,16 @@
'Specify that we are running on Mac OS X platform'],
'--nm': ['nm', 'nm',
'Specify the \'nm\' executable to use (e.g. --nm=/my_dir/nm)'],
+ '--target': ['targetRootFS', '',
+ 'Specify the target root directory for cross environment'],
'--snapshot-log': ['snapshotLogFileName', 'snapshot.log',
- 'Specify snapshot log file to use (e.g. --snapshot-log=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]'],
+ '--distortion': ['distortion', 0,
+ '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'];
@@ -804,7 +884,10 @@
callGraphSize: 5,
ignoreUnknown: false,
separateIc: false,
- nm: 'nm'
+ targetRootFS: '',
+ nm: 'nm',
+ range: 'auto,auto',
+ distortion: 0
};
@@ -868,4 +951,3 @@
}
quit(2);
};
-