Commit f7273dd3 authored by Zeynep Cankara's avatar Zeynep Cankara Committed by Commit Bot

[tools][system-analyzer] Use private class fields

This CL aims to clean dead code across the app
and use private class fields for storing private
information.

Bug: v8:10644, v8:10735

Change-Id: I1129104925f230bed922cc76abdb432d536d2111
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2323352Reviewed-by: 's avatarCamillo Bruni <cbruni@chromium.org>
Reviewed-by: 's avatarSathya Gunasekaran  <gsathya@chromium.org>
Commit-Queue: Zeynep Cankara <zcankara@google.com>
Cr-Commit-Position: refs/heads/master@{#69125}
parent 980e224a
......@@ -8,19 +8,19 @@ import {defineCustomElement, V8CustomElement} from './helper.mjs';
defineCustomElement('ic-panel', (templateText) =>
class ICPanel extends V8CustomElement {
//TODO(zcankara) Entries never set
#entries;
#filteredEntries;
constructor() {
super(templateText);
this.groupKey.addEventListener(
'change', e => this.updateTable(e));
this.$('#filterICTimeBtn').addEventListener(
'click', e => this.handleICTimeFilter(e));
this._noOfItems = 100;
this._startTime = 0;
this._endTime = 0;
}
get entries(){
return this._entries;
return this.#entries;
}
get groupKey() {
......@@ -44,12 +44,12 @@ defineCustomElement('ic-panel', (templateText) =>
}
set filteredEntries(value){
this._filteredEntries = value;
this.#filteredEntries = value;
this.updateTable();
}
get filteredEntries(){
return this._filteredEntries;
return this.#filteredEntries;
}
updateTable(event) {
......@@ -91,14 +91,6 @@ defineCustomElement('ic-panel', (templateText) =>
return node
}
set noOfItems(value){
this._noOfItems = value;
}
get noOfItems(){
return this._noOfItems;
}
handleMapClick(e){
this.dispatchEvent(new CustomEvent(
'mapclick', {bubbles: true, composed: true,
......
......@@ -21,6 +21,7 @@ function parseState(s) {
}
class IcProcessor extends LogReader {
#profile;
constructor() {
super();
let propertyICParser = [
......@@ -69,7 +70,7 @@ class IcProcessor extends LogReader {
processor: this.processPropertyIC.bind(this, 'StoreInArrayLiteralIC')
},
});
this.profile_ = new Profile();
this.#profile = new Profile();
this.LoadGlobalIC = 0;
this.StoreGlobalIC = 0;
......@@ -79,6 +80,9 @@ class IcProcessor extends LogReader {
this.KeyedStoreIC = 0;
this.StoreInArrayLiteralIC = 0;
}
get profile(){
return this.#profile;
}
/**
* @override
*/
......@@ -125,20 +129,20 @@ class IcProcessor extends LogReader {
if (maybe_func.length) {
let funcAddr = parseInt(maybe_func[0]);
let state = parseState(maybe_func[1]);
this.profile_.addFuncCode(
this.#profile.addFuncCode(
type, name, timestamp, start, size, funcAddr, state);
} else {
this.profile_.addCode(type, name, timestamp, start, size);
this.#profile.addCode(type, name, timestamp, start, size);
}
}
processCodeMove(from, to) {
this.profile_.moveCode(from, to);
this.#profile.moveCode(from, to);
}
processCodeDelete(start) {
this.profile_.deleteCode(start);
this.#profile.deleteCode(start);
}
processFunctionMove(from, to) {
this.profile_.moveFunc(from, to);
this.#profile.moveFunc(from, to);
}
formatName(entry) {
if (!entry) return '<unknown>';
......@@ -153,7 +157,7 @@ class IcProcessor extends LogReader {
type, pc, time, line, column, old_state, new_state, map, name, modifier,
slow_reason) {
this[type]++;
let entry = this.profile_.findEntry(pc);
let entry = this.#profile.findEntry(pc);
print(
type + ' (' + old_state + '->' + new_state + modifier + ') at ' +
this.formatName(entry) + ':' + line + ':' + column + ' ' + name +
......@@ -178,12 +182,9 @@ IcProcessor.kProperties = [
class CustomIcProcessor extends IcProcessor {
#timeline = new Timeline();
constructor() {
super();
}
functionName(pc) {
let entry = this.profile_.findEntry(pc);
let entry = this.profile.findEntry(pc);
return this.formatName(entry);
}
......
......@@ -6,6 +6,7 @@ import {V8CustomElement, defineCustomElement} from '../helper.mjs';
defineCustomElement('./map-panel/map-transitions', (templateText) =>
class MapTransitions extends V8CustomElement {
#map;
#mapEntries;
constructor() {
super(templateText);
this.transitionView.addEventListener(
......@@ -72,12 +73,12 @@ defineCustomElement('./map-panel/map-transitions', (templateText) =>
}
set mapEntries(list){
this._mapEntries = list;
this.#mapEntries = list;
this.showMaps();
}
get mapEntries(){
return this._mapEntries;
return this.#mapEntries;
}
addMapAndParentTransitions(map) {
......
......@@ -32,6 +32,9 @@ define(Array.prototype, 'last', function() {
// ===========================================================================
class MapProcessor extends LogReader {
#profile = new Profile();
#timeline = new Timeline();
#formatPCRegexp = /(.*):[0-9]+:[0-9]+$/;
constructor() {
super();
this.dispatchTable_ = {
......@@ -64,9 +67,6 @@ class MapProcessor extends LogReader {
processor: this.processMapDetails
}
};
this.profile_ = new Profile();
this.timeline_ = new Timeline();
this.formatPCRegexp_ = /(.*):[0-9]+:[0-9]+$/;
}
printError(str) {
......@@ -116,21 +116,21 @@ class MapProcessor extends LogReader {
finalize() {
// TODO(cbruni): print stats;
this.timeline_.transitions = new Map();
this.#timeline.transitions = new Map();
let id = 0;
this.timeline_.forEach(map => {
this.#timeline.forEach(map => {
if (map.isRoot()) id = map.finalizeRootMap(id + 1);
if (map.edge && map.edge.name) {
let edge = map.edge;
let list = this.timeline_.transitions.get(edge.name);
let list = this.#timeline.transitions.get(edge.name);
if (list === undefined) {
this.timeline_.transitions.set(edge.name, [edge]);
this.#timeline.transitions.set(edge.name, [edge]);
} else {
list.push(edge);
}
}
});
return this.timeline_;
return this.#timeline;
}
addEntry(entry) {
......@@ -156,33 +156,33 @@ class MapProcessor extends LogReader {
if (maybe_func.length) {
let funcAddr = parseInt(maybe_func[0]);
let state = this.parseState(maybe_func[1]);
this.profile_.addFuncCode(
this.#profile.addFuncCode(
type, name, timestamp, start, size, funcAddr, state);
} else {
this.profile_.addCode(type, name, timestamp, start, size);
this.#profile.addCode(type, name, timestamp, start, size);
}
}
processCodeMove(from, to) {
this.profile_.moveCode(from, to);
this.#profile.moveCode(from, to);
}
processCodeDelete(start) {
this.profile_.deleteCode(start);
this.#profile.deleteCode(start);
}
processFunctionMove(from, to) {
this.profile_.moveFunc(from, to);
this.#profile.moveFunc(from, to);
}
formatPC(pc, line, column) {
let entry = this.profile_.findEntry(pc);
let entry = this.#profile.findEntry(pc);
if (!entry) return '<unknown>'
if (entry.type === 'Builtin') {
return entry.name;
}
let name = entry.func.getName();
let array = this.formatPCRegexp_.exec(name);
let array = this.#formatPCRegexp.exec(name);
if (array === null) {
entry = name;
} else {
......@@ -219,7 +219,7 @@ class MapProcessor extends LogReader {
createMap(id, time) {
let map = new V8Map(id, time);
this.timeline_.push(map);
this.#timeline.push(map);
return map;
}
......
......@@ -5,9 +5,10 @@ import {V8CustomElement, defineCustomElement} from './helper.mjs';
defineCustomElement('stats-panel', (templateText) =>
class StatsPanel extends V8CustomElement {
#timeline;
#transitions;
constructor() {
super(templateText);
this.timeline_ = undefined;
}
get stats() {
......@@ -15,19 +16,20 @@ defineCustomElement('stats-panel', (templateText) =>
}
set timeline(value){
this.timeline_ = value;
//TODO(zcankara) Trigger update
this.#timeline = value;
}
get timeline(){
return this.timeline_;
return this.#timeline;
}
//TODO(zcankare) Depreciate timeline
set transitions(value){
this.transitions_ = value;
this.#transitions = value;
}
get transitions(){
return this.transitions_;
return this.#transitions;
}
filterUniqueTransitions(filter) {
......@@ -47,7 +49,7 @@ defineCustomElement('stats-panel', (templateText) =>
}
updateGeneralStats() {
console.assert(this.timeline_ !== undefined, "Timeline not set yet!");
console.assert(this.#timeline !== undefined, "Timeline not set yet!");
let pairs = [
['Total', null, e => true],
['Transitions', 'primary', e => e.edge && e.edge.isTransition()],
......
......@@ -12,7 +12,6 @@ defineCustomElement('./timeline/timeline-track', (templateText) =>
#nofChunks = 400;
#chunks;
#selectedEntry;
constructor() {
super(templateText);
this.backgroundCanvas = document.createElement('canvas');
......@@ -77,13 +76,10 @@ defineCustomElement('./timeline/timeline-track', (templateText) =>
unique.set(entry.type, unique.get(entry.type) + 1);
}
}
console.log(unique);
//TODO(zcankara) Update it to make it work without relying on hex colors
this.renderStatsWindow(unique);
}
renderStatsWindow(unique){
//TODO(zcankara) Update legend with colors and entries
let timelineLegendContent = this.timelineLegendContent;
this.removeAllChildren(timelineLegendContent);
let fragment = document.createDocumentFragment();
......
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