[Tracing] Remove unnecessary memory allocation in runtime call stats.

Previously we didn't implement TRACE_STR_COPY when we write trace events to
file, which causes us to allocate a growing independent memory chunk for dumped
runtime call stats table. Since we now have a fully functional TRACE_STR_COPY,
this memory allocation can be avoided, this patch removes it.

BUG=v8:5089

Review-Url: https://codereview.chromium.org/2342643004
Cr-Commit-Position: refs/heads/master@{#39462}
This commit is contained in:
lpy 2016-09-15 21:12:49 -07:00 committed by Commit bot
parent e0c98799c0
commit e1997bb7d7
2 changed files with 1 additions and 10 deletions

View File

@ -393,15 +393,8 @@ const char* RuntimeCallStats::Dump() {
FOR_EACH_HANDLER_COUNTER(DUMP_COUNTER)
#undef DUMP_COUNTER
buffer_ << "\"END\":[]}";
const std::string& buffer_str = buffer_.str();
size_t length = buffer_str.size();
if (length > len_) {
buffer_c_str_.reset(new char[length + 1]);
len_ = length;
}
strncpy(buffer_c_str_.get(), buffer_str.c_str(), length + 1);
in_use_ = false;
return buffer_c_str_.get();
return buffer_.str().c_str();
}
} // namespace internal

View File

@ -803,8 +803,6 @@ class RuntimeCallStats {
private:
std::stringstream buffer_;
std::unique_ptr<char[]> buffer_c_str_;
size_t len_ = 0;
// Counter to track recursive time events.
RuntimeCallTimer* current_timer_ = NULL;
// Used to track nested tracing scopes.