Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(769)

Unified Diff: src/log.cc

Issue 119304: Add log compression ability. (Closed)
Patch Set: Created 11 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/log.h ('k') | src/stub-cache.cc » ('j') | src/stub-cache.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/log.cc
diff --git a/src/log.cc b/src/log.cc
index c1edf4d1855a27c37272a12052e9bf0fdc70bd3a..3a75306f61334e9b335ef51caa8c8d5f2f6ce155 100644
--- a/src/log.cc
+++ b/src/log.cc
@@ -262,6 +262,7 @@ void Profiler::Engage() {
Logger::ticker_->SetProfiler(this);
Logger::ProfilerBeginEvent();
+ Logger::LogAliases();
}
@@ -301,6 +302,19 @@ Profiler* Logger::profiler_ = NULL;
VMState* Logger::current_state_ = NULL;
VMState Logger::bottom_state_(EXTERNAL);
SlidingStateWindow* Logger::sliding_state_window_ = NULL;
+const char** Logger::log_events_ = NULL;
+
+#define DECLARE_LONG_EVENT(ignore1, long_name, ignore2) long_name,
+const char* kLongLogEventsNames[Logger::NUMBER_OF_LOG_EVENTS] = {
+ LOG_EVENTS_AND_TAGS_LIST(DECLARE_LONG_EVENT)
+};
+#undef DECLARE_LONG_EVENT
+
+#define DECLARE_SHORT_EVENT(ignore1, ignore2, short_name) short_name,
+const char* kCompressedLogEventsNames[Logger::NUMBER_OF_LOG_EVENTS] = {
+ LOG_EVENTS_AND_TAGS_LIST(DECLARE_SHORT_EVENT)
+};
+#undef DECLARE_SHORT_EVENT
bool Logger::IsEnabled() {
@@ -315,6 +329,17 @@ void Logger::ProfilerBeginEvent() {
msg.WriteToLogFile();
}
+
+void Logger::LogAliases() {
+ if (!Log::IsEnabled() || !FLAG_compress_log) return;
+ LogMessageBuilder msg;
+ for (int i = 0; i < NUMBER_OF_LOG_EVENTS; ++i) {
+ msg.Append("alias,%s,%s\n",
+ kCompressedLogEventsNames[i], kLongLogEventsNames[i]);
+ }
+ msg.WriteToLogFile();
+}
+
#endif // ENABLE_LOGGING_AND_PROFILING
@@ -594,12 +619,14 @@ void Logger::DeleteEvent(const char* name, void* object) {
}
-void Logger::CodeCreateEvent(const char* tag, Code* code, const char* comment) {
+void Logger::CodeCreateEvent(
Søren Thygesen Gjesse 2009/06/08 12:28:47 I think we normally use the following format for l
Mikhail Naganov 2009/06/08 13:39:09 OK, fixed.
+ LogEventsAndTags tag, Code* code, const char* comment) {
#ifdef ENABLE_LOGGING_AND_PROFILING
if (!Log::IsEnabled() || !FLAG_log_code) return;
LogMessageBuilder msg;
- msg.Append("code-creation,%s,0x%" V8PRIxPTR ",%d,\"", tag, code->address(),
- code->ExecutableSize());
+ msg.Append("%s,%s,0x%" V8PRIxPTR ",%d,\"",
+ log_events_[CODE_CREATION_EVENT], log_events_[tag],
+ code->address(), code->ExecutableSize());
for (const char* p = comment; *p != '\0'; p++) {
if (*p == '"') {
msg.Append('\\');
@@ -613,20 +640,21 @@ void Logger::CodeCreateEvent(const char* tag, Code* code, const char* comment) {
}
-void Logger::CodeCreateEvent(const char* tag, Code* code, String* name) {
+void Logger::CodeCreateEvent(LogEventsAndTags tag, Code* code, String* name) {
#ifdef ENABLE_LOGGING_AND_PROFILING
if (!Log::IsEnabled() || !FLAG_log_code) return;
LogMessageBuilder msg;
SmartPointer<char> str =
name->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL);
- msg.Append("code-creation,%s,0x%" V8PRIxPTR ",%d,\"%s\"\n",
- tag, code->address(), code->ExecutableSize(), *str);
+ msg.Append("%s,%s,0x%" V8PRIxPTR ",%d,\"%s\"\n",
+ log_events_[CODE_CREATION_EVENT], log_events_[tag],
+ code->address(), code->ExecutableSize(), *str);
msg.WriteToLogFile();
#endif
}
-void Logger::CodeCreateEvent(const char* tag, Code* code, String* name,
+void Logger::CodeCreateEvent(LogEventsAndTags tag, Code* code, String* name,
String* source, int line) {
#ifdef ENABLE_LOGGING_AND_PROFILING
if (!Log::IsEnabled() || !FLAG_log_code) return;
@@ -635,8 +663,9 @@ void Logger::CodeCreateEvent(const char* tag, Code* code, String* name,
name->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL);
SmartPointer<char> sourcestr =
source->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL);
- msg.Append("code-creation,%s,0x%" V8PRIxPTR ",%d,\"%s %s:%d\"\n",
- tag, code->address(),
+ msg.Append("%s,%s,0x%" V8PRIxPTR ",%d,\"%s %s:%d\"\n",
+ log_events_[CODE_CREATION_EVENT],
+ log_events_[tag], code->address(),
code->ExecutableSize(),
*str, *sourcestr, line);
msg.WriteToLogFile();
@@ -644,11 +673,13 @@ void Logger::CodeCreateEvent(const char* tag, Code* code, String* name,
}
-void Logger::CodeCreateEvent(const char* tag, Code* code, int args_count) {
+void Logger::CodeCreateEvent(LogEventsAndTags tag, Code* code, int args_count) {
#ifdef ENABLE_LOGGING_AND_PROFILING
if (!Log::IsEnabled() || !FLAG_log_code) return;
LogMessageBuilder msg;
- msg.Append("code-creation,%s,0x%" V8PRIxPTR ",%d,\"args_count: %d\"\n", tag,
+ msg.Append("%s,%s,0x%" V8PRIxPTR ",%d,\"args_count: %d\"\n",
+ log_events_[CODE_CREATION_EVENT],
+ log_events_[tag],
code->address(),
code->ExecutableSize(),
args_count);
@@ -661,7 +692,9 @@ void Logger::RegExpCodeCreateEvent(Code* code, String* source) {
#ifdef ENABLE_LOGGING_AND_PROFILING
if (!Log::IsEnabled() || !FLAG_log_code) return;
LogMessageBuilder msg;
- msg.Append("code-creation,%s,0x%" V8PRIxPTR ",%d,\"", "RegExp",
+ msg.Append("%s,%s,0x%" V8PRIxPTR ",%d,\"",
+ log_events_[CODE_CREATION_EVENT],
+ log_events_[REG_EXP_TAG],
code->address(),
code->ExecutableSize());
msg.AppendDetailed(source, false);
@@ -671,23 +704,12 @@ void Logger::RegExpCodeCreateEvent(Code* code, String* source) {
}
-void Logger::CodeAllocateEvent(Code* code, Assembler* assem) {
-#ifdef ENABLE_LOGGING_AND_PROFILING
- if (!Log::IsEnabled() || !FLAG_log_code) return;
- LogMessageBuilder msg;
- msg.Append("code-allocate,0x%" V8PRIxPTR ",0x%" V8PRIxPTR "\n",
- code->address(),
- assem);
- msg.WriteToLogFile();
-#endif
-}
-
-
void Logger::CodeMoveEvent(Address from, Address to) {
#ifdef ENABLE_LOGGING_AND_PROFILING
if (!Log::IsEnabled() || !FLAG_log_code) return;
LogMessageBuilder msg;
- msg.Append("code-move,0x%" V8PRIxPTR ",0x%" V8PRIxPTR "\n", from, to);
+ msg.Append("%s,0x%" V8PRIxPTR ",0x%" V8PRIxPTR "\n",
+ log_events_[CODE_MOVE_EVENT], from, to);
msg.WriteToLogFile();
#endif
}
@@ -697,7 +719,7 @@ void Logger::CodeDeleteEvent(Address from) {
#ifdef ENABLE_LOGGING_AND_PROFILING
if (!Log::IsEnabled() || !FLAG_log_code) return;
LogMessageBuilder msg;
- msg.Append("code-delete,0x%" V8PRIxPTR "\n", from);
+ msg.Append("%s,0x%" V8PRIxPTR "\n", log_events_[CODE_DELETE_EVENT], from);
msg.WriteToLogFile();
#endif
}
@@ -803,13 +825,26 @@ void Logger::DebugEvent(const char* event_type, Vector<uint16_t> parameter) {
void Logger::TickEvent(TickSample* sample, bool overflow) {
if (!Log::IsEnabled() || !FLAG_prof) return;
LogMessageBuilder msg;
- msg.Append("tick,0x%" V8PRIxPTR ",0x%" V8PRIxPTR ",%d",
+ msg.Append("%s,0x%" V8PRIxPTR ",0x%" V8PRIxPTR ",%d",
+ log_events_[TICK_EVENT],
sample->pc, sample->sp, static_cast<int>(sample->state));
if (overflow) {
msg.Append(",overflow");
}
+ uintptr_t prev_ptr = sample->pc;
for (int i = 0; i < sample->frames_count; ++i) {
- msg.Append(",0x%" V8PRIxPTR, sample->stack[i]);
+ if (FLAG_compress_log) {
+ const uintptr_t ptr = OffsetFrom(sample->stack[i]);
+ intptr_t delta = ptr - prev_ptr;
+ prev_ptr = ptr;
+ // To avoid printing negative offsets in an unsigned form,
+ // we are printing an absolute value with a sign.
+ const char sign = delta >= 0 ? '+' : '-';
+ if (sign == '-') { delta = -delta; }
+ msg.Append(",%c0x%" V8PRIxPTR, sign, delta);
+ } else {
+ msg.Append(",0x%" V8PRIxPTR, sample->stack[i]);
+ }
}
msg.Append('\n');
msg.WriteToLogFile();
@@ -913,17 +948,19 @@ void Logger::LogCompiledFunctions() {
int line_num = GetScriptLineNumber(script, shared->start_position());
if (line_num > 0) {
line_num += script->line_offset()->value() + 1;
- LOG(CodeCreateEvent("LazyCompile", shared->code(), *func_name,
+ LOG(CodeCreateEvent(Logger::LAZY_COMPILE_TAG,
+ shared->code(), *func_name,
*script_name, line_num));
} else {
// Can't distinguish enum and script here, so always use Script.
- LOG(CodeCreateEvent("Script", shared->code(), *script_name));
+ LOG(CodeCreateEvent(Logger::SCRIPT_TAG,
+ shared->code(), *script_name));
}
continue;
}
}
// If no script or script has no name.
- LOG(CodeCreateEvent("LazyCompile", shared->code(), *func_name));
+ LOG(CodeCreateEvent(Logger::LAZY_COMPILE_TAG, shared->code(), *func_name));
}
DeleteArray(sfis);
@@ -1022,6 +1059,9 @@ bool Logger::Setup() {
LogMessageBuilder::set_write_failure_handler(StopLoggingAndProfiling);
+ log_events_ = FLAG_compress_log ?
+ kCompressedLogEventsNames : kLongLogEventsNames;
+
return true;
#else
« no previous file with comments | « src/log.h ('k') | src/stub-cache.cc » ('j') | src/stub-cache.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698