2017-02-20 09:20:42 +00:00
|
|
|
// 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.
|
|
|
|
|
2020-10-26 18:02:54 +00:00
|
|
|
import { Processor } from "./system-analyzer/processor.mjs";
|
2020-09-28 14:52:35 +00:00
|
|
|
import { WebInspector } from "./sourcemap.mjs";
|
2020-10-26 18:02:54 +00:00
|
|
|
import { BaseArgumentsProcessor } from "./arguments.mjs";
|
2020-09-28 13:50:56 +00:00
|
|
|
|
2017-02-20 09:20:42 +00:00
|
|
|
function processArguments(args) {
|
2020-11-10 11:47:40 +00:00
|
|
|
const processor = new ArgumentsProcessor(args);
|
2017-02-20 09:20:42 +00:00
|
|
|
if (processor.parse()) {
|
|
|
|
return processor.result();
|
|
|
|
} else {
|
|
|
|
processor.printUsageAndExit();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-10-26 18:02:54 +00:00
|
|
|
/**
|
|
|
|
* 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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-02-20 09:20:42 +00:00
|
|
|
function initSourceMapSupport() {
|
2017-10-30 10:46:59 +00:00
|
|
|
// Pull dev tools source maps into our name space.
|
2017-02-20 09:20:42 +00:00
|
|
|
SourceMap = WebInspector.SourceMap;
|
|
|
|
|
|
|
|
// Overwrite the load function to load scripts synchronously.
|
|
|
|
SourceMap.load = function(sourceMapURL) {
|
2020-11-10 11:47:40 +00:00
|
|
|
const content = readFile(sourceMapURL);
|
|
|
|
const sourceMapObject = (JSON.parse(content));
|
2017-02-20 09:20:42 +00:00
|
|
|
return new SourceMap(sourceMapURL, sourceMapObject);
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2020-10-26 18:02:54 +00:00
|
|
|
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;
|
2017-02-20 09:20:42 +00:00
|
|
|
if (params.sourceMap) {
|
|
|
|
initSourceMapSupport();
|
|
|
|
sourceMap = SourceMap.load(params.sourceMap);
|
|
|
|
}
|
2020-10-26 18:02:54 +00:00
|
|
|
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) {
|
2021-01-07 17:53:21 +00:00
|
|
|
print(Object.values(ic));
|
2020-10-26 18:02:54 +00:00
|
|
|
accumulator[ic.type]++;
|
|
|
|
}
|
|
|
|
|
|
|
|
print("========================================");
|
|
|
|
for (const key of Object.keys(accumulator)) {
|
|
|
|
print(key + ": " + accumulator[key]);
|
|
|
|
}
|
|
|
|
|
|
|
|
|