diff --git a/src/execution/frames.cc b/src/execution/frames.cc index ca37910aee..f8343f3893 100644 --- a/src/execution/frames.cc +++ b/src/execution/frames.cc @@ -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) { diff --git a/src/logging/log.cc b/src/logging/log.cc index d86a666b78..9258a56482 100644 --- a/src/logging/log.cc +++ b/src/logging/log.cc @@ -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) { diff --git a/src/objects/code-kind.cc b/src/objects/code-kind.cc index 51f7dd7079..48b28ea11d 100644 --- a/src/objects/code-kind.cc +++ b/src/objects/code-kind.cc @@ -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 diff --git a/src/objects/code-kind.h b/src/objects/code-kind.h index 6314005649..c5ac4c49c6 100644 --- a/src/objects/code-kind.h +++ b/src/objects/code-kind.h @@ -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; } diff --git a/src/third_party/vtune/vtune-jit.cc b/src/third_party/vtune/vtune-jit.cc index 5f901fa4ba..08fbfbfe39 100644 --- a/src/third_party/vtune/vtune-jit.cc +++ b/src/third_party/vtune/vtune-jit.cc @@ -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(str + index); diff --git a/tools/profile.mjs b/tools/profile.mjs index df6e6a266b..7d40bbe87c 100644 --- a/tools/profile.mjs +++ b/tools/profile.mjs @@ -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]; } diff --git a/tools/system-analyzer/processor.mjs b/tools/system-analyzer/processor.mjs index aeff88ea3e..387b98ea98 100644 --- a/tools/system-analyzer/processor.mjs +++ b/tools/system-analyzer/processor.mjs @@ -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 { diff --git a/tools/tickprocessor.mjs b/tools/tickprocessor.mjs index 5b746d943a..1ebbf8c1bf 100644 --- a/tools/tickprocessor.mjs +++ b/tools/tickprocessor.mjs @@ -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);