Commit 91ace57f authored by Sathya Gunasekaran's avatar Sathya Gunasekaran Committed by Commit Bot

Reland "[presubmit] Add JS formatting for tools/system-analyzer"

This is a reland of 1ec8f1da

Original change's description:
> [presubmit] Add JS formatting for tools/system-analyzer
>
> Bug: v8:10670
> Change-Id: Ifb653ada003719faff261b6e5b2169db37cffdaf
> Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2282522
> Reviewed-by: Tamer Tas <tmrts@chromium.org>
> Commit-Queue: Sathya Gunasekaran  <gsathya@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#68909}

Bug: v8:10670
Change-Id: I4903b3eb8ff39a76594324076f0840b06290044e
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2307229
Commit-Queue: Sathya Gunasekaran  <gsathya@chromium.org>
Reviewed-by: 's avatarTamer Tas <tmrts@chromium.org>
Reviewed-by: 's avatarCamillo Bruni <cbruni@chromium.org>
Cr-Commit-Position: refs/heads/master@{#70938}
parent efff3d18
......@@ -29,6 +29,7 @@
.cproject
.gclient_entries
.gdb_history
.jslint-cache
.landmines
.project
.pydevproject
......
......@@ -80,6 +80,7 @@ def _V8PresubmitChecks(input_api, output_api):
sys.path.append(input_api.os_path.join(
input_api.PresubmitLocalPath(), 'tools'))
from v8_presubmit import CppLintProcessor
from v8_presubmit import JSLintProcessor
from v8_presubmit import TorqueLintProcessor
from v8_presubmit import SourceProcessor
from v8_presubmit import StatusFilesProcessor
......@@ -95,6 +96,11 @@ def _V8PresubmitChecks(input_api, output_api):
affected_file,
files_to_check=(r'.+\.tq'))
def FilterJSFile(affected_file):
return input_api.FilterSourceFile(
affected_file,
white_list=(r'.+\.m?js'))
results = []
if not CppLintProcessor().RunOnFiles(
input_api.AffectedFiles(file_filter=FilterFile, include_deletes=False)):
......@@ -103,6 +109,10 @@ def _V8PresubmitChecks(input_api, output_api):
input_api.AffectedFiles(file_filter=FilterTorqueFile,
include_deletes=False)):
results.append(output_api.PresubmitError("Torque format check failed"))
if not JSLintProcessor().RunOnFiles(
input_api.AffectedFiles(file_filter=FilterJSFile,
include_deletes=False)):
results.append(output_api.PresubmitError("JS format check failed"))
if not SourceProcessor().RunOnFiles(
input_api.AffectedFiles(include_deletes=False)):
results.append(output_api.PresubmitError(
......
......@@ -3,7 +3,7 @@
// found in the LICENSE file.
class State {
_timeSelection = { start: 0, end: Infinity };
_timeSelection = {start: 0, end: Infinity};
_map;
_ic;
_selectedMapLogEntries;
......@@ -60,11 +60,11 @@ class State {
this._deoptTimeline = timeline;
}
set chunks(value) {
//TODO(zcankara) split up between maps and ics, and every timeline track
// TODO(zcankara) split up between maps and ics, and every timeline track
this._chunks = value;
}
get chunks() {
//TODO(zcankara) split up between maps and ics, and every timeline track
// TODO(zcankara) split up between maps and ics, and every timeline track
return this._chunks;
}
get nofChunks() {
......@@ -74,20 +74,20 @@ class State {
this._nofChunks = count;
}
get map() {
//TODO(zcankara) rename as selectedMapEvents, array of selected events
// TODO(zcankara) rename as selectedMapEvents, array of selected events
return this._map;
}
set map(value) {
//TODO(zcankara) rename as selectedMapEvents, array of selected events
// TODO(zcankara) rename as selectedMapEvents, array of selected events
if (!value) return;
this._map = value;
}
get ic() {
//TODO(zcankara) rename selectedICEvents, array of selected events
// TODO(zcankara) rename selectedICEvents, array of selected events
return this._ic;
}
set ic(value) {
//TODO(zcankara) rename selectedIcEvents, array of selected events
// TODO(zcankara) rename selectedIcEvents, array of selected events
if (!value) return;
this._ic = value;
}
......@@ -122,4 +122,4 @@ class State {
}
}
export { State };
export {State};
......@@ -4,44 +4,48 @@
class SelectionEvent extends CustomEvent {
// TODO: turn into static class fields once Safari supports it.
static get name() { return "showentries"; }
static get name() {
return 'showentries';
}
constructor(entries) {
super(SelectionEvent.name, { bubbles: true, composed: true });
super(SelectionEvent.name, {bubbles: true, composed: true});
if (!Array.isArray(entries) || entries.length == 0) {
throw new Error("No valid entries selected!");
throw new Error('No valid entries selected!');
}
this.entries = entries;
}
}
class FocusEvent extends CustomEvent {
static get name() { return "showentrydetail"; }
static get name() {
return 'showentrydetail';
}
constructor(entry) {
super(FocusEvent.name, { bubbles: true, composed: true });
super(FocusEvent.name, {bubbles: true, composed: true});
this.entry = entry;
}
}
class SelectTimeEvent extends CustomEvent {
static get name() { return 'timerangeselect'; }
static get name() {
return 'timerangeselect';
}
constructor(start, end) {
super(SelectTimeEvent.name, { bubbles: true, composed: true });
super(SelectTimeEvent.name, {bubbles: true, composed: true});
this.start = start;
this.end = end;
}
}
class SynchronizeSelectionEvent extends CustomEvent {
static get name() { return 'syncselection'; }
static get name() {
return 'syncselection';
}
constructor(start, end) {
super(SynchronizeSelectionEvent.name, { bubbles: true, composed: true });
super(SynchronizeSelectionEvent.name, {bubbles: true, composed: true});
this.start = start;
this.end = end;
}
}
export {
SelectionEvent, FocusEvent, SelectTimeEvent,
SynchronizeSelectionEvent
};
export {SelectionEvent, FocusEvent, SelectTimeEvent, SynchronizeSelectionEvent};
......@@ -144,7 +144,7 @@ class DOM {
if (className) node.classList.add(className);
return node;
}
static tr(className) {
const node = document.createElement('tr');
if (className) node.classList.add(className);
......@@ -162,12 +162,13 @@ class DOM {
}
static defineCustomElement(path, generator) {
let name = path.substring(path.lastIndexOf("/") + 1, path.length);
let name = path.substring(path.lastIndexOf('/') + 1, path.length);
path = path + '-template.html';
fetch(path)
.then(stream => stream.text())
.then(
templateText => customElements.define(name, generator(templateText)));
.then(stream => stream.text())
.then(
templateText =>
customElements.define(name, generator(templateText)));
}
}
......@@ -178,7 +179,7 @@ function $(id) {
class V8CustomElement extends HTMLElement {
constructor(templateText) {
super();
const shadowRoot = this.attachShadow({ mode: 'open' });
const shadowRoot = this.attachShadow({mode: 'open'});
shadowRoot.innerHTML = templateText;
}
$(id) {
......@@ -190,7 +191,6 @@ class V8CustomElement extends HTMLElement {
}
}
class LazyTable {
constructor(table, rowData, rowElementCreator) {
this._table = table;
......@@ -198,7 +198,7 @@ class LazyTable {
this._rowElementCreator = rowElementCreator;
const tbody = table.querySelector('tbody');
table.replaceChild(document.createElement('tbody'), tbody);
table.querySelector("tfoot td").onclick = (e) => this._addMoreRows();
table.querySelector('tfoot td').onclick = (e) => this._addMoreRows();
this._addMoreRows();
}
......@@ -216,7 +216,6 @@ class LazyTable {
}
}
class LazyTable {
constructor(table, rowData, rowElementCreator) {
this._table = table;
......@@ -224,7 +223,7 @@ class LazyTable {
this._rowElementCreator = rowElementCreator;
const tbody = table.querySelector('tbody');
table.replaceChild(document.createElement('tbody'), tbody);
table.querySelector("tfoot td").onclick = (e) => this._addMoreRows();
table.querySelector('tfoot td').onclick = (e) => this._addMoreRows();
this._addMoreRows();
}
......@@ -247,6 +246,12 @@ function delay(time) {
}
export {
DOM, $, V8CustomElement, formatBytes,
typeToColor, CSSColor, delay, LazyTable,
DOM,
$,
V8CustomElement,
formatBytes,
typeToColor,
CSSColor,
delay,
LazyTable,
};
......@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import { IcLogEntry } from "./log/ic.mjs";
import {IcLogEntry} from './log/ic.mjs';
// For compatibility with console scripts:
print = console.log;
......@@ -51,8 +51,7 @@ export class Group {
group.percentage = Math.round(group.count / length * 100 * 100) / 100;
result.push(group);
}
result.sort((a, b) => { return b.count - a.count });
result.sort((a, b) => {return b.count - a.count});
return result;
}
}
This diff is collapsed.
......@@ -2,22 +2,23 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import { SelectionEvent, FocusEvent, SelectTimeEvent } from "./events.mjs";
import { State } from "./app-model.mjs";
import { MapLogEntry } from "./log/map.mjs";
import { IcLogEntry } from "./log/ic.mjs";
import { Processor } from "./processor.mjs";
import { SourcePosition } from "../profile.mjs";
import { $ } from "./helper.mjs";
import {SourcePosition} from '../profile.mjs';
import {State} from './app-model.mjs';
import {FocusEvent, SelectionEvent, SelectTimeEvent} from './events.mjs';
import {$} from './helper.mjs';
import {IcLogEntry} from './log/ic.mjs';
import {MapLogEntry} from './log/map.mjs';
import {Processor} from './processor.mjs';
class App {
_state;
_view;
_navigation;
_startupPromise;
constructor(fileReaderId, mapPanelId, mapStatsPanelId, timelinePanelId,
icPanelId, mapTrackId, icTrackId, deoptTrackId, sourcePanelId) {
constructor(
fileReaderId, mapPanelId, mapStatsPanelId, timelinePanelId, icPanelId,
mapTrackId, icTrackId, deoptTrackId, sourcePanelId) {
this._view = {
__proto__: null,
logFileReader: $(fileReaderId),
......@@ -31,32 +32,30 @@ class App {
sourcePanel: $(sourcePanelId)
};
this.toggleSwitch = $('.theme-switch input[type="checkbox"]');
this.toggleSwitch.addEventListener("change", (e) => this.switchTheme(e));
this._view.logFileReader.addEventListener("fileuploadstart", (e) =>
this.handleFileUploadStart(e)
);
this._view.logFileReader.addEventListener("fileuploadend", (e) =>
this.handleFileUploadEnd(e)
);
this.toggleSwitch.addEventListener('change', (e) => this.switchTheme(e));
this._view.logFileReader.addEventListener(
'fileuploadstart', (e) => this.handleFileUploadStart(e));
this._view.logFileReader.addEventListener(
'fileuploadend', (e) => this.handleFileUploadEnd(e));
this._startupPromise = this.runAsyncInitialize();
}
async runAsyncInitialize() {
await Promise.all([
import("./ic-panel.mjs"),
import("./timeline-panel.mjs"),
import("./stats-panel.mjs"),
import("./map-panel.mjs"),
import("./source-panel.mjs"),
]);
document.addEventListener('keydown',
e => this._navigation?.handleKeyDown(e));
document.addEventListener(SelectionEvent.name,
e => this.handleShowEntries(e));
document.addEventListener(FocusEvent.name,
e => this.handleShowEntryDetail(e));
document.addEventListener(SelectTimeEvent.name,
e => this.handleTimeRangeSelect(e));
import('./ic-panel.mjs'),
import('./timeline-panel.mjs'),
import('./stats-panel.mjs'),
import('./map-panel.mjs'),
import('./source-panel.mjs'),
]);
document.addEventListener(
'keydown', e => this._navigation?.handleKeyDown(e));
document.addEventListener(
SelectionEvent.name, e => this.handleShowEntries(e));
document.addEventListener(
FocusEvent.name, e => this.handleShowEntryDetail(e));
document.addEventListener(
SelectTimeEvent.name, e => this.handleTimeRangeSelect(e));
}
handleShowEntries(e) {
......@@ -67,7 +66,7 @@ class App {
} else if (e.entries[0] instanceof SourcePosition) {
this.showSourcePositionEntries(e.entries);
} else {
throw new Error("Unknown selection type!");
throw new Error('Unknown selection type!');
}
e.stopPropagation();
}
......@@ -84,7 +83,7 @@ class App {
this._state.selectedDeoptLogEntries = entries;
}
showSourcePositionEntries(entries) {
//TODO: Handle multiple source position selection events
// TODO: Handle multiple source position selection events
this._view.sourcePanel.selectedSourcePositions = entries
}
......@@ -98,7 +97,7 @@ class App {
this.showMapEntries(this._state.mapTimeline.selection);
this.showIcEntries(this._state.icTimeline.selection);
this.showDeoptEntries(this._state.deoptTimeline.selection);
this._view.timelinePanel.timeSelection = {start,end};
this._view.timelinePanel.timeSelection = {start, end};
}
handleShowEntryDetail(e) {
......@@ -109,7 +108,7 @@ class App {
} else if (e.entry instanceof SourcePosition) {
this.selectSourcePosition(e.entry);
} else {
throw new Error("Unknown selection type!");
throw new Error('Unknown selection type!');
}
e.stopPropagation();
}
......@@ -129,7 +128,7 @@ class App {
handleFileUploadStart(e) {
this.restartApp();
$("#container").className = "initial";
$('#container').className = 'initial';
}
restartApp() {
......@@ -150,17 +149,18 @@ class App {
// Transitions must be set before timeline for stats panel.
this._view.mapPanel.timeline = mapTimeline;
this._view.mapTrack.data = mapTimeline;
this._view.mapStatsPanel.transitions = this._state.mapTimeline.transitions;
this._view.mapStatsPanel.transitions =
this._state.mapTimeline.transitions;
this._view.mapStatsPanel.timeline = mapTimeline;
this._view.icPanel.timeline = icTimeline;
this._view.icTrack.data = icTimeline;
this._view.deoptTrack.data = deoptTimeline;
this._view.sourcePanel.data = processor.scripts
} catch(e) {
this._view.logFileReader.error = "Log file contains errors!"
throw(e);
} catch (e) {
this._view.logFileReader.error = 'Log file contains errors!'
throw (e);
} finally {
$("#container").className = "loaded";
$('#container').className = 'loaded';
this.fileLoaded = true;
}
}
......@@ -172,9 +172,8 @@ class App {
}
switchTheme(event) {
document.documentElement.dataset.theme = event.target.checked
? "light"
: "dark";
document.documentElement.dataset.theme =
event.target.checked ? 'light' : 'dark';
if (this.fileLoaded) {
this.refreshTimelineTrackView();
}
......@@ -268,7 +267,7 @@ class Navigation {
}
handleKeyDown(event) {
switch (event.key) {
case "ArrowUp":
case 'ArrowUp':
event.preventDefault();
if (event.shiftKey) {
this.selectPrevEdge();
......@@ -276,7 +275,7 @@ class Navigation {
this.moveInChunk(-1);
}
return false;
case "ArrowDown":
case 'ArrowDown':
event.preventDefault();
if (event.shiftKey) {
this.selectNextEdge();
......@@ -284,20 +283,20 @@ class Navigation {
this.moveInChunk(1);
}
return false;
case "ArrowLeft":
case 'ArrowLeft':
this.moveInChunks(false);
break;
case "ArrowRight":
case 'ArrowRight':
this.moveInChunks(true);
break;
case "+":
case '+':
this.increaseTimelineResolution();
break;
case "-":
case '-':
this.decreaseTimelineResolution();
break;
}
}
}
export { App };
export {App};
// Copyright 2020 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.
import { DOM, V8CustomElement } from './helper.mjs';
import {DOM, V8CustomElement} from './helper.mjs';
DOM.defineCustomElement('log-file-reader', (templateText) =>
class LogFileReader extends V8CustomElement {
constructor() {
super(templateText);
this.addEventListener('click', e => this.handleClick(e));
this.addEventListener('dragover', e => this.handleDragOver(e));
this.addEventListener('drop', e => this.handleChange(e));
this.$('#file').addEventListener('change', e => this.handleChange(e));
this.$('#fileReader').addEventListener('keydown',
e => this.handleKeyEvent(e));
}
DOM.defineCustomElement('log-file-reader',
(templateText) =>
class LogFileReader extends V8CustomElement {
constructor() {
super(templateText);
this.addEventListener('click', e => this.handleClick(e));
this.addEventListener('dragover', e => this.handleDragOver(e));
this.addEventListener('drop', e => this.handleChange(e));
this.$('#file').addEventListener('change', e => this.handleChange(e));
this.$('#fileReader')
.addEventListener('keydown', e => this.handleKeyEvent(e));
}
set error(message) {
this.updateLabel(message);
this.root.className = 'fail';
}
set error(message) {
this.updateLabel(message);
this.root.className = 'fail';
}
updateLabel(text) {
this.$('#label').innerText = text;
}
updateLabel(text) {
this.$('#label').innerText = text;
}
handleKeyEvent(event) {
if (event.key == "Enter") this.handleClick(event);
}
handleKeyEvent(event) {
if (event.key == 'Enter') this.handleClick(event);
}
handleClick(event) {
this.$('#file').click();
}
handleClick(event) {
this.$('#file').click();
}
handleChange(event) {
// Used for drop and file change.
event.preventDefault();
this.dispatchEvent(new CustomEvent(
'fileuploadstart', { bubbles: true, composed: true }));
var host = event.dataTransfer ? event.dataTransfer : event.target;
this.readFile(host.files[0]);
}
handleChange(event) {
// Used for drop and file change.
event.preventDefault();
this.dispatchEvent(
new CustomEvent('fileuploadstart', {bubbles: true, composed: true}));
var host = event.dataTransfer ? event.dataTransfer : event.target;
this.readFile(host.files[0]);
}
handleDragOver(event) {
event.preventDefault();
}
handleDragOver(event) {
event.preventDefault();
}
connectedCallback() {
this.fileReader.focus();
}
connectedCallback() {
this.fileReader.focus();
}
get fileReader() {
return this.$('#fileReader');
}
get fileReader() {
return this.$('#fileReader');
}
get root() { return this.$("#root"); }
get root() {
return this.$('#root');
}
readFile(file) {
if (!file) {
this.error = 'Failed to load file.';
return;
}
this.fileReader.blur();
this.root.className = 'loading';
const reader = new FileReader();
reader.onload = (e) => this.handleFileLoad(e, file);
// Delay the loading a bit to allow for CSS animations to happen.
setTimeout(() => reader.readAsText(file), 0);
readFile(file) {
if (!file) {
this.error = 'Failed to load file.';
return;
}
this.fileReader.blur();
this.root.className = 'loading';
const reader = new FileReader();
reader.onload = (e) => this.handleFileLoad(e, file);
// Delay the loading a bit to allow for CSS animations to happen.
setTimeout(() => reader.readAsText(file), 0);
}
handleFileLoad(e, file) {
const chunk = e.target.result;
this.updateLabel('Finished loading \'' + file.name + '\'.');
this.dispatchEvent(new CustomEvent(
'fileuploadend', {
bubbles: true,
composed: true,
detail: chunk,
}));
this.root.className = 'done';
}
});
handleFileLoad(e, file) {
const chunk = e.target.result;
this.updateLabel('Finished loading \'' + file.name + '\'.');
this.dispatchEvent(new CustomEvent('fileuploadend', {
bubbles: true,
composed: true,
detail: chunk,
}));
this.root.className = 'done';
}
});
// Copyright 2020 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.
import { LogEntry } from './log.mjs';
import {LogEntry} from './log.mjs';
export class DeoptLogEntry extends LogEntry {
constructor(type, time) {
......
// Copyright 2020 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.
import { LogEntry } from './log.mjs';
import {LogEntry} from './log.mjs';
export class IcLogEntry extends LogEntry {
constructor(
type, fn_file, time, line, column, key, oldState, newState, map, reason,
script, modifier, additional) {
type, fn_file, time, line, column, key, oldState, newState, map, reason,
script, modifier, additional) {
super(type, time);
this.category = 'other';
if (this.type.indexOf('Store') !== -1) {
......@@ -55,18 +55,11 @@ export class IcLogEntry extends LogEntry {
this.file = parts[offset];
return offset;
}
static get propertyNames() {
return [
'type',
'category',
'functionName',
'filePosition',
'state',
'key',
'map',
'reason',
'file'
'type', 'category', 'functionName', 'filePosition', 'state', 'key', 'map',
'reason', 'file'
];
}
}
......@@ -6,7 +6,7 @@ export class LogEntry {
_time;
_type;
constructor(type, time) {
//TODO(zcankara) remove type and add empty getters to override
// TODO(zcankara) remove type and add empty getters to override
this._time = time;
this._type = type;
}
......@@ -18,6 +18,6 @@ export class LogEntry {
}
// Returns an Array of all possible #type values.
static get allTypes() {
throw new Error("Not implemented.");
throw new Error('Not implemented.');
}
}
\ No newline at end of file
......@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import { LogEntry } from './log.mjs';
import {LogEntry} from './log.mjs';
// ===========================================================================
// Map Log Events
......@@ -11,10 +11,10 @@ const kChunkHeight = 200;
const kChunkWidth = 10;
function define(prototype, name, fn) {
Object.defineProperty(prototype, name, { value: fn, enumerable: false });
Object.defineProperty(prototype, name, {value: fn, enumerable: false});
}
define(Array.prototype, 'max', function (fn) {
define(Array.prototype, 'max', function(fn) {
if (this.length === 0) return undefined;
if (fn === undefined) fn = (each) => each;
let max = fn(this[0]);
......@@ -23,10 +23,10 @@ define(Array.prototype, 'max', function (fn) {
}
return max;
})
define(Array.prototype, 'first', function () {
define(Array.prototype, 'first', function() {
return this[0]
});
define(Array.prototype, 'last', function () {
define(Array.prototype, 'last', function() {
return this[this.length - 1]
});
......@@ -282,9 +282,8 @@ class Edge {
return this.type + ' ' + this.symbol() + this.name;
}
return this.type + ' ' + (this.reason ? this.reason : '') + ' ' +
(this.name ? this.name : '')
(this.name ? this.name : '')
}
}
export { MapLogEntry, Edge, kChunkWidth, kChunkHeight };
export {MapLogEntry, Edge, kChunkWidth, kChunkHeight};
// Copyright 2020 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.
import "./stats-panel.mjs";
import "./map-panel/map-details.mjs";
import "./map-panel/map-transitions.mjs";
import { FocusEvent } from './events.mjs';
import { MapLogEntry } from "./log/map.mjs";
import { DOM, V8CustomElement } from './helper.mjs';
import './stats-panel.mjs';
import './map-panel/map-details.mjs';
import './map-panel/map-transitions.mjs';
DOM.defineCustomElement('map-panel', (templateText) =>
class MapPanel extends V8CustomElement {
_map;
constructor() {
super(templateText);
this.searchBarBtn.addEventListener(
'click', e => this.handleSearchBar(e));
this.addEventListener(
FocusEvent.name, e => this.handleUpdateMapDetails(e));
}
import {FocusEvent} from './events.mjs';
import {DOM, V8CustomElement} from './helper.mjs';
import {MapLogEntry} from './log/map.mjs';
handleUpdateMapDetails(e) {
if (e.entry instanceof MapLogEntry) {
this.mapDetailsPanel.mapDetails = e.entry;
}
}
DOM.defineCustomElement('map-panel',
(templateText) =>
class MapPanel extends V8CustomElement {
_map;
constructor() {
super(templateText);
this.searchBarBtn.addEventListener('click', e => this.handleSearchBar(e));
this.addEventListener(FocusEvent.name, e => this.handleUpdateMapDetails(e));
}
get mapTransitionsPanel() {
return this.$('#map-transitions');
handleUpdateMapDetails(e) {
if (e.entry instanceof MapLogEntry) {
this.mapDetailsPanel.mapDetails = e.entry;
}
}
get mapDetailsPanel() {
return this.$('#map-details');
}
get mapTransitionsPanel() {
return this.$('#map-transitions');
}
get searchBarBtn() {
return this.$('#searchBarBtn');
}
get mapDetailsPanel() {
return this.$('#map-details');
}
get searchBar() {
return this.$('#searchBar');
}
get searchBarBtn() {
return this.$('#searchBarBtn');
}
get mapDetails() {
return this.mapDetailsPanel.mapDetails;
}
get searchBar() {
return this.$('#searchBar');
}
set timeline(timeline) {
this._timeline = timeline;
}
get mapDetails() {
return this.mapDetailsPanel.mapDetails;
}
set map(value) {
this._map = value;
this.mapTransitionsPanel.map = this._map;
}
set timeline(timeline) {
this._timeline = timeline;
}
handleSearchBar(e) {
let searchBar = this.$('#searchBarInput');
let searchBarInput = searchBar.value;
//access the map from model cache
let selectedMap = MapLogEntry.get(parseInt(searchBarInput));
if (selectedMap) {
searchBar.className = "success";
} else {
searchBar.className = "failure";
}
this.dispatchEvent(new FocusEvent(selectedMap));
}
set map(value) {
this._map = value;
this.mapTransitionsPanel.map = this._map;
}
set selectedMapLogEntries(list) {
this.mapTransitionsPanel.selectedMapLogEntries = list;
}
get selectedMapLogEntries() {
return this.mapTransitionsPanel.selectedMapLogEntries;
handleSearchBar(e) {
let searchBar = this.$('#searchBarInput');
let searchBarInput = searchBar.value;
// access the map from model cache
let selectedMap = MapLogEntry.get(parseInt(searchBarInput));
if (selectedMap) {
searchBar.className = 'success';
} else {
searchBar.className = 'failure';
}
this.dispatchEvent(new FocusEvent(selectedMap));
}
});
set selectedMapLogEntries(list) {
this.mapTransitionsPanel.selectedMapLogEntries = list;
}
get selectedMapLogEntries() {
return this.mapTransitionsPanel.selectedMapLogEntries;
}
});
// Copyright 2020 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.
import { V8CustomElement, DOM} from "../helper.mjs";
import { FocusEvent } from "../events.mjs";
import {FocusEvent} from '../events.mjs';
import {DOM, V8CustomElement} from '../helper.mjs';
DOM.defineCustomElement(
"./map-panel/map-details",
(templateText) =>
class MapDetails extends V8CustomElement {
'./map-panel/map-details',
(templateText) => class MapDetails extends V8CustomElement {
constructor() {
super(templateText);
this._filePositionNode.addEventListener("click", e =>
this.handleFilePositionClick(e)
);
this._filePositionNode.addEventListener(
'click', e => this.handleFilePositionClick(e));
this.selectedMap = undefined;
}
get mapDetails() {
return this.$("#mapDetails");
return this.$('#mapDetails');
}
get _filePositionNode() {
return this.$("#filePositionNode");
return this.$('#filePositionNode');
}
setSelectedMap(value) {
......@@ -28,21 +26,20 @@ DOM.defineCustomElement(
}
set mapDetails(map) {
let details = "";
let clickableDetails = "";
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;
this._filePositionNode.classList.add("clickable");
this._filePositionNode.classList.add('clickable');
this.mapDetails.innerText = details;
}
handleFilePositionClick() {
this.dispatchEvent(new FocusEvent(this.selectedMap.sourcePosition));
}
}
);
});
......@@ -2,12 +2,13 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import { MapLogEntry, Edge } from "./log/map.mjs";
import { IcLogEntry } from "./log/ic.mjs";
import { DeoptLogEntry } from "./log/deopt.mjs";
import { Timeline } from "./timeline.mjs";
import { LogReader, parseString, parseVarArgs } from "../logreader.mjs";
import { Profile } from "../profile.mjs";
import {LogReader, parseString, parseVarArgs} from '../logreader.mjs';
import {Profile} from '../profile.mjs';
import {DeoptLogEntry} from './log/deopt.mjs';
import {IcLogEntry} from './log/ic.mjs';
import {Edge, MapLogEntry} from './log/map.mjs';
import {Timeline} from './timeline.mjs';
// ===========================================================================
......@@ -43,7 +44,8 @@ export class Processor extends LogReader {
},
'v8-version': {
parsers: [
parseInt, parseInt,
parseInt,
parseInt,
],
processor: this.processV8Version
},
......@@ -52,12 +54,12 @@ export class Processor extends LogReader {
processor: this.processScriptSource
},
'code-move':
{ parsers: [parseInt, parseInt], processor: this.processCodeMove },
'code-delete': { parsers: [parseInt], processor: this.processCodeDelete },
{parsers: [parseInt, parseInt], processor: this.processCodeMove},
'code-delete': {parsers: [parseInt], processor: this.processCodeDelete},
'sfi-move':
{ parsers: [parseInt, parseInt], processor: this.processFunctionMove },
{parsers: [parseInt, parseInt], processor: this.processFunctionMove},
'map-create':
{ parsers: [parseInt, parseString], processor: this.processMapCreate },
{parsers: [parseInt, parseString], processor: this.processMapCreate},
'map': {
parsers: [
parseString, parseInt, parseString, parseString, parseInt, parseInt,
......@@ -140,8 +142,8 @@ export class Processor extends LogReader {
}
} catch (e) {
console.error(
'Error occurred during parsing line ' + i +
', trying to continue: ' + e);
'Error occurred during parsing line ' + i +
', trying to continue: ' + e);
}
this.finalize();
}
......@@ -184,24 +186,25 @@ export class Processor extends LogReader {
let funcAddr = parseInt(maybe_func[0]);
let state = this.parseState(maybe_func[1]);
this._profile.addFuncCode(
type, name, timestamp, start, size, funcAddr, state);
type, name, timestamp, start, size, funcAddr, state);
} else {
this._profile.addCode(type, name, timestamp, start, size);
}
}
processCodeDeopt(timestamp, codeSize, instructionStart, inliningId,
scriptOffset, deoptKind, deoptLocation, deoptReason) {
processCodeDeopt(
timestamp, codeSize, instructionStart, inliningId, scriptOffset,
deoptKind, deoptLocation, deoptReason) {
this._deoptTimeline.push(new DeoptLogEntry(deoptKind, timestamp));
}
processV8Version(majorVersion, minorVersion) {
if (
(majorVersion == this.MAJOR_VERSION && minorVersion <= this.MINOR_VERSION)
|| (majorVersion < this.MAJOR_VERSION)) {
if ((majorVersion == this.MAJOR_VERSION &&
minorVersion <= this.MINOR_VERSION) ||
(majorVersion < this.MAJOR_VERSION)) {
window.alert(
`Unsupported version ${majorVersion}.${minorVersion}. \n` +
`Please use the matching tool for given the V8 version.`);
`Unsupported version ${majorVersion}.${minorVersion}. \n` +
`Please use the matching tool for given the V8 version.`);
}
}
......@@ -231,16 +234,16 @@ export class Processor extends LogReader {
}
processPropertyIC(
type, pc, time, line, column, old_state, new_state, map, key, modifier,
slow_reason) {
type, pc, time, line, column, old_state, new_state, map, key, modifier,
slow_reason) {
let fnName = this.functionName(pc);
let parts = fnName.split(' ');
let fileName = parts[parts.length-1];
let fileName = parts[parts.length - 1];
let script = this.getScript(fileName);
// TODO: Use SourcePosition here directly
let entry = new IcLogEntry(
type, fnName, time, line, column, key, old_state, new_state, map,
slow_reason, script, modifier);
type, fnName, time, line, column, key, old_state, new_state, map,
slow_reason, script, modifier);
if (script) {
entry.sourcePosition = script.addSourcePosition(line, column, entry);
}
......@@ -254,9 +257,9 @@ export class Processor extends LogReader {
formatPC(pc, line, column) {
let entry = this._profile.findEntry(pc);
if (!entry) return '<unknown>'
if (entry.type === 'Builtin') {
return entry.name;
}
if (entry.type === 'Builtin') {
return entry.name;
}
let name = entry.func.getName();
let array = this._formatPCRegexp.exec(name);
if (array === null) {
......@@ -272,7 +275,7 @@ export class Processor extends LogReader {
// Try to handle urls with file positions: https://foo.bar.com/:17:330"
filePositionLine = filePositionLine.split(' ');
let parts = filePositionLine[1].split(':');
if (parts[0].length <= 5) return parts[0] + ':' + parts[1]
if (parts[0].length <= 5) return parts[0] + ':' + parts[1];
return parts[1];
}
......
This diff is collapsed.
// Copyright 2020 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.
import { V8CustomElement, DOM} from "./helper.mjs";
import { SelectionEvent } from "./events.mjs";
import { delay, LazyTable } from "./helper.mjs";
import {SelectionEvent} from './events.mjs';
import {DOM, V8CustomElement} from './helper.mjs';
import {delay, LazyTable} from './helper.mjs';
DOM.defineCustomElement(
"stats-panel",
(templateText) =>
class StatsPanel extends V8CustomElement {
'stats-panel', (templateText) => class StatsPanel extends V8CustomElement {
_timeline;
_transitions;
_selectedLogEntries;
......@@ -17,7 +15,7 @@ DOM.defineCustomElement(
}
get stats() {
return this.$("#stats");
return this.$('#stats');
}
set timeline(timeline) {
......@@ -51,40 +49,40 @@ DOM.defineCustomElement(
}
updateGeneralStats() {
console.assert(this._timeline !== undefined, "Timeline not set yet!");
console.assert(this._timeline !== undefined, 'Timeline not set yet!');
let pairs = [
["Transitions", "primary", (e) => e.edge && e.edge.isTransition()],
["Fast to Slow", "violet", (e) => e.edge && e.edge.isFastToSlow()],
["Slow to Fast", "orange", (e) => e.edge && e.edge.isSlowToFast()],
["Initial Map", "yellow", (e) => e.edge && e.edge.isInitial()],
['Transitions', 'primary', (e) => e.edge && e.edge.isTransition()],
['Fast to Slow', 'violet', (e) => e.edge && e.edge.isFastToSlow()],
['Slow to Fast', 'orange', (e) => e.edge && e.edge.isSlowToFast()],
['Initial Map', 'yellow', (e) => e.edge && e.edge.isInitial()],
[
"Replace Descriptors",
"red",
'Replace Descriptors',
'red',
(e) => e.edge && e.edge.isReplaceDescriptors(),
],
[
"Copy as Prototype",
"red",
'Copy as Prototype',
'red',
(e) => e.edge && e.edge.isCopyAsPrototype(),
],
[
"Optimize as Prototype",
'Optimize as Prototype',
null,
(e) => e.edge && e.edge.isOptimizeAsPrototype(),
],
["Deprecated", null, (e) => e.isDeprecated()],
["Bootstrapped", "green", (e) => e.isBootstrapped()],
["Total", null, (e) => true],
['Deprecated', null, (e) => e.isDeprecated()],
['Bootstrapped', 'green', (e) => e.isBootstrapped()],
['Total', null, (e) => true],
];
let tbody = document.createElement("tbody");
let tbody = document.createElement('tbody');
let total = this._selectedLogEntries.length;
pairs.forEach(([name, color, filter]) => {
let row = DOM.tr();
if (color !== null) {
row.appendChild(DOM.td(DOM.div(["colorbox", color])));
row.appendChild(DOM.td(DOM.div(['colorbox', color])));
} else {
row.appendChild(DOM.td(""));
row.appendChild(DOM.td(''));
}
row.classList.add('clickable');
row.onclick = (e) => {
......@@ -99,10 +97,10 @@ DOM.defineCustomElement(
let count = this.count(filter);
row.appendChild(DOM.td(count));
let percent = Math.round((count / total) * 1000) / 10;
row.appendChild(DOM.td(percent.toFixed(1) + "%"));
row.appendChild(DOM.td(percent.toFixed(1) + '%'));
tbody.appendChild(row);
});
this.$("#typeTable").replaceChild(tbody, this.$("#typeTable tbody"));
this.$('#typeTable').replaceChild(tbody, this.$('#typeTable tbody'));
}
count(filter) {
......@@ -116,21 +114,17 @@ DOM.defineCustomElement(
updateNamedTransitionsStats() {
let rowData = Array.from(this._transitions.entries());
rowData.sort((a, b) => b[1].length - a[1].length);
new LazyTable(this.$("#nameTable"), rowData, ([name, maps]) => {
let row = DOM.tr();
row.maps = maps;
row.classList.add('clickable');
row.addEventListener("click", (e) =>
this.dispatchEvent(
new SelectionEvent(
e.target.parentNode.maps.map((map) => map.to)
)
)
);
row.appendChild(DOM.td(maps.length));
row.appendChild(DOM.td(name));
return row;
});
new LazyTable(this.$('#nameTable'), rowData, ([name, maps]) => {
let row = DOM.tr();
row.maps = maps;
row.classList.add('clickable');
row.addEventListener(
'click',
(e) => this.dispatchEvent(new SelectionEvent(
e.target.parentNode.maps.map((map) => map.to))));
row.appendChild(DOM.td(maps.length));
row.appendChild(DOM.td(name));
return row;
});
}
}
);
});
......@@ -2,53 +2,55 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import { DOM, V8CustomElement } from './helper.mjs';
import { SynchronizeSelectionEvent } from './events.mjs';
import './timeline/timeline-track.mjs';
DOM.defineCustomElement('timeline-panel', (templateText) =>
class TimelinePanel extends V8CustomElement {
constructor() {
super(templateText);
this.addEventListener(
'scrolltrack', e => this.handleTrackScroll(e));
this.addEventListener(
SynchronizeSelectionEvent.name,
e => this.handleSelectionSyncronization(e));
}
set nofChunks(count) {
for (const track of this.timelineTracks) {
track.nofChunks = count;
import {SynchronizeSelectionEvent} from './events.mjs';
import {DOM, V8CustomElement} from './helper.mjs';
DOM.defineCustomElement(
'timeline-panel',
(templateText) => class TimelinePanel extends V8CustomElement {
constructor() {
super(templateText);
this.addEventListener('scrolltrack', e => this.handleTrackScroll(e));
this.addEventListener(
SynchronizeSelectionEvent.name,
e => this.handleSelectionSyncronization(e));
}
}
get nofChunks() {
return this.timelineTracks[0].nofChunks;
}
set nofChunks(count) {
for (const track of this.timelineTracks) {
track.nofChunks = count;
}
}
get timelineTracks() {
return this.$("slot").assignedNodes().filter(
node => node.nodeType === Node.ELEMENT_NODE);
}
get nofChunks() {
return this.timelineTracks[0].nofChunks;
}
handleTrackScroll(event) {
//TODO(zcankara) add forEachTrack helper method
for (const track of this.timelineTracks) {
track.scrollLeft = event.detail;
get timelineTracks() {
return this.$('slot').assignedNodes().filter(
node => node.nodeType === Node.ELEMENT_NODE);
}
}
handleSelectionSyncronization(event) {
this.timeSelection = {start:event.start, end:event.end};
}
handleTrackScroll(event) {
// TODO(zcankara) add forEachTrack helper method
for (const track of this.timelineTracks) {
track.scrollLeft = event.detail;
}
}
set timeSelection(timeSelection) {
if (timeSelection.start > timeSelection.end) {
throw new Error("Invalid time range");
handleSelectionSyncronization(event) {
this.timeSelection = {start: event.start, end: event.end};
}
for (const track of this.timelineTracks) {
track.timeSelection = timeSelection;;
set timeSelection(timeSelection) {
if (timeSelection.start > timeSelection.end) {
throw new Error('Invalid time range');
}
for (const track of this.timelineTracks) {
track.timeSelection = timeSelection;
;
}
}
}
});
});
......@@ -35,17 +35,16 @@ class Timeline {
}
selectTimeRange(start, end) {
this._selection = this.filter(
e => e.time >= start && e.time <= end);
this._selection = this.filter(e => e.time >= start && e.time <= end);
}
getChunks(windowSizeMs) {
//TODO(zcankara) Fill this one
// TODO(zcankara) Fill this one
return this.chunkSizes(windowSizeMs);
}
get values() {
//TODO(zcankara) Not to break something delete later
// TODO(zcankara) Not to break something delete later
return this._values;
}
......@@ -253,7 +252,7 @@ class Chunk {
if (event_fn === void 0) {
event_fn = each => each;
}
let breakdown = { __proto__: null };
let breakdown = {__proto__: null};
this.items.forEach(each => {
const type = event_fn(each);
const v = breakdown[type];
......@@ -265,7 +264,6 @@ class Chunk {
filter() {
return this.items.filter(map => !map.parent() || !this.has(map.parent()));
}
}
export { Timeline, Chunk };
export {Timeline, Chunk};
......@@ -131,6 +131,31 @@ def TorqueLintWorker(command):
print('Error running format-torque.py')
process.kill()
def JSLintWorker(command):
try:
file_name = command[-1]
with open(file_name, "r") as file_handle:
contents = file_handle.read()
process = subprocess.Popen(command, stdout=PIPE, stderr=subprocess.PIPE)
output, err = process.communicate()
rc = process.returncode
if rc != 0:
sys.stdout.write("error code " + str(rc) + " running clang-format.\n")
return rc
if output != contents:
sys.stdout.write(file_name + " requires formatting.\n")
return 1
return 0
except KeyboardInterrupt:
process.kill()
except Exception:
print('Error running clang-format. Please make sure you have depot_tools' +
' in your $PATH. Lint check skipped.')
process.kill()
class FileContentsCache(object):
def __init__(self, sums_file_name):
......@@ -392,6 +417,33 @@ class TorqueLintProcessor(CacheableSourceFileProcessor):
return None, arguments
class JSLintProcessor(CacheableSourceFileProcessor):
"""
Check .{m}js file to verify they follow the JS Style guide.
"""
def __init__(self, use_cache=True):
super(JSLintProcessor, self).__init__(
use_cache=use_cache, cache_file_path='.jslint-cache',
file_type='JavaScript')
def IsRelevant(self, name):
return name.endswith('.js') or name.endswith('.mjs')
def GetPathsToSearch(self):
return ['tools/system-analyzer']
def GetProcessorWorker(self):
return JSLintWorker
def GetProcessorScript(self):
for path in [TOOLS_PATH] + os.environ["PATH"].split(os.pathsep):
path = path.strip('"')
clang_format = os.path.join(path, 'clang_format.py')
if os.path.isfile(clang_format):
return clang_format, []
return None, []
COPYRIGHT_HEADER_PATTERN = re.compile(
r'Copyright [\d-]*20[0-2][0-9] the V8 project authors. All rights reserved.')
......@@ -708,6 +760,9 @@ def Main():
print("Running Torque formatting check...")
success &= TorqueLintProcessor(use_cache=use_linter_cache).RunOnPath(
workspace)
print("Running JavaScript formatting check...")
success &= JSLintProcessor(use_cache=use_linter_cache).RunOnPath(
workspace)
print("Running copyright header, trailing whitespaces and " \
"two empty lines between declarations check...")
success &= SourceProcessor().RunOnPath(workspace)
......
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