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