Index: src/counters.h |
diff --git a/src/counters.h b/src/counters.h |
index 27ed8776ee665db93d0362529e569ac244ed25a1..18a35386f40f009ec81431be30a28304ebb39e72 100644 |
--- a/src/counters.h |
+++ b/src/counters.h |
@@ -810,15 +810,14 @@ class RuntimeCallStats { |
#define TRACE_RUNTIME_CALL_STATS(isolate, counter_name) \ |
do { \ |
- if (FLAG_runtime_call_stats) { \ |
- RuntimeCallStats::CorrectCurrentCounterId( \ |
- isolate->counters()->runtime_call_stats(), \ |
- &RuntimeCallStats::counter_name); \ |
- } \ |
if (V8_UNLIKELY(TRACE_EVENT_RUNTIME_CALL_STATS_TRACING_ENABLED())) { \ |
RuntimeCallStats::CorrectCurrentCounterId( \ |
isolate->counters()->tracing_runtime_call_stats(), \ |
&RuntimeCallStats::counter_name); \ |
+ } else if (FLAG_runtime_call_stats) { \ |
+ RuntimeCallStats::CorrectCurrentCounterId( \ |
+ isolate->counters()->runtime_call_stats(), \ |
+ &RuntimeCallStats::counter_name); \ |
} \ |
} while (false) |
@@ -1247,17 +1246,17 @@ class RuntimeCallTimerScope { |
public: |
inline RuntimeCallTimerScope(Isolate* isolate, |
RuntimeCallStats::CounterId counter_id) { |
- if (V8_UNLIKELY(FLAG_runtime_call_stats)) { |
+ if (V8_UNLIKELY(TRACE_EVENT_RUNTIME_CALL_STATS_TRACING_ENABLED())) { |
+ isolate_ = isolate; |
+ is_tracing_ = true; |
+ RuntimeCallStats::Enter( |
+ isolate_->counters()->tracing_runtime_call_stats(), &timer_, |
+ counter_id); |
+ } else if (V8_UNLIKELY(FLAG_runtime_call_stats)) { |
isolate_ = isolate; |
RuntimeCallStats::Enter(isolate_->counters()->runtime_call_stats(), |
&timer_, counter_id); |
} |
- if (V8_UNLIKELY(TRACE_EVENT_RUNTIME_CALL_STATS_TRACING_ENABLED())) { |
- isolate_for_tracing_ = isolate; |
- RuntimeCallStats::Enter( |
- isolate_for_tracing_->counters()->tracing_runtime_call_stats(), |
- &trace_event_timer_, counter_id); |
- } |
} |
// This constructor is here just to avoid calling GetIsolate() when the |
// stats are disabled and the isolate is not directly available. |
@@ -1265,26 +1264,21 @@ class RuntimeCallTimerScope { |
RuntimeCallStats::CounterId counter_id); |
Camillo Bruni
2016/09/07 02:00:29
nit: could you declare both constructors in the sa
lpy
2016/09/07 16:48:09
Done.
|
inline ~RuntimeCallTimerScope() { |
- if (V8_UNLIKELY(FLAG_runtime_call_stats)) { |
- RuntimeCallStats::Leave(isolate_->counters()->runtime_call_stats(), |
- &timer_); |
- } |
- if (V8_UNLIKELY(isolate_for_tracing_ != nullptr)) { |
- RuntimeCallStats::Leave( |
- isolate_for_tracing_->counters()->tracing_runtime_call_stats(), |
- &trace_event_timer_); |
- isolate_for_tracing_ = nullptr; |
+ if (V8_UNLIKELY(isolate_ != nullptr)) { |
+ if (is_tracing_) { |
+ RuntimeCallStats::Leave( |
+ isolate_->counters()->tracing_runtime_call_stats(), &timer_); |
+ } else { |
+ RuntimeCallStats::Leave(isolate_->counters()->runtime_call_stats(), |
+ &timer_); |
+ } |
} |
} |
private: |
- Isolate* isolate_; |
- // TODO(lpy): --runtime-call-stats and tracing should be mutually exclusive |
- // with tracing taking precendence. We need to add checks, and use a single |
- // isolate reference and a timer for both. |
- Isolate* isolate_for_tracing_ = nullptr; |
+ Isolate* isolate_ = nullptr; |
+ bool is_tracing_ = false; |
RuntimeCallTimer timer_; |
- RuntimeCallTimer trace_event_timer_; |
}; |
} // namespace internal |