Commit 213152dd authored by Camillo Bruni's avatar Camillo Bruni Committed by Commit Bot

[tools] Remove outdated ic-processor

- Remove ic-processor.html since it's been fully integrated in the
  system-analyzer
- Use new tools/system-analyzer/processor.mjs for command line
  ic-processor
- Update tools landing page
- Partially fix dependencies on web specific components in helper.mjs

Bug: v8:10644
Change-Id: I0c99ff7c7859684e53aa3ab22489b1a8242e1a6e
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2498606Reviewed-by: 's avatarMarja Hölttä <marja@chromium.org>
Commit-Queue: Camillo Bruni <cbruni@chromium.org>
Cr-Commit-Position: refs/heads/master@{#70799}
parent 47ea5fb6
This diff is collapsed.
......@@ -2,8 +2,9 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import { IcProcessor, ArgumentsProcessor, readFile } from "./ic-processor.mjs";
import { Processor } from "./system-analyzer/processor.mjs";
import { WebInspector } from "./sourcemap.mjs";
import { BaseArgumentsProcessor } from "./arguments.mjs";
function processArguments(args) {
var processor = new ArgumentsProcessor(args);
......@@ -14,6 +15,18 @@ function processArguments(args) {
}
}
/**
* A thin wrapper around shell's 'read' function showing a file name on error.
*/
export function readFile(fileName) {
try {
return read(fileName);
} catch (e) {
print(fileName + ': ' + (e.message || e));
throw e;
}
}
function initSourceMapSupport() {
// Pull dev tools source maps into our name space.
SourceMap = WebInspector.SourceMap;
......@@ -26,11 +39,56 @@ function initSourceMapSupport() {
};
}
var params = processArguments(arguments);
var sourceMap = null;
class ArgumentsProcessor extends BaseArgumentsProcessor {
getArgsDispatch() {
return {
'--range': ['range', 'auto,auto',
'Specify the range limit as [start],[end]'],
'--source-map': ['sourceMap', null,
'Specify the source map that should be used for output']
};
}
getDefaultResults() {
return {
logFileName: 'v8.log',
range: 'auto,auto',
};
}
}
const params = processArguments(arguments);
let sourceMap = null;
if (params.sourceMap) {
initSourceMapSupport();
sourceMap = SourceMap.load(params.sourceMap);
}
var icProcessor = new IcProcessor();
icProcessor.processLogFile(params.logFileName);
const processor = new Processor();
processor.processLogFile(params.logFileName);
const typeAccumulator = new Map();
const accumulator = {
__proto__: null,
LoadGlobalIC: 0,
StoreGlobalIC: 0,
LoadIC: 0,
StoreIC: 0,
KeyedLoadIC: 0,
KeyedStoreIC: 0,
StoreInArrayLiteralIC: 0,
}
for (const ic of processor.icTimeline.all) {
print(
ic.type + ' (' + ic.oldState + '->' + ic.newState + ic.modifier + ') at ' +
ic.filePosition + ' ' + ic.key +
' (map 0x' + ic.map.toString(16) + ')' +
(ic.reason ? ' ' + ic.reason : '') + ' time: ' + ic.time);
accumulator[ic.type]++;
}
print("========================================");
for (const key of Object.keys(accumulator)) {
print(key + ": " + accumulator[key]);
}
// Copyright 2017 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 { LogReader, parseString, parseVarArgs } from "./logreader.mjs";
import { BaseArgumentsProcessor } from "./arguments.mjs";
import { Profile } from "./profile.mjs";
function inherits(childCtor, parentCtor) {
childCtor.prototype.__proto__ = parentCtor.prototype;
};
/**
* A thin wrapper around shell's 'read' function showing a file name on error.
*/
export function readFile(fileName) {
try {
return read(fileName);
} catch (e) {
print(fileName + ': ' + (e.message || e));
throw e;
}
}
/**
* Parser for dynamic code optimization state.
*/
function parseState(s) {
switch (s) {
case "": return Profile.CodeState.COMPILED;
case "~": return Profile.CodeState.OPTIMIZABLE;
case "*": return Profile.CodeState.OPTIMIZED;
}
throw new Error("unknown code state: " + s);
}
export function IcProcessor() {
var propertyICParser = [
parseInt, parseInt, parseInt, parseInt, parseString, parseString,
parseInt, parseString, parseString, parseString];
LogReader.call(this, {
'code-creation': {
parsers: [parseString, parseInt, parseInt, parseInt, parseInt,
parseString, parseVarArgs],
processor: this.processCodeCreation },
'code-move': { parsers: [parseInt, parseInt],
processor: this.processCodeMove },
'code-delete': { parsers: [parseInt],
processor: this.processCodeDelete },
'sfi-move': { parsers: [parseInt, parseInt],
processor: this.processFunctionMove },
'LoadGlobalIC': {
parsers : propertyICParser,
processor: this.processPropertyIC.bind(this, "LoadGlobalIC") },
'StoreGlobalIC': {
parsers : propertyICParser,
processor: this.processPropertyIC.bind(this, "StoreGlobalIC") },
'LoadIC': {
parsers : propertyICParser,
processor: this.processPropertyIC.bind(this, "LoadIC") },
'StoreIC': {
parsers : propertyICParser,
processor: this.processPropertyIC.bind(this, "StoreIC") },
'KeyedLoadIC': {
parsers : propertyICParser,
processor: this.processPropertyIC.bind(this, "KeyedLoadIC") },
'KeyedStoreIC': {
parsers : propertyICParser,
processor: this.processPropertyIC.bind(this, "KeyedStoreIC") },
'StoreInArrayLiteralIC': {
parsers : propertyICParser,
processor: this.processPropertyIC.bind(this, "StoreInArrayLiteralIC") },
});
this.profile_ = new Profile();
this.LoadGlobalIC = 0;
this.StoreGlobalIC = 0;
this.LoadIC = 0;
this.StoreIC = 0;
this.KeyedLoadIC = 0;
this.KeyedStoreIC = 0;
this.StoreInArrayLiteralIC = 0;
}
inherits(IcProcessor, LogReader);
/**
* @override
*/
IcProcessor.prototype.printError = function(str) {
print(str);
};
IcProcessor.prototype.processString = function(string) {
var end = string.length;
var current = 0;
var next = 0;
var line;
var i = 0;
var entry;
while (current < end) {
next = string.indexOf("\n", current);
if (next === -1) break;
i++;
line = string.substring(current, next);
current = next + 1;
this.processLogLine(line);
}
}
IcProcessor.prototype.processLogFile = function(fileName) {
this.collectEntries = true
this.lastLogFileName_ = fileName;
var line;
while (line = readline()) {
this.processLogLine(line);
}
print();
print("=====================");
print("LoadGlobal: " + this.LoadGlobalIC);
print("StoreGlobal: " + this.StoreGlobalIC);
print("Load: " + this.LoadIC);
print("Store: " + this.StoreIC);
print("KeyedLoad: " + this.KeyedLoadIC);
print("KeyedStore: " + this.KeyedStoreIC);
print("StoreInArrayLiteral: " + this.StoreInArrayLiteralIC);
};
IcProcessor.prototype.addEntry = function(entry) {
this.entries.push(entry);
}
IcProcessor.prototype.processCodeCreation = function(
type, kind, timestamp, start, size, name, maybe_func) {
if (maybe_func.length) {
var funcAddr = parseInt(maybe_func[0]);
var state = parseState(maybe_func[1]);
this.profile_.addFuncCode(type, name, timestamp, start, size, funcAddr, state);
} else {
this.profile_.addCode(type, name, timestamp, start, size);
}
};
IcProcessor.prototype.processCodeMove = function(from, to) {
this.profile_.moveCode(from, to);
};
IcProcessor.prototype.processCodeDelete = function(start) {
this.profile_.deleteCode(start);
};
IcProcessor.prototype.processFunctionMove = function(from, to) {
this.profile_.moveFunc(from, to);
};
IcProcessor.prototype.formatName = function(entry) {
if (!entry) return "<unknown>"
var name = entry.func.getName();
var re = /(.*):[0-9]+:[0-9]+$/;
var array = re.exec(name);
if (!array) return name;
return entry.getState() + array[1];
}
IcProcessor.prototype.processPropertyIC = function (
type, pc, time, line, column, old_state, new_state, map, name, modifier,
slow_reason) {
this[type]++;
let entry = this.profile_.findEntry(pc);
print(
type + ' (' + old_state + '->' + new_state + modifier + ') at ' +
this.formatName(entry) + ':' + line + ':' + column + ' ' + name +
' (map 0x' + map.toString(16) + ')' +
(slow_reason ? ' ' + slow_reason : '') + 'time: ' + time);
}
export class ArgumentsProcessor extends BaseArgumentsProcessor {
getArgsDispatch() {
return {
'--range': ['range', 'auto,auto',
'Specify the range limit as [start],[end]'],
'--source-map': ['sourceMap', null,
'Specify the source map that should be used for output']
};
}
getDefaultResults() {
return {
logFileName: 'v8.log',
range: 'auto,auto',
};
}
}
......@@ -75,10 +75,6 @@ dd, dt {
<dt><a href="./heap-stats/index.html">Heap Stats</a></dt>
<dd>Visualize heap memory usage.</dd>
</div>
<div class="card">
<dt><a href="./ic-explorer.html">IC Explorer</a></dt>
<dd>Analyse inline caches.</dd>
</div>
<div class="card">
<dt><a href="./parse-processor.html">Parse Processor</a></dt>
<dd>Analyse parse, compile and first-execution.</dd>
......
......@@ -101,21 +101,8 @@ class CSSColor {
static get violet() {
return CSSColor.getColor('violet');
}
}
const kColors = [
CSSColor.green,
CSSColor.violet,
CSSColor.orange,
CSSColor.yellow,
CSSColor.primaryColor,
CSSColor.red,
CSSColor.blue,
CSSColor.yellow,
CSSColor.secondaryColor,
];
function typeToColor(type) {
switch (type) {
case 'new':
......@@ -201,5 +188,5 @@ class V8CustomElement extends HTMLElement {
export {
defineCustomElement, V8CustomElement, removeAllChildren,
$, div, kColors, typeToColor, CSSColor
$, div, typeToColor, CSSColor
};
......@@ -6,7 +6,7 @@ import { LogEntry } from './log.mjs';
export class IcLogEntry extends LogEntry {
constructor(
type, fn_file, time, line, column, key, oldState, newState, map, reason,
script, additional) {
script, modifier, additional) {
super(type, time);
this.category = 'other';
if (this.type.indexOf('Store') !== -1) {
......@@ -27,6 +27,7 @@ export class IcLogEntry extends LogEntry {
this.reason = reason;
this.additional = additional;
this.script = script;
this.modifier = modifier;
}
parseMapProperties(parts, offset) {
......
......@@ -2,7 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import { typeToColor } from '../helper.mjs';
import { LogEntry } from './log.mjs';
// ===========================================================================
......@@ -184,10 +183,6 @@ class Edge {
this.to = to;
}
getColor() {
return typeToColor(this.type);
}
finishSetup() {
let from = this.from;
if (from) from.addEdge(this);
......
// 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, defineCustomElement } from "../helper.mjs";
import { V8CustomElement, defineCustomElement, typeToColor } from "../helper.mjs";
import { FocusEvent, SelectionEvent } from "../events.mjs";
defineCustomElement(
......@@ -122,7 +122,7 @@ defineCustomElement(
addTransitionEdge(map) {
let classes = ["transitionEdge"];
let edge = this.div(classes);
edge.style.backgroundColor = map.edge.getColor();
edge.style.backgroundColor = typeToColor(map.edge);
let labelNode = this.div("transitionLabel");
labelNode.innerText = map.edge.toString();
edge.appendChild(labelNode);
......@@ -151,7 +151,7 @@ defineCustomElement(
addMapNode(map) {
let node = this.div("map");
if (map.edge) node.style.backgroundColor = map.edge.getColor();
if (map.edge) node.style.backgroundColor = typeToColor(map.edge);
node.map = map;
node.addEventListener("click", () => this.selectMap(map));
if (map.children.length > 1) {
......
......@@ -240,7 +240,7 @@ export class Processor extends LogReader {
// TODO: Use SourcePosition here directly
let entry = new IcLogEntry(
type, fnName, time, line, column, key, old_state, new_state, map,
slow_reason, script);
slow_reason, script, modifier);
if (script) {
entry.sourcePosition = script.addSourcePosition(line, column, entry);
}
......@@ -352,4 +352,4 @@ export class Processor extends LogReader {
get scripts() {
return this._profile.scripts_.filter(script => script !== undefined);
}
}
\ No newline at end of file
}
......@@ -3,8 +3,7 @@
// found in the LICENSE file.
import {
defineCustomElement, V8CustomElement,
kColors, CSSColor
defineCustomElement, V8CustomElement, CSSColor
} from '../helper.mjs';
import { kChunkWidth, kChunkHeight } from "../log/map.mjs";
import {
......@@ -12,6 +11,19 @@ import {
SynchronizeSelectionEvent
} from '../events.mjs';
const kColors = [
CSSColor.green,
CSSColor.violet,
CSSColor.orange,
CSSColor.yellow,
CSSColor.primaryColor,
CSSColor.red,
CSSColor.blue,
CSSColor.yellow,
CSSColor.secondaryColor,
];
defineCustomElement('./timeline/timeline-track', (templateText) =>
class TimelineTrack extends V8CustomElement {
// TODO turn into static field once Safari supports it.
......
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