Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 37a5c8c

Browse filesBrowse files
Matheus Marchinitargos
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 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 4663d1c commit 37a5c8c
Copy full SHA for 37a5c8c

File tree

Expand file treeCollapse file tree

4 files changed

+73
-20
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

4 files changed

+73
-20
lines changed
Open diff view settings
Collapse file

‎common.gypi‎

Copy file name to clipboardExpand all lines: common.gypi
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727

2828
# Reset this number to 0 on major V8 upgrades.
2929
# Increment by one for each non-official patch applied to deps/v8.
30-
'v8_embedder_string': '-node.10',
30+
'v8_embedder_string': '-node.11',
3131

3232
# Enable disassembler for `--print-code` v8 options
3333
'v8_enable_disassembler': 1,
Collapse file

‎deps/v8/src/log.cc‎

Copy file name to clipboardExpand all lines: deps/v8/src/log.cc
+26-18Lines changed: 26 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2031,18 +2031,18 @@ FILE* Logger::TearDown() {
20312031
}
20322032

20332033
void ExistingCodeLogger::LogCodeObject(Object* object) {
2034-
AbstractCode* code_object = AbstractCode::cast(object);
2034+
AbstractCode* abstract_code = AbstractCode::cast(object);
20352035
CodeEventListener::LogEventsAndTags tag = CodeEventListener::STUB_TAG;
20362036
const char* description = "Unknown code from before profiling";
2037-
switch (code_object->kind()) {
2037+
switch (abstract_code->kind()) {
20382038
case AbstractCode::INTERPRETED_FUNCTION:
20392039
case AbstractCode::OPTIMIZED_FUNCTION:
20402040
return; // We log this later using LogCompiledFunctions.
20412041
case AbstractCode::BYTECODE_HANDLER:
20422042
return; // We log it later by walking the dispatch table.
20432043
case AbstractCode::STUB:
20442044
description =
2045-
CodeStub::MajorName(CodeStub::GetMajorKey(code_object->GetCode()));
2045+
CodeStub::MajorName(CodeStub::GetMajorKey(abstract_code->GetCode()));
20462046
if (description == nullptr) description = "A stub from before profiling";
20472047
tag = CodeEventListener::STUB_TAG;
20482048
break;
@@ -2051,8 +2051,13 @@ void ExistingCodeLogger::LogCodeObject(Object* object) {
20512051
tag = CodeEventListener::REG_EXP_TAG;
20522052
break;
20532053
case AbstractCode::BUILTIN:
2054+
if (Code::cast(object)->is_interpreter_trampoline_builtin() &&
2055+
Code::cast(object) ==
2056+
*BUILTIN_CODE(isolate_, InterpreterEntryTrampoline)) {
2057+
return;
2058+
}
20542059
description =
2055-
isolate_->builtins()->name(code_object->GetCode()->builtin_index());
2060+
isolate_->builtins()->name(abstract_code->GetCode()->builtin_index());
20562061
tag = CodeEventListener::BUILTIN_TAG;
20572062
break;
20582063
case AbstractCode::WASM_FUNCTION:
@@ -2078,7 +2083,7 @@ void ExistingCodeLogger::LogCodeObject(Object* object) {
20782083
case AbstractCode::NUMBER_OF_KINDS:
20792084
UNIMPLEMENTED();
20802085
}
2081-
CALL_CODE_EVENT_HANDLER(CodeCreateEvent(tag, code_object, description))
2086+
CALL_CODE_EVENT_HANDLER(CodeCreateEvent(tag, abstract_code, description))
20822087
}
20832088

20842089
void ExistingCodeLogger::LogCodeObjects() {
@@ -2104,6 +2109,12 @@ void ExistingCodeLogger::LogCompiledFunctions() {
21042109
// During iteration, there can be heap allocation due to
21052110
// GetScriptLineNumber call.
21062111
for (int i = 0; i < compiled_funcs_count; ++i) {
2112+
if (sfis[i]->function_data()->IsInterpreterData()) {
2113+
LogExistingFunction(sfis[i],
2114+
Handle<AbstractCode>(AbstractCode::cast(
2115+
sfis[i]->InterpreterTrampoline())),
2116+
CodeEventListener::INTERPRETED_FUNCTION_TAG);
2117+
}
21072118
if (code_objects[i].is_identical_to(BUILTIN_CODE(isolate_, CompileLazy)))
21082119
continue;
21092120
LogExistingFunction(sfis[i], code_objects[i]);
@@ -2148,8 +2159,9 @@ void ExistingCodeLogger::LogBytecodeHandlers() {
21482159
}
21492160
}
21502161

2151-
void ExistingCodeLogger::LogExistingFunction(Handle<SharedFunctionInfo> shared,
2152-
Handle<AbstractCode> code) {
2162+
void ExistingCodeLogger::LogExistingFunction(
2163+
Handle<SharedFunctionInfo> shared, Handle<AbstractCode> code,
2164+
CodeEventListener::LogEventsAndTags tag) {
21532165
if (shared->script()->IsScript()) {
21542166
Handle<Script> script(Script::cast(shared->script()));
21552167
int line_num = Script::GetLineNumber(script, shared->StartPosition()) + 1;
@@ -2159,21 +2171,18 @@ void ExistingCodeLogger::LogExistingFunction(Handle<SharedFunctionInfo> shared,
21592171
Handle<String> script_name(String::cast(script->name()));
21602172
if (line_num > 0) {
21612173
CALL_CODE_EVENT_HANDLER(
2162-
CodeCreateEvent(Logger::ToNativeByScript(
2163-
CodeEventListener::LAZY_COMPILE_TAG, *script),
2164-
*code, *shared, *script_name, line_num, column_num))
2174+
CodeCreateEvent(Logger::ToNativeByScript(tag, *script), *code,
2175+
*shared, *script_name, line_num, column_num))
21652176
} else {
21662177
// Can't distinguish eval and script here, so always use Script.
21672178
CALL_CODE_EVENT_HANDLER(CodeCreateEvent(
21682179
Logger::ToNativeByScript(CodeEventListener::SCRIPT_TAG, *script),
21692180
*code, *shared, *script_name))
21702181
}
21712182
} else {
2172-
CALL_CODE_EVENT_HANDLER(
2173-
CodeCreateEvent(Logger::ToNativeByScript(
2174-
CodeEventListener::LAZY_COMPILE_TAG, *script),
2175-
*code, *shared, isolate_->heap()->empty_string(),
2176-
line_num, column_num))
2183+
CALL_CODE_EVENT_HANDLER(CodeCreateEvent(
2184+
Logger::ToNativeByScript(tag, *script), *code, *shared,
2185+
isolate_->heap()->empty_string(), line_num, column_num))
21772186
}
21782187
} else if (shared->IsApiFunction()) {
21792188
// API function.
@@ -2189,9 +2198,8 @@ void ExistingCodeLogger::LogExistingFunction(Handle<SharedFunctionInfo> shared,
21892198
CALL_CODE_EVENT_HANDLER(CallbackEvent(shared->DebugName(), entry_point))
21902199
}
21912200
} else {
2192-
CALL_CODE_EVENT_HANDLER(CodeCreateEvent(CodeEventListener::LAZY_COMPILE_TAG,
2193-
*code, *shared,
2194-
isolate_->heap()->empty_string()))
2201+
CALL_CODE_EVENT_HANDLER(
2202+
CodeCreateEvent(tag, *code, *shared, isolate_->heap()->empty_string()))
21952203
}
21962204
}
21972205

Collapse file

‎deps/v8/src/log.h‎

Copy file name to clipboardExpand all lines: deps/v8/src/log.h
+3-1Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,9 @@ class ExistingCodeLogger {
105105

106106
void LogCompiledFunctions();
107107
void LogExistingFunction(Handle<SharedFunctionInfo> shared,
108-
Handle<AbstractCode> code);
108+
Handle<AbstractCode> code,
109+
CodeEventListener::LogEventsAndTags tag =
110+
CodeEventListener::LAZY_COMPILE_TAG);
109111
void LogCodeObject(Object* object);
110112
void LogBytecodeHandler(interpreter::Bytecode bytecode,
111113
interpreter::OperandScale operand_scale, Code* code);
Collapse file

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

Copy file name to clipboardExpand all lines: deps/v8/test/cctest/test-log.cc
+43Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -876,6 +876,49 @@ TEST(ExternalCodeEventListener) {
876876
isolate->Dispose();
877877
}
878878

879+
TEST(ExternalCodeEventListenerWithInterpretedFramesNativeStack) {
880+
i::FLAG_log = false;
881+
i::FLAG_prof = false;
882+
i::FLAG_interpreted_frames_native_stack = true;
883+
884+
v8::Isolate::CreateParams create_params;
885+
create_params.array_buffer_allocator = CcTest::array_buffer_allocator();
886+
v8::Isolate* isolate = v8::Isolate::New(create_params);
887+
888+
{
889+
v8::HandleScope scope(isolate);
890+
v8::Isolate::Scope isolate_scope(isolate);
891+
v8::Local<v8::Context> context = v8::Context::New(isolate);
892+
context->Enter();
893+
894+
TestCodeEventHandler code_event_handler(isolate);
895+
896+
const char* source_text_before_start =
897+
"function testCodeEventListenerBeforeStart(a,b) { return a + b };"
898+
"testCodeEventListenerBeforeStart('1', 1);";
899+
CompileRun(source_text_before_start);
900+
901+
CHECK_NULL(code_event_handler.FindLine("InterpretedFunction",
902+
"testCodeEventListenerBeforeStart"));
903+
904+
code_event_handler.Enable();
905+
906+
CHECK_NOT_NULL(code_event_handler.FindLine(
907+
"InterpretedFunction", "testCodeEventListenerBeforeStart"));
908+
909+
const char* source_text_after_start =
910+
"function testCodeEventListenerAfterStart(a,b) { return a + b };"
911+
"testCodeEventListenerAfterStart('1', 1);";
912+
CompileRun(source_text_after_start);
913+
914+
CHECK_NOT_NULL(code_event_handler.FindLine(
915+
"InterpretedFunction", "testCodeEventListenerAfterStart"));
916+
917+
context->Exit();
918+
}
919+
isolate->Dispose();
920+
}
921+
879922
TEST(TraceMaps) {
880923
SETUP_FLAGS();
881924
i::FLAG_trace_maps = true;

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.