Commit 010897c1 authored by ofrobots's avatar ofrobots Committed by Commit bot

Reland improve perf_basic_prof filename reporting

Using perf-basic-prof in the test-case was problematic on windows. Use
CodeEventLogger directly.

Previous issue: https://codereview.chromium.org/1396843004/

R=jkummerow@chromium.org,yangguo@chromium.org,yurys@chromium.org
BUG=chromium:539892
LOG=N

Committed: https://crrev.com/701ba0b255f9c34f4b8c43584ef1e35040474e7d
Cr-Commit-Position: refs/heads/master@{#31197}

patch from issue 1396843004 at patchset 60001 (http://crrev.com/1396843004#ps60001)

Review URL: https://codereview.chromium.org/1403763002

Cr-Commit-Position: refs/heads/master@{#31237}
parent 4f7caf2f
......@@ -123,8 +123,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;
......@@ -132,8 +133,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;
......@@ -145,7 +147,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];
......
......@@ -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"
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaac"
"(){})();";
CompileRun(source_text);
// Must not crash.
logger->LogCompiledFunctions();
}
isolate->Dispose();
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment