deps: cherry-pick b20faff from upstream V8 · nodejs/node@be569f8 · GitHub
Skip to content

Commit be569f8

Browse files
Matheus Marchinirvagg
authored andcommitted
deps: cherry-pick b20faff from upstream V8
Original commit message: [log] fix ExistingCodeLogger behavior on edge case ExistingCodeLogger was behaving incorrectly when the CodeEventHandler API was used in combination with --interpreted-frames-native-stack. Instead of collecting copied trampolines as InterpretedFunction:functionName, they were being collected as Builtin:IntepreterEntryTrampolines. This patch adds special handling for copied trampolines when using ExistingCodeLogger. R=yangguo@google.com Change-Id: I3ee4be03800122d28d53b51b20c60dcf6263e4c1 Reviewed-on: https://chromium-review.googlesource.com/1087813 Reviewed-by: Yang Guo <yangguo@chromium.org> Commit-Queue: Yang Guo <yangguo@chromium.org> Cr-Commit-Position: refs/heads/master@{#53624} Refs: v8/v8@b20faff Backport-PR-URL: #21668 PR-URL: #21126 Refs: v8/v8@aa6ce3e Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent 6df5feb commit be569f8

4 files changed

Lines changed: 73 additions & 20 deletions

File tree

common.gypi

Lines changed: 1 addition & 1 deletion

deps/v8/src/log.cc

Lines changed: 26 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2012,18 +2012,18 @@ FILE* Logger::TearDown() {
20122012
}
20132013

20142014
void ExistingCodeLogger::LogCodeObject(Object* object) {
2015-
AbstractCode* code_object = AbstractCode::cast(object);
2015+
AbstractCode* abstract_code = AbstractCode::cast(object);
20162016
CodeEventListener::LogEventsAndTags tag = CodeEventListener::STUB_TAG;
20172017
const char* description = "Unknown code from before profiling";
2018-
switch (code_object->kind()) {
2018+
switch (abstract_code->kind()) {
20192019
case AbstractCode::INTERPRETED_FUNCTION:
20202020
case AbstractCode::OPTIMIZED_FUNCTION:
20212021
return; // We log this later using LogCompiledFunctions.
20222022
case AbstractCode::BYTECODE_HANDLER:
20232023
return; // We log it later by walking the dispatch table.
20242024
case AbstractCode::STUB:
20252025
description =
2026-
CodeStub::MajorName(CodeStub::GetMajorKey(code_object->GetCode()));
2026+
CodeStub::MajorName(CodeStub::GetMajorKey(abstract_code->GetCode()));
20272027
if (description == nullptr) description = "A stub from before profiling";
20282028
tag = CodeEventListener::STUB_TAG;
20292029
break;
@@ -2032,8 +2032,13 @@ void ExistingCodeLogger::LogCodeObject(Object* object) {
20322032
tag = CodeEventListener::REG_EXP_TAG;
20332033
break;
20342034
case AbstractCode::BUILTIN:
2035+
if (Code::cast(object)->is_interpreter_trampoline_builtin() &&
2036+
Code::cast(object) ==
2037+
*BUILTIN_CODE(isolate_, InterpreterEntryTrampoline)) {
2038+
return;
2039+
}
20352040
description =
2036-
isolate_->builtins()->name(code_object->GetCode()->builtin_index());
2041+
isolate_->builtins()->name(abstract_code->GetCode()->builtin_index());
20372042
tag = CodeEventListener::BUILTIN_TAG;
20382043
break;
20392044
case AbstractCode::WASM_FUNCTION:
@@ -2059,7 +2064,7 @@ void ExistingCodeLogger::LogCodeObject(Object* object) {
20592064
case AbstractCode::NUMBER_OF_KINDS:
20602065
UNIMPLEMENTED();
20612066
}
2062-
CALL_CODE_EVENT_HANDLER(CodeCreateEvent(tag, code_object, description))
2067+
CALL_CODE_EVENT_HANDLER(CodeCreateEvent(tag, abstract_code, description))
20632068
}
20642069

20652070
void ExistingCodeLogger::LogCodeObjects() {
@@ -2085,6 +2090,12 @@ void ExistingCodeLogger::LogCompiledFunctions() {
20852090
// During iteration, there can be heap allocation due to
20862091
// GetScriptLineNumber call.
20872092
for (int i = 0; i < compiled_funcs_count; ++i) {
2093+
if (sfis[i]->function_data()->IsInterpreterData()) {
2094+
LogExistingFunction(sfis[i],
2095+
Handle<AbstractCode>(AbstractCode::cast(
2096+
sfis[i]->InterpreterTrampoline())),
2097+
CodeEventListener::INTERPRETED_FUNCTION_TAG);
2098+
}
20882099
if (code_objects[i].is_identical_to(BUILTIN_CODE(isolate_, CompileLazy)))
20892100
continue;
20902101
LogExistingFunction(sfis[i], code_objects[i]);
@@ -2129,8 +2140,9 @@ void ExistingCodeLogger::LogBytecodeHandlers() {
21292140
}
21302141
}
21312142

2132-
void ExistingCodeLogger::LogExistingFunction(Handle<SharedFunctionInfo> shared,
2133-
Handle<AbstractCode> code) {
2143+
void ExistingCodeLogger::LogExistingFunction(
2144+
Handle<SharedFunctionInfo> shared, Handle<AbstractCode> code,
2145+
CodeEventListener::LogEventsAndTags tag) {
21342146
if (shared->script()->IsScript()) {
21352147
Handle<Script> script(Script::cast(shared->script()));
21362148
int line_num = Script::GetLineNumber(script, shared->StartPosition()) + 1;
@@ -2140,21 +2152,18 @@ void ExistingCodeLogger::LogExistingFunction(Handle<SharedFunctionInfo> shared,
21402152
Handle<String> script_name(String::cast(script->name()));
21412153
if (line_num > 0) {
21422154
CALL_CODE_EVENT_HANDLER(
2143-
CodeCreateEvent(Logger::ToNativeByScript(
2144-
CodeEventListener::LAZY_COMPILE_TAG, *script),
2145-
*code, *shared, *script_name, line_num, column_num))
2155+
CodeCreateEvent(Logger::ToNativeByScript(tag, *script), *code,
2156+
*shared, *script_name, line_num, column_num))
21462157
} else {
21472158
// Can't distinguish eval and script here, so always use Script.
21482159
CALL_CODE_EVENT_HANDLER(CodeCreateEvent(
21492160
Logger::ToNativeByScript(CodeEventListener::SCRIPT_TAG, *script),
21502161
*code, *shared, *script_name))
21512162
}
21522163
} else {
2153-
CALL_CODE_EVENT_HANDLER(
2154-
CodeCreateEvent(Logger::ToNativeByScript(
2155-
CodeEventListener::LAZY_COMPILE_TAG, *script),
2156-
*code, *shared, isolate_->heap()->empty_string(),
2157-
line_num, column_num))
2164+
CALL_CODE_EVENT_HANDLER(CodeCreateEvent(
2165+
Logger::ToNativeByScript(tag, *script), *code, *shared,
2166+
isolate_->heap()->empty_string(), line_num, column_num))
21582167
}
21592168
} else if (shared->IsApiFunction()) {
21602169
// API function.
@@ -2170,9 +2179,8 @@ void ExistingCodeLogger::LogExistingFunction(Handle<SharedFunctionInfo> shared,
21702179
CALL_CODE_EVENT_HANDLER(CallbackEvent(shared->DebugName(), entry_point))
21712180
}
21722181
} else {
2173-
CALL_CODE_EVENT_HANDLER(CodeCreateEvent(CodeEventListener::LAZY_COMPILE_TAG,
2174-
*code, *shared,
2175-
isolate_->heap()->empty_string()))
2182+
CALL_CODE_EVENT_HANDLER(
2183+
CodeCreateEvent(tag, *code, *shared, isolate_->heap()->empty_string()))
21762184
}
21772185
}
21782186

deps/v8/src/log.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,9 @@ class ExistingCodeLogger {
109109

110110
void LogCompiledFunctions();
111111
void LogExistingFunction(Handle<SharedFunctionInfo> shared,
112-
Handle<AbstractCode> code);
112+
Handle<AbstractCode> code,
113+
CodeEventListener::LogEventsAndTags tag =
114+
CodeEventListener::LAZY_COMPILE_TAG);
113115
void LogCodeObject(Object* object);
114116
void LogBytecodeHandler(interpreter::Bytecode bytecode,
115117
interpreter::OperandScale operand_scale, Code* code);

deps/v8/test/cctest/test-log.cc

Lines changed: 43 additions & 0 deletions

0 commit comments

Comments
 (0)