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 a6469e9

Browse filesBrowse files
ofrobotsjasnell
authored andcommitted
deps: backport 010897c from V8 upstream
This is a reland of #3165. The patch abates the truncation of script filenames in the perf-event output produced by V8. V8 commits: Original: v8/v8@03ef3cd Reland: v8/v8@010897c Original commit message: improve perf_basic_prof filename reporting The buffer used for appending filenames to the string printed to the perf_basic_prof log was unnecessarily too small. Bump it up to be at least kUtf8BufferSize. Truncation of filenames makes it really hard to work with profiles gathered on Node.js. Because of the way Node.js works, you can have node module dependencies in deeply nested directories. The last thing you want when investigating a performance problem is to have script names be truncated. This patch is a stop-gap. Ideally, I want no truncation of the filename at all and use a dynamically growing buffer. That would be a larger change, and I wanted to have a quick fix available that can be back-ported to Node.js LTS release. R=yangguo@chromium.org,yurys@chromium.org BUG= Review URL: https://codereview.chromium.org/1388543002 PR-URL: #3520 Reviewed-By: bnoordhuis - Ben Noordhuis <info@bnoordhuis.nl>
1 parent 3bafe1a commit a6469e9
Copy full SHA for a6469e9

File tree

Expand file treeCollapse file tree

2 files changed

+62
-5
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

2 files changed

+62
-5
lines changed
Open diff view settings
Collapse file

‎deps/v8/src/log.cc‎

Copy file name to clipboardExpand all lines: deps/v8/src/log.cc
+7-5Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -125,17 +125,19 @@ class CodeEventLogger::NameBuffer {
125125
}
126126

127127
void AppendInt(int n) {
128-
Vector<char> buffer(utf8_buffer_ + utf8_pos_,
129-
kUtf8BufferSize - utf8_pos_);
128+
int space = kUtf8BufferSize - utf8_pos_;
129+
if (space <= 0) return;
130+
Vector<char> buffer(utf8_buffer_ + utf8_pos_, space);
130131
int size = SNPrintF(buffer, "%d", n);
131132
if (size > 0 && utf8_pos_ + size <= kUtf8BufferSize) {
132133
utf8_pos_ += size;
133134
}
134135
}
135136

136137
void AppendHex(uint32_t n) {
137-
Vector<char> buffer(utf8_buffer_ + utf8_pos_,
138-
kUtf8BufferSize - utf8_pos_);
138+
int space = kUtf8BufferSize - utf8_pos_;
139+
if (space <= 0) return;
140+
Vector<char> buffer(utf8_buffer_ + utf8_pos_, space);
139141
int size = SNPrintF(buffer, "%x", n);
140142
if (size > 0 && utf8_pos_ + size <= kUtf8BufferSize) {
141143
utf8_pos_ += size;
@@ -147,7 +149,7 @@ class CodeEventLogger::NameBuffer {
147149

148150
private:
149151
static const int kUtf8BufferSize = 512;
150-
static const int kUtf16BufferSize = 128;
152+
static const int kUtf16BufferSize = kUtf8BufferSize;
151153

152154
int utf8_pos_;
153155
char utf8_buffer_[kUtf8BufferSize];
Collapse file

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

Copy file name to clipboardExpand all lines: deps/v8/test/cctest/test-log.cc
+55Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -531,3 +531,58 @@ TEST(LogVersion) {
531531
}
532532
isolate->Dispose();
533533
}
534+
535+
536+
// https://crbug.com/539892
537+
// CodeCreateEvents with really large names should not crash.
538+
TEST(Issue539892) {
539+
class : public i::CodeEventLogger {
540+
public:
541+
virtual void CodeMoveEvent(Address from, Address to) {}
542+
virtual void CodeDeleteEvent(Address from) {}
543+
virtual void CodeDisableOptEvent(i::Code* code,
544+
i::SharedFunctionInfo* shared) {}
545+
546+
private:
547+
virtual void LogRecordedBuffer(i::Code* code, i::SharedFunctionInfo* shared,
548+
const char* name, int length) {}
549+
} code_event_logger;
550+
SETUP_FLAGS();
551+
v8::Isolate::CreateParams create_params;
552+
create_params.array_buffer_allocator = CcTest::array_buffer_allocator();
553+
v8::Isolate* isolate = v8::Isolate::New(create_params);
554+
555+
{
556+
ScopedLoggerInitializer initialize_logger(saved_log, saved_prof, isolate);
557+
Logger* logger = initialize_logger.logger();
558+
logger->addCodeEventListener(&code_event_logger);
559+
560+
// Function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aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
577+
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
578+
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
579+
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaac"
580+
"(){})();";
581+
582+
CompileRun(source_text);
583+
584+
// Must not crash.
585+
logger->LogCompiledFunctions();
586+
}
587+
isolate->Dispose();
588+
}

0 commit comments

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