From: yangguo@chromium.org Date: Tue, 14 Oct 2014 14:45:03 +0000 (+0000) Subject: Fix V8's default timer event logger. X-Git-Tag: upstream/4.7.83~6369 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=1a90501909bc9dbee5c66ad3872a1306da9d54a9;p=platform%2Fupstream%2Fv8.git Fix V8's default timer event logger. This broke because the optimizing compiler thread no longer holds Isolate::Current() in its TLS. R=jkummerow@chromium.org Review URL: https://codereview.chromium.org/655813002 git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@24607 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- diff --git a/src/api.cc b/src/api.cc index 4fbbc8070..fe56c2b89 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(this); isolate->set_event_logger(that); } diff --git a/src/counters.cc b/src/counters.cc index a8dcc0bdc..972bd6862 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(timer_.Elapsed().InMilliseconds())); timer_.Stop(); } - isolate()->event_logger()(name(), Logger::END); + Logger::CallEventLogger(isolate(), name(), Logger::END, true); } diff --git a/src/isolate.cc b/src/isolate.cc index 2874c168b..5703225f4 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. diff --git a/src/log-inl.h b/src/log-inl.h index 28677ad23..22ea80058 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_ diff --git a/src/log.cc b/src/log.cc index 0af1c9f03..0dcf6bb97 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(se), name)); -} - - template void TimerEventScope::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()); } diff --git a/src/log.h b/src/log.h index 51597ddda..2bcd42f0d 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.