[tools] Modernize tools .mjs files
This is mostly an auto-conversion done by several tools. - use let / const - use arrow functions - use template strings There are some additional manual rewrite required to modernize the code further. Change-Id: I63a7a43b05b14b33ad9941350d3d5f26aab10ba0 Bug: v8:10667 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2519564 Reviewed-by: Sathya Gunasekaran <gsathya@chromium.org> Commit-Queue: Camillo Bruni <cbruni@chromium.org> Cr-Commit-Position: refs/heads/master@{#71080}
This commit is contained in:
parent
4beadfde31
commit
400b6e7f9d
@ -27,37 +27,37 @@ export class BaseArgumentsProcessor {
|
||||
'Default log file name is "' +
|
||||
this.result_.logFileName + '".\n');
|
||||
print('Options:');
|
||||
for (var arg in this.argsDispatch_) {
|
||||
var synonyms = [arg];
|
||||
var dispatch = this.argsDispatch_[arg];
|
||||
for (var synArg in this.argsDispatch_) {
|
||||
for (const arg in this.argsDispatch_) {
|
||||
const synonyms = [arg];
|
||||
const dispatch = this.argsDispatch_[arg];
|
||||
for (const synArg in this.argsDispatch_) {
|
||||
if (arg !== synArg && dispatch === this.argsDispatch_[synArg]) {
|
||||
synonyms.push(synArg);
|
||||
delete this.argsDispatch_[synArg];
|
||||
}
|
||||
}
|
||||
print(' ' + synonyms.join(', ').padEnd(20) + " " + dispatch[2]);
|
||||
print(` ${synonyms.join(', ').padEnd(20)} ${dispatch[2]}`);
|
||||
}
|
||||
quit(2);
|
||||
}
|
||||
|
||||
parse() {
|
||||
while (this.args_.length) {
|
||||
var arg = this.args_.shift();
|
||||
let arg = this.args_.shift();
|
||||
if (arg.charAt(0) != '-') {
|
||||
this.result_.logFileName = arg;
|
||||
continue;
|
||||
}
|
||||
var userValue = null;
|
||||
var eqPos = arg.indexOf('=');
|
||||
let userValue = null;
|
||||
const eqPos = arg.indexOf('=');
|
||||
if (eqPos != -1) {
|
||||
userValue = arg.substr(eqPos + 1);
|
||||
arg = arg.substr(0, eqPos);
|
||||
}
|
||||
if (arg in this.argsDispatch_) {
|
||||
var dispatch = this.argsDispatch_[arg];
|
||||
var property = dispatch[0];
|
||||
var defaultValue = dispatch[1];
|
||||
const dispatch = this.argsDispatch_[arg];
|
||||
const property = dispatch[0];
|
||||
const defaultValue = dispatch[1];
|
||||
if (typeof defaultValue == "function") {
|
||||
userValue = defaultValue(userValue);
|
||||
} else if (userValue == null) {
|
||||
|
@ -90,7 +90,7 @@ export class CodeMap {
|
||||
* @param {number} to The destination address.
|
||||
*/
|
||||
moveCode(from, to) {
|
||||
var removedNode = this.dynamics_.remove(from);
|
||||
const removedNode = this.dynamics_.remove(from);
|
||||
this.deleteAllCoveredNodes_(this.dynamics_, to, to + removedNode.value.size);
|
||||
this.dynamics_.insert(to, removedNode.value);
|
||||
}
|
||||
@ -102,7 +102,7 @@ export class CodeMap {
|
||||
* @param {number} start The starting address of the entry being deleted.
|
||||
*/
|
||||
deleteCode(start) {
|
||||
var removedNode = this.dynamics_.remove(start);
|
||||
const removedNode = this.dynamics_.remove(start);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -130,7 +130,7 @@ export class CodeMap {
|
||||
* @private
|
||||
*/
|
||||
markPages_(start, end) {
|
||||
for (var addr = start; addr <= end;
|
||||
for (let addr = start; addr <= end;
|
||||
addr += CodeMap.PAGE_SIZE) {
|
||||
this.pages_[(addr / CodeMap.PAGE_SIZE)|0] = 1;
|
||||
}
|
||||
@ -140,16 +140,16 @@ export class CodeMap {
|
||||
* @private
|
||||
*/
|
||||
deleteAllCoveredNodes_(tree, start, end) {
|
||||
var to_delete = [];
|
||||
var addr = end - 1;
|
||||
const to_delete = [];
|
||||
let addr = end - 1;
|
||||
while (addr >= start) {
|
||||
var node = tree.findGreatestLessThan(addr);
|
||||
const node = tree.findGreatestLessThan(addr);
|
||||
if (!node) break;
|
||||
var start2 = node.key, end2 = start2 + node.value.size;
|
||||
const start2 = node.key, end2 = start2 + node.value.size;
|
||||
if (start2 < end && start < end2) to_delete.push(start2);
|
||||
addr = start2 - 1;
|
||||
}
|
||||
for (var i = 0, l = to_delete.length; i < l; ++i) tree.remove(to_delete[i]);
|
||||
for (let i = 0, l = to_delete.length; i < l; ++i) tree.remove(to_delete[i]);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -163,7 +163,7 @@ export class CodeMap {
|
||||
* @private
|
||||
*/
|
||||
findInTree_(tree, addr) {
|
||||
var node = tree.findGreatestLessThan(addr);
|
||||
const node = tree.findGreatestLessThan(addr);
|
||||
return node && this.isAddressBelongsTo_(addr, node) ? node : null;
|
||||
}
|
||||
|
||||
@ -175,29 +175,29 @@ export class CodeMap {
|
||||
* @param {number} addr Address.
|
||||
*/
|
||||
findAddress(addr) {
|
||||
var pageAddr = (addr / CodeMap.PAGE_SIZE)|0;
|
||||
const pageAddr = (addr / CodeMap.PAGE_SIZE)|0;
|
||||
if (pageAddr in this.pages_) {
|
||||
// Static code entries can contain "holes" of unnamed code.
|
||||
// In this case, the whole library is assigned to this address.
|
||||
var result = this.findInTree_(this.statics_, addr);
|
||||
let result = this.findInTree_(this.statics_, addr);
|
||||
if (!result) {
|
||||
result = this.findInTree_(this.libraries_, addr);
|
||||
if (!result) return null;
|
||||
}
|
||||
return { entry : result.value, offset : addr - result.key };
|
||||
}
|
||||
var min = this.dynamics_.findMin();
|
||||
var max = this.dynamics_.findMax();
|
||||
const min = this.dynamics_.findMin();
|
||||
const max = this.dynamics_.findMax();
|
||||
if (max != null && addr < (max.key + max.value.size) && addr >= min.key) {
|
||||
var dynaEntry = this.findInTree_(this.dynamics_, addr);
|
||||
const dynaEntry = this.findInTree_(this.dynamics_, addr);
|
||||
if (dynaEntry == null) return null;
|
||||
// Dedupe entry name.
|
||||
var entry = dynaEntry.value;
|
||||
const entry = dynaEntry.value;
|
||||
if (!entry.nameUpdated_) {
|
||||
entry.name = this.dynamicsNameGen_.getName(entry.name);
|
||||
entry.nameUpdated_ = true;
|
||||
}
|
||||
return { entry : entry, offset : addr - dynaEntry.key };
|
||||
return { entry, offset : addr - dynaEntry.key };
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@ -209,7 +209,7 @@ export class CodeMap {
|
||||
* @param {number} addr Address.
|
||||
*/
|
||||
findEntry(addr) {
|
||||
var result = this.findAddress(addr);
|
||||
const result = this.findAddress(addr);
|
||||
return result ? result.entry : null;
|
||||
}
|
||||
|
||||
@ -219,7 +219,7 @@ export class CodeMap {
|
||||
* @param {number} addr Address.
|
||||
*/
|
||||
findDynamicEntryByStartAddress(addr) {
|
||||
var node = this.dynamics_.find(addr);
|
||||
const node = this.dynamics_.find(addr);
|
||||
return node ? node.value : null;
|
||||
}
|
||||
|
||||
@ -292,7 +292,7 @@ class NameGenerator {
|
||||
this.knownNames_[name] = 0;
|
||||
return name;
|
||||
}
|
||||
var count = ++this.knownNames_[name];
|
||||
const count = ++this.knownNames_[name];
|
||||
return name + ' {' + count + '}';
|
||||
};
|
||||
}
|
||||
|
@ -72,7 +72,7 @@ ConsArray.prototype.atEnd = function() {
|
||||
* Returns the current item, moves to the next one.
|
||||
*/
|
||||
ConsArray.prototype.next = function() {
|
||||
var result = this.currCell_.data[this.currCellPos_++];
|
||||
const result = this.currCell_.data[this.currCellPos_++];
|
||||
if (this.currCellPos_ >= this.currCell_.data.length) {
|
||||
this.currCell_ = this.currCell_.next;
|
||||
this.currCellPos_ = 0;
|
||||
|
@ -84,9 +84,9 @@ export class CsvParser {
|
||||
* @param {string} line Input line.
|
||||
*/
|
||||
parseLine(line) {
|
||||
var pos = 0;
|
||||
var endPos = line.length;
|
||||
var fields = [];
|
||||
let pos = 0;
|
||||
const endPos = line.length;
|
||||
const fields = [];
|
||||
if (endPos == 0) return fields;
|
||||
let nextPos = 0;
|
||||
while(nextPos !== -1) {
|
||||
|
@ -11,7 +11,7 @@ import {
|
||||
// Dump C++ symbols of shared library if possible
|
||||
|
||||
function processArguments(args) {
|
||||
var processor = new ArgumentsProcessor(args);
|
||||
const processor = new ArgumentsProcessor(args);
|
||||
if (processor.parse()) {
|
||||
return processor.result();
|
||||
} else {
|
||||
@ -25,26 +25,26 @@ function initSourceMapSupport() {
|
||||
|
||||
// Overwrite the load function to load scripts synchronously.
|
||||
SourceMap.load = function(sourceMapURL) {
|
||||
var content = readFile(sourceMapURL);
|
||||
var sourceMapObject = (JSON.parse(content));
|
||||
const content = readFile(sourceMapURL);
|
||||
const sourceMapObject = (JSON.parse(content));
|
||||
return new SourceMap(sourceMapURL, sourceMapObject);
|
||||
};
|
||||
}
|
||||
|
||||
var entriesProviders = {
|
||||
const entriesProviders = {
|
||||
'unix': UnixCppEntriesProvider,
|
||||
'windows': WindowsCppEntriesProvider,
|
||||
'mac': MacCppEntriesProvider
|
||||
};
|
||||
|
||||
var params = processArguments(arguments);
|
||||
var sourceMap = null;
|
||||
const params = processArguments(arguments);
|
||||
let sourceMap = null;
|
||||
if (params.sourceMap) {
|
||||
initSourceMapSupport();
|
||||
sourceMap = SourceMap.load(params.sourceMap);
|
||||
}
|
||||
|
||||
var cppProcessor = new CppProcessor(
|
||||
const cppProcessor = new CppProcessor(
|
||||
new (entriesProviders[params.platform])(params.nm, params.targetRootFS,
|
||||
params.apkEmbeddedLibrary),
|
||||
params.timedRange, params.pairwiseTimedRange);
|
||||
|
@ -33,7 +33,7 @@ export class CppProcessor extends LogReader {
|
||||
|
||||
processLogFile(fileName) {
|
||||
this.lastLogFileName_ = fileName;
|
||||
var line;
|
||||
let line;
|
||||
while (line = readline()) {
|
||||
this.processLogLine(line);
|
||||
}
|
||||
@ -42,26 +42,26 @@ export class CppProcessor extends LogReader {
|
||||
processLogFileInTest(fileName) {
|
||||
// Hack file name to avoid dealing with platform specifics.
|
||||
this.lastLogFileName_ = 'v8.log';
|
||||
var contents = readFile(fileName);
|
||||
const contents = readFile(fileName);
|
||||
this.processLogChunk(contents);
|
||||
};
|
||||
|
||||
processSharedLibrary(name, startAddr, endAddr, aslrSlide) {
|
||||
var self = this;
|
||||
var libFuncs = this.cppEntriesProvider_.parseVmSymbols(
|
||||
const self = this;
|
||||
const libFuncs = this.cppEntriesProvider_.parseVmSymbols(
|
||||
name, startAddr, endAddr, aslrSlide, function(fName, fStart, fEnd) {
|
||||
var entry = new CodeEntry(fEnd - fStart, fName, 'CPP');
|
||||
const entry = new CodeEntry(fEnd - fStart, fName, 'CPP');
|
||||
self.codeMap_.addStaticCode(fStart, entry);
|
||||
});
|
||||
};
|
||||
|
||||
dumpCppSymbols() {
|
||||
var staticEntries = this.codeMap_.getAllStaticEntriesWithAddresses();
|
||||
var total = staticEntries.length;
|
||||
for (var i = 0; i < total; ++i) {
|
||||
var entry = staticEntries[i];
|
||||
var printValues = ['cpp', '0x' + entry[0].toString(16), entry[1].size,
|
||||
'"' + entry[1].name + '"'];
|
||||
const staticEntries = this.codeMap_.getAllStaticEntriesWithAddresses();
|
||||
const total = staticEntries.length;
|
||||
for (let i = 0; i < total; ++i) {
|
||||
const entry = staticEntries[i];
|
||||
const printValues = ['cpp', `0x${entry[0].toString(16)}`, entry[1].size,
|
||||
`"${entry[1].name}"`];
|
||||
print(printValues.join(','));
|
||||
}
|
||||
}
|
||||
|
@ -7,7 +7,7 @@ import { WebInspector } from "./sourcemap.mjs";
|
||||
import { BaseArgumentsProcessor } from "./arguments.mjs";
|
||||
|
||||
function processArguments(args) {
|
||||
var processor = new ArgumentsProcessor(args);
|
||||
const processor = new ArgumentsProcessor(args);
|
||||
if (processor.parse()) {
|
||||
return processor.result();
|
||||
} else {
|
||||
@ -33,8 +33,8 @@ function initSourceMapSupport() {
|
||||
|
||||
// Overwrite the load function to load scripts synchronously.
|
||||
SourceMap.load = function(sourceMapURL) {
|
||||
var content = readFile(sourceMapURL);
|
||||
var sourceMapObject = (JSON.parse(content));
|
||||
const content = readFile(sourceMapURL);
|
||||
const sourceMapObject = (JSON.parse(content));
|
||||
return new SourceMap(sourceMapURL, sourceMapObject);
|
||||
};
|
||||
}
|
||||
@ -82,7 +82,7 @@ for (const ic of processor.icTimeline.all) {
|
||||
ic.type + ' (' + ic.oldState + '->' + ic.newState + ic.modifier + ') at ' +
|
||||
ic.filePosition + ' ' + ic.key +
|
||||
' (map 0x' + ic.map.toString(16) + ')' +
|
||||
(ic.reason ? ' ' + ic.reason : '') + ' time: ' + ic.time);
|
||||
(ic.reason ? ` ${ic.reason}` : '') + ' time: ' + ic.time);
|
||||
accumulator[ic.type]++;
|
||||
}
|
||||
|
||||
|
@ -146,11 +146,11 @@ LogReader.prototype.processLogLine = function(line) {
|
||||
* @return {Array.<number>} Processed stack.
|
||||
*/
|
||||
LogReader.prototype.processStack = function(pc, func, stack) {
|
||||
var fullStack = func ? [pc, func] : [pc];
|
||||
var prevFrame = pc;
|
||||
for (var i = 0, n = stack.length; i < n; ++i) {
|
||||
var frame = stack[i];
|
||||
var firstChar = frame.charAt(0);
|
||||
const fullStack = func ? [pc, func] : [pc];
|
||||
let prevFrame = pc;
|
||||
for (let i = 0, n = stack.length; i < n; ++i) {
|
||||
const frame = stack[i];
|
||||
const firstChar = frame.charAt(0);
|
||||
if (firstChar == '+' || firstChar == '-') {
|
||||
// An offset from the previous frame.
|
||||
prevFrame += parseInt(frame, 16);
|
||||
@ -159,7 +159,7 @@ LogReader.prototype.processStack = function(pc, func, stack) {
|
||||
} else if (firstChar != 'o') {
|
||||
fullStack.push(parseInt(frame, 16));
|
||||
} else {
|
||||
this.printError("dropping: " + frame);
|
||||
this.printError(`dropping: ${frame}`);
|
||||
}
|
||||
}
|
||||
return fullStack;
|
||||
@ -172,9 +172,7 @@ LogReader.prototype.processStack = function(pc, func, stack) {
|
||||
* @param {!Object} dispatch Dispatch record.
|
||||
* @return {boolean} True if dispatch must be skipped.
|
||||
*/
|
||||
LogReader.prototype.skipDispatch = function(dispatch) {
|
||||
return false;
|
||||
};
|
||||
LogReader.prototype.skipDispatch = dispatch => false;
|
||||
|
||||
// Parses dummy variable for readability;
|
||||
export const parseString = 'parse-string';
|
||||
@ -188,17 +186,17 @@ export const parseVarArgs = 'parse-var-args';
|
||||
*/
|
||||
LogReader.prototype.dispatchLogRow_ = function(fields) {
|
||||
// Obtain the dispatch.
|
||||
var command = fields[0];
|
||||
var dispatch = this.dispatchTable_[command];
|
||||
const command = fields[0];
|
||||
const dispatch = this.dispatchTable_[command];
|
||||
if (dispatch === undefined) return;
|
||||
if (dispatch === null || this.skipDispatch(dispatch)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Parse fields.
|
||||
var parsedFields = [];
|
||||
for (var i = 0; i < dispatch.parsers.length; ++i) {
|
||||
var parser = dispatch.parsers[i];
|
||||
const parsedFields = [];
|
||||
for (let i = 0; i < dispatch.parsers.length; ++i) {
|
||||
const parser = dispatch.parsers[i];
|
||||
if (parser === parseString) {
|
||||
parsedFields.push(fields[1 + i]);
|
||||
} else if (typeof parser == 'function') {
|
||||
@ -208,7 +206,7 @@ LogReader.prototype.dispatchLogRow_ = function(fields) {
|
||||
parsedFields.push(fields.slice(1 + i));
|
||||
break;
|
||||
} else {
|
||||
throw new Error("Invalid log field parser: " + parser);
|
||||
throw new Error(`Invalid log field parser: ${parser}`);
|
||||
}
|
||||
}
|
||||
|
||||
@ -224,7 +222,7 @@ LogReader.prototype.dispatchLogRow_ = function(fields) {
|
||||
* @private
|
||||
*/
|
||||
LogReader.prototype.processLog_ = function(lines) {
|
||||
for (var i = 0, n = lines.length; i < n; ++i) {
|
||||
for (let i = 0, n = lines.length; i < n; ++i) {
|
||||
this.processLogLine_(lines[i]);
|
||||
}
|
||||
}
|
||||
@ -238,10 +236,10 @@ LogReader.prototype.processLog_ = function(lines) {
|
||||
LogReader.prototype.processLogLine_ = function(line) {
|
||||
if (line.length > 0) {
|
||||
try {
|
||||
var fields = this.csvParser_.parseLine(line);
|
||||
const fields = this.csvParser_.parseLine(line);
|
||||
this.dispatchLogRow_(fields);
|
||||
} catch (e) {
|
||||
this.printError('line ' + (this.lineNum_ + 1) + ': ' + (e.message || e) + '\n' + e.stack);
|
||||
this.printError(`line ${this.lineNum_ + 1}: ${e.message || e}\n${e.stack}`);
|
||||
}
|
||||
}
|
||||
this.lineNum_++;
|
||||
|
@ -8,7 +8,7 @@ import {
|
||||
} from "./parse-processor.mjs";
|
||||
|
||||
function processArguments(args) {
|
||||
var processor = new ArgumentsProcessor(args);
|
||||
const processor = new ArgumentsProcessor(args);
|
||||
if (processor.parse()) {
|
||||
return processor.result();
|
||||
} else {
|
||||
@ -22,17 +22,17 @@ function initSourceMapSupport() {
|
||||
|
||||
// Overwrite the load function to load scripts synchronously.
|
||||
SourceMap.load = function(sourceMapURL) {
|
||||
var content = readFile(sourceMapURL);
|
||||
var sourceMapObject = (JSON.parse(content));
|
||||
const content = readFile(sourceMapURL);
|
||||
const sourceMapObject = (JSON.parse(content));
|
||||
return new SourceMap(sourceMapURL, sourceMapObject);
|
||||
};
|
||||
}
|
||||
|
||||
var params = processArguments(arguments);
|
||||
var sourceMap = null;
|
||||
const params = processArguments(arguments);
|
||||
let sourceMap = null;
|
||||
if (params.sourceMap) {
|
||||
initSourceMapSupport();
|
||||
sourceMap = SourceMap.load(params.sourceMap);
|
||||
}
|
||||
var parseProcessor = new ParseProcessor();
|
||||
const parseProcessor = new ParseProcessor();
|
||||
parseProcessor.processLogFile(params.logFileName);
|
||||
|
@ -1,8 +1,6 @@
|
||||
// Copyright 2017 the V8 project authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
"use strict";
|
||||
|
||||
import { LogReader, parseString } from "./logreader.mjs";
|
||||
import { BaseArgumentsProcessor } from "./arguments.mjs";
|
||||
|
||||
@ -339,7 +337,7 @@ class Script extends CompilationUnit {
|
||||
|
||||
calculateMetrics(printSummary) {
|
||||
let log = (str) => this.summary += str + '\n';
|
||||
log("SCRIPT: " + this.id);
|
||||
log(`SCRIPT: ${this.id}`);
|
||||
let all = this.funktions;
|
||||
if (all.length === 0) return;
|
||||
|
||||
@ -354,7 +352,7 @@ class Script extends CompilationUnit {
|
||||
let value = (funktions.length + "").padStart(6) +
|
||||
(nofPercent + "%").padStart(5) +
|
||||
BYTES(ownBytes, this.bytesTotal).padStart(10);
|
||||
log((" - " + name).padEnd(20) + value);
|
||||
log((` - ${name}`).padEnd(20) + value);
|
||||
this.metrics.set(name + "-bytes", ownBytes);
|
||||
this.metrics.set(name + "-count", funktions.length);
|
||||
this.metrics.set(name + "-count-percent", nofPercent);
|
||||
@ -362,7 +360,7 @@ class Script extends CompilationUnit {
|
||||
Math.round(ownBytes / this.bytesTotal * 100));
|
||||
};
|
||||
|
||||
log(" - file: " + this.file);
|
||||
log(` - file: ${this.file}`);
|
||||
log(' - details: ' +
|
||||
'isEval=' + this.isEval + ' deserialized=' + this.isDeserialized +
|
||||
' streamed=' + this.isStreamingCompiled);
|
||||
@ -409,7 +407,7 @@ class Script extends CompilationUnit {
|
||||
// [start+delta*2, acc(metric0, start, start+delta*2), ...],
|
||||
// ...
|
||||
// ]
|
||||
if (end <= start) throw 'Invalid ranges [' + start + ',' + end + ']';
|
||||
if (end <= start) throw `Invalid ranges [${start},${end}]`;
|
||||
const timespan = end - start;
|
||||
const kSteps = Math.ceil(timespan / delta);
|
||||
// To reduce the time spent iterating over the funktions of this script
|
||||
@ -607,8 +605,8 @@ class ExecutionCost {
|
||||
}
|
||||
|
||||
toString() {
|
||||
return (' - ' + this.prefix + '-time:').padEnd(24) +
|
||||
(" executed=" + formatNumber(this.executedCost) + 'ms').padEnd(20) +
|
||||
return (` - ${this.prefix}-time:`).padEnd(24) +
|
||||
(` executed=${formatNumber(this.executedCost)}ms`).padEnd(20) +
|
||||
" non-executed=" + formatNumber(this.nonExecutedCost) + 'ms';
|
||||
}
|
||||
|
||||
@ -623,11 +621,11 @@ class ExecutionCost {
|
||||
class Funktion extends CompilationUnit {
|
||||
constructor(name, start, end, script) {
|
||||
super();
|
||||
if (start < 0) throw "invalid start position: " + start;
|
||||
if (start < 0) throw `invalid start position: ${start}`;
|
||||
if (script.isEval) {
|
||||
if (end < start) throw 'invalid start end positions';
|
||||
} else {
|
||||
if (end <= 0) throw 'invalid end position: ' + end;
|
||||
if (end <= 0) throw `invalid end position: ${end}`;
|
||||
if (end <= start) throw 'invalid start end positions';
|
||||
}
|
||||
|
||||
@ -722,7 +720,7 @@ class Funktion extends CompilationUnit {
|
||||
}
|
||||
|
||||
toString(details = true) {
|
||||
let result = 'function' + (this.name ? ' ' + this.name : '') +
|
||||
let result = `function${this.name ? ` ${this.name}` : ''}` +
|
||||
`() range=${this.start}-${this.end}`;
|
||||
if (details) result += ` script=${this.script ? this.script.id : 'X'}`;
|
||||
return result;
|
||||
@ -841,7 +839,7 @@ export class ParseProcessor extends LogReader {
|
||||
processLogFile(fileName) {
|
||||
this.collectEntries = true
|
||||
this.lastLogFileName_ = fileName;
|
||||
var line;
|
||||
let line;
|
||||
while (line = readline()) {
|
||||
this.processLogLine(line);
|
||||
}
|
||||
@ -886,7 +884,7 @@ export class ParseProcessor extends LogReader {
|
||||
functionName) {
|
||||
let handlerFn = this.functionEventDispatchTable_[eventName];
|
||||
if (handlerFn === undefined) {
|
||||
console.error('Couldn\'t find handler for function event:' + eventName);
|
||||
console.error(`Couldn't find handler for function event:${eventName}`);
|
||||
}
|
||||
handlerFn(
|
||||
scriptId, startPosition, endPosition, duration, timestamp,
|
||||
@ -965,7 +963,7 @@ export class ParseProcessor extends LogReader {
|
||||
script.preparseTimestamp = toTimestamp(timestamp);
|
||||
return;
|
||||
default:
|
||||
console.error('Unhandled script event: ' + eventName);
|
||||
console.error(`Unhandled script event: ${eventName}`);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -144,7 +144,7 @@ export class Profile {
|
||||
* @param {number} endAddr Ending address.
|
||||
*/
|
||||
addLibrary(name, startAddr, endAddr) {
|
||||
var entry = new CodeEntry(endAddr - startAddr, name, 'SHARED_LIB');
|
||||
const entry = new CodeEntry(endAddr - startAddr, name, 'SHARED_LIB');
|
||||
this.codeMap_.addLibrary(startAddr, entry);
|
||||
return entry;
|
||||
}
|
||||
@ -157,7 +157,7 @@ export class Profile {
|
||||
* @param {number} endAddr Ending address.
|
||||
*/
|
||||
addStaticCode(name, startAddr, endAddr) {
|
||||
var entry = new CodeEntry(endAddr - startAddr, name, 'CPP');
|
||||
const entry = new CodeEntry(endAddr - startAddr, name, 'CPP');
|
||||
this.codeMap_.addStaticCode(startAddr, entry);
|
||||
return entry;
|
||||
}
|
||||
@ -171,7 +171,7 @@ export class Profile {
|
||||
* @param {number} size Code entry size.
|
||||
*/
|
||||
addCode(type, name, timestamp, start, size) {
|
||||
var entry = new DynamicCodeEntry(size, type, name);
|
||||
const entry = new DynamicCodeEntry(size, type, name);
|
||||
this.codeMap_.addCode(start, entry);
|
||||
return entry;
|
||||
}
|
||||
@ -189,7 +189,7 @@ export class Profile {
|
||||
addFuncCode(type, name, timestamp, start, size, funcAddr, state) {
|
||||
// As code and functions are in the same address space,
|
||||
// it is safe to put them in a single code map.
|
||||
var func = this.codeMap_.findDynamicEntryByStartAddress(funcAddr);
|
||||
let func = this.codeMap_.findDynamicEntryByStartAddress(funcAddr);
|
||||
if (!func) {
|
||||
func = new FunctionEntry(name);
|
||||
this.codeMap_.addCode(funcAddr, func);
|
||||
@ -197,7 +197,7 @@ export class Profile {
|
||||
// Function object has been overwritten with a new one.
|
||||
func.name = name;
|
||||
}
|
||||
var entry = this.codeMap_.findDynamicEntryByStartAddress(start);
|
||||
let entry = this.codeMap_.findDynamicEntryByStartAddress(start);
|
||||
if (entry) {
|
||||
if (entry.size === size && entry.func === func) {
|
||||
// Entry state has changed.
|
||||
@ -297,7 +297,7 @@ export class Profile {
|
||||
* @param {Array<number>} stack Stack sample.
|
||||
*/
|
||||
recordTick(time_ns, vmState, stack) {
|
||||
var processedStack = this.resolveAndFilterFuncs_(stack);
|
||||
const processedStack = this.resolveAndFilterFuncs_(stack);
|
||||
this.bottomUpTree_.addPath(processedStack);
|
||||
processedStack.reverse();
|
||||
this.topDownTree_.addPath(processedStack);
|
||||
@ -310,13 +310,13 @@ export class Profile {
|
||||
* @param {Array<number>} stack Stack sample.
|
||||
*/
|
||||
resolveAndFilterFuncs_(stack) {
|
||||
var result = [];
|
||||
var last_seen_c_function = '';
|
||||
var look_for_first_c_function = false;
|
||||
for (var i = 0; i < stack.length; ++i) {
|
||||
var entry = this.codeMap_.findEntry(stack[i]);
|
||||
const result = [];
|
||||
let last_seen_c_function = '';
|
||||
let look_for_first_c_function = false;
|
||||
for (let i = 0; i < stack.length; ++i) {
|
||||
const entry = this.codeMap_.findEntry(stack[i]);
|
||||
if (entry) {
|
||||
var name = entry.getName();
|
||||
const name = entry.getName();
|
||||
if (i === 0 && (entry.type === 'CPP' || entry.type === 'SHARED_LIB')) {
|
||||
look_for_first_c_function = true;
|
||||
}
|
||||
@ -393,7 +393,7 @@ export class Profile {
|
||||
tree.computeTotalWeights();
|
||||
return tree;
|
||||
} else {
|
||||
var subTree = tree.cloneSubtree(opt_label);
|
||||
const subTree = tree.cloneSubtree(opt_label);
|
||||
subTree.computeTotalWeights();
|
||||
return subTree;
|
||||
}
|
||||
@ -406,11 +406,11 @@ export class Profile {
|
||||
* @param {string} opt_label Starting node label.
|
||||
*/
|
||||
getFlatProfile(opt_label) {
|
||||
var counters = new CallTree();
|
||||
var rootLabel = opt_label || CallTree.ROOT_NODE_LABEL;
|
||||
var precs = {};
|
||||
const counters = new CallTree();
|
||||
const rootLabel = opt_label || CallTree.ROOT_NODE_LABEL;
|
||||
const precs = {};
|
||||
precs[rootLabel] = 0;
|
||||
var root = counters.findOrAddChild(rootLabel);
|
||||
const root = counters.findOrAddChild(rootLabel);
|
||||
|
||||
this.topDownTree_.computeTotalWeights();
|
||||
this.topDownTree_.traverseInDepth(
|
||||
@ -418,13 +418,13 @@ export class Profile {
|
||||
if (!(node.label in precs)) {
|
||||
precs[node.label] = 0;
|
||||
}
|
||||
var nodeLabelIsRootLabel = node.label == rootLabel;
|
||||
const nodeLabelIsRootLabel = node.label == rootLabel;
|
||||
if (nodeLabelIsRootLabel || precs[rootLabel] > 0) {
|
||||
if (precs[rootLabel] == 0) {
|
||||
root.selfWeight += node.selfWeight;
|
||||
root.totalWeight += node.totalWeight;
|
||||
} else {
|
||||
var rec = root.findOrAddChild(node.label);
|
||||
const rec = root.findOrAddChild(node.label);
|
||||
rec.selfWeight += node.selfWeight;
|
||||
if (nodeLabelIsRootLabel || precs[node.label] == 0) {
|
||||
rec.totalWeight += node.totalWeight;
|
||||
@ -454,17 +454,15 @@ export class Profile {
|
||||
}
|
||||
|
||||
getCEntryProfile() {
|
||||
var result = [new CEntryNode("TOTAL", 0)];
|
||||
var total_ticks = 0;
|
||||
for (var f in this.c_entries_) {
|
||||
var ticks = this.c_entries_[f];
|
||||
const result = [new CEntryNode("TOTAL", 0)];
|
||||
let total_ticks = 0;
|
||||
for (let f in this.c_entries_) {
|
||||
const ticks = this.c_entries_[f];
|
||||
total_ticks += ticks;
|
||||
result.push(new CEntryNode(f, ticks));
|
||||
}
|
||||
result[0].ticks = total_ticks; // Sorting will keep this at index 0.
|
||||
result.sort(function (n1, n2) {
|
||||
return n2.ticks - n1.ticks || (n2.name < n1.name ? -1 : 1)
|
||||
});
|
||||
result.sort((n1, n2) => n2.ticks - n1.ticks || (n2.name < n1.name ? -1 : 1));
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -473,19 +471,19 @@ export class Profile {
|
||||
* Cleans up function entries that are not referenced by code entries.
|
||||
*/
|
||||
cleanUpFuncEntries() {
|
||||
var referencedFuncEntries = [];
|
||||
var entries = this.codeMap_.getAllDynamicEntriesWithAddresses();
|
||||
for (var i = 0, l = entries.length; i < l; ++i) {
|
||||
const referencedFuncEntries = [];
|
||||
const entries = this.codeMap_.getAllDynamicEntriesWithAddresses();
|
||||
for (let i = 0, l = entries.length; i < l; ++i) {
|
||||
if (entries[i][1].constructor === FunctionEntry) {
|
||||
entries[i][1].used = false;
|
||||
}
|
||||
}
|
||||
for (var i = 0, l = entries.length; i < l; ++i) {
|
||||
for (let i = 0, l = entries.length; i < l; ++i) {
|
||||
if ("func" in entries[i][1]) {
|
||||
entries[i][1].func.used = true;
|
||||
}
|
||||
}
|
||||
for (var i = 0, l = entries.length; i < l; ++i) {
|
||||
for (let i = 0, l = entries.length; i < l; ++i) {
|
||||
if (entries[i][1].constructor === FunctionEntry &&
|
||||
!entries[i][1].used) {
|
||||
this.codeMap_.deleteCode(entries[i][0]);
|
||||
@ -556,9 +554,9 @@ class DynamicFuncCodeEntry extends CodeEntry {
|
||||
getState() {
|
||||
return DynamicFuncCodeEntry.STATE_PREFIX[this.state];
|
||||
}
|
||||
|
||||
|
||||
getName() {
|
||||
var name = this.func.getName();
|
||||
const name = this.func.getName();
|
||||
return this.type + ': ' + this.getState() + name;
|
||||
}
|
||||
|
||||
@ -593,12 +591,12 @@ class FunctionEntry extends CodeEntry {
|
||||
* Returns node name.
|
||||
*/
|
||||
getName() {
|
||||
var name = this.name;
|
||||
let name = this.name;
|
||||
if (name.length == 0) {
|
||||
name = '<anonymous>';
|
||||
} else if (name.charAt(0) == ' ') {
|
||||
// An anonymous function with location: " aaa.js:10".
|
||||
name = '<anonymous>' + name;
|
||||
name = `<anonymous>${name}`;
|
||||
}
|
||||
return name;
|
||||
}
|
||||
@ -634,8 +632,8 @@ class CallTree {
|
||||
if (path.length == 0) {
|
||||
return;
|
||||
}
|
||||
var curr = this.root_;
|
||||
for (var i = 0; i < path.length; ++i) {
|
||||
let curr = this.root_;
|
||||
for (let i = 0; i < path.length; ++i) {
|
||||
curr = curr.findOrAddChild(path[i]);
|
||||
}
|
||||
curr.selfWeight++;
|
||||
@ -670,12 +668,12 @@ class CallTree {
|
||||
* @param {string} label The label of the new root node.
|
||||
*/
|
||||
cloneSubtree(label) {
|
||||
var subTree = new CallTree();
|
||||
const subTree = new CallTree();
|
||||
this.traverse((node, parent) => {
|
||||
if (!parent && node.label != label) {
|
||||
return null;
|
||||
}
|
||||
var child = (parent ? parent : subTree).findOrAddChild(node.label);
|
||||
const child = (parent ? parent : subTree).findOrAddChild(node.label);
|
||||
child.selfWeight += node.selfWeight;
|
||||
return child;
|
||||
});
|
||||
@ -707,13 +705,13 @@ class CallTree {
|
||||
* The second parameter is the result of calling 'f' on the parent node.
|
||||
*/
|
||||
traverse(f) {
|
||||
var pairsToProcess = new ConsArray();
|
||||
const pairsToProcess = new ConsArray();
|
||||
pairsToProcess.concat([{ node: this.root_, param: null }]);
|
||||
while (!pairsToProcess.atEnd()) {
|
||||
var pair = pairsToProcess.next();
|
||||
var node = pair.node;
|
||||
var newParam = f(node, pair.param);
|
||||
var morePairsToProcess = [];
|
||||
const pair = pairsToProcess.next();
|
||||
const node = pair.node;
|
||||
const newParam = f(node, pair.param);
|
||||
const morePairsToProcess = [];
|
||||
node.forEachChild((child) => {
|
||||
morePairsToProcess.push({ node: child, param: newParam });
|
||||
});
|
||||
@ -773,7 +771,7 @@ class CallTree {
|
||||
* @param {string} label Child node label.
|
||||
*/
|
||||
addChild(label) {
|
||||
var child = new CallTreeNode(label, this);
|
||||
const child = new CallTreeNode(label, this);
|
||||
this.children[label] = child;
|
||||
return child;
|
||||
}
|
||||
@ -782,7 +780,7 @@ class CallTree {
|
||||
* Computes node's total weight.
|
||||
*/
|
||||
computeTotalWeight() {
|
||||
var totalWeight = this.selfWeight;
|
||||
let totalWeight = this.selfWeight;
|
||||
this.forEachChild(function (child) {
|
||||
totalWeight += child.computeTotalWeight();
|
||||
});
|
||||
@ -793,7 +791,7 @@ class CallTree {
|
||||
* Returns all node's children as an array.
|
||||
*/
|
||||
exportChildren() {
|
||||
var result = [];
|
||||
const result = [];
|
||||
this.forEachChild(function (node) { result.push(node); });
|
||||
return result;
|
||||
}
|
||||
@ -823,7 +821,7 @@ class CallTree {
|
||||
* @param {function(CallTreeNode)} f Visitor function.
|
||||
*/
|
||||
forEachChild(f) {
|
||||
for (var c in this.children) {
|
||||
for (let c in this.children) {
|
||||
f(this.children[c]);
|
||||
}
|
||||
}
|
||||
@ -834,7 +832,7 @@ class CallTree {
|
||||
* @param {function(CallTreeNode)} f Visitor function.
|
||||
*/
|
||||
walkUpToRoot(f) {
|
||||
for (var curr = this; curr != null; curr = curr.parent) {
|
||||
for (let curr = this; curr != null; curr = curr.parent) {
|
||||
f(curr);
|
||||
}
|
||||
}
|
||||
@ -846,8 +844,9 @@ class CallTree {
|
||||
* @param {function(CallTreeNode)} opt_f Visitor function.
|
||||
*/
|
||||
descendToChild(labels, opt_f) {
|
||||
for (var pos = 0, curr = this; pos < labels.length && curr != null; pos++) {
|
||||
var child = curr.findChild(labels[pos]);
|
||||
let curr = this;
|
||||
for (let pos = 0; pos < labels.length && curr != null; pos++) {
|
||||
const child = curr.findChild(labels[pos]);
|
||||
if (opt_f) {
|
||||
opt_f(child, pos);
|
||||
}
|
||||
@ -867,7 +866,7 @@ export function JsonProfile() {
|
||||
|
||||
JsonProfile.prototype.addLibrary = function (
|
||||
name, startAddr, endAddr) {
|
||||
var entry = new CodeEntry(
|
||||
const entry = new CodeEntry(
|
||||
endAddr - startAddr, name, 'SHARED_LIB');
|
||||
this.codeMap_.addLibrary(startAddr, entry);
|
||||
|
||||
@ -878,7 +877,7 @@ JsonProfile.prototype.addLibrary = function (
|
||||
|
||||
JsonProfile.prototype.addStaticCode = function (
|
||||
name, startAddr, endAddr) {
|
||||
var entry = new CodeEntry(
|
||||
const entry = new CodeEntry(
|
||||
endAddr - startAddr, name, 'CPP');
|
||||
this.codeMap_.addStaticCode(startAddr, entry);
|
||||
|
||||
@ -897,7 +896,7 @@ JsonProfile.prototype.addCode = function (
|
||||
codeId = staticEntry.entry.codeId;
|
||||
}
|
||||
|
||||
var entry = new CodeEntry(size, name, 'CODE');
|
||||
const entry = new CodeEntry(size, name, 'CODE');
|
||||
this.codeMap_.addCode(start, entry);
|
||||
|
||||
entry.codeId = codeId;
|
||||
@ -905,7 +904,7 @@ JsonProfile.prototype.addCode = function (
|
||||
name: entry.name,
|
||||
timestamp: timestamp,
|
||||
type: entry.type,
|
||||
kind: kind
|
||||
kind: kind,
|
||||
};
|
||||
|
||||
return entry;
|
||||
@ -915,22 +914,22 @@ JsonProfile.prototype.addFuncCode = function (
|
||||
kind, name, timestamp, start, size, funcAddr, state) {
|
||||
// As code and functions are in the same address space,
|
||||
// it is safe to put them in a single code map.
|
||||
var func = this.codeMap_.findDynamicEntryByStartAddress(funcAddr);
|
||||
let func = this.codeMap_.findDynamicEntryByStartAddress(funcAddr);
|
||||
if (!func) {
|
||||
var func = new CodeEntry(0, name, 'SFI');
|
||||
func = new CodeEntry(0, name, 'SFI');
|
||||
this.codeMap_.addCode(funcAddr, func);
|
||||
|
||||
func.funcId = this.functionEntries_.length;
|
||||
this.functionEntries_.push({ name: name, codes: [] });
|
||||
this.functionEntries_.push({ name, codes: [] });
|
||||
} else if (func.name !== name) {
|
||||
// Function object has been overwritten with a new one.
|
||||
func.name = name;
|
||||
|
||||
func.funcId = this.functionEntries_.length;
|
||||
this.functionEntries_.push({ name: name, codes: [] });
|
||||
this.functionEntries_.push({ name, codes: [] });
|
||||
}
|
||||
// TODO(jarin): Insert the code object into the SFI's code list.
|
||||
var entry = this.codeMap_.findDynamicEntryByStartAddress(start);
|
||||
let entry = this.codeMap_.findDynamicEntryByStartAddress(start);
|
||||
if (entry) {
|
||||
if (entry.size === size && entry.func === func) {
|
||||
// Entry state has changed.
|
||||
@ -961,7 +960,7 @@ JsonProfile.prototype.addFuncCode = function (
|
||||
type: entry.type,
|
||||
kind: kind,
|
||||
func: func.funcId,
|
||||
tm: timestamp
|
||||
tm: timestamp,
|
||||
});
|
||||
}
|
||||
return entry;
|
||||
@ -971,25 +970,25 @@ JsonProfile.prototype.moveCode = function (from, to) {
|
||||
try {
|
||||
this.codeMap_.moveCode(from, to);
|
||||
} catch (e) {
|
||||
printErr("Move: unknown source " + from);
|
||||
printErr(`Move: unknown source ${from}`);
|
||||
}
|
||||
};
|
||||
|
||||
JsonProfile.prototype.addSourcePositions = function (
|
||||
start, script, startPos, endPos, sourcePositions, inliningPositions,
|
||||
inlinedFunctions) {
|
||||
var entry = this.codeMap_.findDynamicEntryByStartAddress(start);
|
||||
const entry = this.codeMap_.findDynamicEntryByStartAddress(start);
|
||||
if (!entry) return;
|
||||
var codeId = entry.codeId;
|
||||
const codeId = entry.codeId;
|
||||
|
||||
// Resolve the inlined functions list.
|
||||
if (inlinedFunctions.length > 0) {
|
||||
inlinedFunctions = inlinedFunctions.substring(1).split("S");
|
||||
for (var i = 0; i < inlinedFunctions.length; i++) {
|
||||
var funcAddr = parseInt(inlinedFunctions[i]);
|
||||
var func = this.codeMap_.findDynamicEntryByStartAddress(funcAddr);
|
||||
for (let i = 0; i < inlinedFunctions.length; i++) {
|
||||
const funcAddr = parseInt(inlinedFunctions[i]);
|
||||
const func = this.codeMap_.findDynamicEntryByStartAddress(funcAddr);
|
||||
if (!func || func.funcId === undefined) {
|
||||
printErr("Could not find function " + inlinedFunctions[i]);
|
||||
printErr(`Could not find function ${inlinedFunctions[i]}`);
|
||||
inlinedFunctions[i] = null;
|
||||
} else {
|
||||
inlinedFunctions[i] = func.funcId;
|
||||
@ -1029,7 +1028,7 @@ JsonProfile.prototype.deoptCode = function (
|
||||
scriptOffset: scriptOffset,
|
||||
posText: sourcePositionText,
|
||||
reason: deoptReasonText,
|
||||
bailoutType: bailoutType
|
||||
bailoutType: bailoutType,
|
||||
};
|
||||
}
|
||||
}
|
||||
@ -1039,7 +1038,7 @@ JsonProfile.prototype.deleteCode = function (start) {
|
||||
try {
|
||||
this.codeMap_.deleteCode(start);
|
||||
} catch (e) {
|
||||
printErr("Delete: unknown address " + start);
|
||||
printErr(`Delete: unknown address ${start}`);
|
||||
}
|
||||
};
|
||||
|
||||
@ -1056,9 +1055,9 @@ JsonProfile.prototype.findEntry = function (addr) {
|
||||
JsonProfile.prototype.recordTick = function (time_ns, vmState, stack) {
|
||||
// TODO(jarin) Resolve the frame-less case (when top of stack is
|
||||
// known code).
|
||||
var processedStack = [];
|
||||
for (var i = 0; i < stack.length; i++) {
|
||||
var resolved = this.codeMap_.findAddress(stack[i]);
|
||||
const processedStack = [];
|
||||
for (let i = 0; i < stack.length; i++) {
|
||||
const resolved = this.codeMap_.findAddress(stack[i]);
|
||||
if (resolved) {
|
||||
processedStack.push(resolved.entry.codeId, resolved.offset);
|
||||
} else {
|
||||
@ -1086,7 +1085,7 @@ JsonProfile.prototype.writeJson = function () {
|
||||
write(',\n');
|
||||
|
||||
write(' "ticks": [\n');
|
||||
for (var i = 0; i < this.ticks_.length; i++) {
|
||||
for (let i = 0; i < this.ticks_.length; i++) {
|
||||
write(' ');
|
||||
writeJson(this.ticks_[i]);
|
||||
if (i < this.ticks_.length - 1) {
|
||||
|
@ -47,12 +47,12 @@ export function ViewBuilder(samplingRate) {
|
||||
*/
|
||||
ViewBuilder.prototype.buildView = function(
|
||||
callTree, opt_bottomUpViewWeights) {
|
||||
var head;
|
||||
var samplingRate = this.samplingRate;
|
||||
var createViewNode = this.createViewNode;
|
||||
let head;
|
||||
const samplingRate = this.samplingRate;
|
||||
const createViewNode = this.createViewNode;
|
||||
callTree.traverse(function(node, viewParent) {
|
||||
var totalWeight = node.totalWeight * samplingRate;
|
||||
var selfWeight = node.selfWeight * samplingRate;
|
||||
const totalWeight = node.totalWeight * samplingRate;
|
||||
let selfWeight = node.selfWeight * samplingRate;
|
||||
if (opt_bottomUpViewWeights === true) {
|
||||
if (viewParent === head) {
|
||||
selfWeight = totalWeight;
|
||||
@ -60,7 +60,7 @@ ViewBuilder.prototype.buildView = function(
|
||||
selfWeight = 0;
|
||||
}
|
||||
}
|
||||
var viewNode = createViewNode(node.label, totalWeight, selfWeight, head);
|
||||
const viewNode = createViewNode(node.label, totalWeight, selfWeight, head);
|
||||
if (viewParent) {
|
||||
viewParent.addChild(viewNode);
|
||||
} else {
|
||||
@ -68,7 +68,7 @@ ViewBuilder.prototype.buildView = function(
|
||||
}
|
||||
return viewNode;
|
||||
});
|
||||
var view = this.createView(head);
|
||||
const view = this.createView(head);
|
||||
return view;
|
||||
};
|
||||
|
||||
@ -79,9 +79,7 @@ ViewBuilder.prototype.buildView = function(
|
||||
* @param {ProfileView.Node} head View head node.
|
||||
* @return {ProfileView} Profile view.
|
||||
*/
|
||||
ViewBuilder.prototype.createView = function(head) {
|
||||
return new ProfileView(head);
|
||||
};
|
||||
ViewBuilder.prototype.createView = head => new ProfileView(head);
|
||||
|
||||
|
||||
/**
|
||||
@ -96,11 +94,11 @@ ViewBuilder.prototype.createView = function(head) {
|
||||
* @param {ProfileView.Node} head Profile view head.
|
||||
* @return {ProfileView.Node} Profile view node.
|
||||
*/
|
||||
ViewBuilder.prototype.createViewNode = function(
|
||||
funcName, totalTime, selfTime, head) {
|
||||
return new ProfileView.Node(
|
||||
funcName, totalTime, selfTime, head);
|
||||
};
|
||||
ViewBuilder.prototype.createViewNode = (
|
||||
funcName, totalTime, selfTime, head) =>
|
||||
new ProfileView.Node(
|
||||
funcName, totalTime, selfTime, head)
|
||||
;
|
||||
|
||||
|
||||
/**
|
||||
@ -135,10 +133,10 @@ ProfileView.prototype.sort = function(sortFunc) {
|
||||
* @param {function(ProfileView.Node)} f Visitor function.
|
||||
*/
|
||||
ProfileView.prototype.traverse = function(f) {
|
||||
var nodesToTraverse = new ConsArray();
|
||||
const nodesToTraverse = new ConsArray();
|
||||
nodesToTraverse.concat([this.head]);
|
||||
while (!nodesToTraverse.atEnd()) {
|
||||
var node = nodesToTraverse.next();
|
||||
const node = nodesToTraverse.next();
|
||||
f(node);
|
||||
nodesToTraverse.concat(node.children);
|
||||
}
|
||||
|
@ -77,7 +77,7 @@ WebInspector.SourceMap = function(sourceMappingURL, payload)
|
||||
if (!WebInspector.SourceMap.prototype._base64Map) {
|
||||
const base64Digits = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
||||
WebInspector.SourceMap.prototype._base64Map = {};
|
||||
for (var i = 0; i < base64Digits.length; ++i)
|
||||
for (let i = 0; i < base64Digits.length; ++i)
|
||||
WebInspector.SourceMap.prototype._base64Map[base64Digits.charAt(i)] = i;
|
||||
}
|
||||
|
||||
@ -107,7 +107,7 @@ WebInspector.SourceMap.load = function(sourceMapURL, compiledURL, callback)
|
||||
function contentLoaded(error, statusCode, headers, content)
|
||||
{
|
||||
if (error || !content || statusCode >= 400) {
|
||||
console.error("Could not load content for " + sourceMapURL + " : " + (error || ("HTTP status code: " + statusCode)));
|
||||
console.error(`Could not load content for ${sourceMapURL} : ${error || (`HTTP status code: ${statusCode}`)}`);
|
||||
callback(null);
|
||||
return;
|
||||
}
|
||||
@ -115,8 +115,8 @@ WebInspector.SourceMap.load = function(sourceMapURL, compiledURL, callback)
|
||||
if (content.slice(0, 3) === ")]}")
|
||||
content = content.substring(content.indexOf('\n'));
|
||||
try {
|
||||
var payload = /** @type {SourceMapV3} */ (JSON.parse(content));
|
||||
var baseURL = sourceMapURL.startsWith("data:") ? compiledURL : sourceMapURL;
|
||||
const payload = /** @type {SourceMapV3} */ (JSON.parse(content));
|
||||
const baseURL = sourceMapURL.startsWith("data:") ? compiledURL : sourceMapURL;
|
||||
callback(new WebInspector.SourceMap(baseURL, payload));
|
||||
} catch(e) {
|
||||
console.error(e.message);
|
||||
@ -129,7 +129,7 @@ WebInspector.SourceMap.prototype = {
|
||||
/**
|
||||
* @return {Array.<string>}
|
||||
*/
|
||||
sources: function()
|
||||
sources()
|
||||
{
|
||||
return Object.keys(this._sources);
|
||||
},
|
||||
@ -138,7 +138,7 @@ WebInspector.SourceMap.prototype = {
|
||||
* @param {string} sourceURL
|
||||
* @return {string|undefined}
|
||||
*/
|
||||
sourceContent: function(sourceURL)
|
||||
sourceContent(sourceURL)
|
||||
{
|
||||
return this._sourceContentByURL[sourceURL];
|
||||
},
|
||||
@ -148,12 +148,12 @@ WebInspector.SourceMap.prototype = {
|
||||
* @param {WebInspector.ResourceType} contentType
|
||||
* @return {WebInspector.ContentProvider}
|
||||
*/
|
||||
sourceContentProvider: function(sourceURL, contentType)
|
||||
sourceContentProvider(sourceURL, contentType)
|
||||
{
|
||||
var lastIndexOfDot = sourceURL.lastIndexOf(".");
|
||||
var extension = lastIndexOfDot !== -1 ? sourceURL.substr(lastIndexOfDot + 1) : "";
|
||||
var mimeType = WebInspector.ResourceType.mimeTypesForExtensions[extension.toLowerCase()];
|
||||
var sourceContent = this.sourceContent(sourceURL);
|
||||
const lastIndexOfDot = sourceURL.lastIndexOf(".");
|
||||
const extension = lastIndexOfDot !== -1 ? sourceURL.substr(lastIndexOfDot + 1) : "";
|
||||
const mimeType = WebInspector.ResourceType.mimeTypesForExtensions[extension.toLowerCase()];
|
||||
const sourceContent = this.sourceContent(sourceURL);
|
||||
if (sourceContent)
|
||||
return new WebInspector.StaticContentProvider(contentType, sourceContent, mimeType);
|
||||
return new WebInspector.CompilerSourceMappingContentProvider(sourceURL, contentType, mimeType);
|
||||
@ -162,7 +162,7 @@ WebInspector.SourceMap.prototype = {
|
||||
/**
|
||||
* @param {SourceMapV3} mappingPayload
|
||||
*/
|
||||
_parseMappingPayload: function(mappingPayload)
|
||||
_parseMappingPayload(mappingPayload)
|
||||
{
|
||||
if (mappingPayload.sections)
|
||||
this._parseSections(mappingPayload.sections);
|
||||
@ -173,10 +173,10 @@ WebInspector.SourceMap.prototype = {
|
||||
/**
|
||||
* @param {Array.<SourceMapV3.Section>} sections
|
||||
*/
|
||||
_parseSections: function(sections)
|
||||
_parseSections(sections)
|
||||
{
|
||||
for (var i = 0; i < sections.length; ++i) {
|
||||
var section = sections[i];
|
||||
for (let i = 0; i < sections.length; ++i) {
|
||||
const section = sections[i];
|
||||
this._parseMap(section.map, section.offset.line, section.offset.column);
|
||||
}
|
||||
},
|
||||
@ -186,14 +186,14 @@ WebInspector.SourceMap.prototype = {
|
||||
* @param {number} columnNumber in compiled resource
|
||||
* @return {?Array}
|
||||
*/
|
||||
findEntry: function(lineNumber, columnNumber)
|
||||
findEntry(lineNumber, columnNumber)
|
||||
{
|
||||
var first = 0;
|
||||
var count = this._mappings.length;
|
||||
let first = 0;
|
||||
let count = this._mappings.length;
|
||||
while (count > 1) {
|
||||
var step = count >> 1;
|
||||
var middle = first + step;
|
||||
var mapping = this._mappings[middle];
|
||||
const step = count >> 1;
|
||||
const middle = first + step;
|
||||
const mapping = this._mappings[middle];
|
||||
if (lineNumber < mapping[0] || (lineNumber === mapping[0] && columnNumber < mapping[1]))
|
||||
count = step;
|
||||
else {
|
||||
@ -201,7 +201,7 @@ WebInspector.SourceMap.prototype = {
|
||||
count -= step;
|
||||
}
|
||||
}
|
||||
var entry = this._mappings[first];
|
||||
const entry = this._mappings[first];
|
||||
if (!first && entry && (lineNumber < entry[0] || (lineNumber === entry[0] && columnNumber < entry[1])))
|
||||
return null;
|
||||
return entry;
|
||||
@ -212,11 +212,11 @@ WebInspector.SourceMap.prototype = {
|
||||
* @param {number} lineNumber in the originating resource
|
||||
* @return {Array}
|
||||
*/
|
||||
findEntryReversed: function(sourceURL, lineNumber)
|
||||
findEntryReversed(sourceURL, lineNumber)
|
||||
{
|
||||
var mappings = this._reverseMappingsBySourceURL[sourceURL];
|
||||
const mappings = this._reverseMappingsBySourceURL[sourceURL];
|
||||
for ( ; lineNumber < mappings.length; ++lineNumber) {
|
||||
var mapping = mappings[lineNumber];
|
||||
const mapping = mappings[lineNumber];
|
||||
if (mapping)
|
||||
return mapping;
|
||||
}
|
||||
@ -226,32 +226,32 @@ WebInspector.SourceMap.prototype = {
|
||||
/**
|
||||
* @override
|
||||
*/
|
||||
_parseMap: function(map, lineNumber, columnNumber)
|
||||
_parseMap(map, lineNumber, columnNumber)
|
||||
{
|
||||
var sourceIndex = 0;
|
||||
var sourceLineNumber = 0;
|
||||
var sourceColumnNumber = 0;
|
||||
var nameIndex = 0;
|
||||
let sourceIndex = 0;
|
||||
let sourceLineNumber = 0;
|
||||
let sourceColumnNumber = 0;
|
||||
let nameIndex = 0;
|
||||
|
||||
var sources = [];
|
||||
var originalToCanonicalURLMap = {};
|
||||
for (var i = 0; i < map.sources.length; ++i) {
|
||||
var originalSourceURL = map.sources[i];
|
||||
var sourceRoot = map.sourceRoot || "";
|
||||
if (sourceRoot && !sourceRoot.endsWith("/"))
|
||||
sourceRoot += "/";
|
||||
var href = sourceRoot + originalSourceURL;
|
||||
var url = WebInspector.ParsedURL.completeURL(this._sourceMappingURL, href) || href;
|
||||
const sources = [];
|
||||
const originalToCanonicalURLMap = {};
|
||||
for (let i = 0; i < map.sources.length; ++i) {
|
||||
const originalSourceURL = map.sources[i];
|
||||
let sourceRoot = map.sourceRoot || "";
|
||||
if (sourceRoot && !sourceRoot.endsWith("/")) sourceRoot += "/";
|
||||
const href = sourceRoot + originalSourceURL;
|
||||
const url = WebInspector.ParsedURL.completeURL(this._sourceMappingURL, href) || href;
|
||||
originalToCanonicalURLMap[originalSourceURL] = url;
|
||||
sources.push(url);
|
||||
this._sources[url] = true;
|
||||
|
||||
if (map.sourcesContent && map.sourcesContent[i])
|
||||
if (map.sourcesContent && map.sourcesContent[i]) {
|
||||
this._sourceContentByURL[url] = map.sourcesContent[i];
|
||||
}
|
||||
}
|
||||
|
||||
var stringCharIterator = new WebInspector.SourceMap.StringCharIterator(map.mappings);
|
||||
var sourceURL = sources[sourceIndex];
|
||||
const stringCharIterator = new WebInspector.SourceMap.StringCharIterator(map.mappings);
|
||||
let sourceURL = sources[sourceIndex];
|
||||
|
||||
while (true) {
|
||||
if (stringCharIterator.peek() === ",")
|
||||
@ -272,7 +272,7 @@ WebInspector.SourceMap.prototype = {
|
||||
continue;
|
||||
}
|
||||
|
||||
var sourceIndexDelta = this._decodeVLQ(stringCharIterator);
|
||||
const sourceIndexDelta = this._decodeVLQ(stringCharIterator);
|
||||
if (sourceIndexDelta) {
|
||||
sourceIndex += sourceIndexDelta;
|
||||
sourceURL = sources[sourceIndex];
|
||||
@ -285,17 +285,18 @@ WebInspector.SourceMap.prototype = {
|
||||
this._mappings.push([lineNumber, columnNumber, sourceURL, sourceLineNumber, sourceColumnNumber]);
|
||||
}
|
||||
|
||||
for (var i = 0; i < this._mappings.length; ++i) {
|
||||
var mapping = this._mappings[i];
|
||||
var url = mapping[2];
|
||||
if (!url)
|
||||
continue;
|
||||
if (!this._reverseMappingsBySourceURL[url])
|
||||
for (let i = 0; i < this._mappings.length; ++i) {
|
||||
const mapping = this._mappings[i];
|
||||
const url = mapping[2];
|
||||
if (!url) continue;
|
||||
if (!this._reverseMappingsBySourceURL[url]) {
|
||||
this._reverseMappingsBySourceURL[url] = [];
|
||||
var reverseMappings = this._reverseMappingsBySourceURL[url];
|
||||
var sourceLine = mapping[3];
|
||||
if (!reverseMappings[sourceLine])
|
||||
}
|
||||
const reverseMappings = this._reverseMappingsBySourceURL[url];
|
||||
const sourceLine = mapping[3];
|
||||
if (!reverseMappings[sourceLine]) {
|
||||
reverseMappings[sourceLine] = [mapping[0], mapping[1]];
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
@ -303,7 +304,7 @@ WebInspector.SourceMap.prototype = {
|
||||
* @param {string} char
|
||||
* @return {boolean}
|
||||
*/
|
||||
_isSeparator: function(char)
|
||||
_isSeparator(char)
|
||||
{
|
||||
return char === "," || char === ";";
|
||||
},
|
||||
@ -312,19 +313,20 @@ WebInspector.SourceMap.prototype = {
|
||||
* @param {WebInspector.SourceMap.StringCharIterator} stringCharIterator
|
||||
* @return {number}
|
||||
*/
|
||||
_decodeVLQ: function(stringCharIterator)
|
||||
_decodeVLQ(stringCharIterator)
|
||||
{
|
||||
// Read unsigned value.
|
||||
var result = 0;
|
||||
var shift = 0;
|
||||
let result = 0;
|
||||
let shift = 0;
|
||||
let digit;
|
||||
do {
|
||||
var digit = this._base64Map[stringCharIterator.next()];
|
||||
digit = this._base64Map[stringCharIterator.next()];
|
||||
result += (digit & this._VLQ_BASE_MASK) << shift;
|
||||
shift += this._VLQ_BASE_SHIFT;
|
||||
} while (digit & this._VLQ_CONTINUATION_MASK);
|
||||
|
||||
// Fix the sign.
|
||||
var negative = result & 1;
|
||||
const negative = result & 1;
|
||||
// Use unsigned right shift, so that the 32nd bit is properly shifted
|
||||
// to the 31st, and the 32nd becomes unset.
|
||||
result >>>= 1;
|
||||
@ -359,7 +361,7 @@ WebInspector.SourceMap.StringCharIterator.prototype = {
|
||||
/**
|
||||
* @return {string}
|
||||
*/
|
||||
next: function()
|
||||
next()
|
||||
{
|
||||
return this._string.charAt(this._position++);
|
||||
},
|
||||
@ -367,7 +369,7 @@ WebInspector.SourceMap.StringCharIterator.prototype = {
|
||||
/**
|
||||
* @return {string}
|
||||
*/
|
||||
peek: function()
|
||||
peek()
|
||||
{
|
||||
return this._string.charAt(this._position);
|
||||
},
|
||||
@ -375,7 +377,7 @@ WebInspector.SourceMap.StringCharIterator.prototype = {
|
||||
/**
|
||||
* @return {boolean}
|
||||
*/
|
||||
hasNext: function()
|
||||
hasNext()
|
||||
{
|
||||
return this._position < this._string.length;
|
||||
}
|
||||
|
@ -75,7 +75,7 @@ SplayTree.prototype.insert = function(key, value) {
|
||||
if (this.root_.key == key) {
|
||||
return;
|
||||
}
|
||||
var node = new SplayTree.Node(key, value);
|
||||
const node = new SplayTree.Node(key, value);
|
||||
if (key > this.root_.key) {
|
||||
node.left = this.root_;
|
||||
node.right = this.root_.right;
|
||||
@ -99,17 +99,17 @@ SplayTree.prototype.insert = function(key, value) {
|
||||
*/
|
||||
SplayTree.prototype.remove = function(key) {
|
||||
if (this.isEmpty()) {
|
||||
throw Error('Key not found: ' + key);
|
||||
throw Error(`Key not found: ${key}`);
|
||||
}
|
||||
this.splay_(key);
|
||||
if (this.root_.key != key) {
|
||||
throw Error('Key not found: ' + key);
|
||||
throw Error(`Key not found: ${key}`);
|
||||
}
|
||||
var removed = this.root_;
|
||||
const removed = this.root_;
|
||||
if (!this.root_.left) {
|
||||
this.root_ = this.root_.right;
|
||||
} else {
|
||||
var right = this.root_.right;
|
||||
const { right } = this.root_;
|
||||
this.root_ = this.root_.left;
|
||||
// Splay to make sure that the new root has an empty right child.
|
||||
this.splay_(key);
|
||||
@ -144,7 +144,7 @@ SplayTree.prototype.findMin = function() {
|
||||
if (this.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
var current = this.root_;
|
||||
let current = this.root_;
|
||||
while (current.left) {
|
||||
current = current.left;
|
||||
}
|
||||
@ -159,7 +159,7 @@ SplayTree.prototype.findMax = function(opt_startNode) {
|
||||
if (this.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
var current = opt_startNode || this.root_;
|
||||
let current = opt_startNode || this.root_;
|
||||
while (current.right) {
|
||||
current = current.right;
|
||||
}
|
||||
@ -195,7 +195,7 @@ SplayTree.prototype.findGreatestLessThan = function(key) {
|
||||
* with keys.
|
||||
*/
|
||||
SplayTree.prototype.exportKeysAndValues = function() {
|
||||
var result = [];
|
||||
const result = [];
|
||||
this.traverse_(function(node) { result.push([node.key, node.value]); });
|
||||
return result;
|
||||
};
|
||||
@ -205,7 +205,7 @@ SplayTree.prototype.exportKeysAndValues = function() {
|
||||
* @return {Array<*>} An array containing all the values of tree's nodes.
|
||||
*/
|
||||
SplayTree.prototype.exportValues = function() {
|
||||
var result = [];
|
||||
const result = [];
|
||||
this.traverse_(function(node) { result.push(node.value); });
|
||||
return result;
|
||||
};
|
||||
@ -230,9 +230,9 @@ SplayTree.prototype.splay_ = function(key) {
|
||||
// the L tree of the algorithm. The left child of the dummy node
|
||||
// will hold the R tree of the algorithm. Using a dummy node, left
|
||||
// and right will always be nodes and we avoid special cases.
|
||||
var dummy, left, right;
|
||||
let dummy, left, right;
|
||||
dummy = left = right = new SplayTree.Node(null, null);
|
||||
var current = this.root_;
|
||||
let current = this.root_;
|
||||
while (true) {
|
||||
if (key < current.key) {
|
||||
if (!current.left) {
|
||||
@ -240,7 +240,7 @@ SplayTree.prototype.splay_ = function(key) {
|
||||
}
|
||||
if (key < current.left.key) {
|
||||
// Rotate right.
|
||||
var tmp = current.left;
|
||||
const tmp = current.left;
|
||||
current.left = tmp.right;
|
||||
tmp.right = current;
|
||||
current = tmp;
|
||||
@ -258,7 +258,7 @@ SplayTree.prototype.splay_ = function(key) {
|
||||
}
|
||||
if (key > current.right.key) {
|
||||
// Rotate left.
|
||||
var tmp = current.right;
|
||||
const tmp = current.right;
|
||||
current.right = tmp.left;
|
||||
tmp.left = current;
|
||||
current = tmp;
|
||||
@ -290,9 +290,9 @@ SplayTree.prototype.splay_ = function(key) {
|
||||
* @private
|
||||
*/
|
||||
SplayTree.prototype.traverse_ = function(f) {
|
||||
var nodesToVisit = [this.root_];
|
||||
const nodesToVisit = [this.root_];
|
||||
while (nodesToVisit.length > 0) {
|
||||
var node = nodesToVisit.shift();
|
||||
const node = nodesToVisit.shift();
|
||||
if (node == null) {
|
||||
continue;
|
||||
}
|
||||
|
@ -55,16 +55,15 @@ DOM.defineCustomElement(
|
||||
}
|
||||
|
||||
updateCount() {
|
||||
this.count.innerHTML = 'length=' + this._selectedLogEntries.length;
|
||||
this.count.innerHTML = `length=${this._selectedLogEntries.length}`;
|
||||
}
|
||||
|
||||
updateTable(event) {
|
||||
let select = this.groupKey;
|
||||
let key = select.options[select.selectedIndex].text;
|
||||
let tableBody = this.tableBody;
|
||||
DOM.removeAllChildren(tableBody);
|
||||
DOM.removeAllChildren(this.tableBody);
|
||||
let groups = Group.groupBy(this._selectedLogEntries, key, true);
|
||||
this.render(groups, tableBody);
|
||||
this.render(groups, this.tableBody);
|
||||
}
|
||||
|
||||
escapeHtml(unsafe) {
|
||||
@ -89,8 +88,7 @@ DOM.defineCustomElement(
|
||||
// searches for mapLogEntries using the id, time
|
||||
const selectedMapLogEntriesSet = new Set();
|
||||
for (const icLogEntry of icLogEntries) {
|
||||
const time = icLogEntry.time;
|
||||
const selectedMap = MapLogEntry.get(id, time);
|
||||
const selectedMap = MapLogEntry.get(id, icLogEntry.time);
|
||||
selectedMapLogEntriesSet.add(selectedMap);
|
||||
}
|
||||
return Array.from(selectedMapLogEntriesSet);
|
||||
@ -131,8 +129,7 @@ DOM.defineCustomElement(
|
||||
const omitted = groups.length - max;
|
||||
if (omitted > 0) {
|
||||
const tr = DOM.tr();
|
||||
const tdNode =
|
||||
tr.appendChild(DOM.td('Omitted ' + omitted + ' entries.'));
|
||||
const tdNode = tr.appendChild(DOM.td(`Omitted ${omitted} entries.`));
|
||||
tdNode.colSpan = 4;
|
||||
fragment.appendChild(tr);
|
||||
}
|
||||
|
@ -38,7 +38,7 @@ DOM.defineCustomElement('log-file-reader',
|
||||
event.preventDefault();
|
||||
this.dispatchEvent(
|
||||
new CustomEvent('fileuploadstart', {bubbles: true, composed: true}));
|
||||
var host = event.dataTransfer ? event.dataTransfer : event.target;
|
||||
const host = event.dataTransfer ? event.dataTransfer : event.target;
|
||||
this.readFile(host.files[0]);
|
||||
}
|
||||
|
||||
@ -73,7 +73,7 @@ DOM.defineCustomElement('log-file-reader',
|
||||
|
||||
handleFileLoad(e, file) {
|
||||
const chunk = e.target.result;
|
||||
this.updateLabel('Finished loading \'' + file.name + '\'.');
|
||||
this.updateLabel(`Finished loading '${file.name}'.`);
|
||||
this.dispatchEvent(new CustomEvent('fileuploadend', {
|
||||
bubbles: true,
|
||||
composed: true,
|
||||
|
@ -184,9 +184,9 @@ class Edge {
|
||||
}
|
||||
|
||||
finishSetup() {
|
||||
let from = this.from;
|
||||
const from = this.from;
|
||||
if (from) from.addEdge(this);
|
||||
let to = this.to;
|
||||
const to = this.to;
|
||||
if (to === undefined) return;
|
||||
to.edge = this;
|
||||
if (from === undefined) return;
|
||||
|
@ -29,9 +29,9 @@ DOM.defineCustomElement(
|
||||
let details = '';
|
||||
let clickableDetails = '';
|
||||
if (map) {
|
||||
clickableDetails += 'ID: ' + map.id;
|
||||
clickableDetails += '\nSource location: ' + map.filePosition;
|
||||
details += '\n' + map.description;
|
||||
clickableDetails += `ID: ${map.id}`;
|
||||
clickableDetails += `\nSource location: ${map.filePosition}`;
|
||||
details += `\n${map.description}`;
|
||||
this.setSelectedMap(map);
|
||||
}
|
||||
this._filePositionNode.innerText = clickableDetails;
|
||||
|
@ -39,7 +39,7 @@ DOM.defineCustomElement('./map-panel/map-transitions',
|
||||
handleTransitionViewChange(e) {
|
||||
this.tooltip.style.left = e.pageX + 'px';
|
||||
this.tooltip.style.top = e.pageY + 'px';
|
||||
let map = e.target.map;
|
||||
const map = e.target.map;
|
||||
if (map) {
|
||||
this.tooltipContents.innerText = map.description;
|
||||
}
|
||||
|
@ -125,7 +125,7 @@ export class Processor extends LogReader {
|
||||
this.processLogLine(line);
|
||||
}
|
||||
} catch (e) {
|
||||
console.error('Error occurred during parsing, trying to continue: ' + e);
|
||||
console.error(`Error occurred during parsing, trying to continue: ${e}`);
|
||||
}
|
||||
this.finalize();
|
||||
}
|
||||
@ -142,7 +142,7 @@ export class Processor extends LogReader {
|
||||
}
|
||||
} catch (e) {
|
||||
console.error(
|
||||
'Error occurred during parsing line ' + i +
|
||||
`Error occurred during parsing line ${i}` +
|
||||
', trying to continue: ' + e);
|
||||
}
|
||||
this.finalize();
|
||||
@ -155,8 +155,8 @@ export class Processor extends LogReader {
|
||||
this._mapTimeline.forEach(map => {
|
||||
if (map.isRoot()) id = map.finalizeRootMap(id + 1);
|
||||
if (map.edge && map.edge.name) {
|
||||
let edge = map.edge;
|
||||
let list = this._mapTimeline.transitions.get(edge.name);
|
||||
const edge = map.edge;
|
||||
const list = this._mapTimeline.transitions.get(edge.name);
|
||||
if (list === undefined) {
|
||||
this._mapTimeline.transitions.set(edge.name, [edge]);
|
||||
} else {
|
||||
@ -178,13 +178,13 @@ export class Processor extends LogReader {
|
||||
case '*':
|
||||
return Profile.CodeState.OPTIMIZED;
|
||||
}
|
||||
throw new Error('unknown code state: ' + s);
|
||||
throw new Error(`unknown code state: ${s}`);
|
||||
}
|
||||
|
||||
processCodeCreation(type, kind, timestamp, start, size, name, maybe_func) {
|
||||
if (maybe_func.length) {
|
||||
let funcAddr = parseInt(maybe_func[0]);
|
||||
let state = this.parseState(maybe_func[1]);
|
||||
const funcAddr = parseInt(maybe_func[0]);
|
||||
const state = this.parseState(maybe_func[1]);
|
||||
this._profile.addFuncCode(
|
||||
type, name, timestamp, start, size, funcAddr, state);
|
||||
} else {
|
||||
@ -324,7 +324,7 @@ export class Processor extends LogReader {
|
||||
if (id === '0x000000000000') return undefined;
|
||||
let map = MapLogEntry.get(id, time);
|
||||
if (map === undefined) {
|
||||
console.error('No map details provided: id=' + id);
|
||||
console.error(`No map details provided: id=${id}`);
|
||||
// Manually patch in a map to continue running.
|
||||
return this.createMapEntry(id, time);
|
||||
};
|
||||
|
@ -188,12 +188,11 @@ class LineBuilder {
|
||||
this._selection = new Set(highlightPositions);
|
||||
this._clickHandler = panel.handleSourcePositionClick.bind(panel);
|
||||
// TODO: sort on script finalization.
|
||||
script.sourcePositions
|
||||
.sort((a, b) => {
|
||||
if (a.line === b.line) return a.column - b.column;
|
||||
return a.line - b.line;
|
||||
}) this._sourcePositions =
|
||||
new SourcePositionIterator(script.sourcePositions);
|
||||
script.sourcePositions.sort((a, b) => {
|
||||
if (a.line === b.line) return a.column - b.column;
|
||||
return a.line - b.line;
|
||||
});
|
||||
this._sourcePositions = new SourcePositionIterator(script.sourcePositions);
|
||||
}
|
||||
|
||||
get sourcePositionToMarkers() {
|
||||
|
@ -220,7 +220,6 @@ DOM.defineCustomElement('./timeline/timeline-track',
|
||||
}
|
||||
|
||||
renderLegend() {
|
||||
let timelineLegend = this.timelineLegend;
|
||||
let timelineLegendContent = this.timelineLegendContent;
|
||||
DOM.removeAllChildren(timelineLegendContent);
|
||||
this._timeline.uniqueTypes.forEach((entries, type) => {
|
||||
@ -249,7 +248,7 @@ DOM.defineCustomElement('./timeline/timeline-track',
|
||||
row.appendChild(DOM.td(this.data.all.length));
|
||||
row.appendChild(DOM.td('100%'));
|
||||
timelineLegendContent.appendChild(row);
|
||||
timelineLegend.appendChild(timelineLegendContent);
|
||||
this.timelineLegend.appendChild(timelineLegendContent);
|
||||
}
|
||||
|
||||
handleEntryTypeDblClick(e) {
|
||||
@ -306,7 +305,7 @@ DOM.defineCustomElement('./timeline/timeline-track',
|
||||
}
|
||||
|
||||
let imageData = this.backgroundCanvas.toDataURL('image/webp', 0.2);
|
||||
node.style.backgroundImage = 'url(' + imageData + ')';
|
||||
node.style.backgroundImage = `url(${imageData})`;
|
||||
}
|
||||
|
||||
updateTimeline() {
|
||||
|
@ -34,7 +34,7 @@ import {
|
||||
// Tick Processor's code flow.
|
||||
|
||||
function processArguments(args) {
|
||||
var processor = new ArgumentsProcessor(args);
|
||||
const processor = new ArgumentsProcessor(args);
|
||||
if (processor.parse()) {
|
||||
return processor.result();
|
||||
} else {
|
||||
@ -48,25 +48,25 @@ function initSourceMapSupport() {
|
||||
|
||||
// Overwrite the load function to load scripts synchronously.
|
||||
SourceMap.load = function(sourceMapURL) {
|
||||
var content = readFile(sourceMapURL);
|
||||
var sourceMapObject = (JSON.parse(content));
|
||||
const content = readFile(sourceMapURL);
|
||||
const sourceMapObject = (JSON.parse(content));
|
||||
return new SourceMap(sourceMapURL, sourceMapObject);
|
||||
};
|
||||
}
|
||||
|
||||
var entriesProviders = {
|
||||
const entriesProviders = {
|
||||
'unix': UnixCppEntriesProvider,
|
||||
'windows': WindowsCppEntriesProvider,
|
||||
'mac': MacCppEntriesProvider
|
||||
};
|
||||
|
||||
var params = processArguments(arguments);
|
||||
var sourceMap = null;
|
||||
const params = processArguments(arguments);
|
||||
let sourceMap = null;
|
||||
if (params.sourceMap) {
|
||||
initSourceMapSupport();
|
||||
sourceMap = SourceMap.load(params.sourceMap);
|
||||
}
|
||||
var tickProcessor = new TickProcessor(
|
||||
const tickProcessor = new TickProcessor(
|
||||
new (entriesProviders[params.platform])(params.nm, params.objdump, params.targetRootFS,
|
||||
params.apkEmbeddedLibrary),
|
||||
params.separateIc,
|
||||
|
@ -45,14 +45,14 @@ class V8Profile extends Profile {
|
||||
|
||||
constructor(separateIc, separateBytecodes, separateBuiltins, separateStubs) {
|
||||
super();
|
||||
var regexps = [];
|
||||
const 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++) {
|
||||
for (let i=0; i<regexps.length; i++) {
|
||||
if (regexps[i].test(name)) return true;
|
||||
}
|
||||
return false;
|
||||
@ -84,7 +84,7 @@ function parseState(s) {
|
||||
case "~": return Profile.CodeState.OPTIMIZABLE;
|
||||
case "*": return Profile.CodeState.OPTIMIZED;
|
||||
}
|
||||
throw new Error("unknown code state: " + s);
|
||||
throw new Error(`unknown code state: ${s}`);
|
||||
}
|
||||
|
||||
|
||||
@ -165,29 +165,29 @@ export function TickProcessor(
|
||||
this.stateFilter_ = stateFilter;
|
||||
this.runtimeTimerFilter_ = runtimeTimerFilter;
|
||||
this.sourceMap = sourceMap;
|
||||
var ticks = this.ticks_ =
|
||||
const 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]);
|
||||
const rangelimits = range ? range.split(",") : [];
|
||||
const range_start = parseInt(rangelimits[0]);
|
||||
const 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;
|
||||
const op = Profile.Operation;
|
||||
switch (operation) {
|
||||
case op.MOVE:
|
||||
printErr('Code move event for unknown code: 0x' + addr.toString(16));
|
||||
printErr(`Code move event for unknown code: 0x${addr.toString(16)}`);
|
||||
break;
|
||||
case op.DELETE:
|
||||
printErr('Code delete event for unknown code: 0x' + addr.toString(16));
|
||||
printErr(`Code delete event for unknown code: 0x${addr.toString(16)}`);
|
||||
break;
|
||||
case op.TICK:
|
||||
// Only unknown PCs (the first frame) are reported as unaccounted,
|
||||
@ -272,7 +272,7 @@ TickProcessor.prototype.isJsCode = function(name) {
|
||||
|
||||
TickProcessor.prototype.processLogFile = function(fileName) {
|
||||
this.lastLogFileName_ = fileName;
|
||||
var line;
|
||||
let line;
|
||||
while (line = readline()) {
|
||||
this.processLogLine(line);
|
||||
}
|
||||
@ -282,18 +282,18 @@ TickProcessor.prototype.processLogFile = function(fileName) {
|
||||
TickProcessor.prototype.processLogFileInTest = function(fileName) {
|
||||
// Hack file name to avoid dealing with platform specifics.
|
||||
this.lastLogFileName_ = 'v8.log';
|
||||
var contents = readFile(fileName);
|
||||
const contents = readFile(fileName);
|
||||
this.processLogChunk(contents);
|
||||
};
|
||||
|
||||
|
||||
TickProcessor.prototype.processSharedLibrary = function(
|
||||
name, startAddr, endAddr, aslrSlide) {
|
||||
var entry = this.profile_.addLibrary(name, startAddr, endAddr, aslrSlide);
|
||||
const entry = this.profile_.addLibrary(name, startAddr, endAddr, aslrSlide);
|
||||
this.setCodeType(entry.getName(), 'SHARED_LIB');
|
||||
|
||||
var self = this;
|
||||
var libFuncs = this.cppEntriesProvider_.parseVmSymbols(
|
||||
const self = this;
|
||||
const libFuncs = this.cppEntriesProvider_.parseVmSymbols(
|
||||
name, startAddr, endAddr, aslrSlide, function(fName, fStart, fEnd) {
|
||||
self.profile_.addStaticCode(fName, fStart, fEnd);
|
||||
self.setCodeType(fName, 'CPP');
|
||||
@ -304,8 +304,8 @@ TickProcessor.prototype.processSharedLibrary = function(
|
||||
TickProcessor.prototype.processCodeCreation = function(
|
||||
type, kind, timestamp, start, size, name, maybe_func) {
|
||||
if (maybe_func.length) {
|
||||
var funcAddr = parseInt(maybe_func[0]);
|
||||
var state = parseState(maybe_func[1]);
|
||||
const funcAddr = parseInt(maybe_func[0]);
|
||||
const state = parseState(maybe_func[1]);
|
||||
this.profile_.addFuncCode(type, name, timestamp, start, size, funcAddr, state);
|
||||
} else {
|
||||
this.profile_.addCode(type, name, timestamp, start, size);
|
||||
@ -385,7 +385,7 @@ TickProcessor.prototype.processTick = function(pc,
|
||||
} 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);
|
||||
const funcEntry = this.profile_.findEntry(tos_or_external_callback);
|
||||
if (!funcEntry || !funcEntry.isJSFunction || !funcEntry.isJSFunction()) {
|
||||
tos_or_external_callback = 0;
|
||||
}
|
||||
@ -411,14 +411,14 @@ TickProcessor.prototype.processHeapSampleBegin = function(space, state, ticks) {
|
||||
TickProcessor.prototype.processHeapSampleEnd = function(space, state) {
|
||||
if (space != 'Heap' || !this.currentProducerProfile_) return;
|
||||
|
||||
print('Generation ' + this.generation_ + ':');
|
||||
var tree = this.currentProducerProfile_;
|
||||
print(`Generation ${this.generation_}:`);
|
||||
const tree = this.currentProducerProfile_;
|
||||
tree.computeTotalWeights();
|
||||
var producersView = this.viewBuilder_.buildView(tree);
|
||||
const 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); });
|
||||
producersView.sort((rec1, rec2) =>
|
||||
rec2.totalTime - rec1.totalTime ||
|
||||
(rec2.internalFuncName < rec1.internalFuncName ? -1 : 1) );
|
||||
this.printHeavyProfile(producersView.head.children);
|
||||
|
||||
this.currentProducerProfile_ = null;
|
||||
@ -432,46 +432,46 @@ TickProcessor.prototype.printStatistics = function() {
|
||||
return;
|
||||
}
|
||||
|
||||
print('Statistical profiling result from ' + this.lastLogFileName_ +
|
||||
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);
|
||||
const flatProfile = this.profile_.getFlatProfile();
|
||||
const 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;
|
||||
flatView.sort((rec1, rec2) =>
|
||||
rec2.selfTime - rec1.selfTime ||
|
||||
(rec2.internalFuncName < rec1.internalFuncName ? -1 : 1) );
|
||||
let totalTicks = this.ticks_.total;
|
||||
if (this.ignoreUnknown_) {
|
||||
totalTicks -= this.ticks_.unaccounted;
|
||||
}
|
||||
var printAllTicks = !this.onlySummary_;
|
||||
const printAllTicks = !this.onlySummary_;
|
||||
|
||||
// Count library ticks
|
||||
var flatViewNodes = flatView.head.children;
|
||||
var self = this;
|
||||
const flatViewNodes = flatView.head.children;
|
||||
const self = this;
|
||||
|
||||
var libraryTicks = 0;
|
||||
let libraryTicks = 0;
|
||||
if(printAllTicks) this.printHeader('Shared libraries');
|
||||
this.printEntries(flatViewNodes, totalTicks, null,
|
||||
function(name) { return self.isSharedLibrary(name); },
|
||||
name => self.isSharedLibrary(name),
|
||||
function(rec) { libraryTicks += rec.selfTime; }, printAllTicks);
|
||||
var nonLibraryTicks = totalTicks - libraryTicks;
|
||||
const nonLibraryTicks = totalTicks - libraryTicks;
|
||||
|
||||
var jsTicks = 0;
|
||||
let jsTicks = 0;
|
||||
if(printAllTicks) this.printHeader('JavaScript');
|
||||
this.printEntries(flatViewNodes, totalTicks, nonLibraryTicks,
|
||||
function(name) { return self.isJsCode(name); },
|
||||
name => self.isJsCode(name),
|
||||
function(rec) { jsTicks += rec.selfTime; }, printAllTicks);
|
||||
|
||||
var cppTicks = 0;
|
||||
let cppTicks = 0;
|
||||
if(printAllTicks) this.printHeader('C++');
|
||||
this.printEntries(flatViewNodes, totalTicks, nonLibraryTicks,
|
||||
function(name) { return self.isCppCode(name); },
|
||||
name => self.isCppCode(name),
|
||||
function(rec) { cppTicks += rec.selfTime; }, printAllTicks);
|
||||
|
||||
this.printHeader('Summary');
|
||||
@ -487,22 +487,22 @@ TickProcessor.prototype.printStatistics = function() {
|
||||
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++) {
|
||||
const c_entry_functions = this.profile_.getCEntryProfile();
|
||||
const total_c_entry = c_entry_functions[0].ticks;
|
||||
for (let i = 1; i < c_entry_functions.length; i++) {
|
||||
const c = c_entry_functions[i];
|
||||
this.printLine(c.name, c.ticks, total_c_entry, totalTicks);
|
||||
}
|
||||
|
||||
this.printHeavyProfHeader();
|
||||
var heavyProfile = this.profile_.getBottomUpProfile();
|
||||
var heavyView = this.viewBuilder_.buildView(heavyProfile);
|
||||
const heavyProfile = this.profile_.getBottomUpProfile();
|
||||
const 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); });
|
||||
heavyView.sort((rec1, rec2) =>
|
||||
rec2.totalTime - rec1.totalTime ||
|
||||
(rec2.internalFuncName < rec1.internalFuncName ? -1 : 1) );
|
||||
this.printHeavyProfile(heavyView.head.children);
|
||||
}
|
||||
};
|
||||
@ -511,7 +511,7 @@ TickProcessor.prototype.printStatistics = function() {
|
||||
function padLeft(s, len) {
|
||||
s = s.toString();
|
||||
if (s.length < len) {
|
||||
var padLength = len - s.length;
|
||||
const padLength = len - s.length;
|
||||
if (!(padLength in padLeft)) {
|
||||
padLeft[padLength] = new Array(padLength + 1).join(' ');
|
||||
}
|
||||
@ -522,18 +522,18 @@ function padLeft(s, len) {
|
||||
|
||||
|
||||
TickProcessor.prototype.printHeader = function(headerTitle) {
|
||||
print('\n [' + headerTitle + ']:');
|
||||
print(`\n [${headerTitle}]:`);
|
||||
print(' ticks total nonlib name');
|
||||
};
|
||||
|
||||
|
||||
TickProcessor.prototype.printLine = function(
|
||||
entry, ticks, totalTicks, nonLibTicks) {
|
||||
var pct = ticks * 100 / totalTicks;
|
||||
var nonLibPct = nonLibTicks != null
|
||||
const pct = ticks * 100 / totalTicks;
|
||||
const nonLibPct = nonLibTicks != null
|
||||
? padLeft((ticks * 100 / nonLibTicks).toFixed(1), 5) + '% '
|
||||
: ' ';
|
||||
print(' ' + padLeft(ticks, 5) + ' ' +
|
||||
print(` ${padLeft(ticks, 5)} ` +
|
||||
padLeft(pct.toFixed(1), 5) + '% ' +
|
||||
nonLibPct +
|
||||
entry);
|
||||
@ -553,8 +553,8 @@ TickProcessor.prototype.printHeavyProfHeader = function() {
|
||||
|
||||
TickProcessor.prototype.processProfile = function(
|
||||
profile, filterP, func) {
|
||||
for (var i = 0, n = profile.length; i < n; ++i) {
|
||||
var rec = profile[i];
|
||||
for (let i = 0, n = profile.length; i < n; ++i) {
|
||||
const rec = profile[i];
|
||||
if (!filterP(rec.internalFuncName)) {
|
||||
continue;
|
||||
}
|
||||
@ -563,8 +563,8 @@ TickProcessor.prototype.processProfile = function(
|
||||
};
|
||||
|
||||
TickProcessor.prototype.getLineAndColumn = function(name) {
|
||||
var re = /:([0-9]+):([0-9]+)$/;
|
||||
var array = re.exec(name);
|
||||
const re = /:([0-9]+):([0-9]+)$/;
|
||||
const array = re.exec(name);
|
||||
if (!array) {
|
||||
return null;
|
||||
}
|
||||
@ -580,28 +580,28 @@ TickProcessor.prototype.formatFunctionName = function(funcName) {
|
||||
if (!this.hasSourceMap()) {
|
||||
return funcName;
|
||||
}
|
||||
var lc = this.getLineAndColumn(funcName);
|
||||
const 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;
|
||||
const lineNumber = lc.line - 1;
|
||||
const column = lc.column - 1;
|
||||
const entry = this.sourceMap.findEntry(lineNumber, column);
|
||||
const sourceFile = entry[2];
|
||||
const sourceLine = entry[3] + 1;
|
||||
const sourceColumn = entry[4] + 1;
|
||||
|
||||
return sourceFile + ':' + sourceLine + ':' + sourceColumn + ' -> ' + funcName;
|
||||
};
|
||||
|
||||
TickProcessor.prototype.printEntries = function(
|
||||
profile, totalTicks, nonLibTicks, filterP, callback, printAllTicks) {
|
||||
var that = this;
|
||||
const that = this;
|
||||
this.processProfile(profile, filterP, function (rec) {
|
||||
if (rec.selfTime == 0) return;
|
||||
callback(rec);
|
||||
var funcName = that.formatFunctionName(rec.internalFuncName);
|
||||
const funcName = that.formatFunctionName(rec.internalFuncName);
|
||||
if(printAllTicks) {
|
||||
that.printLine(funcName, rec.selfTime, totalTicks, nonLibTicks);
|
||||
}
|
||||
@ -610,14 +610,14 @@ TickProcessor.prototype.printEntries = function(
|
||||
|
||||
|
||||
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) {
|
||||
const self = this;
|
||||
const indent = opt_indent || 0;
|
||||
const indentStr = padLeft('', indent);
|
||||
this.processProfile(profile, () => 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) + ' ' +
|
||||
const funcName = self.formatFunctionName(rec.internalFuncName);
|
||||
print(` ${padLeft(rec.totalTime, 5)} ` +
|
||||
padLeft(rec.parentTotalPercent.toFixed(1), 5) + '% ' +
|
||||
indentStr + funcName);
|
||||
// Limit backtrace depth.
|
||||
@ -640,8 +640,8 @@ CppEntriesProvider.prototype.parseVmSymbols = function(
|
||||
libName, libStart, libEnd, libASLRSlide, processorFunc) {
|
||||
this.loadSymbols(libName);
|
||||
|
||||
var lastUnknownSize;
|
||||
var lastAdded;
|
||||
let lastUnknownSize;
|
||||
let lastAdded;
|
||||
|
||||
function inRange(funcInfo, start, end) {
|
||||
return funcInfo.start >= start && funcInfo.end <= end;
|
||||
@ -681,7 +681,7 @@ CppEntriesProvider.prototype.parseVmSymbols = function(
|
||||
}
|
||||
|
||||
while (true) {
|
||||
var funcInfo = this.parseNextLine();
|
||||
const funcInfo = this.parseNextLine();
|
||||
if (funcInfo === null) {
|
||||
continue;
|
||||
} else if (funcInfo === false) {
|
||||
@ -706,9 +706,7 @@ CppEntriesProvider.prototype.loadSymbols = function(libName) {
|
||||
};
|
||||
|
||||
|
||||
CppEntriesProvider.prototype.parseNextLine = function() {
|
||||
return false;
|
||||
};
|
||||
CppEntriesProvider.prototype.parseNextLine = () => false;
|
||||
|
||||
|
||||
export function UnixCppEntriesProvider(nmExec, objdumpExec, targetRootFS, apkEmbeddedLibrary) {
|
||||
@ -759,17 +757,17 @@ UnixCppEntriesProvider.prototype.parseNextLine = function() {
|
||||
if (this.symbols.length == 0) {
|
||||
return false;
|
||||
}
|
||||
var lineEndPos = this.symbols[0].indexOf('\n', this.parsePos);
|
||||
const 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);
|
||||
const line = this.symbols[0].substring(this.parsePos, lineEndPos);
|
||||
this.parsePos = lineEndPos + 1;
|
||||
var fields = line.match(this.FUNC_RE);
|
||||
var funcInfo = null;
|
||||
const fields = line.match(this.FUNC_RE);
|
||||
let funcInfo = null;
|
||||
if (fields) {
|
||||
funcInfo = { name: fields[3], start: parseInt(fields[1], 16) + this.fileOffsetMinusVma };
|
||||
if (fields[2]) {
|
||||
@ -829,9 +827,9 @@ WindowsCppEntriesProvider.EXE_IMAGE_BASE = 0x00400000;
|
||||
|
||||
WindowsCppEntriesProvider.prototype.loadSymbols = function(libName) {
|
||||
libName = this.targetRootFS + libName;
|
||||
var fileNameFields = libName.match(WindowsCppEntriesProvider.FILENAME_RE);
|
||||
const fileNameFields = libName.match(WindowsCppEntriesProvider.FILENAME_RE);
|
||||
if (!fileNameFields) return;
|
||||
var mapFileName = fileNameFields[1] + '.map';
|
||||
const mapFileName = fileNameFields[1] + '.map';
|
||||
this.moduleType_ = fileNameFields[2].toLowerCase();
|
||||
try {
|
||||
this.symbols = read(mapFileName);
|
||||
@ -843,26 +841,26 @@ WindowsCppEntriesProvider.prototype.loadSymbols = function(libName) {
|
||||
|
||||
|
||||
WindowsCppEntriesProvider.prototype.parseNextLine = function() {
|
||||
var lineEndPos = this.symbols.indexOf('\r\n', this.parsePos);
|
||||
const lineEndPos = this.symbols.indexOf('\r\n', this.parsePos);
|
||||
if (lineEndPos == -1) {
|
||||
return false;
|
||||
}
|
||||
|
||||
var line = this.symbols.substring(this.parsePos, lineEndPos);
|
||||
const line = this.symbols.substring(this.parsePos, lineEndPos);
|
||||
this.parsePos = lineEndPos + 2;
|
||||
|
||||
// Image base entry is above all other symbols, so we can just
|
||||
// terminate parsing.
|
||||
var imageBaseFields = line.match(WindowsCppEntriesProvider.IMAGE_BASE_RE);
|
||||
const imageBaseFields = line.match(WindowsCppEntriesProvider.IMAGE_BASE_RE);
|
||||
if (imageBaseFields) {
|
||||
var imageBase = parseInt(imageBaseFields[1], 16);
|
||||
const imageBase = parseInt(imageBaseFields[1], 16);
|
||||
if ((this.moduleType_ == 'exe') !=
|
||||
(imageBase == WindowsCppEntriesProvider.EXE_IMAGE_BASE)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
var fields = line.match(WindowsCppEntriesProvider.FUNC_RE);
|
||||
const fields = line.match(WindowsCppEntriesProvider.FUNC_RE);
|
||||
return fields ?
|
||||
{ name: this.unmangleName(fields[1]), start: parseInt(fields[2], 16) } :
|
||||
null;
|
||||
@ -880,8 +878,8 @@ WindowsCppEntriesProvider.prototype.parseNextLine = function() {
|
||||
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('@');
|
||||
const nameEndPos = name.indexOf('@@');
|
||||
const components = name.substring(1, nameEndPos).split('@');
|
||||
components.reverse();
|
||||
return components.join('::');
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user