Author: [email protected]
Date: Tue Feb  3 06:44:39 2009
New Revision: 1220

Modified:
    branches/bleeding_edge/src/compiler.cc
    branches/bleeding_edge/src/mark-compact.cc

Log:
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

Modified: branches/bleeding_edge/src/compiler.cc
==============================================================================
--- branches/bleeding_edge/src/compiler.cc      (original)
+++ branches/bleeding_edge/src/compiler.cc      Tue Feb  3 06:44:39 2009
@@ -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(CodeCreateEvent("LazyCompile", *code, *lit->name(),
-                        String::cast(script->name()), lineNum));
-  } else {
-    LOG(CodeCreateEvent("LazyCompile", *code, *lit->name()));
+  // 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()));
+    }
    }
  #endif


Modified: branches/bleeding_edge/src/mark-compact.cc
==============================================================================
--- branches/bleeding_edge/src/mark-compact.cc  (original)
+++ branches/bleeding_edge/src/mark-compact.cc  Tue Feb  3 06:44:39 2009
@@ -1111,6 +1111,7 @@
          }
        } else {
          if (object->IsCode()) {
+          // Notify the logger that compiled code has been collected.
            LOG(CodeDeleteEvent(Code::cast(object)->address()));
          }
          if (is_previous_alive) {  // Transition from live to free.
@@ -1678,7 +1679,7 @@
    if (copied_to->IsCode()) {
      // may also update inline cache target.
      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));
    }


--~--~---------~--~----~------------~-------~--~----~
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
-~----------~----~----~----~------~----~------~--~---

Reply via email to