Commit c0f72de7 authored by Camillo Bruni's avatar Camillo Bruni Committed by Commit Bot

[tools] Extend optimizations markers

This CL extends the existing optimization markers:

- "~" for interpreted code
- "-" for native context independent code (new)
- "+" for turboprop code (new)
- "*" for turbofan code

Bug: v8:10644
Change-Id: If8940a8c3f32c6f347f61a901be101078df66331
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2567693
Commit-Queue: Camillo Bruni <cbruni@chromium.org>
Reviewed-by: 's avatarJakob Gruber <jgruber@chromium.org>
Cr-Commit-Position: refs/heads/master@{#71541}
parent 5bdb1cec
......@@ -1189,7 +1189,7 @@ void JavaScriptFrame::PrintFunctionAndOffset(JSFunction function,
AbstractCode code, int code_offset,
FILE* file,
bool print_line_number) {
PrintF(file, "%s", CodeKindIsOptimizedJSFunction(code.kind()) ? "*" : "~");
PrintF(file, "%s", CodeKindToMarker(code.kind()));
function.PrintName(file);
PrintF(file, "+%d", code_offset);
if (print_line_number) {
......
......@@ -34,6 +34,7 @@
#include "src/logging/log-inl.h"
#include "src/logging/log-utils.h"
#include "src/objects/api-callbacks.h"
#include "src/objects/code-kind.h"
#include "src/profiler/tick-sample.h"
#include "src/snapshot/embedded/embedded-data.h"
#include "src/strings/string-stream.h"
......@@ -79,17 +80,11 @@ static v8::CodeEventType GetCodeEventTypeForTag(
}
static const char* ComputeMarker(SharedFunctionInfo shared, AbstractCode code) {
// TODO(mythria,jgruber): Use different markers for Turboprop/NCI.
switch (code.kind()) {
case CodeKind::INTERPRETED_FUNCTION:
return shared.optimization_disabled() ? "" : "~";
case CodeKind::TURBOFAN:
case CodeKind::NATIVE_CONTEXT_INDEPENDENT:
case CodeKind::TURBOPROP:
return "*";
default:
return "";
if (shared.optimization_disabled() &&
code.kind() == CodeKind::INTERPRETED_FUNCTION) {
return "";
}
return CodeKindToMarker(code.kind());
}
static const char* ComputeMarker(const wasm::WasmCode* code) {
......
......@@ -18,5 +18,20 @@ const char* CodeKindToString(CodeKind kind) {
UNREACHABLE();
}
const char* CodeKindToMarker(CodeKind kind) {
switch (kind) {
case CodeKind::INTERPRETED_FUNCTION:
return "~";
case CodeKind::NATIVE_CONTEXT_INDEPENDENT:
return "-";
case CodeKind::TURBOPROP:
return "+";
case CodeKind::TURBOFAN:
return "*";
default:
return "";
}
}
} // namespace internal
} // namespace v8
......@@ -47,6 +47,8 @@ static constexpr int kCodeKindCount = CODE_KIND_LIST(V);
const char* CodeKindToString(CodeKind kind);
const char* CodeKindToMarker(CodeKind kind);
inline constexpr bool CodeKindIsInterpretedJSFunction(CodeKind kind) {
return kind == CodeKind::INTERPRETED_FUNCTION;
}
......
......@@ -146,7 +146,8 @@ static std::string GetFunctionNameFromMixedName(const char* str, int length) {
while (str[index++] != ':' && (index < length)) {}
if (str[index] == '*' || str[index] == '~' ) index++;
const char state = str[index];
if (state == '*' || state == '+' || state == '-' || state == '~') index++;
if (index >= length) return std::string();
start_ptr = const_cast<char*>(str + index);
......
......@@ -141,8 +141,29 @@ export class Profile {
*/
static CodeState = {
COMPILED: 0,
OPTIMIZABLE: 1,
OPTIMIZED: 2
IGNITION: 1,
NATIVE_CONTEXT_INDEPENDENT: 2,
TURBOPROP: 3,
TURBOFAN: 4,
}
/**
* Parser for dynamic code optimization state.
*/
static parseState(s) {
switch (s) {
case '':
return this.CodeState.COMPILED;
case '~':
return this.CodeState.IGNITION;
case '-':
return this.CodeState.NATIVE_CONTEXT_INDEPENDENT;
case '=':
return this.CodeState.TURBOPROP;
case '*':
return this.CodeState.TURBOFAN;
}
throw new Error(`unknown code state: ${s}`);
}
/**
......@@ -602,7 +623,7 @@ class DynamicFuncCodeEntry extends CodeEntry {
this.state = state;
}
static STATE_PREFIX = ["", "~", "*"];
static STATE_PREFIX = ["", "~", "-", "+", "*"];
getState() {
return DynamicFuncCodeEntry.STATE_PREFIX[this.state];
}
......
......@@ -174,26 +174,11 @@ export class Processor extends LogReader {
});
}
/**
* Parser for dynamic code optimization state.
*/
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}`);
}
processCodeCreation(type, kind, timestamp, start, size, name, maybe_func) {
let entry;
if (maybe_func.length) {
const funcAddr = parseInt(maybe_func[0]);
const state = this.parseState(maybe_func[1]);
const state = Profile.parseState(maybe_func[1]);
entry = this._profile.addFuncCode(
type, name, timestamp, start, size, funcAddr, state);
} else {
......
......@@ -75,19 +75,6 @@ export function readFile(fileName) {
}
/**
* 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 TickProcessor(
cppEntriesProvider,
separateIc,
......@@ -305,7 +292,7 @@ TickProcessor.prototype.processCodeCreation = function(
type, kind, timestamp, start, size, name, maybe_func) {
if (maybe_func.length) {
const funcAddr = parseInt(maybe_func[0]);
const state = parseState(maybe_func[1]);
const state = Profile.parseState(maybe_func[1]);
this.profile_.addFuncCode(type, name, timestamp, start, size, funcAddr, state);
} else {
this.profile_.addCode(type, name, timestamp, start, size);
......
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