Index: src/log.cc |
diff --git a/src/log.cc b/src/log.cc |
index 1777234d5b93b4408b283b2e214f89e3afebdc0f..9fbea14dbe33e5e007fe8e95c1d066ee5df2883b 100644 |
--- a/src/log.cc |
+++ b/src/log.cc |
@@ -627,6 +627,42 @@ void Logger::DeleteEvent(const char* name, void* object) { |
} |
+#ifdef ENABLE_LOGGING_AND_PROFILING |
+ |
+// A class that contains all common code dealing with record compression. |
+class CompressionHelper { |
+ public: |
+ explicit CompressionHelper(int window_size) |
+ : compressor_(window_size), repeat_count_(0) { } |
+ |
+ // Handles storing message in compressor, retrieving the previous one and |
+ // prefixing it with repeat count, if needed. |
+ // Returns true if message needs to be written to log. |
+ bool HandleMessage(LogMessageBuilder* msg) { |
+ if (!msg->StoreInCompressor(&compressor_)) { |
+ // Current message repeats the previous one, don't write it. |
+ ++repeat_count_; |
+ return false; |
+ } |
+ if (repeat_count_ == 0) { |
+ return msg->RetrieveCompressedPrevious(&compressor_); |
+ } |
+ OS::SNPrintF(prefix_, "%s,%d,", |
+ Logger::log_events_[Logger::REPEAT_META_EVENT], |
+ repeat_count_ + 1); |
+ repeat_count_ = 0; |
+ return msg->RetrieveCompressedPrevious(&compressor_, prefix_.start()); |
+ } |
+ |
+ private: |
+ LogRecordCompressor compressor_; |
+ int repeat_count_; |
+ EmbeddedVector<char, 20> prefix_; |
+}; |
+ |
+#endif // ENABLE_LOGGING_AND_PROFILING |
+ |
+ |
void Logger::CodeCreateEvent(LogEventsAndTags tag, |
Code* code, |
const char* comment) { |
@@ -643,6 +679,10 @@ void Logger::CodeCreateEvent(LogEventsAndTags tag, |
msg.Append(*p); |
} |
msg.Append('"'); |
+ if (FLAG_compress_log) { |
+ ASSERT(compression_helper_ != NULL); |
+ if (!compression_helper_->HandleMessage(&msg)) return; |
+ } |
msg.Append('\n'); |
msg.WriteToLogFile(); |
#endif |
@@ -657,7 +697,12 @@ void Logger::CodeCreateEvent(LogEventsAndTags tag, Code* code, String* name) { |
name->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL); |
msg.Append("%s,%s,", log_events_[CODE_CREATION_EVENT], log_events_[tag]); |
msg.AppendAddress(code->address()); |
- msg.Append(",%d,\"%s\"\n", code->ExecutableSize(), *str); |
+ msg.Append(",%d,\"%s\"", code->ExecutableSize(), *str); |
+ if (FLAG_compress_log) { |
+ ASSERT(compression_helper_ != NULL); |
+ if (!compression_helper_->HandleMessage(&msg)) return; |
+ } |
+ msg.Append('\n'); |
msg.WriteToLogFile(); |
#endif |
} |
@@ -675,8 +720,13 @@ void Logger::CodeCreateEvent(LogEventsAndTags tag, |
source->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL); |
msg.Append("%s,%s,", log_events_[CODE_CREATION_EVENT], log_events_[tag]); |
msg.AppendAddress(code->address()); |
- msg.Append(",%d,\"%s %s:%d\"\n", |
+ msg.Append(",%d,\"%s %s:%d\"", |
code->ExecutableSize(), *str, *sourcestr, line); |
+ if (FLAG_compress_log) { |
+ ASSERT(compression_helper_ != NULL); |
+ if (!compression_helper_->HandleMessage(&msg)) return; |
+ } |
+ msg.Append('\n'); |
msg.WriteToLogFile(); |
#endif |
} |
@@ -688,7 +738,12 @@ void Logger::CodeCreateEvent(LogEventsAndTags tag, Code* code, int args_count) { |
LogMessageBuilder msg; |
msg.Append("%s,%s,", log_events_[CODE_CREATION_EVENT], log_events_[tag]); |
msg.AppendAddress(code->address()); |
- msg.Append(",%d,\"args_count: %d\"\n", code->ExecutableSize(), args_count); |
+ msg.Append(",%d,\"args_count: %d\"", code->ExecutableSize(), args_count); |
+ if (FLAG_compress_log) { |
+ ASSERT(compression_helper_ != NULL); |
+ if (!compression_helper_->HandleMessage(&msg)) return; |
+ } |
+ msg.Append('\n'); |
msg.WriteToLogFile(); |
#endif |
} |
@@ -703,48 +758,17 @@ void Logger::RegExpCodeCreateEvent(Code* code, String* source) { |
msg.AppendAddress(code->address()); |
msg.Append(",%d,\"", code->ExecutableSize()); |
msg.AppendDetailed(source, false); |
- msg.Append("\"\n"); |
+ msg.Append('\"'); |
+ if (FLAG_compress_log) { |
+ ASSERT(compression_helper_ != NULL); |
+ if (!compression_helper_->HandleMessage(&msg)) return; |
+ } |
+ msg.Append('\n'); |
msg.WriteToLogFile(); |
#endif |
} |
-#ifdef ENABLE_LOGGING_AND_PROFILING |
- |
-// A class that contains all common code dealing with record compression. |
-class CompressionHelper { |
- public: |
- explicit CompressionHelper(int window_size) |
- : compressor_(window_size), repeat_count_(0) { } |
- |
- // Handles storing message in compressor, retrieving the previous one and |
- // prefixing it with repeat count, if needed. |
- // Returns true if message needs to be written to log. |
- bool HandleMessage(LogMessageBuilder* msg) { |
- if (!msg->StoreInCompressor(&compressor_)) { |
- // Current message repeats the previous one, don't write it. |
- ++repeat_count_; |
- return false; |
- } |
- if (repeat_count_ == 0) { |
- return msg->RetrieveCompressedPrevious(&compressor_); |
- } |
- OS::SNPrintF(prefix_, "%s,%d,", |
- Logger::log_events_[Logger::REPEAT_META_EVENT], |
- repeat_count_ + 1); |
- repeat_count_ = 0; |
- return msg->RetrieveCompressedPrevious(&compressor_, prefix_.start()); |
- } |
- |
- private: |
- LogRecordCompressor compressor_; |
- int repeat_count_; |
- EmbeddedVector<char, 20> prefix_; |
-}; |
- |
-#endif // ENABLE_LOGGING_AND_PROFILING |
- |
- |
void Logger::CodeMoveEvent(Address from, Address to) { |
#ifdef ENABLE_LOGGING_AND_PROFILING |
static Address prev_to_ = NULL; |