diff options
author | Ali Ijaz Sheikh <ofrobots@google.com> | 2015-10-25 17:19:58 -0700 |
---|---|---|
committer | James M Snell <jasnell@gmail.com> | 2015-10-29 08:38:44 -0700 |
commit | a6469e901a5073bad63ef514ebc5d1dab75d6e21 (patch) | |
tree | 64d7c08925770975125a04b4fc6d4fe1cdd2f313 /deps | |
parent | 3bafe1a59b0eeabb102ba3b2de17167a3e55c105 (diff) | |
download | nodejs-a6469e901a5073bad63ef514ebc5d1dab75d6e21.tar.gz nodejs-a6469e901a5073bad63ef514ebc5d1dab75d6e21.tar.bz2 nodejs-a6469e901a5073bad63ef514ebc5d1dab75d6e21.zip |
deps: backport 010897c from V8 upstream
This is a reland of https://github.com/nodejs/node/pull/3165. The patch abates
the truncation of script filenames in the perf-event output produced by V8.
V8 commits:
Original: https://github.com/v8/v8/commit/03ef3cd004c2fd31ae7e48772f106df67b8c2feb
Reland: https://github.com/v8/v8/commit/010897c16adb46d3fe403eab525502a63e174b0c
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: https://github.com/nodejs/node/pull/3520
Reviewed-By: bnoordhuis - Ben Noordhuis <info@bnoordhuis.nl>
Diffstat (limited to 'deps')
-rw-r--r-- | deps/v8/src/log.cc | 12 | ||||
-rw-r--r-- | deps/v8/test/cctest/test-log.cc | 55 |
2 files changed, 62 insertions, 5 deletions
diff --git a/deps/v8/src/log.cc b/deps/v8/src/log.cc index 8f47e81f0..d5842597c 100644 --- a/deps/v8/src/log.cc +++ b/deps/v8/src/log.cc @@ -125,8 +125,9 @@ class CodeEventLogger::NameBuffer { } void AppendInt(int n) { - Vector<char> buffer(utf8_buffer_ + utf8_pos_, - kUtf8BufferSize - utf8_pos_); + int space = kUtf8BufferSize - utf8_pos_; + if (space <= 0) return; + Vector<char> buffer(utf8_buffer_ + utf8_pos_, space); int size = SNPrintF(buffer, "%d", n); if (size > 0 && utf8_pos_ + size <= kUtf8BufferSize) { utf8_pos_ += size; @@ -134,8 +135,9 @@ class CodeEventLogger::NameBuffer { } void AppendHex(uint32_t n) { - Vector<char> buffer(utf8_buffer_ + utf8_pos_, - kUtf8BufferSize - utf8_pos_); + int space = kUtf8BufferSize - utf8_pos_; + if (space <= 0) return; + Vector<char> buffer(utf8_buffer_ + utf8_pos_, space); int size = SNPrintF(buffer, "%x", n); if (size > 0 && utf8_pos_ + size <= kUtf8BufferSize) { utf8_pos_ += size; @@ -147,7 +149,7 @@ class CodeEventLogger::NameBuffer { private: static const int kUtf8BufferSize = 512; - static const int kUtf16BufferSize = 128; + static const int kUtf16BufferSize = kUtf8BufferSize; int utf8_pos_; char utf8_buffer_[kUtf8BufferSize]; diff --git a/deps/v8/test/cctest/test-log.cc b/deps/v8/test/cctest/test-log.cc index 0938a9ede..daf2e688b 100644 --- a/deps/v8/test/cctest/test-log.cc +++ b/deps/v8/test/cctest/test-log.cc @@ -531,3 +531,58 @@ TEST(LogVersion) { } isolate->Dispose(); } + + +// https://crbug.com/539892 +// CodeCreateEvents with really large names should not crash. +TEST(Issue539892) { + class : public i::CodeEventLogger { + public: + virtual void CodeMoveEvent(Address from, Address to) {} + virtual void CodeDeleteEvent(Address from) {} + virtual void CodeDisableOptEvent(i::Code* code, + i::SharedFunctionInfo* shared) {} + + private: + virtual void LogRecordedBuffer(i::Code* code, i::SharedFunctionInfo* shared, + const char* name, int length) {} + } code_event_logger; + SETUP_FLAGS(); + v8::Isolate::CreateParams create_params; + create_params.array_buffer_allocator = CcTest::array_buffer_allocator(); + v8::Isolate* isolate = v8::Isolate::New(create_params); + + { + ScopedLoggerInitializer initialize_logger(saved_log, saved_prof, isolate); + Logger* logger = initialize_logger.logger(); + logger->addCodeEventListener(&code_event_logger); + + // Function with a really large name. + const char* source_text = + "(function " + "baaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + "aaaaaaaaaaaa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