Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/deps
diff options
context:
space:
mode:
authorMatheus Marchini <matheus@sthima.com>2018-06-11 19:05:33 +0300
committerMichaël Zasso <targos@protonmail.com>2018-07-26 09:34:13 +0300
commit76f4a5e055c1b457b44a6dc1eae4cc759aa679f1 (patch)
tree2885ab408fd01da74c51fe601cb98cb50632c6c3 /deps
parent71fae5e81dc96e5501ddb3e89e4a49c427d89398 (diff)
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: https://github.com/v8/v8/commit/b20faffb07bc97b869a00b935c639bd1c PR-URL: https://github.com/nodejs/node/pull/21126 Refs: https://github.com/v8/v8/commit/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>
Diffstat (limited to 'deps')
-rw-r--r--deps/v8/src/log.cc44
-rw-r--r--deps/v8/src/log.h4
-rw-r--r--deps/v8/test/cctest/test-log.cc43
3 files changed, 72 insertions, 19 deletions
diff --git a/deps/v8/src/log.cc b/deps/v8/src/log.cc
index 20e5f2c9643..8ed6f43ba6b 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>(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<SharedFunctionInfo> shared,
- Handle<AbstractCode> code) {
+void ExistingCodeLogger::LogExistingFunction(
+ Handle<SharedFunctionInfo> shared, Handle<AbstractCode> code,
+ CodeEventListener::LogEventsAndTags tag) {
if (shared->script()->IsScript()) {
Handle<Script> script(Script::cast(shared->script()));
int line_num = Script::GetLineNumber(script, shared->StartPosition()) + 1;
@@ -2140,9 +2152,8 @@ void ExistingCodeLogger::LogExistingFunction(Handle<SharedFunctionInfo> shared,
Handle<String> script_name(String::cast(script->name()));
if (line_num > 0) {
CALL_CODE_EVENT_HANDLER(
- CodeCreateEvent(Logger::ToNativeByScript(
- CodeEventListener::LAZY_COMPILE_TAG, *script),
- *code, *shared, *script_name, line_num, column_num))
+ CodeCreateEvent(Logger::ToNativeByScript(tag, *script), *code,
+ *shared, *script_name, line_num, column_num))
} else {
// Can't distinguish eval and script here, so always use Script.
CALL_CODE_EVENT_HANDLER(CodeCreateEvent(
@@ -2150,11 +2161,9 @@ void ExistingCodeLogger::LogExistingFunction(Handle<SharedFunctionInfo> shared,
*code, *shared, *script_name))
}
} else {
- CALL_CODE_EVENT_HANDLER(
- CodeCreateEvent(Logger::ToNativeByScript(
- CodeEventListener::LAZY_COMPILE_TAG, *script),
- *code, *shared, isolate_->heap()->empty_string(),
- line_num, column_num))
+ CALL_CODE_EVENT_HANDLER(CodeCreateEvent(
+ Logger::ToNativeByScript(tag, *script), *code, *shared,
+ isolate_->heap()->empty_string(), line_num, column_num))
}
} else if (shared->IsApiFunction()) {
// API function.
@@ -2170,9 +2179,8 @@ void ExistingCodeLogger::LogExistingFunction(Handle<SharedFunctionInfo> shared,
CALL_CODE_EVENT_HANDLER(CallbackEvent(shared->DebugName(), entry_point))
}
} else {
- CALL_CODE_EVENT_HANDLER(CodeCreateEvent(CodeEventListener::LAZY_COMPILE_TAG,
- *code, *shared,
- isolate_->heap()->empty_string()))
+ CALL_CODE_EVENT_HANDLER(
+ CodeCreateEvent(tag, *code, *shared, isolate_->heap()->empty_string()))
}
}
diff --git a/deps/v8/src/log.h b/deps/v8/src/log.h
index 738aef4d733..ad254097e66 100644
--- a/deps/v8/src/log.h
+++ b/deps/v8/src/log.h
@@ -109,7 +109,9 @@ class ExistingCodeLogger {
void LogCompiledFunctions();
void LogExistingFunction(Handle<SharedFunctionInfo> shared,
- Handle<AbstractCode> code);
+ Handle<AbstractCode> code,
+ CodeEventListener::LogEventsAndTags tag =
+ CodeEventListener::LAZY_COMPILE_TAG);
void LogCodeObject(Object* object);
void LogBytecodeHandler(interpreter::Bytecode bytecode,
interpreter::OperandScale operand_scale, Code* code);
diff --git a/deps/v8/test/cctest/test-log.cc b/deps/v8/test/cctest/test-log.cc
index 97071a63f58..c7864034c96 100644
--- a/deps/v8/test/cctest/test-log.cc
+++ b/deps/v8/test/cctest/test-log.cc
@@ -875,6 +875,49 @@ TEST(ExternalCodeEventListener) {
isolate->Dispose();
}
+TEST(ExternalCodeEventListenerWithInterpretedFramesNativeStack) {
+ i::FLAG_log = false;
+ i::FLAG_prof = false;
+ i::FLAG_interpreted_frames_native_stack = true;
+
+ v8::Isolate::CreateParams create_params;
+ create_params.array_buffer_allocator = CcTest::array_buffer_allocator();
+ v8::Isolate* isolate = v8::Isolate::New(create_params);
+
+ {
+ v8::HandleScope scope(isolate);
+ v8::Isolate::Scope isolate_scope(isolate);
+ v8::Local<v8::Context> context = v8::Context::New(isolate);
+ context->Enter();
+
+ TestCodeEventHandler code_event_handler(isolate);
+
+ const char* source_text_before_start =
+ "function testCodeEventListenerBeforeStart(a,b) { return a + b };"
+ "testCodeEventListenerBeforeStart('1', 1);";
+ CompileRun(source_text_before_start);
+
+ CHECK_NULL(code_event_handler.FindLine("InterpretedFunction",
+ "testCodeEventListenerBeforeStart"));
+
+ code_event_handler.Enable();
+
+ CHECK_NOT_NULL(code_event_handler.FindLine(
+ "InterpretedFunction", "testCodeEventListenerBeforeStart"));
+
+ const char* source_text_after_start =
+ "function testCodeEventListenerAfterStart(a,b) { return a + b };"
+ "testCodeEventListenerAfterStart('1', 1);";
+ CompileRun(source_text_after_start);
+
+ CHECK_NOT_NULL(code_event_handler.FindLine(
+ "InterpretedFunction", "testCodeEventListenerAfterStart"));
+
+ context->Exit();
+ }
+ isolate->Dispose();
+}
+
TEST(TraceMaps) {
SETUP_FLAGS();
i::FLAG_trace_maps = true;