Revision: 15287
Author: [email protected]
Date: Mon Jun 24 05:55:19 2013
Log: CPUProfiler: Simplify logging part of CreateCodeEvent functions.
We have 5 overloaded functions with name CreateCodeEvent.
All these functions have many common parts. I'd like to eliminate the
difference between them.
TEST=existing tests
[email protected], [email protected]
Review URL: https://codereview.chromium.org/16901014
http://code.google.com/p/v8/source/detail?r=15287
Modified:
/branches/bleeding_edge/src/log-utils.cc
/branches/bleeding_edge/src/log-utils.h
/branches/bleeding_edge/src/log.cc
/branches/bleeding_edge/src/log.h
/branches/bleeding_edge/src/objects.cc
/branches/bleeding_edge/src/objects.h
/branches/bleeding_edge/src/spaces.cc
/branches/bleeding_edge/tools/plot-timer-events.js
=======================================
--- /branches/bleeding_edge/src/log-utils.cc Mon Jun 3 08:32:22 2013
+++ /branches/bleeding_edge/src/log-utils.cc Mon Jun 24 05:55:19 2013
@@ -235,6 +235,18 @@
}
ASSERT(pos_ <= Log::kMessageBufferSize);
}
+
+
+void LogMessageBuilder::AppendDoubleQuotedString(const char* string) {
+ Append('"');
+ for (const char* p = string; *p != '\0'; p++) {
+ if (*p == '"') {
+ Append('\\');
+ }
+ Append(*p);
+ }
+ Append('"');
+}
void LogMessageBuilder::Append(String* str) {
=======================================
--- /branches/bleeding_edge/src/log-utils.h Wed Apr 24 07:44:08 2013
+++ /branches/bleeding_edge/src/log-utils.h Mon Jun 24 05:55:19 2013
@@ -132,6 +132,9 @@
// Append a character to the log message.
void Append(const char c);
+ // Append double quoted string to the log message.
+ void AppendDoubleQuotedString(const char* string);
+
// Append a heap string.
void Append(String* str);
=======================================
--- /branches/bleeding_edge/src/log.cc Mon Jun 24 01:40:38 2013
+++ /branches/bleeding_edge/src/log.cc Mon Jun 24 05:55:19 2013
@@ -862,7 +862,7 @@
Address entry_point) {
if (!log_->IsEnabled() || !FLAG_log_code) return;
LogMessageBuilder msg(this);
- msg.Append("%s,%s,-3,",
+ msg.Append("%s,%s,-2,",
kLogEventsNames[CODE_CREATION_EVENT],
kLogEventsNames[CALLBACK_TAG]);
msg.AppendAddress(entry_point);
@@ -945,6 +945,32 @@
RegisterSnapshotCodeName(code, name_buffer_->get(),
name_buffer_->size());
}
}
+
+
+void Logger::AppendCodeCreateHeader(LogMessageBuilder* msg,
+ LogEventsAndTags tag,
+ Code* code) {
+ ASSERT(msg);
+ msg->Append("%s,%s,%d,",
+ kLogEventsNames[CODE_CREATION_EVENT],
+ kLogEventsNames[tag],
+ code->kind());
+ msg->AppendAddress(code->address());
+ msg->Append(",%d,", code->ExecutableSize());
+}
+
+
+void Logger::AppendSymbolName(LogMessageBuilder* msg,
+ Symbol* symbol) {
+ ASSERT(symbol);
+ msg->Append("symbol(");
+ if (!symbol->name()->IsUndefined()) {
+ msg->Append("\"");
+ msg->AppendDetailed(String::cast(symbol->name()), false);
+ msg->Append("\" ");
+ }
+ msg->Append("hash %x)", symbol->Hash());
+}
void Logger::CodeCreateEvent(LogEventsAndTags tag,
@@ -959,19 +985,8 @@
if (!FLAG_log_code || !log_->IsEnabled()) return;
LogMessageBuilder msg(this);
- msg.Append("%s,%s,%d,",
- kLogEventsNames[CODE_CREATION_EVENT],
- kLogEventsNames[tag],
- code->kind());
- msg.AppendAddress(code->address());
- msg.Append(",%d,\"", code->ExecutableSize());
- for (const char* p = comment; *p != '\0'; p++) {
- if (*p == '"') {
- msg.Append('\\');
- }
- msg.Append(*p);
- }
- msg.Append('"');
+ AppendCodeCreateHeader(&msg, tag, code);
+ msg.AppendDoubleQuotedString(comment);
msg.Append('\n');
msg.WriteToLogFile();
}
@@ -989,25 +1004,13 @@
if (!FLAG_log_code || !log_->IsEnabled()) return;
LogMessageBuilder msg(this);
- msg.Append("%s,%s,%d,",
- kLogEventsNames[CODE_CREATION_EVENT],
- kLogEventsNames[tag],
- code->kind());
- msg.AppendAddress(code->address());
- msg.Append(",%d,", code->ExecutableSize());
+ AppendCodeCreateHeader(&msg, tag, code);
if (name->IsString()) {
msg.Append('"');
msg.AppendDetailed(String::cast(name), false);
msg.Append('"');
} else {
- Symbol* symbol = Symbol::cast(name);
- msg.Append("symbol(");
- if (!symbol->name()->IsUndefined()) {
- msg.Append("\"");
- msg.AppendDetailed(String::cast(symbol->name()), false);
- msg.Append("\" ");
- }
- msg.Append("hash %x)", symbol->Hash());
+ AppendSymbolName(&msg, Symbol::cast(name));
}
msg.Append('\n');
msg.WriteToLogFile();
@@ -1043,25 +1046,13 @@
return;
LogMessageBuilder msg(this);
- msg.Append("%s,%s,%d,",
- kLogEventsNames[CODE_CREATION_EVENT],
- kLogEventsNames[tag],
- code->kind());
- msg.AppendAddress(code->address());
- msg.Append(",%d,", code->ExecutableSize());
+ AppendCodeCreateHeader(&msg, tag, code);
if (name->IsString()) {
SmartArrayPointer<char> str =
String::cast(name)->ToCString(DISALLOW_NULLS,
ROBUST_STRING_TRAVERSAL);
msg.Append("\"%s\"", *str);
} else {
- Symbol* symbol = Symbol::cast(name);
- msg.Append("symbol(");
- if (!symbol->name()->IsUndefined()) {
- msg.Append("\"");
- msg.AppendDetailed(String::cast(symbol->name()), false);
- msg.Append("\" ");
- }
- msg.Append("hash %x)", symbol->Hash());
+ AppendSymbolName(&msg, Symbol::cast(name));
}
msg.Append(',');
msg.AppendAddress(shared->address());
@@ -1099,27 +1090,16 @@
if (!FLAG_log_code || !log_->IsEnabled()) return;
LogMessageBuilder msg(this);
+ AppendCodeCreateHeader(&msg, tag, code);
SmartArrayPointer<char> name =
shared->DebugName()->ToCString(DISALLOW_NULLS,
ROBUST_STRING_TRAVERSAL);
- msg.Append("%s,%s,%d,",
- kLogEventsNames[CODE_CREATION_EVENT],
- kLogEventsNames[tag],
- code->kind());
- msg.AppendAddress(code->address());
- msg.Append(",%d,\"%s ", code->ExecutableSize(), *name);
+ msg.Append("\"%s ", *name);
if (source->IsString()) {
SmartArrayPointer<char> sourcestr =
String::cast(source)->ToCString(DISALLOW_NULLS,
ROBUST_STRING_TRAVERSAL);
msg.Append("%s", *sourcestr);
} else {
- Symbol* symbol = Symbol::cast(source);
- msg.Append("symbol(");
- if (!symbol->name()->IsUndefined()) {
- msg.Append("\"");
- msg.AppendDetailed(String::cast(symbol->name()), false);
- msg.Append("\" ");
- }
- msg.Append("hash %x)", symbol->Hash());
+ AppendSymbolName(&msg, Symbol::cast(source));
}
msg.Append(":%d\",", line);
msg.AppendAddress(shared->address());
@@ -1139,12 +1119,8 @@
if (!FLAG_log_code || !log_->IsEnabled()) return;
LogMessageBuilder msg(this);
- msg.Append("%s,%s,%d,",
- kLogEventsNames[CODE_CREATION_EVENT],
- kLogEventsNames[tag],
- code->kind());
- msg.AppendAddress(code->address());
- msg.Append(",%d,\"args_count: %d\"", code->ExecutableSize(), args_count);
+ AppendCodeCreateHeader(&msg, tag, code);
+ msg.Append("\"args_count: %d\"", args_count);
msg.Append('\n');
msg.WriteToLogFile();
}
@@ -1167,13 +1143,10 @@
if (!FLAG_log_code || !log_->IsEnabled()) return;
LogMessageBuilder msg(this);
- msg.Append("%s,%s,-2,",
- kLogEventsNames[CODE_CREATION_EVENT],
- kLogEventsNames[REG_EXP_TAG]);
- msg.AppendAddress(code->address());
- msg.Append(",%d,\"", code->ExecutableSize());
+ AppendCodeCreateHeader(&msg, REG_EXP_TAG, code);
+ msg.Append('"');
msg.AppendDetailed(source, false);
- msg.Append('\"');
+ msg.Append('"');
msg.Append('\n');
msg.WriteToLogFile();
}
@@ -1242,12 +1215,9 @@
const char* code_name = address_to_name_map_->Lookup(addr);
if (code_name == NULL) return; // Not a code object.
LogMessageBuilder msg(this);
- msg.Append("%s,%d,\"", kLogEventsNames[SNAPSHOT_CODE_NAME_EVENT], pos);
- for (const char* p = code_name; *p != '\0'; ++p) {
- if (*p == '"') msg.Append('\\');
- msg.Append(*p);
- }
- msg.Append("\"\n");
+ msg.Append("%s,%d,", kLogEventsNames[SNAPSHOT_CODE_NAME_EVENT], pos);
+ msg.AppendDoubleQuotedString(code_name);
+ msg.Append("\n");
msg.WriteToLogFile();
}
if (!FLAG_log_snapshot_positions) return;
@@ -1319,14 +1289,7 @@
msg.Append(String::cast(name));
msg.Append('"');
} else {
- Symbol* symbol = Symbol::cast(name);
- msg.Append("symbol(");
- if (!symbol->name()->IsUndefined()) {
- msg.Append("\"");
- msg.AppendDetailed(String::cast(symbol->name()), false);
- msg.Append("\" ");
- }
- msg.Append("hash %x)", symbol->Hash());
+ AppendSymbolName(&msg, Symbol::cast(name));
}
msg.Append('\n');
msg.WriteToLogFile();
@@ -1548,6 +1511,10 @@
description = "A stub from the snapshot";
tag = Logger::STUB_TAG;
break;
+ case Code::REGEXP:
+ description = "Regular expression code";
+ tag = Logger::REG_EXP_TAG;
+ break;
case Code::BUILTIN:
description = "A builtin from the snapshot";
tag = Logger::BUILTIN_TAG;
=======================================
--- /branches/bleeding_edge/src/log.h Mon Jun 24 01:40:38 2013
+++ /branches/bleeding_edge/src/log.h Mon Jun 24 05:55:19 2013
@@ -422,6 +422,12 @@
// Helper method. It dumps name into name_buffer_.
void AppendName(Name* name);
+ // Appends standard code header.
+ void AppendCodeCreateHeader(LogMessageBuilder*, LogEventsAndTags, Code*);
+
+ // Appends symbol for the name.
+ void AppendSymbolName(LogMessageBuilder*, Symbol*);
+
// Emits general information about generated code.
void LogCodeInfo();
=======================================
--- /branches/bleeding_edge/src/objects.cc Fri Jun 21 06:02:38 2013
+++ /branches/bleeding_edge/src/objects.cc Mon Jun 24 05:55:19 2013
@@ -10365,6 +10365,7 @@
case COMPARE_IC: return "COMPARE_IC";
case COMPARE_NIL_IC: return "COMPARE_NIL_IC";
case TO_BOOLEAN_IC: return "TO_BOOLEAN_IC";
+ case REGEXP: return "REGEXP";
}
UNREACHABLE();
return NULL;
=======================================
--- /branches/bleeding_edge/src/objects.h Fri Jun 21 06:02:38 2013
+++ /branches/bleeding_edge/src/objects.h Mon Jun 24 05:55:19 2013
@@ -4454,7 +4454,9 @@
V(BINARY_OP_IC) \
V(COMPARE_IC) \
V(COMPARE_NIL_IC) \
- V(TO_BOOLEAN_IC)
+ V(TO_BOOLEAN_IC) \
+ V(REGEXP)
+
enum Kind {
#define DEFINE_CODE_KIND_ENUM(name) name,
@@ -4463,7 +4465,6 @@
// Pseudo-kinds.
LAST_CODE_KIND = TO_BOOLEAN_IC,
- REGEXP = BUILTIN,
FIRST_IC_KIND = LOAD_IC,
LAST_IC_KIND = TO_BOOLEAN_IC
};
=======================================
--- /branches/bleeding_edge/src/spaces.cc Fri Jun 14 09:06:12 2013
+++ /branches/bleeding_edge/src/spaces.cc Mon Jun 24 05:55:19 2013
@@ -1823,6 +1823,7 @@
CASE(COMPARE_IC);
CASE(COMPARE_NIL_IC);
CASE(TO_BOOLEAN_IC);
+ CASE(REGEXP);
}
}
=======================================
--- /branches/bleeding_edge/tools/plot-timer-events.js Tue Jan 29 06:41:02
2013
+++ /branches/bleeding_edge/tools/plot-timer-events.js Mon Jun 24 05:55:19
2013
@@ -104,14 +104,14 @@
var CodeKinds = {
- 'external ': new CodeKind("#3399FF", [-3]),
- 'reg.exp. ': new CodeKind("#0000FF", [-2]),
+ 'external ': new CodeKind("#3399FF", [-2]),
'runtime ': new CodeKind("#000000", [-1]),
'full code': new CodeKind("#DD0000", [0]),
'opt code ': new CodeKind("#00EE00", [1]),
'code stub': new CodeKind("#FF00FF", [2]),
'built-in ': new CodeKind("#AA00AA", [3]),
- 'inl.cache': new CodeKind("#4444AA", [4, 5, 6, 7, 8, 9, 10, 11, 12, 13]),
+ 'inl.cache': new CodeKind("#4444AA", [4, 5, 6, 7, 8, 9, 10, 11, 12, 13,
14]),
+ 'reg.exp. ': new CodeKind("#0000FF", [15]),
}
@@ -197,7 +197,7 @@
function ProcessSharedLibrary(name, start, end) {
var code_entry = new CodeMap.CodeEntry(end - start, name);
- code_entry.kind = -3; // External code kind.
+ code_entry.kind = -2; // External code kind.
for (var i = 0; i < kV8BinarySuffixes.length; i++) {
var suffix = kV8BinarySuffixes[i];
if (name.indexOf(suffix, name.length - suffix.length) >= 0) {
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.