Reviewers: Jakob,

Description:
Fix V8's default timer event logger.

This broke because the optimizing compiler thread no longer holds
Isolate::Current() in its TLS.

[email protected]

Please review this at https://codereview.chromium.org/655813002/

Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge

Affected files (+18, -21 lines):
  M src/api.cc
  M src/counters.cc
  M src/isolate.cc
  M src/log.h
  M src/log.cc
  M src/log-inl.h


Index: src/api.cc
diff --git a/src/api.cc b/src/api.cc
index 4fbbc80708b1ee723c68843922faec65a6eaa22c..fe56c2b8904d590a2861f2d991625a574bd82373 100644
--- a/src/api.cc
+++ b/src/api.cc
@@ -6711,7 +6711,7 @@ void Isolate::GetStackSample(const RegisterState& state, void** frames,

 void Isolate::SetEventLogger(LogEventCallback that) {
   // Do not overwrite the event logger if we want to log explicitly.
-  if (i::FLAG_log_timer_events) return;
+  if (i::FLAG_log_internal_timer_events) return;
   i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this);
   isolate->set_event_logger(that);
 }
Index: src/counters.cc
diff --git a/src/counters.cc b/src/counters.cc
index a8dcc0bdcb882c3bbb0e1634dba3a5577d1cf468..972bd6862c0f5a5524dfd9f57021e9eb4b61c1a8 100644
--- a/src/counters.cc
+++ b/src/counters.cc
@@ -7,6 +7,7 @@
 #include "src/base/platform/platform.h"
 #include "src/counters.h"
 #include "src/isolate.h"
+#include "src/log-inl.h"

 namespace v8 {
 namespace internal {
@@ -39,7 +40,7 @@ void HistogramTimer::Start() {
   if (Enabled()) {
     timer_.Start();
   }
-  isolate()->event_logger()(name(), Logger::START);
+  Logger::CallEventLogger(isolate(), name(), Logger::START, true);
 }


@@ -50,7 +51,7 @@ void HistogramTimer::Stop() {
     AddSample(static_cast<int>(timer_.Elapsed().InMilliseconds()));
     timer_.Stop();
   }
-  isolate()->event_logger()(name(), Logger::END);
+  Logger::CallEventLogger(isolate(), name(), Logger::END, true);
 }


Index: src/isolate.cc
diff --git a/src/isolate.cc b/src/isolate.cc
index 2874c168b74bdcc9e769b189e27020d3830f40ed..5703225f4e0b6f14789ec7e6778aed881e5544af 100644
--- a/src/isolate.cc
+++ b/src/isolate.cc
@@ -1911,12 +1911,6 @@ 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::DefaultTimerEventsLogger);
-  } else {
-    set_event_logger(Logger::EmptyTimerEventsLogger);
-  }
-
   // Set default value if not yet set.
   // TODO(yangguo): move this to ResourceConstraints::ConfigureDefaults
// once ResourceConstraints becomes an argument to the Isolate constructor.
Index: src/log-inl.h
diff --git a/src/log-inl.h b/src/log-inl.h
index 28677ad235dc7ce59c4886cbc8dbf711393fe8cf..22ea800585c326866cc8dc1efab35b7c19966d2a 100644
--- a/src/log-inl.h
+++ b/src/log-inl.h
@@ -6,6 +6,7 @@
 #define V8_LOG_INL_H_

 #include "src/log.h"
+#include "src/isolate.h"

 namespace v8 {
 namespace internal {
@@ -26,6 +27,14 @@ 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);
+  }
+}
 } }  // namespace v8::internal

 #endif  // V8_LOG_INL_H_
Index: src/log.cc
diff --git a/src/log.cc b/src/log.cc
index 0af1c9f03d1b04b8a3b2e6af7a54ebb4bdc570bd..0dcf6bb976960c389e5be71edbea88238c7dbe29 100644
--- a/src/log.cc
+++ b/src/log.cc
@@ -16,6 +16,7 @@
 #include "src/cpu-profiler.h"
 #include "src/deoptimizer.h"
 #include "src/global-handles.h"
+#include "src/log-inl.h"
 #include "src/log-utils.h"
 #include "src/macro-assembler.h"
 #include "src/perf-jit.h"
@@ -954,18 +955,10 @@ void Logger::LeaveExternal(Isolate* isolate) {
 }


-void Logger::DefaultTimerEventsLogger(const char* name, int se) {
-  Isolate* isolate = Isolate::Current();
-  LOG(isolate, TimerEvent(static_cast<StartEnd>(se), name));
-}
-
-
 template <class TimerEvent>
 void TimerEventScope<TimerEvent>::LogTimerEvent(Logger::StartEnd se) {
-  if (TimerEvent::expose_to_api() ||
-      isolate_->event_logger() == Logger::DefaultTimerEventsLogger) {
-    isolate_->event_logger()(TimerEvent::name(), se);
-  }
+  Logger::CallEventLogger(isolate_, TimerEvent::name(), se,
+                          TimerEvent::expose_to_api());
 }


Index: src/log.h
diff --git a/src/log.h b/src/log.h
index 51597ddda93a902d3c7ffd73b2974d47ec0706fd..2bcd42f0d2be17d541920ca746e79befb50f647b 100644
--- a/src/log.h
+++ b/src/log.h
@@ -300,8 +300,8 @@ class Logger {
   static void EnterExternal(Isolate* isolate);
   static void LeaveExternal(Isolate* isolate);

-  static void EmptyTimerEventsLogger(const char* name, int se) {}
-  static void DefaultTimerEventsLogger(const char* name, int se);
+  static inline void CallEventLogger(Isolate* isolate, const char* name,
+                                     StartEnd se, bool expose_to_api);

   // ==== Events logged by --log-regexp ====
   // Regexp compilation and execution events.


--
--
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/d/optout.

Reply via email to