From be569f82f10a1d4b08e5a2bb23e99ea93504b964 Mon Sep 17 00:00:00 2001 From: Matheus Marchini Date: Mon, 11 Jun 2018 09:05:33 -0700 Subject: [PATCH] deps: cherry-pick b20faff from upstream V8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Commit-Queue: Yang Guo Cr-Commit-Position: refs/heads/master@{#53624} Refs: https://github.com/v8/v8/commit/b20faffb07bc97b869a00b935c639bd1c Backport-PR-URL: https://github.com/nodejs/node/pull/21668 PR-URL: https://github.com/nodejs/node/pull/21126 Refs: https://github.com/v8/v8/commit/aa6ce3e Reviewed-By: Michaƫl Zasso Reviewed-By: Michael Dawson Reviewed-By: James M Snell --- common.gypi | 2 +- deps/v8/src/log.cc | 44 +++++++++++++++++++-------------- deps/v8/src/log.h | 4 ++- deps/v8/test/cctest/test-log.cc | 43 ++++++++++++++++++++++++++++++++ 4 files changed, 73 insertions(+), 20 deletions(-) diff --git a/common.gypi b/common.gypi index e40158ec57caaf..6740a8ab8c912a 100644 --- a/common.gypi +++ b/common.gypi @@ -29,7 +29,7 @@ # Reset this number to 0 on major V8 upgrades. # Increment by one for each non-official patch applied to deps/v8. - 'v8_embedder_string': '-node.3', + 'v8_embedder_string': '-node.4', # Enable disassembler for `--print-code` v8 options 'v8_enable_disassembler': 1, diff --git a/deps/v8/src/log.cc b/deps/v8/src/log.cc index 20e5f2c9643cf4..8ed6f43ba6b34f 100644 --- a/deps/v8/src/log.cc +++ b/deps/v8/src/log.cc @@ -2012,10 +2012,10 @@ FILE* Logger::TearDown() { } void ExistingCodeLogger::LogCodeObject(Object* object) { - AbstractCode* code_object = AbstractCode::cast(object); + AbstractCode* abstract_code = AbstractCode::cast(object); CodeEventListener::LogEventsAndTags tag = CodeEventListener::STUB_TAG; const char* description = "Unknown code from before profiling"; - switch (code_object->kind()) { + switch (abstract_code->kind()) { case AbstractCode::INTERPRETED_FUNCTION: case AbstractCode::OPTIMIZED_FUNCTION: return; // We log this later using LogCompiledFunctions. @@ -2023,7 +2023,7 @@ void ExistingCodeLogger::LogCodeObject(Object* object) { return; // We log it later by walking the dispatch table. case AbstractCode::STUB: description = - CodeStub::MajorName(CodeStub::GetMajorKey(code_object->GetCode())); + CodeStub::MajorName(CodeStub::GetMajorKey(abstract_code->GetCode())); if (description == nullptr) description = "A stub from before profiling"; tag = CodeEventListener::STUB_TAG; break; @@ -2032,8 +2032,13 @@ void ExistingCodeLogger::LogCodeObject(Object* object) { tag = CodeEventListener::REG_EXP_TAG; break; case AbstractCode::BUILTIN: + if (Code::cast(object)->is_interpreter_trampoline_builtin() && + Code::cast(object) == + *BUILTIN_CODE(isolate_, InterpreterEntryTrampoline)) { + return; + } description = - isolate_->builtins()->name(code_object->GetCode()->builtin_index()); + isolate_->builtins()->name(abstract_code->GetCode()->builtin_index()); tag = CodeEventListener::BUILTIN_TAG; break; case AbstractCode::WASM_FUNCTION: @@ -2059,7 +2064,7 @@ void ExistingCodeLogger::LogCodeObject(Object* object) { case AbstractCode::NUMBER_OF_KINDS: UNIMPLEMENTED(); } - CALL_CODE_EVENT_HANDLER(CodeCreateEvent(tag, code_object, description)) + CALL_CODE_EVENT_HANDLER(CodeCreateEvent(tag, abstract_code, description)) } void ExistingCodeLogger::LogCodeObjects() { @@ -2085,6 +2090,12 @@ void ExistingCodeLogger::LogCompiledFunctions() { // During iteration, there can be heap allocation due to // GetScriptLineNumber call. for (int i = 0; i < compiled_funcs_count; ++i) { + if (sfis[i]->function_data()->IsInterpreterData()) { + LogExistingFunction(sfis[i], + Handle(AbstractCode::cast( + sfis[i]->InterpreterTrampoline())), + CodeEventListener::INTERPRETED_FUNCTION_TAG); + } if (code_objects[i].is_identical_to(BUILTIN_CODE(isolate_, CompileLazy))) continue; LogExistingFunction(sfis[i], code_objects[i]); @@ -2129,8 +2140,9 @@ void ExistingCodeLogger::LogBytecodeHandlers() { } } -void ExistingCodeLogger::LogExistingFunction(Handle shared, - Handle code) { +void ExistingCodeLogger::LogExistingFunction( + Handle shared, Handle code, + CodeEventListener::LogEventsAndTags tag) { if (shared->script()->IsScript()) { Handle