| Index: tools/tickprocessor.js
|
| diff --git a/tools/tickprocessor.js b/tools/tickprocessor.js
|
| index 3c5fab463b54946b66eebc4404ef8ed0f4b7d676..72d367f1990aab42b80b46435b3e446f8bddd5fd 100644
|
| --- a/tools/tickprocessor.js
|
| +++ b/tools/tickprocessor.js
|
| @@ -52,8 +52,35 @@ function readFile(fileName) {
|
| }
|
|
|
|
|
| +function inherits(childCtor, parentCtor) {
|
| + function tempCtor() {};
|
| + tempCtor.prototype = parentCtor.prototype;
|
| + childCtor.prototype = new tempCtor();
|
| +};
|
| +
|
| +
|
| function TickProcessor(
|
| cppEntriesProvider, separateIc, ignoreUnknown, stateFilter) {
|
| + devtools.profiler.LogReader.call(this, {
|
| + 'shared-library': { parsers: [null, parseInt, parseInt],
|
| + processor: this.processSharedLibrary },
|
| + 'code-creation': {
|
| + parsers: [null, this.createAddressParser('code'), parseInt, null],
|
| + processor: this.processCodeCreation, backrefs: true },
|
| + 'code-move': { parsers: [this.createAddressParser('code'),
|
| + this.createAddressParser('code-move-to')],
|
| + processor: this.processCodeMove, backrefs: true },
|
| + 'code-delete': { parsers: [this.createAddressParser('code')],
|
| + processor: this.processCodeDelete, backrefs: true },
|
| + 'tick': { parsers: [this.createAddressParser('code'),
|
| + this.createAddressParser('stack'), parseInt, 'var-args'],
|
| + processor: this.processTick, backrefs: true },
|
| + 'profiler': null,
|
| + // Obsolete row types.
|
| + 'code-allocate': null,
|
| + 'begin-code-region': null,
|
| + 'end-code-region': null });
|
| +
|
| this.cppEntriesProvider_ = cppEntriesProvider;
|
| this.ignoreUnknown_ = ignoreUnknown;
|
| this.stateFilter_ = stateFilter;
|
| @@ -86,8 +113,8 @@ function TickProcessor(
|
| // Count each tick as a time unit.
|
| this.viewBuilder_ = new devtools.profiler.ViewBuilder(1);
|
| this.lastLogFileName_ = null;
|
| - this.aliases_ = {};
|
| };
|
| +inherits(TickProcessor, devtools.profiler.LogReader);
|
|
|
|
|
| TickProcessor.VmStates = {
|
| @@ -107,27 +134,17 @@ TickProcessor.CodeTypes = {
|
| // codeTypes_ map because there can be zillions of them.
|
|
|
|
|
| -TickProcessor.RecordsDispatch = {
|
| - 'shared-library': { parsers: [null, parseInt, parseInt],
|
| - processor: 'processSharedLibrary' },
|
| - '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' },
|
| - 'alias': { parsers: [null, null], processor: 'processAlias' },
|
| - 'profiler': null,
|
| - // Obsolete row types.
|
| - 'code-allocate': null,
|
| - 'begin-code-region': null,
|
| - 'end-code-region': null
|
| -};
|
| -
|
| TickProcessor.CALL_PROFILE_CUTOFF_PCT = 2.0;
|
|
|
|
|
| +/**
|
| + * @override
|
| + */
|
| +TickProcessor.prototype.printError = function(str) {
|
| + print(str);
|
| +};
|
| +
|
| +
|
| TickProcessor.prototype.setCodeType = function(name, type) {
|
| this.codeTypes_[name] = TickProcessor.CodeTypes[type];
|
| };
|
| @@ -151,52 +168,7 @@ TickProcessor.prototype.isJsCode = function(name) {
|
| TickProcessor.prototype.processLogFile = function(fileName) {
|
| this.lastLogFileName_ = fileName;
|
| var contents = readFile(fileName);
|
| - this.processLog(contents.split('\n'));
|
| -};
|
| -
|
| -
|
| -TickProcessor.prototype.processLog = function(lines) {
|
| - var csvParser = new devtools.profiler.CsvParser();
|
| - 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);
|
| - }
|
| -};
|
| -
|
| -
|
| -TickProcessor.prototype.dispatchLogRow = function(fields) {
|
| - // Obtain the dispatch.
|
| - var command = fields[0];
|
| - if (!(command in TickProcessor.RecordsDispatch)) {
|
| - throw new Error('unknown command: ' + command);
|
| - }
|
| - var dispatch = TickProcessor.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);
|
| + this.processLogChunk(contents);
|
| };
|
|
|
|
|
| @@ -214,22 +186,10 @@ TickProcessor.prototype.processSharedLibrary = function(
|
| };
|
|
|
|
|
| -TickProcessor.prototype.processAlias = function(symbol, expansion) {
|
| - if (expansion in TickProcessor.RecordsDispatch) {
|
| - TickProcessor.RecordsDispatch[symbol] =
|
| - TickProcessor.RecordsDispatch[expansion];
|
| - } else {
|
| - this.aliases_[symbol] = expansion;
|
| - }
|
| -};
|
| -
|
| -
|
| TickProcessor.prototype.processCodeCreation = function(
|
| type, start, size, name) {
|
| - if (type in this.aliases_) {
|
| - type = this.aliases_[type];
|
| - }
|
| - var entry = this.profile_.addCode(type, name, start, size);
|
| + var entry = this.profile_.addCode(
|
| + this.expandAlias(type), name, start, size);
|
| };
|
|
|
|
|
| @@ -256,21 +216,7 @@ TickProcessor.prototype.processTick = function(pc, sp, vmState, stack) {
|
| return;
|
| }
|
|
|
| - var fullStack = [pc];
|
| - var prevFrame = pc;
|
| - for (var i = 0, n = stack.length; i < n; ++i) {
|
| - var frame = stack[i];
|
| - var firstChar = frame.charAt(0);
|
| - // Leave only numbers starting with 0x. Filter possible 'overflow' string.
|
| - if (firstChar == '0') {
|
| - fullStack.push(parseInt(frame, 16));
|
| - } else if (firstChar == '+' || firstChar == '-') {
|
| - // An offset from the previous frame.
|
| - prevFrame += parseInt(frame, 16);
|
| - fullStack.push(prevFrame);
|
| - }
|
| - }
|
| - this.profile_.recordTick(fullStack);
|
| + this.profile_.recordTick(this.processStack(pc, stack));
|
| };
|
|
|
|
|
| @@ -464,13 +410,6 @@ CppEntriesProvider.prototype.parseNextLine = function() {
|
| };
|
|
|
|
|
| -function inherits(childCtor, parentCtor) {
|
| - function tempCtor() {};
|
| - tempCtor.prototype = parentCtor.prototype;
|
| - childCtor.prototype = new tempCtor();
|
| -};
|
| -
|
| -
|
| function UnixCppEntriesProvider() {
|
| this.symbols = [];
|
| this.parsePos = 0;
|
| @@ -490,7 +429,7 @@ UnixCppEntriesProvider.prototype.loadSymbols = function(libName) {
|
| ];
|
| } catch (e) {
|
| // If the library cannot be found on this system let's not panic.
|
| - this.symbols = [ '', '' ];
|
| + this.symbols = ['', ''];
|
| }
|
| };
|
|
|
|
|