mirror of
https://github.com/zebrajr/node.git
synced 2026-01-15 12:15:26 +00:00
deps: cherry-pick acc336c from upstream V8
Original commit message:
[log] fix boolean logic on LogCodeObject
R=yangguo@google.com
Change-Id: Icb4825344991e5b2d15050e037064c60eeb9617e
Reviewed-on: https://chromium-review.googlesource.com/1097578
Reviewed-by: Benedikt Meurer <bmeurer@chromium.org>
Reviewed-by: Yang Guo <yangguo@chromium.org>
Commit-Queue: Benedikt Meurer <bmeurer@chromium.org>
Cr-Commit-Position: refs/heads/master@{#53777}
Refs: https://github.com/v8/v8/commit/acc336c1257cc7ceee4b31094ee1e9e41
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>
This commit is contained in:
committed by
Michaël Zasso
parent
76f4a5e055
commit
d15db8257c
@@ -28,7 +28,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.4',
|
||||
'v8_embedder_string': '-node.5',
|
||||
|
||||
# Enable disassembler for `--print-code` v8 options
|
||||
'v8_enable_disassembler': 1,
|
||||
|
||||
2
deps/v8/src/log.cc
vendored
2
deps/v8/src/log.cc
vendored
@@ -2033,7 +2033,7 @@ void ExistingCodeLogger::LogCodeObject(Object* object) {
|
||||
break;
|
||||
case AbstractCode::BUILTIN:
|
||||
if (Code::cast(object)->is_interpreter_trampoline_builtin() &&
|
||||
Code::cast(object) ==
|
||||
Code::cast(object) !=
|
||||
*BUILTIN_CODE(isolate_, InterpreterEntryTrampoline)) {
|
||||
return;
|
||||
}
|
||||
|
||||
84
deps/v8/test/cctest/test-log.cc
vendored
84
deps/v8/test/cctest/test-log.cc
vendored
@@ -36,6 +36,9 @@
|
||||
|
||||
#include <unordered_set>
|
||||
#include <vector>
|
||||
// The C++ style guide recommends using <re2> instead of <regex>. However, the
|
||||
// former isn't available in V8.
|
||||
#include <regex> // NOLINT(build/c++11)
|
||||
#include "src/api.h"
|
||||
#include "src/log-utils.h"
|
||||
#include "src/log.h"
|
||||
@@ -257,30 +260,41 @@ class TestCodeEventHandler : public v8::CodeEventHandler {
|
||||
explicit TestCodeEventHandler(v8::Isolate* isolate)
|
||||
: v8::CodeEventHandler(isolate) {}
|
||||
|
||||
const char* FindLine(const char* prefix, const char* suffix = nullptr,
|
||||
const char* start = nullptr) {
|
||||
if (!log_.length()) return NULL;
|
||||
const char* c_log = log_.c_str();
|
||||
if (start == nullptr) start = c_log;
|
||||
const char* end = c_log + log_.length();
|
||||
return FindLogLine(start, end, prefix, suffix);
|
||||
size_t CountLines(std::string prefix, std::string suffix = std::string()) {
|
||||
if (!log_.length()) return 0;
|
||||
|
||||
std::regex expression("(^|\\n)" + prefix + ".*" + suffix + "(?=\\n|$)");
|
||||
|
||||
size_t match_count(std::distance(
|
||||
std::sregex_iterator(log_.begin(), log_.end(), expression),
|
||||
std::sregex_iterator()));
|
||||
|
||||
return match_count;
|
||||
}
|
||||
|
||||
void Handle(v8::CodeEvent* code_event) override {
|
||||
const char* code_type =
|
||||
v8::CodeEvent::GetCodeEventTypeName(code_event->GetCodeType());
|
||||
char function_name[1000];
|
||||
strncpy(function_name, code_type, 1000);
|
||||
function_name[strlen(code_type)] = ' ';
|
||||
code_event->GetFunctionName()->WriteUtf8(
|
||||
function_name + strlen(code_type) + 1, 1000);
|
||||
function_name[strlen(function_name) + 1] = '\0';
|
||||
function_name[strlen(function_name)] = '\n';
|
||||
|
||||
log_ += std::string(function_name);
|
||||
std::string log_line = "";
|
||||
log_line += v8::CodeEvent::GetCodeEventTypeName(code_event->GetCodeType());
|
||||
log_line += " ";
|
||||
log_line += FormatName(code_event);
|
||||
log_line += "\n";
|
||||
log_ += log_line;
|
||||
}
|
||||
|
||||
private:
|
||||
std::string FormatName(v8::CodeEvent* code_event) {
|
||||
std::string name = std::string(code_event->GetComment());
|
||||
if (name.empty()) {
|
||||
v8::Local<v8::String> functionName = code_event->GetFunctionName();
|
||||
std::string buffer(functionName->Utf8Length() + 1, 0);
|
||||
functionName->WriteUtf8(&buffer[0], functionName->Utf8Length() + 1);
|
||||
// Sanitize name, removing unwanted \0 resulted from WriteUtf8
|
||||
name = std::string(buffer.c_str());
|
||||
}
|
||||
|
||||
return name;
|
||||
}
|
||||
|
||||
std::string log_;
|
||||
};
|
||||
|
||||
@@ -854,21 +868,24 @@ TEST(ExternalCodeEventListener) {
|
||||
"testCodeEventListenerBeforeStart('1', 1);";
|
||||
CompileRun(source_text_before_start);
|
||||
|
||||
CHECK_NULL(code_event_handler.FindLine("LazyCompile",
|
||||
"testCodeEventListenerBeforeStart"));
|
||||
CHECK_EQ(code_event_handler.CountLines("LazyCompile",
|
||||
"testCodeEventListenerBeforeStart"),
|
||||
0);
|
||||
|
||||
code_event_handler.Enable();
|
||||
|
||||
CHECK_NOT_NULL(code_event_handler.FindLine(
|
||||
"LazyCompile", "testCodeEventListenerBeforeStart"));
|
||||
CHECK_GE(code_event_handler.CountLines("LazyCompile",
|
||||
"testCodeEventListenerBeforeStart"),
|
||||
1);
|
||||
|
||||
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(
|
||||
"LazyCompile", "testCodeEventListenerAfterStart"));
|
||||
CHECK_GE(code_event_handler.CountLines("LazyCompile",
|
||||
"testCodeEventListenerAfterStart"),
|
||||
1);
|
||||
|
||||
context->Exit();
|
||||
}
|
||||
@@ -897,21 +914,28 @@ TEST(ExternalCodeEventListenerWithInterpretedFramesNativeStack) {
|
||||
"testCodeEventListenerBeforeStart('1', 1);";
|
||||
CompileRun(source_text_before_start);
|
||||
|
||||
CHECK_NULL(code_event_handler.FindLine("InterpretedFunction",
|
||||
"testCodeEventListenerBeforeStart"));
|
||||
CHECK_EQ(code_event_handler.CountLines("InterpretedFunction",
|
||||
"testCodeEventListenerBeforeStart"),
|
||||
0);
|
||||
|
||||
code_event_handler.Enable();
|
||||
|
||||
CHECK_NOT_NULL(code_event_handler.FindLine(
|
||||
"InterpretedFunction", "testCodeEventListenerBeforeStart"));
|
||||
CHECK_GE(code_event_handler.CountLines("InterpretedFunction",
|
||||
"testCodeEventListenerBeforeStart"),
|
||||
1);
|
||||
|
||||
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"));
|
||||
CHECK_GE(code_event_handler.CountLines("InterpretedFunction",
|
||||
"testCodeEventListenerAfterStart"),
|
||||
1);
|
||||
|
||||
CHECK_EQ(
|
||||
code_event_handler.CountLines("Builtin", "InterpreterEntryTrampoline"),
|
||||
1);
|
||||
|
||||
context->Exit();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user