Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef V8_COUNTERS_H_ | 5 #ifndef V8_COUNTERS_H_ |
| 6 #define V8_COUNTERS_H_ | 6 #define V8_COUNTERS_H_ |
| 7 | 7 |
| 8 #include "include/v8.h" | 8 #include "include/v8.h" |
| 9 #include "src/allocation.h" | 9 #include "src/allocation.h" |
| 10 #include "src/base/platform/elapsed-timer.h" | 10 #include "src/base/platform/elapsed-timer.h" |
| (...skipping 787 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 798 // Leave a scope for a measured runtime function. This will properly add | 798 // Leave a scope for a measured runtime function. This will properly add |
| 799 // the time delta to the current_counter and subtract the delta from its | 799 // the time delta to the current_counter and subtract the delta from its |
| 800 // parent. | 800 // parent. |
| 801 static void Leave(RuntimeCallStats* stats, RuntimeCallTimer* timer); | 801 static void Leave(RuntimeCallStats* stats, RuntimeCallTimer* timer); |
| 802 | 802 |
| 803 // Set counter id for the innermost measurement. It can be used to refine | 803 // Set counter id for the innermost measurement. It can be used to refine |
| 804 // event kind when a runtime entry counter is too generic. | 804 // event kind when a runtime entry counter is too generic. |
| 805 static void CorrectCurrentCounterId(RuntimeCallStats* stats, | 805 static void CorrectCurrentCounterId(RuntimeCallStats* stats, |
| 806 CounterId counter_id); | 806 CounterId counter_id); |
| 807 | 807 |
| 808 // Returns true if RuntimeCallStats are enabled either through a flag or | |
| 809 // with tracing. | |
| 810 static bool IsEnabled() { | |
|
fmeawad
2016/10/28 21:54:25
Wouldn't that add an extra call per check? Why a m
Camillo Bruni
2016/10/31 09:57:18
From what I've seen so far is that clang inlines v
| |
| 811 return V8_UNLIKELY(TRACE_EVENT_RUNTIME_CALL_STATS_TRACING_ENABLED()) || | |
| 812 FLAG_runtime_call_stats; | |
|
Camillo Bruni
2016/10/31 09:57:58
nit: put the V8_UNLIKELY around the whole clause,
| |
| 813 } | |
| 814 | |
| 808 void Reset(); | 815 void Reset(); |
| 809 void Print(std::ostream& os); | 816 void Print(std::ostream& os); |
| 810 V8_NOINLINE void Dump(v8::tracing::TracedValue* value); | 817 V8_NOINLINE void Dump(v8::tracing::TracedValue* value); |
| 811 | 818 |
| 812 RuntimeCallStats() { | 819 RuntimeCallStats() { |
| 813 Reset(); | 820 Reset(); |
| 814 in_use_ = false; | 821 in_use_ = false; |
| 815 } | 822 } |
| 816 | 823 |
| 817 RuntimeCallTimer* current_timer() { return current_timer_; } | 824 RuntimeCallTimer* current_timer() { return current_timer_; } |
| 818 bool InUse() { return in_use_; } | 825 bool InUse() { return in_use_; } |
| 819 | 826 |
| 820 private: | 827 private: |
| 821 // Counter to track recursive time events. | 828 // Counter to track recursive time events. |
| 822 RuntimeCallTimer* current_timer_ = NULL; | 829 RuntimeCallTimer* current_timer_ = NULL; |
| 823 // Used to track nested tracing scopes. | 830 // Used to track nested tracing scopes. |
| 824 bool in_use_; | 831 bool in_use_; |
| 825 }; | 832 }; |
| 826 | 833 |
| 827 #define TRACE_RUNTIME_CALL_STATS(isolate, counter_name) \ | 834 #define TRACE_RUNTIME_CALL_STATS(isolate, counter_name) \ |
| 828 do { \ | 835 do { \ |
| 829 if (V8_UNLIKELY(TRACE_EVENT_RUNTIME_CALL_STATS_TRACING_ENABLED() || \ | 836 if (RuntimeCallStats::IsEnabled()) { \ |
| 830 FLAG_runtime_call_stats)) { \ | 837 RuntimeCallStats::CorrectCurrentCounterId( \ |
| 831 RuntimeCallStats::CorrectCurrentCounterId( \ | 838 isolate->counters()->runtime_call_stats(), \ |
| 832 isolate->counters()->runtime_call_stats(), \ | 839 &RuntimeCallStats::counter_name); \ |
| 833 &RuntimeCallStats::counter_name); \ | 840 } \ |
| 834 } \ | |
| 835 } while (false) | 841 } while (false) |
| 836 | 842 |
| 837 #define TRACE_HANDLER_STATS(isolate, counter_name) \ | 843 #define TRACE_HANDLER_STATS(isolate, counter_name) \ |
| 838 TRACE_RUNTIME_CALL_STATS(isolate, Handler_##counter_name) | 844 TRACE_RUNTIME_CALL_STATS(isolate, Handler_##counter_name) |
| 839 | 845 |
| 840 #define HISTOGRAM_RANGE_LIST(HR) \ | 846 #define HISTOGRAM_RANGE_LIST(HR) \ |
| 841 /* Generic range histograms */ \ | 847 /* Generic range histograms */ \ |
| 842 HR(detached_context_age_in_gc, V8.DetachedContextAgeInGC, 0, 20, 21) \ | 848 HR(detached_context_age_in_gc, V8.DetachedContextAgeInGC, 0, 20, 21) \ |
| 843 HR(gc_idle_time_allotted_in_ms, V8.GCIdleTimeAllottedInMS, 0, 10000, 101) \ | 849 HR(gc_idle_time_allotted_in_ms, V8.GCIdleTimeAllottedInMS, 0, 10000, 101) \ |
| 844 HR(gc_idle_time_limit_overshot, V8.GCIdleTimeLimit.Overshot, 0, 10000, 101) \ | 850 HR(gc_idle_time_limit_overshot, V8.GCIdleTimeLimit.Overshot, 0, 10000, 101) \ |
| (...skipping 430 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1275 } | 1281 } |
| 1276 | 1282 |
| 1277 Isolate* isolate_ = nullptr; | 1283 Isolate* isolate_ = nullptr; |
| 1278 RuntimeCallTimer timer_; | 1284 RuntimeCallTimer timer_; |
| 1279 }; | 1285 }; |
| 1280 | 1286 |
| 1281 } // namespace internal | 1287 } // namespace internal |
| 1282 } // namespace v8 | 1288 } // namespace v8 |
| 1283 | 1289 |
| 1284 #endif // V8_COUNTERS_H_ | 1290 #endif // V8_COUNTERS_H_ |
| OLD | NEW |