Skip to content

Commit

Permalink
Reland "[presubmit] Add JS formatting for tools/system-analyzer"
Browse files Browse the repository at this point in the history
This is a reland of 1ec8f1d

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: Tamer Tas <tmrts@chromium.org>
Reviewed-by: Camillo Bruni <cbruni@chromium.org>
Cr-Commit-Position: refs/heads/master@{#70938}
  • Loading branch information
gsathya authored and Commit Bot committed Nov 3, 2020
1 parent efff3d1 commit 91ace57
Show file tree
Hide file tree
Showing 23 changed files with 1,367 additions and 1,327 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
.cproject
.gclient_entries
.gdb_history
.jslint-cache
.landmines
.project
.pydevproject
Expand Down
10 changes: 10 additions & 0 deletions PRESUBMIT.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -95,6 +96,11 @@ def FilterTorqueFile(affected_file):
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)):
Expand All @@ -103,6 +109,10 @@ def FilterTorqueFile(affected_file):
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(
Expand Down
16 changes: 8 additions & 8 deletions tools/system-analyzer/app-model.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// found in the LICENSE file.

class State {
_timeSelection = { start: 0, end: Infinity };
_timeSelection = {start: 0, end: Infinity};
_map;
_ic;
_selectedMapLogEntries;
Expand Down Expand Up @@ -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() {
Expand All @@ -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;
}
Expand Down Expand Up @@ -122,4 +122,4 @@ class State {
}
}

export { State };
export {State};
32 changes: 18 additions & 14 deletions tools/system-analyzer/events.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
29 changes: 17 additions & 12 deletions tools/system-analyzer/helper.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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)));
}
}

Expand All @@ -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) {
Expand All @@ -190,15 +191,14 @@ class V8CustomElement extends HTMLElement {
}
}


class LazyTable {
constructor(table, rowData, rowElementCreator) {
this._table = table;
this._rowData = rowData;
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();
}

Expand All @@ -216,15 +216,14 @@ class LazyTable {
}
}


class LazyTable {
constructor(table, rowData, rowElementCreator) {
this._table = table;
this._rowData = rowData;
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();
}

Expand All @@ -247,6 +246,12 @@ function delay(time) {
}

export {
DOM, $, V8CustomElement, formatBytes,
typeToColor, CSSColor, delay, LazyTable,
DOM,
$,
V8CustomElement,
formatBytes,
typeToColor,
CSSColor,
delay,
LazyTable,
};
5 changes: 2 additions & 3 deletions tools/system-analyzer/ic-model.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}

}
Loading

0 comments on commit 91ace57

Please sign in to comment.