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

[tools][system-analyzer] Add Generic Event Class

This CL adds a generic Event Class to unify common
methods of IC and Map events. The Entry Class for IC
Events and V8Map Class for Map Events inherits from
this generic Event Class.

Bug: v8:10644, v8:10735

Change-Id: I77d68fb40ee0ffbe297fcd1a13c3e2b746938168
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2317309
Commit-Queue: Zeynep Cankara <zcankara@google.com>
Reviewed-by: 's avatarCamillo Bruni <cbruni@chromium.org>
Reviewed-by: 's avatarSathya Gunasekaran  <gsathya@chromium.org>
Cr-Commit-Position: refs/heads/master@{#69066}
parent fd45d44a
......@@ -28,8 +28,7 @@ class State {
this.map = e.detail;
}
handleShowMaps(e){
this.mapPanel_.mapEntries = e.detail.filter(event =>
!event.parent() || !this.has(event.parent()));
this.mapPanel_.mapEntries = e.detail.filter();
}
get icTimeline() {
return this.#icTimeline;
......
// 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.
class Event {
#time;
#type;
constructor(type, time) {
this.#time = time;
this.#type = type;
}
get time(){
return this.#time;
}
get type(){
return this.#type;
}
}
export {Event};
......@@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import {Event} from './event.mjs';
import {Timeline} from './timeline.mjs';
/**
......@@ -207,12 +208,11 @@ class CustomIcProcessor extends IcProcessor {
}
};
class Entry {
class Entry extends Event {
constructor(
type, fn_file, time, line, column, key, oldState, newState, map, reason,
additional) {
this.time = time;
this.type = type;
super(type, time);
this.category = 'other';
if (this.type.indexOf('Store') !== -1) {
this.category = 'Store';
......@@ -233,6 +233,7 @@ class Entry {
this.additional = additional;
}
parseMapProperties(parts, offset) {
let next = parts[++offset];
if (!next.startsWith('dict')) return offset;
......
......@@ -5,6 +5,7 @@
import {Timeline} from './timeline.mjs';
// ===========================================================================
import {Event} from './event.mjs';
const kChunkHeight = 250;
const kChunkWidth = 10;
......@@ -235,22 +236,21 @@ class MapProcessor extends LogReader {
// ===========================================================================
class V8Map {
class V8Map extends Event {
edge = void 0;
children = [];
depth = 0;
// TODO(zcankara): Change this to private class field.
#isDeprecated = false;
deprecatedTargets = null;
leftId= 0;
rightId = 0;
filePosition = '';
constructor(id, time = -1) {
if (!id) throw 'Invalid ID';
this.id = id;
this.time = time;
if (!(time > 0)) throw 'Invalid time';
this.description = '';
this.edge = void 0;
this.children = [];
this.depth = 0;
this._isDeprecated = false;
this.deprecationTargets = null;
V8Map.set(id, this);
this.leftId = 0;
this.rightId = 0;
this.filePosition = '';
if (time <= 0) throw new Error('Invalid time');
super(id, time);
V8Map.set(id, this);
}
finalizeRootMap(id) {
......@@ -282,11 +282,11 @@ class V8Map {
}
isDeprecated() {
return this._isDeprecated;
return this.#isDeprecated;
}
deprecate() {
this._isDeprecated = true;
this.#isDeprecated = true;
}
isRoot() {
......
......@@ -229,8 +229,8 @@ class Chunk {
return Object.entries(breakdown).sort((a, b) => a[1] - b[1]);
}
filter(filterFn){
return this.items.filter(filterFn);
filter(){
return this.items.filter(map => !map.parent() || !this.has(map.parent()));
}
}
......
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