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 ab27e0e

Browse filesBrowse files
Matheus Marchinitargos
authored andcommitted
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: v8/v8@acc336c 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 37a5c8c commit ab27e0e
Copy full SHA for ab27e0e

File tree

Expand file treeCollapse file tree

3 files changed

+56
-32
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

3 files changed

+56
-32
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.11',
30+
'v8_embedder_string': '-node.12',
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
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2052,7 +2052,7 @@ void ExistingCodeLogger::LogCodeObject(Object* object) {
20522052
break;
20532053
case AbstractCode::BUILTIN:
20542054
if (Code::cast(object)->is_interpreter_trampoline_builtin() &&
2055-
Code::cast(object) ==
2055+
Code::cast(object) !=
20562056
*BUILTIN_CODE(isolate_, InterpreterEntryTrampoline)) {
20572057
return;
20582058
}
Collapse file

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

Copy file name to clipboardExpand all lines: deps/v8/test/cctest/test-log.cc
+54-30Lines changed: 54 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@
3636

3737
#include <unordered_set>
3838
#include <vector>
39+
// The C++ style guide recommends using <re2> instead of <regex>. However, the
40+
// former isn't available in V8.
41+
#include <regex> // NOLINT(build/c++11)
3942
#include "src/api.h"
4043
#include "src/log-utils.h"
4144
#include "src/log.h"
@@ -257,30 +260,41 @@ class TestCodeEventHandler : public v8::CodeEventHandler {
257260
explicit TestCodeEventHandler(v8::Isolate* isolate)
258261
: v8::CodeEventHandler(isolate) {}
259262

260-
const char* FindLine(const char* prefix, const char* suffix = nullptr,
261-
const char* start = nullptr) {
262-
if (!log_.length()) return NULL;
263-
const char* c_log = log_.c_str();
264-
if (start == nullptr) start = c_log;
265-
const char* end = c_log + log_.length();
266-
return FindLogLine(start, end, prefix, suffix);
263+
size_t CountLines(std::string prefix, std::string suffix = std::string()) {
264+
if (!log_.length()) return 0;
265+
266+
std::regex expression("(^|\\n)" + prefix + ".*" + suffix + "(?=\\n|$)");
267+
268+
size_t match_count(std::distance(
269+
std::sregex_iterator(log_.begin(), log_.end(), expression),
270+
std::sregex_iterator()));
271+
272+
return match_count;
267273
}
268274

269275
void Handle(v8::CodeEvent* code_event) override {
270-
const char* code_type =
271-
v8::CodeEvent::GetCodeEventTypeName(code_event->GetCodeType());
272-
char function_name[1000];
273-
strncpy(function_name, code_type, 1000);
274-
function_name[strlen(code_type)] = ' ';
275-
code_event->GetFunctionName()->WriteUtf8(
276-
function_name + strlen(code_type) + 1, 1000);
277-
function_name[strlen(function_name) + 1] = '\0';
278-
function_name[strlen(function_name)] = '\n';
279-
280-
log_ += std::string(function_name);
276+
std::string log_line = "";
277+
log_line += v8::CodeEvent::GetCodeEventTypeName(code_event->GetCodeType());
278+
log_line += " ";
279+
log_line += FormatName(code_event);
280+
log_line += "\n";
281+
log_ += log_line;
281282
}
282283

283284
private:
285+
std::string FormatName(v8::CodeEvent* code_event) {
286+
std::string name = std::string(code_event->GetComment());
287+
if (name.empty()) {
288+
v8::Local<v8::String> functionName = code_event->GetFunctionName();
289+
std::string buffer(functionName->Utf8Length() + 1, 0);
290+
functionName->WriteUtf8(&buffer[0], functionName->Utf8Length() + 1);
291+
// Sanitize name, removing unwanted \0 resulted from WriteUtf8
292+
name = std::string(buffer.c_str());
293+
}
294+
295+
return name;
296+
}
297+
284298
std::string log_;
285299
};
286300

@@ -855,21 +869,24 @@ TEST(ExternalCodeEventListener) {
855869
"testCodeEventListenerBeforeStart('1', 1);";
856870
CompileRun(source_text_before_start);
857871

858-
CHECK_NULL(code_event_handler.FindLine("LazyCompile",
859-
"testCodeEventListenerBeforeStart"));
872+
CHECK_EQ(code_event_handler.CountLines("LazyCompile",
873+
"testCodeEventListenerBeforeStart"),
874+
0);
860875

861876
code_event_handler.Enable();
862877

863-
CHECK_NOT_NULL(code_event_handler.FindLine(
864-
"LazyCompile", "testCodeEventListenerBeforeStart"));
878+
CHECK_GE(code_event_handler.CountLines("LazyCompile",
879+
"testCodeEventListenerBeforeStart"),
880+
1);
865881

866882
const char* source_text_after_start =
867883
"function testCodeEventListenerAfterStart(a,b) { return a + b };"
868884
"testCodeEventListenerAfterStart('1', 1);";
869885
CompileRun(source_text_after_start);
870886

871-
CHECK_NOT_NULL(code_event_handler.FindLine(
872-
"LazyCompile", "testCodeEventListenerAfterStart"));
887+
CHECK_GE(code_event_handler.CountLines("LazyCompile",
888+
"testCodeEventListenerAfterStart"),
889+
1);
873890

874891
context->Exit();
875892
}
@@ -898,21 +915,28 @@ TEST(ExternalCodeEventListenerWithInterpretedFramesNativeStack) {
898915
"testCodeEventListenerBeforeStart('1', 1);";
899916
CompileRun(source_text_before_start);
900917

901-
CHECK_NULL(code_event_handler.FindLine("InterpretedFunction",
902-
"testCodeEventListenerBeforeStart"));
918+
CHECK_EQ(code_event_handler.CountLines("InterpretedFunction",
919+
"testCodeEventListenerBeforeStart"),
920+
0);
903921

904922
code_event_handler.Enable();
905923

906-
CHECK_NOT_NULL(code_event_handler.FindLine(
907-
"InterpretedFunction", "testCodeEventListenerBeforeStart"));
924+
CHECK_GE(code_event_handler.CountLines("InterpretedFunction",
925+
"testCodeEventListenerBeforeStart"),
926+
1);
908927

909928
const char* source_text_after_start =
910929
"function testCodeEventListenerAfterStart(a,b) { return a + b };"
911930
"testCodeEventListenerAfterStart('1', 1);";
912931
CompileRun(source_text_after_start);
913932

914-
CHECK_NOT_NULL(code_event_handler.FindLine(
915-
"InterpretedFunction", "testCodeEventListenerAfterStart"));
933+
CHECK_GE(code_event_handler.CountLines("InterpretedFunction",
934+
"testCodeEventListenerAfterStart"),
935+
1);
936+
937+
CHECK_EQ(
938+
code_event_handler.CountLines("Builtin", "InterpreterEntryTrampoline"),
939+
1);
916940

917941
context->Exit();
918942
}

0 commit comments

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