2012-07-16 11:00:44 +00:00
|
|
|
// Copyright 2012 the V8 project authors. All rights reserved.
|
2009-04-27 13:50:42 +00:00
|
|
|
// Redistribution and use in source and binary forms, with or without
|
|
|
|
// modification, are permitted provided that the following conditions are
|
|
|
|
// met:
|
|
|
|
//
|
|
|
|
// * Redistributions of source code must retain the above copyright
|
|
|
|
// notice, this list of conditions and the following disclaimer.
|
|
|
|
// * Redistributions in binary form must reproduce the above
|
|
|
|
// copyright notice, this list of conditions and the following
|
|
|
|
// disclaimer in the documentation and/or other materials provided
|
|
|
|
// with the distribution.
|
|
|
|
// * Neither the name of Google Inc. nor the names of its
|
|
|
|
// contributors may be used to endorse or promote products derived
|
|
|
|
// from this software without specific prior written permission.
|
|
|
|
//
|
|
|
|
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
|
|
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
|
|
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
|
|
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
|
|
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
|
|
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
|
|
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
|
|
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
|
|
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
|
|
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
|
2011-02-10 07:47:28 +00:00
|
|
|
function inherits(childCtor, parentCtor) {
|
|
|
|
childCtor.prototype.__proto__ = parentCtor.prototype;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2017-04-11 09:56:03 +00:00
|
|
|
function V8Profile(separateIc, separateBytecodes, separateBuiltins,
|
|
|
|
separateStubs) {
|
2011-02-10 07:47:28 +00:00
|
|
|
Profile.call(this);
|
2017-04-11 09:56:03 +00:00
|
|
|
var regexps = [];
|
|
|
|
if (!separateIc) regexps.push(V8Profile.IC_RE);
|
|
|
|
if (!separateBytecodes) regexps.push(V8Profile.BYTECODES_RE);
|
|
|
|
if (!separateBuiltins) regexps.push(V8Profile.BUILTINS_RE);
|
|
|
|
if (!separateStubs) regexps.push(V8Profile.STUBS_RE);
|
|
|
|
if (regexps.length > 0) {
|
|
|
|
this.skipThisFunction = function(name) {
|
|
|
|
for (var i=0; i<regexps.length; i++) {
|
|
|
|
if (regexps[i].test(name)) return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
};
|
2009-04-27 13:50:42 +00:00
|
|
|
}
|
|
|
|
};
|
2011-02-10 07:47:28 +00:00
|
|
|
inherits(V8Profile, Profile);
|
2009-04-27 13:50:42 +00:00
|
|
|
|
|
|
|
|
2011-02-10 07:47:28 +00:00
|
|
|
V8Profile.IC_RE =
|
2017-04-11 09:56:03 +00:00
|
|
|
/^(LoadGlobalIC: )|(Handler: )|(?:CallIC|LoadIC|StoreIC)|(?:Builtin: (?:Keyed)?(?:Load|Store)IC_)/;
|
|
|
|
V8Profile.BYTECODES_RE = /^(BytecodeHandler: )/
|
|
|
|
V8Profile.BUILTINS_RE = /^(Builtin: )/
|
|
|
|
V8Profile.STUBS_RE = /^(Stub: )/
|
2009-04-27 13:50:42 +00:00
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* A thin wrapper around shell's 'read' function showing a file name on error.
|
|
|
|
*/
|
|
|
|
function readFile(fileName) {
|
|
|
|
try {
|
|
|
|
return read(fileName);
|
|
|
|
} catch (e) {
|
2017-03-04 13:04:58 +00:00
|
|
|
printErr(fileName + ': ' + (e.message || e));
|
2009-04-27 13:50:42 +00:00
|
|
|
throw e;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-02-22 16:31:24 +00:00
|
|
|
/**
|
|
|
|
* Parser for dynamic code optimization state.
|
|
|
|
*/
|
|
|
|
function parseState(s) {
|
|
|
|
switch (s) {
|
|
|
|
case "": return Profile.CodeState.COMPILED;
|
|
|
|
case "~": return Profile.CodeState.OPTIMIZABLE;
|
|
|
|
case "*": return Profile.CodeState.OPTIMIZED;
|
|
|
|
}
|
|
|
|
throw new Error("unknown code state: " + s);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-04-27 13:50:42 +00:00
|
|
|
function TickProcessor(
|
2012-02-13 10:07:57 +00:00
|
|
|
cppEntriesProvider,
|
|
|
|
separateIc,
|
2017-04-11 09:56:03 +00:00
|
|
|
separateBytecodes,
|
|
|
|
separateBuiltins,
|
|
|
|
separateStubs,
|
2012-02-13 10:07:57 +00:00
|
|
|
callGraphSize,
|
|
|
|
ignoreUnknown,
|
|
|
|
stateFilter,
|
2013-01-29 14:41:02 +00:00
|
|
|
distortion,
|
2013-08-23 17:20:54 +00:00
|
|
|
range,
|
2015-01-20 16:06:03 +00:00
|
|
|
sourceMap,
|
2015-05-05 14:15:07 +00:00
|
|
|
timedRange,
|
2015-09-03 18:01:40 +00:00
|
|
|
pairwiseTimedRange,
|
2016-06-10 09:16:03 +00:00
|
|
|
onlySummary,
|
2017-03-04 13:04:58 +00:00
|
|
|
runtimeTimerFilter,
|
|
|
|
preprocessJson) {
|
|
|
|
this.preprocessJson = preprocessJson;
|
2011-02-10 07:47:28 +00:00
|
|
|
LogReader.call(this, {
|
2016-05-02 08:00:48 +00:00
|
|
|
'shared-library': { parsers: [null, parseInt, parseInt, parseInt],
|
2009-06-18 07:59:13 +00:00
|
|
|
processor: this.processSharedLibrary },
|
|
|
|
'code-creation': {
|
2017-03-22 16:02:25 +00:00
|
|
|
parsers: [null, parseInt, parseInt, parseInt, parseInt,
|
|
|
|
null, 'var-args'],
|
2010-12-07 13:24:22 +00:00
|
|
|
processor: this.processCodeCreation },
|
2017-03-22 16:02:25 +00:00
|
|
|
'code-deopt': {
|
|
|
|
parsers: [parseInt, parseInt, parseInt, parseInt, parseInt,
|
|
|
|
null, null, null],
|
|
|
|
processor: this.processCodeDeopt },
|
|
|
|
'code-move': { parsers: [parseInt, parseInt, ],
|
2010-12-07 13:24:22 +00:00
|
|
|
processor: this.processCodeMove },
|
2011-09-12 10:50:40 +00:00
|
|
|
'code-delete': { parsers: [parseInt],
|
|
|
|
processor: this.processCodeDelete },
|
2017-07-27 19:46:32 +00:00
|
|
|
'code-source-info': {
|
|
|
|
parsers: [parseInt, parseInt, parseInt, parseInt, null, null, null],
|
|
|
|
processor: this.processCodeSourceInfo },
|
|
|
|
'script': {
|
2017-08-08 13:31:38 +00:00
|
|
|
parsers: [parseInt, null, null],
|
2017-07-27 19:46:32 +00:00
|
|
|
processor: this.processCodeScript },
|
2011-02-22 16:31:24 +00:00
|
|
|
'sfi-move': { parsers: [parseInt, parseInt],
|
2010-12-07 13:24:22 +00:00
|
|
|
processor: this.processFunctionMove },
|
2016-06-10 09:16:03 +00:00
|
|
|
'active-runtime-timer': {
|
|
|
|
parsers: [null],
|
|
|
|
processor: this.processRuntimeTimerEvent },
|
2011-03-21 18:13:27 +00:00
|
|
|
'tick': {
|
2013-07-03 16:20:59 +00:00
|
|
|
parsers: [parseInt, parseInt, parseInt,
|
2013-04-19 11:55:01 +00:00
|
|
|
parseInt, parseInt, 'var-args'],
|
2010-12-07 13:24:22 +00:00
|
|
|
processor: this.processTick },
|
2009-10-15 07:50:23 +00:00
|
|
|
'heap-sample-begin': { parsers: [null, null, parseInt],
|
|
|
|
processor: this.processHeapSampleBegin },
|
|
|
|
'heap-sample-end': { parsers: [null, null],
|
|
|
|
processor: this.processHeapSampleEnd },
|
2013-01-29 14:41:02 +00:00
|
|
|
'timer-event-start' : { parsers: [null, null, null],
|
|
|
|
processor: this.advanceDistortion },
|
|
|
|
'timer-event-end' : { parsers: [null, null, null],
|
|
|
|
processor: this.advanceDistortion },
|
2009-10-15 07:50:23 +00:00
|
|
|
// Ignored events.
|
2009-06-18 07:59:13 +00:00
|
|
|
'profiler': null,
|
2011-02-22 16:31:24 +00:00
|
|
|
'function-creation': null,
|
|
|
|
'function-move': null,
|
|
|
|
'function-delete': null,
|
2009-10-15 07:50:23 +00:00
|
|
|
'heap-sample-item': null,
|
2015-01-20 16:06:03 +00:00
|
|
|
'current-time': null, // Handled specially, not parsed.
|
2009-06-18 07:59:13 +00:00
|
|
|
// Obsolete row types.
|
|
|
|
'code-allocate': null,
|
|
|
|
'begin-code-region': null,
|
2015-01-20 16:06:03 +00:00
|
|
|
'end-code-region': null },
|
2015-05-05 14:15:07 +00:00
|
|
|
timedRange,
|
|
|
|
pairwiseTimedRange);
|
2009-06-18 07:59:13 +00:00
|
|
|
|
2009-04-27 13:50:42 +00:00
|
|
|
this.cppEntriesProvider_ = cppEntriesProvider;
|
2012-02-13 10:07:57 +00:00
|
|
|
this.callGraphSize_ = callGraphSize;
|
2009-04-27 13:50:42 +00:00
|
|
|
this.ignoreUnknown_ = ignoreUnknown;
|
|
|
|
this.stateFilter_ = stateFilter;
|
2016-06-10 09:16:03 +00:00
|
|
|
this.runtimeTimerFilter_ = runtimeTimerFilter;
|
2013-08-23 17:20:54 +00:00
|
|
|
this.sourceMap = sourceMap;
|
2010-01-18 16:04:25 +00:00
|
|
|
this.deserializedEntriesNames_ = [];
|
2009-04-27 13:50:42 +00:00
|
|
|
var ticks = this.ticks_ =
|
|
|
|
{ total: 0, unaccounted: 0, excluded: 0, gc: 0 };
|
|
|
|
|
2013-01-29 14:41:02 +00:00
|
|
|
distortion = parseInt(distortion);
|
|
|
|
// Convert picoseconds to nanoseconds.
|
|
|
|
this.distortion_per_entry = isNaN(distortion) ? 0 : (distortion / 1000);
|
|
|
|
this.distortion = 0;
|
2013-07-02 15:34:28 +00:00
|
|
|
var rangelimits = range ? range.split(",") : [];
|
2013-01-29 14:41:02 +00:00
|
|
|
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)
|
|
|
|
|
2011-02-10 07:47:28 +00:00
|
|
|
V8Profile.prototype.handleUnknownCode = function(
|
2009-04-27 13:50:42 +00:00
|
|
|
operation, addr, opt_stackPos) {
|
2011-02-10 07:47:28 +00:00
|
|
|
var op = Profile.Operation;
|
2009-04-27 13:50:42 +00:00
|
|
|
switch (operation) {
|
|
|
|
case op.MOVE:
|
2017-03-04 13:04:58 +00:00
|
|
|
printErr('Code move event for unknown code: 0x' + addr.toString(16));
|
2009-04-27 13:50:42 +00:00
|
|
|
break;
|
2011-09-12 10:50:40 +00:00
|
|
|
case op.DELETE:
|
2017-03-04 13:04:58 +00:00
|
|
|
printErr('Code delete event for unknown code: 0x' + addr.toString(16));
|
2011-09-12 10:50:40 +00:00
|
|
|
break;
|
2009-04-27 13:50:42 +00:00
|
|
|
case op.TICK:
|
|
|
|
// Only unknown PCs (the first frame) are reported as unaccounted,
|
|
|
|
// otherwise tick balance will be corrupted (this behavior is compatible
|
|
|
|
// with the original tickprocessor.py script.)
|
|
|
|
if (opt_stackPos == 0) {
|
|
|
|
ticks.unaccounted++;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2017-03-04 13:04:58 +00:00
|
|
|
if (preprocessJson) {
|
|
|
|
this.profile_ = new JsonProfile();
|
|
|
|
} else {
|
2017-04-11 09:56:03 +00:00
|
|
|
this.profile_ = new V8Profile(separateIc, separateBytecodes,
|
|
|
|
separateBuiltins, separateStubs);
|
2017-03-04 13:04:58 +00:00
|
|
|
}
|
2009-04-27 13:50:42 +00:00
|
|
|
this.codeTypes_ = {};
|
|
|
|
// Count each tick as a time unit.
|
2011-02-10 07:47:28 +00:00
|
|
|
this.viewBuilder_ = new ViewBuilder(1);
|
2009-04-27 13:50:42 +00:00
|
|
|
this.lastLogFileName_ = null;
|
2009-10-15 07:50:23 +00:00
|
|
|
|
|
|
|
this.generation_ = 1;
|
|
|
|
this.currentProducerProfile_ = null;
|
2015-09-03 18:01:40 +00:00
|
|
|
this.onlySummary_ = onlySummary;
|
2009-04-27 13:50:42 +00:00
|
|
|
};
|
2011-02-10 07:47:28 +00:00
|
|
|
inherits(TickProcessor, LogReader);
|
2009-04-27 13:50:42 +00:00
|
|
|
|
|
|
|
|
|
|
|
TickProcessor.VmStates = {
|
|
|
|
JS: 0,
|
|
|
|
GC: 1,
|
2017-08-10 14:39:55 +00:00
|
|
|
PARSER: 2,
|
|
|
|
BYTECODE_COMPILER: 3,
|
|
|
|
COMPILER: 4,
|
|
|
|
OTHER: 5,
|
|
|
|
EXTERNAL: 6,
|
|
|
|
IDLE: 7,
|
2009-04-27 13:50:42 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
TickProcessor.CodeTypes = {
|
2009-05-08 11:27:02 +00:00
|
|
|
CPP: 0,
|
|
|
|
SHARED_LIB: 1
|
2009-04-27 13:50:42 +00:00
|
|
|
};
|
2009-05-08 11:27:02 +00:00
|
|
|
// Otherwise, this is JS-related code. We are not adding it to
|
|
|
|
// codeTypes_ map because there can be zillions of them.
|
2009-04-27 13:50:42 +00:00
|
|
|
|
|
|
|
|
2017-03-10 10:06:06 +00:00
|
|
|
TickProcessor.CALL_PROFILE_CUTOFF_PCT = 1.0;
|
2009-04-27 13:50:42 +00:00
|
|
|
|
2012-02-13 10:07:57 +00:00
|
|
|
TickProcessor.CALL_GRAPH_SIZE = 5;
|
2009-04-27 13:50:42 +00:00
|
|
|
|
2009-06-18 07:59:13 +00:00
|
|
|
/**
|
|
|
|
* @override
|
|
|
|
*/
|
|
|
|
TickProcessor.prototype.printError = function(str) {
|
2017-03-04 13:04:58 +00:00
|
|
|
printErr(str);
|
2009-06-18 07:59:13 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2009-04-27 13:50:42 +00:00
|
|
|
TickProcessor.prototype.setCodeType = function(name, type) {
|
|
|
|
this.codeTypes_[name] = TickProcessor.CodeTypes[type];
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
TickProcessor.prototype.isSharedLibrary = function(name) {
|
|
|
|
return this.codeTypes_[name] == TickProcessor.CodeTypes.SHARED_LIB;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
TickProcessor.prototype.isCppCode = function(name) {
|
|
|
|
return this.codeTypes_[name] == TickProcessor.CodeTypes.CPP;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
TickProcessor.prototype.isJsCode = function(name) {
|
2015-01-20 16:06:03 +00:00
|
|
|
return name !== "UNKNOWN" && !(name in this.codeTypes_);
|
2009-04-27 13:50:42 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
TickProcessor.prototype.processLogFile = function(fileName) {
|
|
|
|
this.lastLogFileName_ = fileName;
|
2010-02-08 08:15:18 +00:00
|
|
|
var line;
|
|
|
|
while (line = readline()) {
|
|
|
|
this.processLogLine(line);
|
|
|
|
}
|
2009-04-27 13:50:42 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2010-02-08 08:55:01 +00:00
|
|
|
TickProcessor.prototype.processLogFileInTest = function(fileName) {
|
|
|
|
// Hack file name to avoid dealing with platform specifics.
|
|
|
|
this.lastLogFileName_ = 'v8.log';
|
|
|
|
var contents = readFile(fileName);
|
|
|
|
this.processLogChunk(contents);
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2009-04-27 13:50:42 +00:00
|
|
|
TickProcessor.prototype.processSharedLibrary = function(
|
2016-05-02 08:00:48 +00:00
|
|
|
name, startAddr, endAddr, aslrSlide) {
|
|
|
|
var entry = this.profile_.addLibrary(name, startAddr, endAddr, aslrSlide);
|
2009-04-27 13:50:42 +00:00
|
|
|
this.setCodeType(entry.getName(), 'SHARED_LIB');
|
|
|
|
|
|
|
|
var self = this;
|
|
|
|
var libFuncs = this.cppEntriesProvider_.parseVmSymbols(
|
2016-05-02 08:00:48 +00:00
|
|
|
name, startAddr, endAddr, aslrSlide, function(fName, fStart, fEnd) {
|
2009-04-27 13:50:42 +00:00
|
|
|
self.profile_.addStaticCode(fName, fStart, fEnd);
|
|
|
|
self.setCodeType(fName, 'CPP');
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
TickProcessor.prototype.processCodeCreation = function(
|
2017-03-22 16:02:25 +00:00
|
|
|
type, kind, timestamp, start, size, name, maybe_func) {
|
2010-01-18 16:04:25 +00:00
|
|
|
name = this.deserializedEntriesNames_[start] || name;
|
2011-02-22 16:31:24 +00:00
|
|
|
if (maybe_func.length) {
|
|
|
|
var funcAddr = parseInt(maybe_func[0]);
|
|
|
|
var state = parseState(maybe_func[1]);
|
2017-03-22 16:02:25 +00:00
|
|
|
this.profile_.addFuncCode(type, name, timestamp, start, size, funcAddr, state);
|
2011-02-22 16:31:24 +00:00
|
|
|
} else {
|
2017-03-22 16:02:25 +00:00
|
|
|
this.profile_.addCode(type, name, timestamp, start, size);
|
2011-02-22 16:31:24 +00:00
|
|
|
}
|
2009-04-27 13:50:42 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2017-03-22 16:02:25 +00:00
|
|
|
TickProcessor.prototype.processCodeDeopt = function(
|
|
|
|
timestamp, size, code, inliningId, scriptOffset, bailoutType,
|
|
|
|
sourcePositionText, deoptReasonText) {
|
|
|
|
this.profile_.deoptCode(timestamp, code, inliningId, scriptOffset,
|
|
|
|
bailoutType, sourcePositionText, deoptReasonText);
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2009-04-27 13:50:42 +00:00
|
|
|
TickProcessor.prototype.processCodeMove = function(from, to) {
|
|
|
|
this.profile_.moveCode(from, to);
|
|
|
|
};
|
|
|
|
|
2011-09-12 10:50:40 +00:00
|
|
|
TickProcessor.prototype.processCodeDelete = function(start) {
|
|
|
|
this.profile_.deleteCode(start);
|
|
|
|
};
|
|
|
|
|
2017-07-27 19:46:32 +00:00
|
|
|
TickProcessor.prototype.processCodeSourceInfo = function(
|
|
|
|
start, script, startPos, endPos, sourcePositions, inliningPositions,
|
|
|
|
inlinedFunctions) {
|
|
|
|
this.profile_.addSourcePositions(start, script, startPos,
|
|
|
|
endPos, sourcePositions, inliningPositions, inlinedFunctions);
|
|
|
|
};
|
|
|
|
|
2017-08-08 13:31:38 +00:00
|
|
|
TickProcessor.prototype.processCodeScript = function(script, url, source) {
|
|
|
|
this.profile_.addScriptSource(script, url, source);
|
2017-07-27 19:46:32 +00:00
|
|
|
};
|
2011-09-12 10:50:40 +00:00
|
|
|
|
Fix issue 553: function frame is skipped in profile when compare stub is called.
The problem appeared due to a fact that stubs doesn't create a stack
frame, reusing the stack frame of the caller function. When building
stack traces, the current function is retrieved from PC, and its
callees are retrieved by traversing the stack backwards. Thus, for
stubs, the stub itself was discovered via PC, and then stub's caller's
caller was retrieved from stack.
To fix this problem, a pointer to JSFunction object is now captured
from the topmost stack frame, and is saved into stack trace log
record. Then a simple heuristics is applied whether a referred
function should be added to decoded stack, or not, to avoid reporting
the same function twice (from PC and from the pointer.)
BUG=553
TEST=added to mjsunit/tools/tickprocessor
Review URL: http://codereview.chromium.org/546089
git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@3673 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2010-01-21 16:42:41 +00:00
|
|
|
TickProcessor.prototype.processFunctionMove = function(from, to) {
|
2011-02-22 16:31:24 +00:00
|
|
|
this.profile_.moveFunc(from, to);
|
Fix issue 553: function frame is skipped in profile when compare stub is called.
The problem appeared due to a fact that stubs doesn't create a stack
frame, reusing the stack frame of the caller function. When building
stack traces, the current function is retrieved from PC, and its
callees are retrieved by traversing the stack backwards. Thus, for
stubs, the stub itself was discovered via PC, and then stub's caller's
caller was retrieved from stack.
To fix this problem, a pointer to JSFunction object is now captured
from the topmost stack frame, and is saved into stack trace log
record. Then a simple heuristics is applied whether a referred
function should be added to decoded stack, or not, to avoid reporting
the same function twice (from PC and from the pointer.)
BUG=553
TEST=added to mjsunit/tools/tickprocessor
Review URL: http://codereview.chromium.org/546089
git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@3673 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2010-01-21 16:42:41 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2009-04-27 13:50:42 +00:00
|
|
|
TickProcessor.prototype.includeTick = function(vmState) {
|
2016-06-10 09:16:03 +00:00
|
|
|
if (this.stateFilter_ !== null) {
|
|
|
|
return this.stateFilter_ == vmState;
|
|
|
|
} else if (this.runtimeTimerFilter_ !== null) {
|
|
|
|
return this.currentRuntimeTimer == this.runtimeTimerFilter_;
|
|
|
|
}
|
|
|
|
return true;
|
2009-04-27 13:50:42 +00:00
|
|
|
};
|
|
|
|
|
2016-06-10 09:16:03 +00:00
|
|
|
TickProcessor.prototype.processRuntimeTimerEvent = function(name) {
|
|
|
|
this.currentRuntimeTimer = name;
|
|
|
|
}
|
|
|
|
|
2011-03-21 18:13:27 +00:00
|
|
|
TickProcessor.prototype.processTick = function(pc,
|
2012-11-28 11:01:10 +00:00
|
|
|
ns_since_start,
|
2013-04-19 11:55:01 +00:00
|
|
|
is_external_callback,
|
|
|
|
tos_or_external_callback,
|
2011-03-21 18:13:27 +00:00
|
|
|
vmState,
|
|
|
|
stack) {
|
2013-01-29 14:41:02 +00:00
|
|
|
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;
|
|
|
|
}
|
2009-04-27 13:50:42 +00:00
|
|
|
this.ticks_.total++;
|
|
|
|
if (vmState == TickProcessor.VmStates.GC) this.ticks_.gc++;
|
|
|
|
if (!this.includeTick(vmState)) {
|
|
|
|
this.ticks_.excluded++;
|
|
|
|
return;
|
|
|
|
}
|
2013-04-19 11:55:01 +00:00
|
|
|
if (is_external_callback) {
|
2011-03-21 18:13:27 +00:00
|
|
|
// Don't use PC when in external callback code, as it can point
|
|
|
|
// inside callback's code, and we will erroneously report
|
2011-03-30 13:30:52 +00:00
|
|
|
// that a callback calls itself. Instead we use tos_or_external_callback,
|
|
|
|
// as simply resetting PC will produce unaccounted ticks.
|
2013-04-19 11:55:01 +00:00
|
|
|
pc = tos_or_external_callback;
|
|
|
|
tos_or_external_callback = 0;
|
|
|
|
} else if (tos_or_external_callback) {
|
|
|
|
// Find out, if top of stack was pointing inside a JS function
|
|
|
|
// meaning that we have encountered a frameless invocation.
|
|
|
|
var funcEntry = this.profile_.findEntry(tos_or_external_callback);
|
2017-04-27 10:07:13 +00:00
|
|
|
if (!funcEntry || !funcEntry.isJSFunction || !funcEntry.isJSFunction()) {
|
2013-04-19 11:55:01 +00:00
|
|
|
tos_or_external_callback = 0;
|
|
|
|
}
|
|
|
|
}
|
Fix issue 553: function frame is skipped in profile when compare stub is called.
The problem appeared due to a fact that stubs doesn't create a stack
frame, reusing the stack frame of the caller function. When building
stack traces, the current function is retrieved from PC, and its
callees are retrieved by traversing the stack backwards. Thus, for
stubs, the stub itself was discovered via PC, and then stub's caller's
caller was retrieved from stack.
To fix this problem, a pointer to JSFunction object is now captured
from the topmost stack frame, and is saved into stack trace log
record. Then a simple heuristics is applied whether a referred
function should be added to decoded stack, or not, to avoid reporting
the same function twice (from PC and from the pointer.)
BUG=553
TEST=added to mjsunit/tools/tickprocessor
Review URL: http://codereview.chromium.org/546089
git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@3673 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2010-01-21 16:42:41 +00:00
|
|
|
|
2017-03-04 13:04:58 +00:00
|
|
|
this.profile_.recordTick(
|
|
|
|
ns_since_start, vmState,
|
|
|
|
this.processStack(pc, tos_or_external_callback, stack));
|
2009-04-27 13:50:42 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2013-01-29 14:41:02 +00:00
|
|
|
TickProcessor.prototype.advanceDistortion = function() {
|
|
|
|
this.distortion += this.distortion_per_entry;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-10-15 07:50:23 +00:00
|
|
|
TickProcessor.prototype.processHeapSampleBegin = function(space, state, ticks) {
|
|
|
|
if (space != 'Heap') return;
|
2011-02-10 07:47:28 +00:00
|
|
|
this.currentProducerProfile_ = new CallTree();
|
2009-10-15 07:50:23 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
TickProcessor.prototype.processHeapSampleEnd = function(space, state) {
|
|
|
|
if (space != 'Heap' || !this.currentProducerProfile_) return;
|
|
|
|
|
|
|
|
print('Generation ' + this.generation_ + ':');
|
|
|
|
var tree = this.currentProducerProfile_;
|
|
|
|
tree.computeTotalWeights();
|
|
|
|
var producersView = this.viewBuilder_.buildView(tree);
|
|
|
|
// Sort by total time, desc, then by name, desc.
|
|
|
|
producersView.sort(function(rec1, rec2) {
|
|
|
|
return rec2.totalTime - rec1.totalTime ||
|
|
|
|
(rec2.internalFuncName < rec1.internalFuncName ? -1 : 1); });
|
|
|
|
this.printHeavyProfile(producersView.head.children);
|
|
|
|
|
|
|
|
this.currentProducerProfile_ = null;
|
|
|
|
this.generation_++;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2009-04-27 13:50:42 +00:00
|
|
|
TickProcessor.prototype.printStatistics = function() {
|
2017-03-04 13:04:58 +00:00
|
|
|
if (this.preprocessJson) {
|
|
|
|
this.profile_.writeJson();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2009-04-27 13:50:42 +00:00
|
|
|
print('Statistical profiling result from ' + this.lastLogFileName_ +
|
|
|
|
', (' + this.ticks_.total +
|
|
|
|
' ticks, ' + this.ticks_.unaccounted + ' unaccounted, ' +
|
|
|
|
this.ticks_.excluded + ' excluded).');
|
|
|
|
|
|
|
|
if (this.ticks_.total == 0) return;
|
|
|
|
|
|
|
|
var flatProfile = this.profile_.getFlatProfile();
|
|
|
|
var flatView = this.viewBuilder_.buildView(flatProfile);
|
|
|
|
// Sort by self time, desc, then by name, desc.
|
|
|
|
flatView.sort(function(rec1, rec2) {
|
|
|
|
return rec2.selfTime - rec1.selfTime ||
|
|
|
|
(rec2.internalFuncName < rec1.internalFuncName ? -1 : 1); });
|
|
|
|
var totalTicks = this.ticks_.total;
|
|
|
|
if (this.ignoreUnknown_) {
|
|
|
|
totalTicks -= this.ticks_.unaccounted;
|
|
|
|
}
|
2015-09-03 18:01:40 +00:00
|
|
|
var printAllTicks = !this.onlySummary_;
|
2009-04-27 13:50:42 +00:00
|
|
|
|
|
|
|
// Count library ticks
|
|
|
|
var flatViewNodes = flatView.head.children;
|
|
|
|
var self = this;
|
2014-08-04 08:31:49 +00:00
|
|
|
|
2009-04-27 13:50:42 +00:00
|
|
|
var libraryTicks = 0;
|
2015-09-03 18:01:40 +00:00
|
|
|
if(printAllTicks) this.printHeader('Shared libraries');
|
2014-08-04 08:31:49 +00:00
|
|
|
this.printEntries(flatViewNodes, totalTicks, null,
|
2009-04-27 13:50:42 +00:00
|
|
|
function(name) { return self.isSharedLibrary(name); },
|
2015-09-03 18:01:40 +00:00
|
|
|
function(rec) { libraryTicks += rec.selfTime; }, printAllTicks);
|
2009-04-27 13:50:42 +00:00
|
|
|
var nonLibraryTicks = totalTicks - libraryTicks;
|
|
|
|
|
2014-08-04 08:31:49 +00:00
|
|
|
var jsTicks = 0;
|
2015-09-03 18:01:40 +00:00
|
|
|
if(printAllTicks) this.printHeader('JavaScript');
|
2014-08-04 08:31:49 +00:00
|
|
|
this.printEntries(flatViewNodes, totalTicks, nonLibraryTicks,
|
|
|
|
function(name) { return self.isJsCode(name); },
|
2015-09-03 18:01:40 +00:00
|
|
|
function(rec) { jsTicks += rec.selfTime; }, printAllTicks);
|
2009-04-27 13:50:42 +00:00
|
|
|
|
2014-08-04 08:31:49 +00:00
|
|
|
var cppTicks = 0;
|
2015-09-03 18:01:40 +00:00
|
|
|
if(printAllTicks) this.printHeader('C++');
|
2014-08-04 08:31:49 +00:00
|
|
|
this.printEntries(flatViewNodes, totalTicks, nonLibraryTicks,
|
|
|
|
function(name) { return self.isCppCode(name); },
|
2015-09-03 18:01:40 +00:00
|
|
|
function(rec) { cppTicks += rec.selfTime; }, printAllTicks);
|
2014-08-04 08:31:49 +00:00
|
|
|
|
|
|
|
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);
|
|
|
|
}
|
2009-04-27 13:50:42 +00:00
|
|
|
|
2015-09-03 18:01:40 +00:00
|
|
|
if(printAllTicks) {
|
|
|
|
print('\n [C++ entry points]:');
|
|
|
|
print(' ticks cpp total name');
|
|
|
|
var c_entry_functions = this.profile_.getCEntryProfile();
|
|
|
|
var total_c_entry = c_entry_functions[0].ticks;
|
|
|
|
for (var i = 1; i < c_entry_functions.length; i++) {
|
|
|
|
c = c_entry_functions[i];
|
|
|
|
this.printLine(c.name, c.ticks, total_c_entry, totalTicks);
|
|
|
|
}
|
2014-10-17 15:44:02 +00:00
|
|
|
|
2015-09-03 18:01:40 +00:00
|
|
|
this.printHeavyProfHeader();
|
|
|
|
var heavyProfile = this.profile_.getBottomUpProfile();
|
|
|
|
var heavyView = this.viewBuilder_.buildView(heavyProfile);
|
|
|
|
// To show the same percentages as in the flat profile.
|
|
|
|
heavyView.head.totalTime = totalTicks;
|
|
|
|
// Sort by total time, desc, then by name, desc.
|
|
|
|
heavyView.sort(function(rec1, rec2) {
|
|
|
|
return rec2.totalTime - rec1.totalTime ||
|
|
|
|
(rec2.internalFuncName < rec1.internalFuncName ? -1 : 1); });
|
|
|
|
this.printHeavyProfile(heavyView.head.children);
|
|
|
|
}
|
2009-04-27 13:50:42 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
function padLeft(s, len) {
|
|
|
|
s = s.toString();
|
|
|
|
if (s.length < len) {
|
2009-07-09 06:39:38 +00:00
|
|
|
var padLength = len - s.length;
|
|
|
|
if (!(padLength in padLeft)) {
|
|
|
|
padLeft[padLength] = new Array(padLength + 1).join(' ');
|
|
|
|
}
|
|
|
|
s = padLeft[padLength] + s;
|
2009-04-27 13:50:42 +00:00
|
|
|
}
|
|
|
|
return s;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
TickProcessor.prototype.printHeader = function(headerTitle) {
|
|
|
|
print('\n [' + headerTitle + ']:');
|
|
|
|
print(' ticks total nonlib name');
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2014-08-04 08:31:49 +00:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2009-04-27 13:50:42 +00:00
|
|
|
TickProcessor.prototype.printHeavyProfHeader = function() {
|
|
|
|
print('\n [Bottom up (heavy) profile]:');
|
|
|
|
print(' Note: percentage shows a share of a particular caller in the ' +
|
|
|
|
'total\n' +
|
|
|
|
' amount of its parent calls.');
|
|
|
|
print(' Callers occupying less than ' +
|
|
|
|
TickProcessor.CALL_PROFILE_CUTOFF_PCT.toFixed(1) +
|
|
|
|
'% are not shown.\n');
|
|
|
|
print(' ticks parent name');
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
TickProcessor.prototype.processProfile = function(
|
|
|
|
profile, filterP, func) {
|
|
|
|
for (var i = 0, n = profile.length; i < n; ++i) {
|
|
|
|
var rec = profile[i];
|
2009-04-30 08:10:27 +00:00
|
|
|
if (!filterP(rec.internalFuncName)) {
|
2009-04-27 13:50:42 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
func(rec);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2013-08-23 17:20:54 +00:00
|
|
|
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;
|
|
|
|
};
|
2009-04-27 13:50:42 +00:00
|
|
|
|
|
|
|
TickProcessor.prototype.printEntries = function(
|
2015-09-03 18:01:40 +00:00
|
|
|
profile, totalTicks, nonLibTicks, filterP, callback, printAllTicks) {
|
2013-08-23 17:20:54 +00:00
|
|
|
var that = this;
|
2009-04-27 13:50:42 +00:00
|
|
|
this.processProfile(profile, filterP, function (rec) {
|
|
|
|
if (rec.selfTime == 0) return;
|
2014-08-04 08:31:49 +00:00
|
|
|
callback(rec);
|
2013-08-23 17:20:54 +00:00
|
|
|
var funcName = that.formatFunctionName(rec.internalFuncName);
|
2015-09-03 18:01:40 +00:00
|
|
|
if(printAllTicks) {
|
|
|
|
that.printLine(funcName, rec.selfTime, totalTicks, nonLibTicks);
|
|
|
|
}
|
2009-04-27 13:50:42 +00:00
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
TickProcessor.prototype.printHeavyProfile = function(profile, opt_indent) {
|
|
|
|
var self = this;
|
|
|
|
var indent = opt_indent || 0;
|
|
|
|
var indentStr = padLeft('', indent);
|
|
|
|
this.processProfile(profile, function() { return true; }, function (rec) {
|
|
|
|
// Cut off too infrequent callers.
|
|
|
|
if (rec.parentTotalPercent < TickProcessor.CALL_PROFILE_CUTOFF_PCT) return;
|
2013-08-23 17:20:54 +00:00
|
|
|
var funcName = self.formatFunctionName(rec.internalFuncName);
|
2009-04-27 13:50:42 +00:00
|
|
|
print(' ' + padLeft(rec.totalTime, 5) + ' ' +
|
|
|
|
padLeft(rec.parentTotalPercent.toFixed(1), 5) + '% ' +
|
2013-08-23 17:20:54 +00:00
|
|
|
indentStr + funcName);
|
2009-04-27 13:50:42 +00:00
|
|
|
// Limit backtrace depth.
|
2012-02-13 10:07:57 +00:00
|
|
|
if (indent < 2 * self.callGraphSize_) {
|
2009-04-27 13:50:42 +00:00
|
|
|
self.printHeavyProfile(rec.children, indent + 2);
|
|
|
|
}
|
|
|
|
// Delimit top-level functions.
|
|
|
|
if (indent == 0) {
|
|
|
|
print('');
|
|
|
|
}
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
function CppEntriesProvider() {
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
CppEntriesProvider.prototype.parseVmSymbols = function(
|
2016-05-02 08:00:48 +00:00
|
|
|
libName, libStart, libEnd, libASLRSlide, processorFunc) {
|
2009-05-08 11:27:02 +00:00
|
|
|
this.loadSymbols(libName);
|
2009-04-27 13:50:42 +00:00
|
|
|
|
|
|
|
var prevEntry;
|
|
|
|
|
2009-07-14 09:47:44 +00:00
|
|
|
function addEntry(funcInfo) {
|
2009-04-27 13:50:42 +00:00
|
|
|
// Several functions can be mapped onto the same address. To avoid
|
|
|
|
// creating zero-sized entries, skip such duplicates.
|
2009-06-19 07:08:31 +00:00
|
|
|
// Also double-check that function belongs to the library address space.
|
2009-07-14 09:47:44 +00:00
|
|
|
if (prevEntry && !prevEntry.end &&
|
|
|
|
prevEntry.start < funcInfo.start &&
|
|
|
|
prevEntry.start >= libStart && funcInfo.start <= libEnd) {
|
|
|
|
processorFunc(prevEntry.name, prevEntry.start, funcInfo.start);
|
2009-04-27 13:50:42 +00:00
|
|
|
}
|
2009-07-14 09:47:44 +00:00
|
|
|
if (funcInfo.end &&
|
|
|
|
(!prevEntry || prevEntry.start != funcInfo.start) &&
|
|
|
|
funcInfo.start >= libStart && funcInfo.end <= libEnd) {
|
|
|
|
processorFunc(funcInfo.name, funcInfo.start, funcInfo.end);
|
|
|
|
}
|
|
|
|
prevEntry = funcInfo;
|
2009-04-27 13:50:42 +00:00
|
|
|
}
|
|
|
|
|
2009-05-08 11:27:02 +00:00
|
|
|
while (true) {
|
|
|
|
var funcInfo = this.parseNextLine();
|
|
|
|
if (funcInfo === null) {
|
2009-04-27 13:50:42 +00:00
|
|
|
continue;
|
2009-05-08 11:27:02 +00:00
|
|
|
} else if (funcInfo === false) {
|
|
|
|
break;
|
2009-04-27 13:50:42 +00:00
|
|
|
}
|
2017-06-23 04:23:26 +00:00
|
|
|
if (funcInfo.start < libStart - libASLRSlide &&
|
|
|
|
funcInfo.start < libEnd - libStart) {
|
2009-04-27 13:50:42 +00:00
|
|
|
funcInfo.start += libStart;
|
2017-06-23 04:23:26 +00:00
|
|
|
} else {
|
|
|
|
funcInfo.start += libASLRSlide;
|
2009-04-27 13:50:42 +00:00
|
|
|
}
|
2009-07-14 09:47:44 +00:00
|
|
|
if (funcInfo.size) {
|
|
|
|
funcInfo.end = funcInfo.start + funcInfo.size;
|
|
|
|
}
|
|
|
|
addEntry(funcInfo);
|
2009-04-27 13:50:42 +00:00
|
|
|
}
|
2009-07-14 09:47:44 +00:00
|
|
|
addEntry({name: '', start: libEnd});
|
2009-04-27 13:50:42 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
CppEntriesProvider.prototype.loadSymbols = function(libName) {
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2009-05-08 11:27:02 +00:00
|
|
|
CppEntriesProvider.prototype.parseNextLine = function() {
|
|
|
|
return false;
|
2009-04-27 13:50:42 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2012-07-16 11:00:44 +00:00
|
|
|
function UnixCppEntriesProvider(nmExec, targetRootFS) {
|
2009-05-08 11:27:02 +00:00
|
|
|
this.symbols = [];
|
|
|
|
this.parsePos = 0;
|
2009-06-20 12:54:02 +00:00
|
|
|
this.nmExec = nmExec;
|
2012-07-16 11:00:44 +00:00
|
|
|
this.targetRootFS = targetRootFS;
|
2009-07-28 15:37:05 +00:00
|
|
|
this.FUNC_RE = /^([0-9a-fA-F]{8,16}) ([0-9a-fA-F]{8,16} )?[tTwW] (.*)$/;
|
2009-04-27 13:50:42 +00:00
|
|
|
};
|
|
|
|
inherits(UnixCppEntriesProvider, CppEntriesProvider);
|
|
|
|
|
|
|
|
|
|
|
|
UnixCppEntriesProvider.prototype.loadSymbols = function(libName) {
|
2009-05-08 11:27:02 +00:00
|
|
|
this.parsePos = 0;
|
2012-07-16 11:00:44 +00:00
|
|
|
libName = this.targetRootFS + libName;
|
2009-06-16 13:44:48 +00:00
|
|
|
try {
|
|
|
|
this.symbols = [
|
2009-07-14 09:47:44 +00:00
|
|
|
os.system(this.nmExec, ['-C', '-n', '-S', libName], -1, -1),
|
|
|
|
os.system(this.nmExec, ['-C', '-n', '-S', '-D', libName], -1, -1)
|
2009-06-16 13:44:48 +00:00
|
|
|
];
|
|
|
|
} catch (e) {
|
|
|
|
// If the library cannot be found on this system let's not panic.
|
2009-06-18 07:59:13 +00:00
|
|
|
this.symbols = ['', ''];
|
2009-06-16 13:44:48 +00:00
|
|
|
}
|
2009-04-27 13:50:42 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2009-05-08 11:27:02 +00:00
|
|
|
UnixCppEntriesProvider.prototype.parseNextLine = function() {
|
|
|
|
if (this.symbols.length == 0) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
var lineEndPos = this.symbols[0].indexOf('\n', this.parsePos);
|
|
|
|
if (lineEndPos == -1) {
|
|
|
|
this.symbols.shift();
|
|
|
|
this.parsePos = 0;
|
|
|
|
return this.parseNextLine();
|
|
|
|
}
|
|
|
|
|
|
|
|
var line = this.symbols[0].substring(this.parsePos, lineEndPos);
|
|
|
|
this.parsePos = lineEndPos + 1;
|
2009-07-14 05:01:06 +00:00
|
|
|
var fields = line.match(this.FUNC_RE);
|
2009-07-14 09:47:44 +00:00
|
|
|
var funcInfo = null;
|
|
|
|
if (fields) {
|
|
|
|
funcInfo = { name: fields[3], start: parseInt(fields[1], 16) };
|
|
|
|
if (fields[2]) {
|
|
|
|
funcInfo.size = parseInt(fields[2], 16);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return funcInfo;
|
2009-04-27 13:50:42 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2012-07-16 11:00:44 +00:00
|
|
|
function MacCppEntriesProvider(nmExec, targetRootFS) {
|
|
|
|
UnixCppEntriesProvider.call(this, nmExec, targetRootFS);
|
2009-07-14 09:47:44 +00:00
|
|
|
// Note an empty group. It is required, as UnixCppEntriesProvider expects 3 groups.
|
2017-03-04 13:04:58 +00:00
|
|
|
this.FUNC_RE = /^([0-9a-fA-F]{8,16})() (.*)$/;
|
2009-07-14 05:01:06 +00:00
|
|
|
};
|
|
|
|
inherits(MacCppEntriesProvider, UnixCppEntriesProvider);
|
|
|
|
|
|
|
|
|
|
|
|
MacCppEntriesProvider.prototype.loadSymbols = function(libName) {
|
|
|
|
this.parsePos = 0;
|
2012-07-16 11:00:44 +00:00
|
|
|
libName = this.targetRootFS + libName;
|
2016-04-13 12:19:02 +00:00
|
|
|
|
|
|
|
// It seems that in OS X `nm` thinks that `-f` is a format option, not a
|
|
|
|
// "flat" display option flag.
|
2009-07-14 05:01:06 +00:00
|
|
|
try {
|
2016-04-13 12:19:02 +00:00
|
|
|
this.symbols = [os.system(this.nmExec, ['-n', libName], -1, -1), ''];
|
2009-07-14 05:01:06 +00:00
|
|
|
} catch (e) {
|
|
|
|
// If the library cannot be found on this system let's not panic.
|
|
|
|
this.symbols = '';
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2012-07-16 11:00:44 +00:00
|
|
|
function WindowsCppEntriesProvider(_ignored_nmExec, targetRootFS) {
|
|
|
|
this.targetRootFS = targetRootFS;
|
2009-05-08 11:27:02 +00:00
|
|
|
this.symbols = '';
|
|
|
|
this.parsePos = 0;
|
2009-04-27 13:50:42 +00:00
|
|
|
};
|
|
|
|
inherits(WindowsCppEntriesProvider, CppEntriesProvider);
|
|
|
|
|
|
|
|
|
2009-08-17 13:45:03 +00:00
|
|
|
WindowsCppEntriesProvider.FILENAME_RE = /^(.*)\.([^.]+)$/;
|
2009-04-27 13:50:42 +00:00
|
|
|
|
|
|
|
|
|
|
|
WindowsCppEntriesProvider.FUNC_RE =
|
2009-08-17 13:45:03 +00:00
|
|
|
/^\s+0001:[0-9a-fA-F]{8}\s+([_\?@$0-9a-zA-Z]+)\s+([0-9a-fA-F]{8}).*$/;
|
|
|
|
|
|
|
|
|
|
|
|
WindowsCppEntriesProvider.IMAGE_BASE_RE =
|
|
|
|
/^\s+0000:00000000\s+___ImageBase\s+([0-9a-fA-F]{8}).*$/;
|
|
|
|
|
|
|
|
|
|
|
|
// This is almost a constant on Windows.
|
|
|
|
WindowsCppEntriesProvider.EXE_IMAGE_BASE = 0x00400000;
|
2009-04-27 13:50:42 +00:00
|
|
|
|
|
|
|
|
|
|
|
WindowsCppEntriesProvider.prototype.loadSymbols = function(libName) {
|
2012-07-16 11:00:44 +00:00
|
|
|
libName = this.targetRootFS + libName;
|
2009-04-27 13:50:42 +00:00
|
|
|
var fileNameFields = libName.match(WindowsCppEntriesProvider.FILENAME_RE);
|
2009-05-08 11:27:02 +00:00
|
|
|
if (!fileNameFields) return;
|
2009-04-27 13:50:42 +00:00
|
|
|
var mapFileName = fileNameFields[1] + '.map';
|
2009-08-17 13:45:03 +00:00
|
|
|
this.moduleType_ = fileNameFields[2].toLowerCase();
|
|
|
|
try {
|
|
|
|
this.symbols = read(mapFileName);
|
|
|
|
} catch (e) {
|
|
|
|
// If .map file cannot be found let's not panic.
|
|
|
|
this.symbols = '';
|
|
|
|
}
|
2009-04-27 13:50:42 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2009-05-08 11:27:02 +00:00
|
|
|
WindowsCppEntriesProvider.prototype.parseNextLine = function() {
|
|
|
|
var lineEndPos = this.symbols.indexOf('\r\n', this.parsePos);
|
|
|
|
if (lineEndPos == -1) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
var line = this.symbols.substring(this.parsePos, lineEndPos);
|
|
|
|
this.parsePos = lineEndPos + 2;
|
2009-08-17 13:45:03 +00:00
|
|
|
|
|
|
|
// Image base entry is above all other symbols, so we can just
|
|
|
|
// terminate parsing.
|
|
|
|
var imageBaseFields = line.match(WindowsCppEntriesProvider.IMAGE_BASE_RE);
|
|
|
|
if (imageBaseFields) {
|
|
|
|
var imageBase = parseInt(imageBaseFields[1], 16);
|
|
|
|
if ((this.moduleType_ == 'exe') !=
|
|
|
|
(imageBase == WindowsCppEntriesProvider.EXE_IMAGE_BASE)) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-04-27 13:50:42 +00:00
|
|
|
var fields = line.match(WindowsCppEntriesProvider.FUNC_RE);
|
|
|
|
return fields ?
|
|
|
|
{ name: this.unmangleName(fields[1]), start: parseInt(fields[2], 16) } :
|
|
|
|
null;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Performs very simple unmangling of C++ names.
|
|
|
|
*
|
|
|
|
* Does not handle arguments and template arguments. The mangled names have
|
|
|
|
* the form:
|
|
|
|
*
|
|
|
|
* ?LookupInDescriptor@JSObject@internal@v8@@...arguments info...
|
|
|
|
*/
|
|
|
|
WindowsCppEntriesProvider.prototype.unmangleName = function(name) {
|
|
|
|
// Empty or non-mangled name.
|
|
|
|
if (name.length < 1 || name.charAt(0) != '?') return name;
|
|
|
|
var nameEndPos = name.indexOf('@@');
|
|
|
|
var components = name.substring(1, nameEndPos).split('@');
|
|
|
|
components.reverse();
|
|
|
|
return components.join('::');
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2017-10-23 22:47:02 +00:00
|
|
|
class ArgumentsProcessor extends BaseArgumentsProcessor {
|
|
|
|
getArgsDispatch() {
|
|
|
|
let dispatch = {
|
|
|
|
'-j': ['stateFilter', TickProcessor.VmStates.JS,
|
|
|
|
'Show only ticks from JS VM state'],
|
|
|
|
'-g': ['stateFilter', TickProcessor.VmStates.GC,
|
|
|
|
'Show only ticks from GC VM state'],
|
|
|
|
'-p': ['stateFilter', TickProcessor.VmStates.PARSER,
|
|
|
|
'Show only ticks from PARSER VM state'],
|
|
|
|
'-b': ['stateFilter', TickProcessor.VmStates.BYTECODE_COMPILER,
|
|
|
|
'Show only ticks from BYTECODE_COMPILER VM state'],
|
|
|
|
'-c': ['stateFilter', TickProcessor.VmStates.COMPILER,
|
|
|
|
'Show only ticks from COMPILER VM state'],
|
|
|
|
'-o': ['stateFilter', TickProcessor.VmStates.OTHER,
|
|
|
|
'Show only ticks from OTHER VM state'],
|
|
|
|
'-e': ['stateFilter', TickProcessor.VmStates.EXTERNAL,
|
|
|
|
'Show only ticks from EXTERNAL VM state'],
|
|
|
|
'--filter-runtime-timer': ['runtimeTimerFilter', null,
|
|
|
|
'Show only ticks matching the given runtime timer scope'],
|
|
|
|
'--call-graph-size': ['callGraphSize', TickProcessor.CALL_GRAPH_SIZE,
|
|
|
|
'Set the call graph size'],
|
|
|
|
'--ignore-unknown': ['ignoreUnknown', true,
|
|
|
|
'Exclude ticks of unknown code entries from processing'],
|
|
|
|
'--separate-ic': ['separateIc', parseBool,
|
|
|
|
'Separate IC entries'],
|
|
|
|
'--separate-bytecodes': ['separateBytecodes', parseBool,
|
|
|
|
'Separate Bytecode entries'],
|
|
|
|
'--separate-builtins': ['separateBuiltins', parseBool,
|
|
|
|
'Separate Builtin entries'],
|
|
|
|
'--separate-stubs': ['separateStubs', parseBool,
|
|
|
|
'Separate Stub entries'],
|
|
|
|
'--unix': ['platform', 'unix',
|
|
|
|
'Specify that we are running on *nix platform'],
|
|
|
|
'--windows': ['platform', 'windows',
|
|
|
|
'Specify that we are running on Windows platform'],
|
|
|
|
'--mac': ['platform', 'mac',
|
|
|
|
'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'],
|
|
|
|
'--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'],
|
|
|
|
'--timed-range': ['timedRange', true,
|
|
|
|
'Ignore ticks before first and after last Date.now() call'],
|
|
|
|
'--pairwise-timed-range': ['pairwiseTimedRange', true,
|
|
|
|
'Ignore ticks outside pairs of Date.now() calls'],
|
|
|
|
'--only-summary': ['onlySummary', true,
|
|
|
|
'Print only tick summary, exclude other information'],
|
|
|
|
'--preprocess': ['preprocessJson', true,
|
|
|
|
'Preprocess for consumption with web interface']
|
|
|
|
};
|
|
|
|
dispatch['--js'] = dispatch['-j'];
|
|
|
|
dispatch['--gc'] = dispatch['-g'];
|
|
|
|
dispatch['--compiler'] = dispatch['-c'];
|
|
|
|
dispatch['--other'] = dispatch['-o'];
|
|
|
|
dispatch['--external'] = dispatch['-e'];
|
|
|
|
dispatch['--ptr'] = dispatch['--pairwise-timed-range'];
|
|
|
|
return dispatch;
|
|
|
|
}
|
|
|
|
|
|
|
|
getDefaultResults() {
|
|
|
|
return {
|
|
|
|
logFileName: 'v8.log',
|
|
|
|
platform: 'unix',
|
|
|
|
stateFilter: null,
|
|
|
|
callGraphSize: 5,
|
|
|
|
ignoreUnknown: false,
|
|
|
|
separateIc: true,
|
|
|
|
separateBytecodes: false,
|
|
|
|
separateBuiltins: true,
|
|
|
|
separateStubs: true,
|
|
|
|
preprocessJson: null,
|
|
|
|
targetRootFS: '',
|
|
|
|
nm: 'nm',
|
|
|
|
range: 'auto,auto',
|
|
|
|
distortion: 0,
|
|
|
|
timedRange: false,
|
|
|
|
pairwiseTimedRange: false,
|
|
|
|
onlySummary: false,
|
|
|
|
runtimeTimerFilter: null,
|
|
|
|
};
|
2009-07-09 06:39:38 +00:00
|
|
|
}
|
2017-10-23 22:47:02 +00:00
|
|
|
}
|