v8/tools/ic-processor-driver.mjs
Camillo Bruni 2668907759 [tools] Fix profview for sparkplug
- Handle sparkplug code
- Handle regexp code-creation events in the tick-processor, which
  have no valid state marker in the maybe_func data
- Remove calls to print() that break the tick-processor web version

Change-Id: Ic726d1ae3a41cd46f42cf5498e8463564d3b6b83
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2784562
Reviewed-by: Camillo Bruni <cbruni@chromium.org>
Reviewed-by: Patrick Thier <pthier@chromium.org>
Commit-Queue: Camillo Bruni <cbruni@chromium.org>
Cr-Commit-Position: refs/heads/master@{#73631}
2021-03-24 13:22:21 +00:00

91 lines
2.3 KiB
JavaScript

// 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 { Processor } from "./system-analyzer/processor.mjs";
import { WebInspector } from "./sourcemap.mjs";
import { BaseArgumentsProcessor } from "./arguments.mjs";
function processArguments(args) {
const processor = new ArgumentsProcessor(args);
if (processor.parse()) {
return processor.result();
} else {
processor.printUsageAndExit();
}
}
/**
* A thin wrapper around shell's 'read' function showing a file name on error.
*/
export function readFile(fileName) {
try {
return read(fileName);
} catch (e) {
console.log(fileName + ': ' + (e.message || e));
throw e;
}
}
function initSourceMapSupport() {
// Pull dev tools source maps into our name space.
SourceMap = WebInspector.SourceMap;
// Overwrite the load function to load scripts synchronously.
SourceMap.load = function(sourceMapURL) {
const content = readFile(sourceMapURL);
const sourceMapObject = (JSON.parse(content));
return new SourceMap(sourceMapURL, sourceMapObject);
};
}
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);
}
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) {
console.log(Object.values(ic));
accumulator[ic.type]++;
}
console.log("========================================");
for (const key of Object.keys(accumulator)) {
console.log(key + ": " + accumulator[key]);
}