Commit 400b6e7f authored by Camillo Bruni's avatar Camillo Bruni Committed by Commit Bot

[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/+/2519564Reviewed-by: 's avatarSathya Gunasekaran  <gsathya@chromium.org>
Commit-Queue: Camillo Bruni <cbruni@chromium.org>
Cr-Commit-Position: refs/heads/master@{#71080}
parent 4beadfde
...@@ -27,37 +27,37 @@ export class BaseArgumentsProcessor { ...@@ -27,37 +27,37 @@ export class BaseArgumentsProcessor {
'Default log file name is "' + 'Default log file name is "' +
this.result_.logFileName + '".\n'); this.result_.logFileName + '".\n');
print('Options:'); print('Options:');
for (var arg in this.argsDispatch_) { for (const arg in this.argsDispatch_) {
var synonyms = [arg]; const synonyms = [arg];
var dispatch = this.argsDispatch_[arg]; const dispatch = this.argsDispatch_[arg];
for (var synArg in this.argsDispatch_) { for (const synArg in this.argsDispatch_) {
if (arg !== synArg && dispatch === this.argsDispatch_[synArg]) { if (arg !== synArg && dispatch === this.argsDispatch_[synArg]) {
synonyms.push(synArg); synonyms.push(synArg);
delete this.argsDispatch_[synArg]; delete this.argsDispatch_[synArg];
} }
} }
print(' ' + synonyms.join(', ').padEnd(20) + " " + dispatch[2]); print(` ${synonyms.join(', ').padEnd(20)} ${dispatch[2]}`);
} }
quit(2); quit(2);
} }
parse() { parse() {
while (this.args_.length) { while (this.args_.length) {
var arg = this.args_.shift(); let arg = this.args_.shift();
if (arg.charAt(0) != '-') { if (arg.charAt(0) != '-') {
this.result_.logFileName = arg; this.result_.logFileName = arg;
continue; continue;
} }
var userValue = null; let userValue = null;
var eqPos = arg.indexOf('='); const eqPos = arg.indexOf('=');
if (eqPos != -1) { if (eqPos != -1) {
userValue = arg.substr(eqPos + 1); userValue = arg.substr(eqPos + 1);
arg = arg.substr(0, eqPos); arg = arg.substr(0, eqPos);
} }
if (arg in this.argsDispatch_) { if (arg in this.argsDispatch_) {
var dispatch = this.argsDispatch_[arg]; const dispatch = this.argsDispatch_[arg];
var property = dispatch[0]; const property = dispatch[0];
var defaultValue = dispatch[1]; const defaultValue = dispatch[1];
if (typeof defaultValue == "function") { if (typeof defaultValue == "function") {
userValue = defaultValue(userValue); userValue = defaultValue(userValue);
} else if (userValue == null) { } else if (userValue == null) {
......
...@@ -90,7 +90,7 @@ export class CodeMap { ...@@ -90,7 +90,7 @@ export class CodeMap {
* @param {number} to The destination address. * @param {number} to The destination address.
*/ */
moveCode(from, to) { 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.deleteAllCoveredNodes_(this.dynamics_, to, to + removedNode.value.size);
this.dynamics_.insert(to, removedNode.value); this.dynamics_.insert(to, removedNode.value);
} }
...@@ -102,7 +102,7 @@ export class CodeMap { ...@@ -102,7 +102,7 @@ export class CodeMap {
* @param {number} start The starting address of the entry being deleted. * @param {number} start The starting address of the entry being deleted.
*/ */
deleteCode(start) { deleteCode(start) {
var removedNode = this.dynamics_.remove(start); const removedNode = this.dynamics_.remove(start);
} }
/** /**
...@@ -130,7 +130,7 @@ export class CodeMap { ...@@ -130,7 +130,7 @@ export class CodeMap {
* @private * @private
*/ */
markPages_(start, end) { markPages_(start, end) {
for (var addr = start; addr <= end; for (let addr = start; addr <= end;
addr += CodeMap.PAGE_SIZE) { addr += CodeMap.PAGE_SIZE) {
this.pages_[(addr / CodeMap.PAGE_SIZE)|0] = 1; this.pages_[(addr / CodeMap.PAGE_SIZE)|0] = 1;
} }
...@@ -140,16 +140,16 @@ export class CodeMap { ...@@ -140,16 +140,16 @@ export class CodeMap {
* @private * @private
*/ */
deleteAllCoveredNodes_(tree, start, end) { deleteAllCoveredNodes_(tree, start, end) {
var to_delete = []; const to_delete = [];
var addr = end - 1; let addr = end - 1;
while (addr >= start) { while (addr >= start) {
var node = tree.findGreatestLessThan(addr); const node = tree.findGreatestLessThan(addr);
if (!node) break; 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); if (start2 < end && start < end2) to_delete.push(start2);
addr = start2 - 1; 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 { ...@@ -163,7 +163,7 @@ export class CodeMap {
* @private * @private
*/ */
findInTree_(tree, addr) { findInTree_(tree, addr) {
var node = tree.findGreatestLessThan(addr); const node = tree.findGreatestLessThan(addr);
return node && this.isAddressBelongsTo_(addr, node) ? node : null; return node && this.isAddressBelongsTo_(addr, node) ? node : null;
} }
...@@ -175,29 +175,29 @@ export class CodeMap { ...@@ -175,29 +175,29 @@ export class CodeMap {
* @param {number} addr Address. * @param {number} addr Address.
*/ */
findAddress(addr) { findAddress(addr) {
var pageAddr = (addr / CodeMap.PAGE_SIZE)|0; const pageAddr = (addr / CodeMap.PAGE_SIZE)|0;
if (pageAddr in this.pages_) { if (pageAddr in this.pages_) {
// Static code entries can contain "holes" of unnamed code. // Static code entries can contain "holes" of unnamed code.
// In this case, the whole library is assigned to this address. // 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) { if (!result) {
result = this.findInTree_(this.libraries_, addr); result = this.findInTree_(this.libraries_, addr);
if (!result) return null; if (!result) return null;
} }
return { entry : result.value, offset : addr - result.key }; return { entry : result.value, offset : addr - result.key };
} }
var min = this.dynamics_.findMin(); const min = this.dynamics_.findMin();
var max = this.dynamics_.findMax(); const max = this.dynamics_.findMax();
if (max != null && addr < (max.key + max.value.size) && addr >= min.key) { 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; if (dynaEntry == null) return null;
// Dedupe entry name. // Dedupe entry name.
var entry = dynaEntry.value; const entry = dynaEntry.value;
if (!entry.nameUpdated_) { if (!entry.nameUpdated_) {
entry.name = this.dynamicsNameGen_.getName(entry.name); entry.name = this.dynamicsNameGen_.getName(entry.name);
entry.nameUpdated_ = true; entry.nameUpdated_ = true;
} }
return { entry : entry, offset : addr - dynaEntry.key }; return { entry, offset : addr - dynaEntry.key };
} }
return null; return null;
} }
...@@ -209,7 +209,7 @@ export class CodeMap { ...@@ -209,7 +209,7 @@ export class CodeMap {
* @param {number} addr Address. * @param {number} addr Address.
*/ */
findEntry(addr) { findEntry(addr) {
var result = this.findAddress(addr); const result = this.findAddress(addr);
return result ? result.entry : null; return result ? result.entry : null;
} }
...@@ -219,7 +219,7 @@ export class CodeMap { ...@@ -219,7 +219,7 @@ export class CodeMap {
* @param {number} addr Address. * @param {number} addr Address.
*/ */
findDynamicEntryByStartAddress(addr) { findDynamicEntryByStartAddress(addr) {
var node = this.dynamics_.find(addr); const node = this.dynamics_.find(addr);
return node ? node.value : null; return node ? node.value : null;
} }
...@@ -292,7 +292,7 @@ class NameGenerator { ...@@ -292,7 +292,7 @@ class NameGenerator {
this.knownNames_[name] = 0; this.knownNames_[name] = 0;
return name; return name;
} }
var count = ++this.knownNames_[name]; const count = ++this.knownNames_[name];
return name + ' {' + count + '}'; return name + ' {' + count + '}';
}; };
} }
...@@ -72,7 +72,7 @@ ConsArray.prototype.atEnd = function() { ...@@ -72,7 +72,7 @@ ConsArray.prototype.atEnd = function() {
* Returns the current item, moves to the next one. * Returns the current item, moves to the next one.
*/ */
ConsArray.prototype.next = function() { 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) { if (this.currCellPos_ >= this.currCell_.data.length) {
this.currCell_ = this.currCell_.next; this.currCell_ = this.currCell_.next;
this.currCellPos_ = 0; this.currCellPos_ = 0;
......
...@@ -84,9 +84,9 @@ export class CsvParser { ...@@ -84,9 +84,9 @@ export class CsvParser {
* @param {string} line Input line. * @param {string} line Input line.
*/ */
parseLine(line) { parseLine(line) {
var pos = 0; let pos = 0;
var endPos = line.length; const endPos = line.length;
var fields = []; const fields = [];
if (endPos == 0) return fields; if (endPos == 0) return fields;
let nextPos = 0; let nextPos = 0;
while(nextPos !== -1) { while(nextPos !== -1) {
......
...@@ -11,7 +11,7 @@ import { ...@@ -11,7 +11,7 @@ import {
// Dump C++ symbols of shared library if possible // Dump C++ symbols of shared library if possible
function processArguments(args) { function processArguments(args) {
var processor = new ArgumentsProcessor(args); const processor = new ArgumentsProcessor(args);
if (processor.parse()) { if (processor.parse()) {
return processor.result(); return processor.result();
} else { } else {
...@@ -25,26 +25,26 @@ function initSourceMapSupport() { ...@@ -25,26 +25,26 @@ function initSourceMapSupport() {
// Overwrite the load function to load scripts synchronously. // Overwrite the load function to load scripts synchronously.
SourceMap.load = function(sourceMapURL) { SourceMap.load = function(sourceMapURL) {
var content = readFile(sourceMapURL); const content = readFile(sourceMapURL);
var sourceMapObject = (JSON.parse(content)); const sourceMapObject = (JSON.parse(content));
return new SourceMap(sourceMapURL, sourceMapObject); return new SourceMap(sourceMapURL, sourceMapObject);
}; };
} }
var entriesProviders = { const entriesProviders = {
'unix': UnixCppEntriesProvider, 'unix': UnixCppEntriesProvider,
'windows': WindowsCppEntriesProvider, 'windows': WindowsCppEntriesProvider,
'mac': MacCppEntriesProvider 'mac': MacCppEntriesProvider
}; };
var params = processArguments(arguments); const params = processArguments(arguments);
var sourceMap = null; let sourceMap = null;
if (params.sourceMap) { if (params.sourceMap) {
initSourceMapSupport(); initSourceMapSupport();
sourceMap = SourceMap.load(params.sourceMap); sourceMap = SourceMap.load(params.sourceMap);
} }
var cppProcessor = new CppProcessor( const cppProcessor = new CppProcessor(
new (entriesProviders[params.platform])(params.nm, params.targetRootFS, new (entriesProviders[params.platform])(params.nm, params.targetRootFS,
params.apkEmbeddedLibrary), params.apkEmbeddedLibrary),
params.timedRange, params.pairwiseTimedRange); params.timedRange, params.pairwiseTimedRange);
......
...@@ -33,7 +33,7 @@ export class CppProcessor extends LogReader { ...@@ -33,7 +33,7 @@ export class CppProcessor extends LogReader {
processLogFile(fileName) { processLogFile(fileName) {
this.lastLogFileName_ = fileName; this.lastLogFileName_ = fileName;
var line; let line;
while (line = readline()) { while (line = readline()) {
this.processLogLine(line); this.processLogLine(line);
} }
...@@ -42,26 +42,26 @@ export class CppProcessor extends LogReader { ...@@ -42,26 +42,26 @@ export class CppProcessor extends LogReader {
processLogFileInTest(fileName) { processLogFileInTest(fileName) {
// Hack file name to avoid dealing with platform specifics. // Hack file name to avoid dealing with platform specifics.
this.lastLogFileName_ = 'v8.log'; this.lastLogFileName_ = 'v8.log';
var contents = readFile(fileName); const contents = readFile(fileName);
this.processLogChunk(contents); this.processLogChunk(contents);
}; };
processSharedLibrary(name, startAddr, endAddr, aslrSlide) { processSharedLibrary(name, startAddr, endAddr, aslrSlide) {
var self = this; const self = this;
var libFuncs = this.cppEntriesProvider_.parseVmSymbols( const libFuncs = this.cppEntriesProvider_.parseVmSymbols(
name, startAddr, endAddr, aslrSlide, function(fName, fStart, fEnd) { 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); self.codeMap_.addStaticCode(fStart, entry);
}); });
}; };
dumpCppSymbols() { dumpCppSymbols() {
var staticEntries = this.codeMap_.getAllStaticEntriesWithAddresses(); const staticEntries = this.codeMap_.getAllStaticEntriesWithAddresses();
var total = staticEntries.length; const total = staticEntries.length;
for (var i = 0; i < total; ++i) { for (let i = 0; i < total; ++i) {
var entry = staticEntries[i]; const entry = staticEntries[i];
var printValues = ['cpp', '0x' + entry[0].toString(16), entry[1].size, const printValues = ['cpp', `0x${entry[0].toString(16)}`, entry[1].size,
'"' + entry[1].name + '"']; `"${entry[1].name}"`];
print(printValues.join(',')); print(printValues.join(','));
} }
} }
......
...@@ -7,7 +7,7 @@ import { WebInspector } from "./sourcemap.mjs"; ...@@ -7,7 +7,7 @@ import { WebInspector } from "./sourcemap.mjs";
import { BaseArgumentsProcessor } from "./arguments.mjs"; import { BaseArgumentsProcessor } from "./arguments.mjs";
function processArguments(args) { function processArguments(args) {
var processor = new ArgumentsProcessor(args); const processor = new ArgumentsProcessor(args);
if (processor.parse()) { if (processor.parse()) {
return processor.result(); return processor.result();
} else { } else {
...@@ -33,8 +33,8 @@ function initSourceMapSupport() { ...@@ -33,8 +33,8 @@ function initSourceMapSupport() {
// Overwrite the load function to load scripts synchronously. // Overwrite the load function to load scripts synchronously.
SourceMap.load = function(sourceMapURL) { SourceMap.load = function(sourceMapURL) {
var content = readFile(sourceMapURL); const content = readFile(sourceMapURL);
var sourceMapObject = (JSON.parse(content)); const sourceMapObject = (JSON.parse(content));
return new SourceMap(sourceMapURL, sourceMapObject); return new SourceMap(sourceMapURL, sourceMapObject);
}; };
} }
...@@ -82,7 +82,7 @@ for (const ic of processor.icTimeline.all) { ...@@ -82,7 +82,7 @@ for (const ic of processor.icTimeline.all) {
ic.type + ' (' + ic.oldState + '->' + ic.newState + ic.modifier + ') at ' + ic.type + ' (' + ic.oldState + '->' + ic.newState + ic.modifier + ') at ' +
ic.filePosition + ' ' + ic.key + ic.filePosition + ' ' + ic.key +
' (map 0x' + ic.map.toString(16) + ')' + ' (map 0x' + ic.map.toString(16) + ')' +
(ic.reason ? ' ' + ic.reason : '') + ' time: ' + ic.time); (ic.reason ? ` ${ic.reason}` : '') + ' time: ' + ic.time);
accumulator[ic.type]++; accumulator[ic.type]++;
} }
......
...@@ -146,11 +146,11 @@ LogReader.prototype.processLogLine = function(line) { ...@@ -146,11 +146,11 @@ LogReader.prototype.processLogLine = function(line) {
* @return {Array.<number>} Processed stack. * @return {Array.<number>} Processed stack.
*/ */
LogReader.prototype.processStack = function(pc, func, stack) { LogReader.prototype.processStack = function(pc, func, stack) {
var fullStack = func ? [pc, func] : [pc]; const fullStack = func ? [pc, func] : [pc];
var prevFrame = pc; let prevFrame = pc;
for (var i = 0, n = stack.length; i < n; ++i) { for (let i = 0, n = stack.length; i < n; ++i) {
var frame = stack[i]; const frame = stack[i];
var firstChar = frame.charAt(0); const firstChar = frame.charAt(0);
if (firstChar == '+' || firstChar == '-') { if (firstChar == '+' || firstChar == '-') {
// An offset from the previous frame. // An offset from the previous frame.
prevFrame += parseInt(frame, 16); prevFrame += parseInt(frame, 16);
...@@ -159,7 +159,7 @@ LogReader.prototype.processStack = function(pc, func, stack) { ...@@ -159,7 +159,7 @@ LogReader.prototype.processStack = function(pc, func, stack) {
} else if (firstChar != 'o') { } else if (firstChar != 'o') {
fullStack.push(parseInt(frame, 16)); fullStack.push(parseInt(frame, 16));
} else { } else {
this.printError("dropping: " + frame); this.printError(`dropping: ${frame}`);
} }
} }
return fullStack; return fullStack;
...@@ -172,9 +172,7 @@ LogReader.prototype.processStack = function(pc, func, stack) { ...@@ -172,9 +172,7 @@ LogReader.prototype.processStack = function(pc, func, stack) {
* @param {!Object} dispatch Dispatch record. * @param {!Object} dispatch Dispatch record.
* @return {boolean} True if dispatch must be skipped. * @return {boolean} True if dispatch must be skipped.
*/ */
LogReader.prototype.skipDispatch = function(dispatch) { LogReader.prototype.skipDispatch = dispatch => false;
return false;
};
// Parses dummy variable for readability; // Parses dummy variable for readability;
export const parseString = 'parse-string'; export const parseString = 'parse-string';
...@@ -188,17 +186,17 @@ export const parseVarArgs = 'parse-var-args'; ...@@ -188,17 +186,17 @@ export const parseVarArgs = 'parse-var-args';
*/ */
LogReader.prototype.dispatchLogRow_ = function(fields) { LogReader.prototype.dispatchLogRow_ = function(fields) {
// Obtain the dispatch. // Obtain the dispatch.
var command = fields[0]; const command = fields[0];
var dispatch = this.dispatchTable_[command]; const dispatch = this.dispatchTable_[command];
if (dispatch === undefined) return; if (dispatch === undefined) return;
if (dispatch === null || this.skipDispatch(dispatch)) { if (dispatch === null || this.skipDispatch(dispatch)) {
return; return;
} }
// Parse fields. // Parse fields.
var parsedFields = []; const parsedFields = [];
for (var i = 0; i < dispatch.parsers.length; ++i) { for (let i = 0; i < dispatch.parsers.length; ++i) {
var parser = dispatch.parsers[i]; const parser = dispatch.parsers[i];
if (parser === parseString) { if (parser === parseString) {
parsedFields.push(fields[1 + i]); parsedFields.push(fields[1 + i]);
} else if (typeof parser == 'function') { } else if (typeof parser == 'function') {
...@@ -208,7 +206,7 @@ LogReader.prototype.dispatchLogRow_ = function(fields) { ...@@ -208,7 +206,7 @@ LogReader.prototype.dispatchLogRow_ = function(fields) {
parsedFields.push(fields.slice(1 + i)); parsedFields.push(fields.slice(1 + i));
break; break;
} else { } 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) { ...@@ -224,7 +222,7 @@ LogReader.prototype.dispatchLogRow_ = function(fields) {
* @private * @private
*/ */
LogReader.prototype.processLog_ = function(lines) { 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]); this.processLogLine_(lines[i]);
} }
} }
...@@ -238,10 +236,10 @@ LogReader.prototype.processLog_ = function(lines) { ...@@ -238,10 +236,10 @@ LogReader.prototype.processLog_ = function(lines) {
LogReader.prototype.processLogLine_ = function(line) { LogReader.prototype.processLogLine_ = function(line) {
if (line.length > 0) { if (line.length > 0) {
try { try {
var fields = this.csvParser_.parseLine(line); const fields = this.csvParser_.parseLine(line);
this.dispatchLogRow_(fields); this.dispatchLogRow_(fields);
} catch (e) { } 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_++; this.lineNum_++;
......
...@@ -8,7 +8,7 @@ import { ...@@ -8,7 +8,7 @@ import {
} from "./parse-processor.mjs"; } from "./parse-processor.mjs";
function processArguments(args) { function processArguments(args) {
var processor = new ArgumentsProcessor(args); const processor = new ArgumentsProcessor(args);
if (processor.parse()) { if (processor.parse()) {
return processor.result(); return processor.result();
} else { } else {
...@@ -22,17 +22,17 @@ function initSourceMapSupport() { ...@@ -22,17 +22,17 @@ function initSourceMapSupport() {
// Overwrite the load function to load scripts synchronously. // Overwrite the load function to load scripts synchronously.
SourceMap.load = function(sourceMapURL) { SourceMap.load = function(sourceMapURL) {
var content = readFile(sourceMapURL); const content = readFile(sourceMapURL);
var sourceMapObject = (JSON.parse(content)); const sourceMapObject = (JSON.parse(content));
return new SourceMap(sourceMapURL, sourceMapObject); return new SourceMap(sourceMapURL, sourceMapObject);
}; };
} }
var params = processArguments(arguments); const params = processArguments(arguments);
var sourceMap = null; let sourceMap = null;
if (params.sourceMap) { if (params.sourceMap) {
initSourceMapSupport(); initSourceMapSupport();
sourceMap = SourceMap.load(params.sourceMap); sourceMap = SourceMap.load(params.sourceMap);
} }
var parseProcessor = new ParseProcessor(); const parseProcessor = new ParseProcessor();
parseProcessor.processLogFile(params.logFileName); parseProcessor.processLogFile(params.logFileName);
// Copyright 2017 the V8 project authors. All rights reserved. // Copyright 2017 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
"use strict";
import { LogReader, parseString } from "./logreader.mjs"; import { LogReader, parseString } from "./logreader.mjs";
import { BaseArgumentsProcessor } from "./arguments.mjs"; import { BaseArgumentsProcessor } from "./arguments.mjs";
...@@ -339,7 +337,7 @@ class Script extends CompilationUnit { ...@@ -339,7 +337,7 @@ class Script extends CompilationUnit {
calculateMetrics(printSummary) { calculateMetrics(printSummary) {
let log = (str) => this.summary += str + '\n'; let log = (str) => this.summary += str + '\n';
log("SCRIPT: " + this.id); log(`SCRIPT: ${this.id}`);
let all = this.funktions; let all = this.funktions;
if (all.length === 0) return; if (all.length === 0) return;
...@@ -354,7 +352,7 @@ class Script extends CompilationUnit { ...@@ -354,7 +352,7 @@ class Script extends CompilationUnit {
let value = (funktions.length + "").padStart(6) + let value = (funktions.length + "").padStart(6) +
(nofPercent + "%").padStart(5) + (nofPercent + "%").padStart(5) +
BYTES(ownBytes, this.bytesTotal).padStart(10); 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 + "-bytes", ownBytes);
this.metrics.set(name + "-count", funktions.length); this.metrics.set(name + "-count", funktions.length);
this.metrics.set(name + "-count-percent", nofPercent); this.metrics.set(name + "-count-percent", nofPercent);
...@@ -362,7 +360,7 @@ class Script extends CompilationUnit { ...@@ -362,7 +360,7 @@ class Script extends CompilationUnit {
Math.round(ownBytes / this.bytesTotal * 100)); Math.round(ownBytes / this.bytesTotal * 100));
}; };
log(" - file: " + this.file); log(` - file: ${this.file}`);
log(' - details: ' + log(' - details: ' +
'isEval=' + this.isEval + ' deserialized=' + this.isDeserialized + 'isEval=' + this.isEval + ' deserialized=' + this.isDeserialized +
' streamed=' + this.isStreamingCompiled); ' streamed=' + this.isStreamingCompiled);
...@@ -409,7 +407,7 @@ class Script extends CompilationUnit { ...@@ -409,7 +407,7 @@ class Script extends CompilationUnit {
// [start+delta*2, acc(metric0, start, start+delta*2), ...], // [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 timespan = end - start;
const kSteps = Math.ceil(timespan / delta); const kSteps = Math.ceil(timespan / delta);
// To reduce the time spent iterating over the funktions of this script // To reduce the time spent iterating over the funktions of this script
...@@ -607,8 +605,8 @@ class ExecutionCost { ...@@ -607,8 +605,8 @@ class ExecutionCost {
} }
toString() { toString() {
return (' - ' + this.prefix + '-time:').padEnd(24) + return (` - ${this.prefix}-time:`).padEnd(24) +
(" executed=" + formatNumber(this.executedCost) + 'ms').padEnd(20) + (` executed=${formatNumber(this.executedCost)}ms`).padEnd(20) +
" non-executed=" + formatNumber(this.nonExecutedCost) + 'ms'; " non-executed=" + formatNumber(this.nonExecutedCost) + 'ms';
} }
...@@ -623,11 +621,11 @@ class ExecutionCost { ...@@ -623,11 +621,11 @@ class ExecutionCost {
class Funktion extends CompilationUnit { class Funktion extends CompilationUnit {
constructor(name, start, end, script) { constructor(name, start, end, script) {
super(); super();
if (start < 0) throw "invalid start position: " + start; if (start < 0) throw `invalid start position: ${start}`;
if (script.isEval) { if (script.isEval) {
if (end < start) throw 'invalid start end positions'; if (end < start) throw 'invalid start end positions';
} else { } 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'; if (end <= start) throw 'invalid start end positions';
} }
...@@ -722,7 +720,7 @@ class Funktion extends CompilationUnit { ...@@ -722,7 +720,7 @@ class Funktion extends CompilationUnit {
} }
toString(details = true) { toString(details = true) {
let result = 'function' + (this.name ? ' ' + this.name : '') + let result = `function${this.name ? ` ${this.name}` : ''}` +
`() range=${this.start}-${this.end}`; `() range=${this.start}-${this.end}`;
if (details) result += ` script=${this.script ? this.script.id : 'X'}`; if (details) result += ` script=${this.script ? this.script.id : 'X'}`;
return result; return result;
...@@ -841,7 +839,7 @@ export class ParseProcessor extends LogReader { ...@@ -841,7 +839,7 @@ export class ParseProcessor extends LogReader {
processLogFile(fileName) { processLogFile(fileName) {
this.collectEntries = true this.collectEntries = true
this.lastLogFileName_ = fileName; this.lastLogFileName_ = fileName;
var line; let line;
while (line = readline()) { while (line = readline()) {
this.processLogLine(line); this.processLogLine(line);
} }
...@@ -886,7 +884,7 @@ export class ParseProcessor extends LogReader { ...@@ -886,7 +884,7 @@ export class ParseProcessor extends LogReader {
functionName) { functionName) {
let handlerFn = this.functionEventDispatchTable_[eventName]; let handlerFn = this.functionEventDispatchTable_[eventName];
if (handlerFn === undefined) { if (handlerFn === undefined) {
console.error('Couldn\'t find handler for function event:' + eventName); console.error(`Couldn't find handler for function event:${eventName}`);
} }
handlerFn( handlerFn(
scriptId, startPosition, endPosition, duration, timestamp, scriptId, startPosition, endPosition, duration, timestamp,
...@@ -965,7 +963,7 @@ export class ParseProcessor extends LogReader { ...@@ -965,7 +963,7 @@ export class ParseProcessor extends LogReader {
script.preparseTimestamp = toTimestamp(timestamp); script.preparseTimestamp = toTimestamp(timestamp);
return; return;
default: default:
console.error('Unhandled script event: ' + eventName); console.error(`Unhandled script event: ${eventName}`);
} }
} }
......
This diff is collapsed.
...@@ -47,12 +47,12 @@ export function ViewBuilder(samplingRate) { ...@@ -47,12 +47,12 @@ export function ViewBuilder(samplingRate) {
*/ */
ViewBuilder.prototype.buildView = function( ViewBuilder.prototype.buildView = function(
callTree, opt_bottomUpViewWeights) { callTree, opt_bottomUpViewWeights) {
var head; let head;
var samplingRate = this.samplingRate; const samplingRate = this.samplingRate;
var createViewNode = this.createViewNode; const createViewNode = this.createViewNode;
callTree.traverse(function(node, viewParent) { callTree.traverse(function(node, viewParent) {
var totalWeight = node.totalWeight * samplingRate; const totalWeight = node.totalWeight * samplingRate;
var selfWeight = node.selfWeight * samplingRate; let selfWeight = node.selfWeight * samplingRate;
if (opt_bottomUpViewWeights === true) { if (opt_bottomUpViewWeights === true) {
if (viewParent === head) { if (viewParent === head) {
selfWeight = totalWeight; selfWeight = totalWeight;
...@@ -60,7 +60,7 @@ ViewBuilder.prototype.buildView = function( ...@@ -60,7 +60,7 @@ ViewBuilder.prototype.buildView = function(
selfWeight = 0; selfWeight = 0;
} }
} }
var viewNode = createViewNode(node.label, totalWeight, selfWeight, head); const viewNode = createViewNode(node.label, totalWeight, selfWeight, head);
if (viewParent) { if (viewParent) {
viewParent.addChild(viewNode); viewParent.addChild(viewNode);
} else { } else {
...@@ -68,7 +68,7 @@ ViewBuilder.prototype.buildView = function( ...@@ -68,7 +68,7 @@ ViewBuilder.prototype.buildView = function(
} }
return viewNode; return viewNode;
}); });
var view = this.createView(head); const view = this.createView(head);
return view; return view;
}; };
...@@ -79,9 +79,7 @@ ViewBuilder.prototype.buildView = function( ...@@ -79,9 +79,7 @@ ViewBuilder.prototype.buildView = function(
* @param {ProfileView.Node} head View head node. * @param {ProfileView.Node} head View head node.
* @return {ProfileView} Profile view. * @return {ProfileView} Profile view.
*/ */
ViewBuilder.prototype.createView = function(head) { ViewBuilder.prototype.createView = head => new ProfileView(head);
return new ProfileView(head);
};
/** /**
...@@ -96,11 +94,11 @@ ViewBuilder.prototype.createView = function(head) { ...@@ -96,11 +94,11 @@ ViewBuilder.prototype.createView = function(head) {
* @param {ProfileView.Node} head Profile view head. * @param {ProfileView.Node} head Profile view head.
* @return {ProfileView.Node} Profile view node. * @return {ProfileView.Node} Profile view node.
*/ */
ViewBuilder.prototype.createViewNode = function( ViewBuilder.prototype.createViewNode = (
funcName, totalTime, selfTime, head) { funcName, totalTime, selfTime, head) =>
return new ProfileView.Node( new ProfileView.Node(
funcName, totalTime, selfTime, head); funcName, totalTime, selfTime, head)
}; ;
/** /**
...@@ -135,10 +133,10 @@ ProfileView.prototype.sort = function(sortFunc) { ...@@ -135,10 +133,10 @@ ProfileView.prototype.sort = function(sortFunc) {
* @param {function(ProfileView.Node)} f Visitor function. * @param {function(ProfileView.Node)} f Visitor function.
*/ */
ProfileView.prototype.traverse = function(f) { ProfileView.prototype.traverse = function(f) {
var nodesToTraverse = new ConsArray(); const nodesToTraverse = new ConsArray();
nodesToTraverse.concat([this.head]); nodesToTraverse.concat([this.head]);
while (!nodesToTraverse.atEnd()) { while (!nodesToTraverse.atEnd()) {
var node = nodesToTraverse.next(); const node = nodesToTraverse.next();
f(node); f(node);
nodesToTraverse.concat(node.children); nodesToTraverse.concat(node.children);
} }
......
This diff is collapsed.
...@@ -75,7 +75,7 @@ SplayTree.prototype.insert = function(key, value) { ...@@ -75,7 +75,7 @@ SplayTree.prototype.insert = function(key, value) {
if (this.root_.key == key) { if (this.root_.key == key) {
return; return;
} }
var node = new SplayTree.Node(key, value); const node = new SplayTree.Node(key, value);
if (key > this.root_.key) { if (key > this.root_.key) {
node.left = this.root_; node.left = this.root_;
node.right = this.root_.right; node.right = this.root_.right;
...@@ -99,17 +99,17 @@ SplayTree.prototype.insert = function(key, value) { ...@@ -99,17 +99,17 @@ SplayTree.prototype.insert = function(key, value) {
*/ */
SplayTree.prototype.remove = function(key) { SplayTree.prototype.remove = function(key) {
if (this.isEmpty()) { if (this.isEmpty()) {
throw Error('Key not found: ' + key); throw Error(`Key not found: ${key}`);
} }
this.splay_(key); this.splay_(key);
if (this.root_.key != 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) { if (!this.root_.left) {
this.root_ = this.root_.right; this.root_ = this.root_.right;
} else { } else {
var right = this.root_.right; const { right } = this.root_;
this.root_ = this.root_.left; this.root_ = this.root_.left;
// Splay to make sure that the new root has an empty right child. // Splay to make sure that the new root has an empty right child.
this.splay_(key); this.splay_(key);
...@@ -144,7 +144,7 @@ SplayTree.prototype.findMin = function() { ...@@ -144,7 +144,7 @@ SplayTree.prototype.findMin = function() {
if (this.isEmpty()) { if (this.isEmpty()) {
return null; return null;
} }
var current = this.root_; let current = this.root_;
while (current.left) { while (current.left) {
current = current.left; current = current.left;
} }
...@@ -159,7 +159,7 @@ SplayTree.prototype.findMax = function(opt_startNode) { ...@@ -159,7 +159,7 @@ SplayTree.prototype.findMax = function(opt_startNode) {
if (this.isEmpty()) { if (this.isEmpty()) {
return null; return null;
} }
var current = opt_startNode || this.root_; let current = opt_startNode || this.root_;
while (current.right) { while (current.right) {
current = current.right; current = current.right;
} }
...@@ -195,7 +195,7 @@ SplayTree.prototype.findGreatestLessThan = function(key) { ...@@ -195,7 +195,7 @@ SplayTree.prototype.findGreatestLessThan = function(key) {
* with keys. * with keys.
*/ */
SplayTree.prototype.exportKeysAndValues = function() { SplayTree.prototype.exportKeysAndValues = function() {
var result = []; const result = [];
this.traverse_(function(node) { result.push([node.key, node.value]); }); this.traverse_(function(node) { result.push([node.key, node.value]); });
return result; return result;
}; };
...@@ -205,7 +205,7 @@ SplayTree.prototype.exportKeysAndValues = function() { ...@@ -205,7 +205,7 @@ SplayTree.prototype.exportKeysAndValues = function() {
* @return {Array<*>} An array containing all the values of tree's nodes. * @return {Array<*>} An array containing all the values of tree's nodes.
*/ */
SplayTree.prototype.exportValues = function() { SplayTree.prototype.exportValues = function() {
var result = []; const result = [];
this.traverse_(function(node) { result.push(node.value); }); this.traverse_(function(node) { result.push(node.value); });
return result; return result;
}; };
...@@ -230,9 +230,9 @@ SplayTree.prototype.splay_ = function(key) { ...@@ -230,9 +230,9 @@ SplayTree.prototype.splay_ = function(key) {
// the L tree of the algorithm. The left child of the dummy node // 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 // will hold the R tree of the algorithm. Using a dummy node, left
// and right will always be nodes and we avoid special cases. // 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); dummy = left = right = new SplayTree.Node(null, null);
var current = this.root_; let current = this.root_;
while (true) { while (true) {
if (key < current.key) { if (key < current.key) {
if (!current.left) { if (!current.left) {
...@@ -240,7 +240,7 @@ SplayTree.prototype.splay_ = function(key) { ...@@ -240,7 +240,7 @@ SplayTree.prototype.splay_ = function(key) {
} }
if (key < current.left.key) { if (key < current.left.key) {
// Rotate right. // Rotate right.
var tmp = current.left; const tmp = current.left;
current.left = tmp.right; current.left = tmp.right;
tmp.right = current; tmp.right = current;
current = tmp; current = tmp;
...@@ -258,7 +258,7 @@ SplayTree.prototype.splay_ = function(key) { ...@@ -258,7 +258,7 @@ SplayTree.prototype.splay_ = function(key) {
} }
if (key > current.right.key) { if (key > current.right.key) {
// Rotate left. // Rotate left.
var tmp = current.right; const tmp = current.right;
current.right = tmp.left; current.right = tmp.left;
tmp.left = current; tmp.left = current;
current = tmp; current = tmp;
...@@ -290,9 +290,9 @@ SplayTree.prototype.splay_ = function(key) { ...@@ -290,9 +290,9 @@ SplayTree.prototype.splay_ = function(key) {
* @private * @private
*/ */
SplayTree.prototype.traverse_ = function(f) { SplayTree.prototype.traverse_ = function(f) {
var nodesToVisit = [this.root_]; const nodesToVisit = [this.root_];
while (nodesToVisit.length > 0) { while (nodesToVisit.length > 0) {
var node = nodesToVisit.shift(); const node = nodesToVisit.shift();
if (node == null) { if (node == null) {
continue; continue;
} }
......
...@@ -55,16 +55,15 @@ DOM.defineCustomElement( ...@@ -55,16 +55,15 @@ DOM.defineCustomElement(
} }
updateCount() { updateCount() {
this.count.innerHTML = 'length=' + this._selectedLogEntries.length; this.count.innerHTML = `length=${this._selectedLogEntries.length}`;
} }
updateTable(event) { updateTable(event) {
let select = this.groupKey; let select = this.groupKey;
let key = select.options[select.selectedIndex].text; let key = select.options[select.selectedIndex].text;
let tableBody = this.tableBody; DOM.removeAllChildren(this.tableBody);
DOM.removeAllChildren(tableBody);
let groups = Group.groupBy(this._selectedLogEntries, key, true); let groups = Group.groupBy(this._selectedLogEntries, key, true);
this.render(groups, tableBody); this.render(groups, this.tableBody);
} }
escapeHtml(unsafe) { escapeHtml(unsafe) {
...@@ -89,8 +88,7 @@ DOM.defineCustomElement( ...@@ -89,8 +88,7 @@ DOM.defineCustomElement(
// searches for mapLogEntries using the id, time // searches for mapLogEntries using the id, time
const selectedMapLogEntriesSet = new Set(); const selectedMapLogEntriesSet = new Set();
for (const icLogEntry of icLogEntries) { for (const icLogEntry of icLogEntries) {
const time = icLogEntry.time; const selectedMap = MapLogEntry.get(id, icLogEntry.time);
const selectedMap = MapLogEntry.get(id, time);
selectedMapLogEntriesSet.add(selectedMap); selectedMapLogEntriesSet.add(selectedMap);
} }
return Array.from(selectedMapLogEntriesSet); return Array.from(selectedMapLogEntriesSet);
...@@ -131,8 +129,7 @@ DOM.defineCustomElement( ...@@ -131,8 +129,7 @@ DOM.defineCustomElement(
const omitted = groups.length - max; const omitted = groups.length - max;
if (omitted > 0) { if (omitted > 0) {
const tr = DOM.tr(); const tr = DOM.tr();
const tdNode = const tdNode = tr.appendChild(DOM.td(`Omitted ${omitted} entries.`));
tr.appendChild(DOM.td('Omitted ' + omitted + ' entries.'));
tdNode.colSpan = 4; tdNode.colSpan = 4;
fragment.appendChild(tr); fragment.appendChild(tr);
} }
......
...@@ -38,7 +38,7 @@ DOM.defineCustomElement('log-file-reader', ...@@ -38,7 +38,7 @@ DOM.defineCustomElement('log-file-reader',
event.preventDefault(); event.preventDefault();
this.dispatchEvent( this.dispatchEvent(
new CustomEvent('fileuploadstart', {bubbles: true, composed: true})); 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]); this.readFile(host.files[0]);
} }
...@@ -73,7 +73,7 @@ DOM.defineCustomElement('log-file-reader', ...@@ -73,7 +73,7 @@ DOM.defineCustomElement('log-file-reader',
handleFileLoad(e, file) { handleFileLoad(e, file) {
const chunk = e.target.result; const chunk = e.target.result;
this.updateLabel('Finished loading \'' + file.name + '\'.'); this.updateLabel(`Finished loading '${file.name}'.`);
this.dispatchEvent(new CustomEvent('fileuploadend', { this.dispatchEvent(new CustomEvent('fileuploadend', {
bubbles: true, bubbles: true,
composed: true, composed: true,
......
...@@ -184,9 +184,9 @@ class Edge { ...@@ -184,9 +184,9 @@ class Edge {
} }
finishSetup() { finishSetup() {
let from = this.from; const from = this.from;
if (from) from.addEdge(this); if (from) from.addEdge(this);
let to = this.to; const to = this.to;
if (to === undefined) return; if (to === undefined) return;
to.edge = this; to.edge = this;
if (from === undefined) return; if (from === undefined) return;
......
...@@ -29,9 +29,9 @@ DOM.defineCustomElement( ...@@ -29,9 +29,9 @@ DOM.defineCustomElement(
let details = ''; let details = '';
let clickableDetails = ''; let clickableDetails = '';
if (map) { if (map) {
clickableDetails += 'ID: ' + map.id; clickableDetails += `ID: ${map.id}`;
clickableDetails += '\nSource location: ' + map.filePosition; clickableDetails += `\nSource location: ${map.filePosition}`;
details += '\n' + map.description; details += `\n${map.description}`;
this.setSelectedMap(map); this.setSelectedMap(map);
} }
this._filePositionNode.innerText = clickableDetails; this._filePositionNode.innerText = clickableDetails;
......
...@@ -39,7 +39,7 @@ DOM.defineCustomElement('./map-panel/map-transitions', ...@@ -39,7 +39,7 @@ DOM.defineCustomElement('./map-panel/map-transitions',
handleTransitionViewChange(e) { handleTransitionViewChange(e) {
this.tooltip.style.left = e.pageX + 'px'; this.tooltip.style.left = e.pageX + 'px';
this.tooltip.style.top = e.pageY + 'px'; this.tooltip.style.top = e.pageY + 'px';
let map = e.target.map; const map = e.target.map;
if (map) { if (map) {
this.tooltipContents.innerText = map.description; this.tooltipContents.innerText = map.description;
} }
......
...@@ -125,7 +125,7 @@ export class Processor extends LogReader { ...@@ -125,7 +125,7 @@ export class Processor extends LogReader {
this.processLogLine(line); this.processLogLine(line);
} }
} catch (e) { } catch (e) {
console.error('Error occurred during parsing, trying to continue: ' + e); console.error(`Error occurred during parsing, trying to continue: ${e}`);
} }
this.finalize(); this.finalize();
} }
...@@ -142,7 +142,7 @@ export class Processor extends LogReader { ...@@ -142,7 +142,7 @@ export class Processor extends LogReader {
} }
} catch (e) { } catch (e) {
console.error( console.error(
'Error occurred during parsing line ' + i + `Error occurred during parsing line ${i}` +
', trying to continue: ' + e); ', trying to continue: ' + e);
} }
this.finalize(); this.finalize();
...@@ -155,8 +155,8 @@ export class Processor extends LogReader { ...@@ -155,8 +155,8 @@ export class Processor extends LogReader {
this._mapTimeline.forEach(map => { this._mapTimeline.forEach(map => {
if (map.isRoot()) id = map.finalizeRootMap(id + 1); if (map.isRoot()) id = map.finalizeRootMap(id + 1);
if (map.edge && map.edge.name) { if (map.edge && map.edge.name) {
let edge = map.edge; const edge = map.edge;
let list = this._mapTimeline.transitions.get(edge.name); const list = this._mapTimeline.transitions.get(edge.name);
if (list === undefined) { if (list === undefined) {
this._mapTimeline.transitions.set(edge.name, [edge]); this._mapTimeline.transitions.set(edge.name, [edge]);
} else { } else {
...@@ -178,13 +178,13 @@ export class Processor extends LogReader { ...@@ -178,13 +178,13 @@ export class Processor extends LogReader {
case '*': case '*':
return Profile.CodeState.OPTIMIZED; 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) { processCodeCreation(type, kind, timestamp, start, size, name, maybe_func) {
if (maybe_func.length) { if (maybe_func.length) {
let funcAddr = parseInt(maybe_func[0]); const funcAddr = parseInt(maybe_func[0]);
let state = this.parseState(maybe_func[1]); const state = this.parseState(maybe_func[1]);
this._profile.addFuncCode( this._profile.addFuncCode(
type, name, timestamp, start, size, funcAddr, state); type, name, timestamp, start, size, funcAddr, state);
} else { } else {
...@@ -324,7 +324,7 @@ export class Processor extends LogReader { ...@@ -324,7 +324,7 @@ export class Processor extends LogReader {
if (id === '0x000000000000') return undefined; if (id === '0x000000000000') return undefined;
let map = MapLogEntry.get(id, time); let map = MapLogEntry.get(id, time);
if (map === undefined) { 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. // Manually patch in a map to continue running.
return this.createMapEntry(id, time); return this.createMapEntry(id, time);
}; };
......
...@@ -188,12 +188,11 @@ class LineBuilder { ...@@ -188,12 +188,11 @@ class LineBuilder {
this._selection = new Set(highlightPositions); this._selection = new Set(highlightPositions);
this._clickHandler = panel.handleSourcePositionClick.bind(panel); this._clickHandler = panel.handleSourcePositionClick.bind(panel);
// TODO: sort on script finalization. // TODO: sort on script finalization.
script.sourcePositions script.sourcePositions.sort((a, b) => {
.sort((a, b) => { if (a.line === b.line) return a.column - b.column;
if (a.line === b.line) return a.column - b.column; return a.line - b.line;
return a.line - b.line; });
}) this._sourcePositions = this._sourcePositions = new SourcePositionIterator(script.sourcePositions);
new SourcePositionIterator(script.sourcePositions);
} }
get sourcePositionToMarkers() { get sourcePositionToMarkers() {
......
...@@ -220,7 +220,6 @@ DOM.defineCustomElement('./timeline/timeline-track', ...@@ -220,7 +220,6 @@ DOM.defineCustomElement('./timeline/timeline-track',
} }
renderLegend() { renderLegend() {
let timelineLegend = this.timelineLegend;
let timelineLegendContent = this.timelineLegendContent; let timelineLegendContent = this.timelineLegendContent;
DOM.removeAllChildren(timelineLegendContent); DOM.removeAllChildren(timelineLegendContent);
this._timeline.uniqueTypes.forEach((entries, type) => { this._timeline.uniqueTypes.forEach((entries, type) => {
...@@ -249,7 +248,7 @@ DOM.defineCustomElement('./timeline/timeline-track', ...@@ -249,7 +248,7 @@ DOM.defineCustomElement('./timeline/timeline-track',
row.appendChild(DOM.td(this.data.all.length)); row.appendChild(DOM.td(this.data.all.length));
row.appendChild(DOM.td('100%')); row.appendChild(DOM.td('100%'));
timelineLegendContent.appendChild(row); timelineLegendContent.appendChild(row);
timelineLegend.appendChild(timelineLegendContent); this.timelineLegend.appendChild(timelineLegendContent);
} }
handleEntryTypeDblClick(e) { handleEntryTypeDblClick(e) {
...@@ -306,7 +305,7 @@ DOM.defineCustomElement('./timeline/timeline-track', ...@@ -306,7 +305,7 @@ DOM.defineCustomElement('./timeline/timeline-track',
} }
let imageData = this.backgroundCanvas.toDataURL('image/webp', 0.2); let imageData = this.backgroundCanvas.toDataURL('image/webp', 0.2);
node.style.backgroundImage = 'url(' + imageData + ')'; node.style.backgroundImage = `url(${imageData})`;
} }
updateTimeline() { updateTimeline() {
......
...@@ -34,7 +34,7 @@ import { ...@@ -34,7 +34,7 @@ import {
// Tick Processor's code flow. // Tick Processor's code flow.
function processArguments(args) { function processArguments(args) {
var processor = new ArgumentsProcessor(args); const processor = new ArgumentsProcessor(args);
if (processor.parse()) { if (processor.parse()) {
return processor.result(); return processor.result();
} else { } else {
...@@ -48,25 +48,25 @@ function initSourceMapSupport() { ...@@ -48,25 +48,25 @@ function initSourceMapSupport() {
// Overwrite the load function to load scripts synchronously. // Overwrite the load function to load scripts synchronously.
SourceMap.load = function(sourceMapURL) { SourceMap.load = function(sourceMapURL) {
var content = readFile(sourceMapURL); const content = readFile(sourceMapURL);
var sourceMapObject = (JSON.parse(content)); const sourceMapObject = (JSON.parse(content));
return new SourceMap(sourceMapURL, sourceMapObject); return new SourceMap(sourceMapURL, sourceMapObject);
}; };
} }
var entriesProviders = { const entriesProviders = {
'unix': UnixCppEntriesProvider, 'unix': UnixCppEntriesProvider,
'windows': WindowsCppEntriesProvider, 'windows': WindowsCppEntriesProvider,
'mac': MacCppEntriesProvider 'mac': MacCppEntriesProvider
}; };
var params = processArguments(arguments); const params = processArguments(arguments);
var sourceMap = null; let sourceMap = null;
if (params.sourceMap) { if (params.sourceMap) {
initSourceMapSupport(); initSourceMapSupport();
sourceMap = SourceMap.load(params.sourceMap); sourceMap = SourceMap.load(params.sourceMap);
} }
var tickProcessor = new TickProcessor( const tickProcessor = new TickProcessor(
new (entriesProviders[params.platform])(params.nm, params.objdump, params.targetRootFS, new (entriesProviders[params.platform])(params.nm, params.objdump, params.targetRootFS,
params.apkEmbeddedLibrary), params.apkEmbeddedLibrary),
params.separateIc, params.separateIc,
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment