Commit 4b05db4e authored by sgjesse@chromium.org's avatar sgjesse@chromium.org

Added check for logging enabled in two places where processing/allocation was...

Added check for logging enabled in two places where processing/allocation was performed only to be used only as parameters for the LOG macro. Looked through all the uses of the LOG macro and found only these two places where additional checking was required.

Fixed a couple of comments looking through all the uses of the LOG macro.
Review URL: http://codereview.chromium.org/20018

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@1220 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 78ec5863
...@@ -121,13 +121,19 @@ static Handle<JSFunction> MakeFunction(bool is_global, ...@@ -121,13 +121,19 @@ static Handle<JSFunction> MakeFunction(bool is_global,
return Handle<JSFunction>::null(); return Handle<JSFunction>::null();
} }
if (script->name()->IsString()) { #ifdef ENABLE_LOGGING_AND_PROFILING
SmartPointer<char> data = // Log the code generation for the script. Check explicit whether logging is
String::cast(script->name())->ToCString(DISALLOW_NULLS); // to avoid allocating when not required.
LOG(CodeCreateEvent(is_eval ? "Eval" : "Script", *code, *data)); if (Logger::is_enabled()) {
} else { if (script->name()->IsString()) {
LOG(CodeCreateEvent(is_eval ? "Eval" : "Script", *code, "")); 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. // Allocate function.
Handle<JSFunction> fun = Handle<JSFunction> fun =
...@@ -292,17 +298,21 @@ bool Compiler::CompileLazy(Handle<SharedFunctionInfo> shared, ...@@ -292,17 +298,21 @@ bool Compiler::CompileLazy(Handle<SharedFunctionInfo> shared,
return false; return false;
} }
// Generate the code, update the function info, and return the code.
#ifdef ENABLE_LOGGING_AND_PROFILING #ifdef ENABLE_LOGGING_AND_PROFILING
if (script->name()->IsString()) { // Log the code generation. If source information is available include script
int lineNum = script->GetLineNumber(start_position); // name and line number. Check explicit whether logging is enabled as finding
if (lineNum > 0) { // the line number is not for free.
lineNum += script->line_offset()->value() + 1; 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 #endif
......
...@@ -1111,6 +1111,7 @@ static void SweepSpace(PagedSpace* space, DeallocateFunction dealloc) { ...@@ -1111,6 +1111,7 @@ static void SweepSpace(PagedSpace* space, DeallocateFunction dealloc) {
} }
} else { } else {
if (object->IsCode()) { if (object->IsCode()) {
// Notify the logger that compiled code has been collected.
LOG(CodeDeleteEvent(Code::cast(object)->address())); LOG(CodeDeleteEvent(Code::cast(object)->address()));
} }
if (is_previous_alive) { // Transition from live to free. if (is_previous_alive) { // Transition from live to free.
...@@ -1678,7 +1679,7 @@ int MarkCompactCollector::RelocateCodeObject(HeapObject* obj) { ...@@ -1678,7 +1679,7 @@ int MarkCompactCollector::RelocateCodeObject(HeapObject* obj) {
if (copied_to->IsCode()) { if (copied_to->IsCode()) {
// may also update inline cache target. // may also update inline cache target.
Code::cast(copied_to)->Relocate(new_addr - old_addr); Code::cast(copied_to)->Relocate(new_addr - old_addr);
// Notify the logger that compile code has moved. // Notify the logger that compiled code has moved.
LOG(CodeMoveEvent(old_addr, new_addr)); LOG(CodeMoveEvent(old_addr, new_addr));
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment