Commit aac25548 authored by Mythri A's avatar Mythri A Committed by Commit Bot

[tools,turboprop] Extend profview to show turboprop information

This cl extends profview to
1. Show Turboprop ticks in a different color in timeline panel
2. In summary panel, show Turboprop optimizations and TurboFan
optimizations as two different entries
3. Fix deopts in summary panel after the rename to deopts
4. Also show information about bailouts (happen only with Turboprop)

Bug: v8:9684
Change-Id: I028b12a55741c789ecc1d212d1517a57496379dc
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2573477
Commit-Queue: Mythri Alle <mythria@chromium.org>
Reviewed-by: 's avatarRoss McIlroy <rmcilroy@chromium.org>
Reviewed-by: 's avatarCamillo Bruni <cbruni@chromium.org>
Cr-Commit-Position: refs/heads/master@{#71638}
parent 51401b4b
......@@ -190,6 +190,21 @@ export class Profile {
throw new Error(`unknown code state: ${s}`);
}
static getKindFromState(state) {
if (state === this.CodeState.COMPILED) {
return "Builtin";
} else if (state === this.CodeState.IGNITION) {
return "Unopt";
} else if (state === this.CodeState.NATIVE_CONTEXT_INDEPENDENT) {
return "NCI";
} else if (state === this.CodeState.TURBOPROP) {
return "Turboprop";
} else if (state === this.CodeState.TURBOFAN) {
return "Opt";
}
throw new Error(`unknown code state: ${state}`);
}
/**
* Called whenever the specified operation has failed finding a function
* containing the specified address. Should be overriden by subclasses.
......@@ -1072,13 +1087,7 @@ JsonProfile.prototype.addFuncCode = function (
this.functionEntries_[func.funcId].codes.push(entry.codeId);
if (state === 0) {
kind = "Builtin";
} else if (state === 1) {
kind = "Unopt";
} else if (state === 2) {
kind = "Opt";
}
kind = Profile.getKindFromState(state);
this.codeEntries_.push({
name: entry.name,
......
......@@ -19,7 +19,9 @@ let codeKinds = [
"BUILTIN",
"REGEXP",
"JSOPT",
"JSUNOPT"
"JSUNOPT",
"JSNCI",
"JSTURBOPROP"
];
function resolveCodeKind(code) {
......@@ -55,6 +57,10 @@ function resolveCodeKind(code) {
return "JSOPT";
} else if (code.kind === "Unopt") {
return "JSUNOPT";
} else if (code.kind === "NCI") {
return "JSNCI";
} else if (code.kind === "Turboprop") {
return "JSTURBOPROP";
}
}
console.log("Unknown code type '" + type + "'.");
......@@ -264,6 +270,8 @@ function buildCategoryTreeAndLookup() {
root.children.push(n);
}
addCategory("JS Optimized", [ "JSOPT" ]);
addCategory("JS NCI", [ "JSNCI" ]);
addCategory("JS Turboprop", [ "JSTURBOPROP" ]);
addCategory("JS Unoptimized", [ "JSUNOPT", "BC" ]);
addCategory("IC", [ "IC" ]);
addCategory("RegExp", [ "REGEXP" ]);
......@@ -526,11 +534,15 @@ function computeOptimizationStats(file,
let functionCount = 0;
let optimizedFunctionCount = 0;
let turbopropOptimizedFunctionCount = 0;
let deoptimizedFunctionCount = 0;
let optimizations = newCollection();
let turbopropOptimizations = newCollection();
let eagerDeoptimizations = newCollection();
let softDeoptimizations = newCollection();
let lazyDeoptimizations = newCollection();
let softBailouts = newCollection();
let eagerBailouts = newCollection();
for (let i = 0; i < file.functions.length; i++) {
let f = file.functions[i];
......@@ -541,6 +553,7 @@ function computeOptimizationStats(file,
functionCount++;
let optimized = false;
let turboprop_optimized = false;
let deoptimized = false;
for (let j = 0; j < f.codes.length; j++) {
......@@ -552,19 +565,33 @@ function computeOptimizationStats(file,
addToCollection(optimizations, code);
}
}
if (code.kind === "Turboprop") {
turboprop_optimized = true;
if (code.tm >= timeStart && code.tm <= timeEnd) {
addToCollection(turbopropOptimizations, code);
}
}
if (code.deopt) {
if (code.deopt.bailoutType === "deopt-lazy" || code.deopt.bailoutType === "deopt-eager" || code.deopt.bailoutType === "deopt-lazy") {
deoptimized = true;
}
if (code.deopt.tm >= timeStart && code.deopt.tm <= timeEnd) {
switch (code.deopt.bailoutType) {
case "lazy":
case "deopt-lazy":
addToCollection(lazyDeoptimizations, code);
break;
case "eager":
case "deopt-eager":
addToCollection(eagerDeoptimizations, code);
break;
case "soft":
case "deopt-soft":
addToCollection(softDeoptimizations, code);
break;
case "bailout-soft":
addToCollection(softBailouts, code);
break;
case "bailout":
addToCollection(eagerBailouts, code);
break;
}
}
}
......@@ -572,6 +599,9 @@ function computeOptimizationStats(file,
if (optimized) {
optimizedFunctionCount++;
}
if (turboprop_optimized) {
turbopropOptimizedFunctionCount++;
}
if (deoptimized) {
deoptimizedFunctionCount++;
}
......@@ -586,15 +616,20 @@ function computeOptimizationStats(file,
sortCollection(lazyDeoptimizations);
sortCollection(softDeoptimizations);
sortCollection(optimizations);
sortCollection(turbopropOptimizations);
return {
functionCount,
optimizedFunctionCount,
turbopropOptimizedFunctionCount,
deoptimizedFunctionCount,
optimizations,
turbopropOptimizations,
eagerDeoptimizations,
lazyDeoptimizations,
softDeoptimizations,
softBailouts,
eagerBailouts,
};
}
......
......@@ -216,6 +216,14 @@ const bucketDescriptors =
color : "#64dd17",
backgroundColor : "#80e27e",
text : "JS Optimized" },
{ kinds : [ "JSNCI" ],
color : "#3289a8",
backgroundColor : "#3289a8",
text : "JS NCI" },
{ kinds : [ "JSTURBOPROP" ],
color : "#693eb8",
backgroundColor : "#a6c452",
text : "JS Turboprop" },
{ kinds : [ "JSUNOPT", "BC" ],
color : "#dd2c00",
backgroundColor : "#ff9e80",
......@@ -308,6 +316,10 @@ function codeTypeToText(type) {
return "RegExp";
case "JSOPT":
return "JS opt";
case "JSNCI":
return "JS NCI";
case "JSTURBOPROP":
return "JS Turboprop";
case "JSUNOPT":
return "JS unopt";
}
......@@ -1275,15 +1287,27 @@ class SummaryView {
addRow("Total function count:", stats.functionCount);
addRow("Optimized function count:", stats.optimizedFunctionCount, 1);
if (stats.turbopropOptimizedFunctionCount != 0) {
addRow("Turboprop optimized function count:", stats.turbopropOptimizedFunctionCount, 1);
}
addRow("Deoptimized function count:", stats.deoptimizedFunctionCount, 2);
addExpandableRow("Optimization count:", stats.optimizations, 0, "opt");
if (stats.turbopropOptimizedFunctionCount != 0) {
addExpandableRow("Turboprop Optimization count:", stats.turbopropOptimizations, 0, "tp");
}
let deoptCount = stats.eagerDeoptimizations.count +
stats.softDeoptimizations.count + stats.lazyDeoptimizations.count;
addRow("Deoptimization count:", deoptCount);
addExpandableRow("Eager:", stats.eagerDeoptimizations, 1, "eager");
addExpandableRow("Lazy:", stats.lazyDeoptimizations, 1, "lazy");
addExpandableRow("Soft:", stats.softDeoptimizations, 1, "soft");
if (stats.softBailouts.count != 0) {
addExpandableRow("SoftBailout:", stats.softBailouts, 1, "softbailout");
}
if (stats.eagerBailouts.count != 0) {
addExpandableRow("EagerBailout:", stats.eagerBailouts, 1, "eagerbailout");
}
table.appendChild(rows);
this.element.appendChild(table);
......@@ -1369,6 +1393,7 @@ class SourceData {
for (let i = 0; i < file.scripts.length; i++) {
const scriptBlock = file.scripts[i];
if (scriptBlock === null) continue; // Array may be sparse.
if (scriptBlock.source === undefined) continue;
let source = scriptBlock.source.split("\n");
this.scripts.set(i, source);
}
......
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