Make event logger slightly more light-weight.
authoryangguo@chromium.org <yangguo@chromium.org>
Wed, 15 Oct 2014 11:16:42 +0000 (11:16 +0000)
committeryangguo@chromium.org <yangguo@chromium.org>
Wed, 15 Oct 2014 11:16:42 +0000 (11:16 +0000)
R=dcarney@chromium.org
BUG=chromium:423668
LOG=N

Review URL: https://codereview.chromium.org/651413002

git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@24624 ce2b1a6d-e550-0410-aec6-3dcde31c8c00

src/isolate.cc
src/log-inl.h
src/log.h

index 5703225f4e0b6f14789ec7e6778aed881e5544af..ef980dc2b9ea26ee2482ba40c078d2e594b0acc0 100644 (file)
@@ -1911,6 +1911,10 @@ bool Isolate::Init(Deserializer* des) {
   bootstrapper_->Initialize(create_heap_objects);
   builtins_.SetUp(this, create_heap_objects);
 
+  if (FLAG_log_internal_timer_events) {
+    set_event_logger(Logger::DefaultEventLoggerSentinel);
+  }
+
   // Set default value if not yet set.
   // TODO(yangguo): move this to ResourceConstraints::ConfigureDefaults
   // once ResourceConstraints becomes an argument to the Isolate constructor.
index 22ea800585c326866cc8dc1efab35b7c19966d2a..a96631d059d1a5dd0dffb7d3ebd9ec9d2cd64584 100644 (file)
@@ -29,10 +29,12 @@ Logger::LogEventsAndTags Logger::ToNativeByScript(Logger::LogEventsAndTags tag,
 
 void Logger::CallEventLogger(Isolate* isolate, const char* name, StartEnd se,
                              bool expose_to_api) {
-  if (isolate->event_logger() == NULL) {
-    if (FLAG_log_internal_timer_events) LOG(isolate, TimerEvent(se, name));
-  } else if (expose_to_api) {
-    isolate->event_logger()(name, se);
+  if (isolate->event_logger() != NULL) {
+    if (isolate->event_logger() == DefaultEventLoggerSentinel) {
+      LOG(isolate, TimerEvent(se, name));
+    } else if (expose_to_api) {
+      isolate->event_logger()(name, se);
+    }
   }
 }
 } }  // namespace v8::internal
index 2bcd42f0d2be17d541920ca746e79befb50f647b..abf35f0ebc5ddcf0373f598d0cf48eee1d479e5c 100644 (file)
--- a/src/log.h
+++ b/src/log.h
@@ -300,8 +300,10 @@ class Logger {
   static void EnterExternal(Isolate* isolate);
   static void LeaveExternal(Isolate* isolate);
 
-  static inline void CallEventLogger(Isolate* isolate, const char* name,
-                                     StartEnd se, bool expose_to_api);
+  static void DefaultEventLoggerSentinel(const char* name, int event) {}
+
+  INLINE(static void CallEventLogger(Isolate* isolate, const char* name,
+                                     StartEnd se, bool expose_to_api));
 
   // ==== Events logged by --log-regexp ====
   // Regexp compilation and execution events.