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

Unified Diff: src/compiler.cc

Issue 20018: Added check for logging enabled in two places where processing/allocation was... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 11 years, 11 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 | « no previous file | src/mark-compact.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/compiler.cc
===================================================================
--- src/compiler.cc (revision 1216)
+++ src/compiler.cc (working copy)
@@ -121,13 +121,19 @@
return Handle<JSFunction>::null();
}
- if (script->name()->IsString()) {
- SmartPointer<char> data =
- String::cast(script->name())->ToCString(DISALLOW_NULLS);
- LOG(CodeCreateEvent(is_eval ? "Eval" : "Script", *code, *data));
- } else {
- LOG(CodeCreateEvent(is_eval ? "Eval" : "Script", *code, ""));
+#ifdef ENABLE_LOGGING_AND_PROFILING
+ // Log the code generation for the script. Check explicit whether logging is
+ // to avoid allocating when not required.
+ if (Logger::is_enabled()) {
+ if (script->name()->IsString()) {
+ SmartPointer<char> data =
+ String::cast(script->name())->ToCString(DISALLOW_NULLS);
+ LOG(CodeCreateEvent(is_eval ? "Eval" : "Script", *code, *data));
+ } else {
+ LOG(CodeCreateEvent(is_eval ? "Eval" : "Script", *code, ""));
+ }
}
+#endif
// Allocate function.
Handle<JSFunction> fun =
@@ -292,17 +298,21 @@
return false;
}
- // Generate the code, update the function info, and return the code.
#ifdef ENABLE_LOGGING_AND_PROFILING
- if (script->name()->IsString()) {
- int lineNum = script->GetLineNumber(start_position);
- if (lineNum > 0) {
- lineNum += script->line_offset()->value() + 1;
+ // Log the code generation. If source information is available include script
+ // name and line number. Check explicit whether logging is enabled as finding
+ // the line number is not for free.
+ if (Logger::is_enabled()) {
+ if (script->name()->IsString()) {
+ int lineNum = script->GetLineNumber(start_position);
+ if (lineNum > 0) {
+ lineNum += script->line_offset()->value() + 1;
+ }
+ LOG(CodeCreateEvent("LazyCompile", *code, *lit->name(),
+ String::cast(script->name()), lineNum));
+ } else {
+ LOG(CodeCreateEvent("LazyCompile", *code, *lit->name()));
}
- LOG(CodeCreateEvent("LazyCompile", *code, *lit->name(),
- String::cast(script->name()), lineNum));
- } else {
- LOG(CodeCreateEvent("LazyCompile", *code, *lit->name()));
}
#endif
« no previous file with comments | « no previous file | src/mark-compact.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698