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 683 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
694 SC(lo_space_bytes_used, V8.MemoryLoSpaceBytesUsed) \ | 694 SC(lo_space_bytes_used, V8.MemoryLoSpaceBytesUsed) \ |
695 SC(turbo_escape_allocs_replaced, V8.TurboEscapeAllocsReplaced) \ | 695 SC(turbo_escape_allocs_replaced, V8.TurboEscapeAllocsReplaced) \ |
696 SC(crankshaft_escape_allocs_replaced, V8.CrankshaftEscapeAllocsReplaced) \ | 696 SC(crankshaft_escape_allocs_replaced, V8.CrankshaftEscapeAllocsReplaced) \ |
697 SC(turbo_escape_loads_replaced, V8.TurboEscapeLoadsReplaced) \ | 697 SC(turbo_escape_loads_replaced, V8.TurboEscapeLoadsReplaced) \ |
698 SC(crankshaft_escape_loads_replaced, V8.CrankshaftEscapeLoadsReplaced) \ | 698 SC(crankshaft_escape_loads_replaced, V8.CrankshaftEscapeLoadsReplaced) \ |
699 /* Total code size (including metadata) of baseline code or bytecode. */ \ | 699 /* Total code size (including metadata) of baseline code or bytecode. */ \ |
700 SC(total_baseline_code_size, V8.TotalBaselineCodeSize) \ | 700 SC(total_baseline_code_size, V8.TotalBaselineCodeSize) \ |
701 /* Total count of functions compiled using the baseline compiler. */ \ | 701 /* Total count of functions compiled using the baseline compiler. */ \ |
702 SC(total_baseline_compile_count, V8.TotalBaselineCompileCount) | 702 SC(total_baseline_compile_count, V8.TotalBaselineCompileCount) |
703 | 703 |
704 typedef struct RuntimeCallCounter { | 704 struct RuntimeCallCounter { |
| 705 explicit RuntimeCallCounter(const char* name) : name(name) {} |
| 706 void Reset(); |
| 707 |
| 708 const char* name; |
705 int64_t count = 0; | 709 int64_t count = 0; |
706 base::TimeDelta time; | 710 base::TimeDelta time; |
707 RuntimeCallCounter* parent_counter; | 711 }; |
708 | 712 |
709 void Reset(); | 713 // TimerLink is used to keep track of the stack of currently active timers used |
710 } RuntimeCallCounter; | 714 // for RuntimeCallCounter. |
| 715 class TimerLink { |
| 716 public: |
| 717 TimerLink(RuntimeCallCounter* counter, TimerLink* parent) |
| 718 : counter_(counter), parent_(parent) {} |
| 719 |
| 720 inline void Start() { |
| 721 timer_.Start(); |
| 722 counter_->count++; |
| 723 } |
| 724 |
| 725 inline TimerLink* Stop() { |
| 726 base::TimeDelta delta = timer_.Elapsed(); |
| 727 counter_->time += delta; |
| 728 if (parent_ != NULL) { |
| 729 parent_->AdjustForSubTimer(delta); |
| 730 } |
| 731 return parent_; |
| 732 } |
| 733 |
| 734 void AdjustForSubTimer(base::TimeDelta delta) { counter_->time -= delta; } |
| 735 |
| 736 private: |
| 737 RuntimeCallCounter* counter_; |
| 738 TimerLink* parent_; |
| 739 base::ElapsedTimer timer_; |
| 740 }; |
711 | 741 |
712 struct RuntimeCallStats { | 742 struct RuntimeCallStats { |
| 743 // Dummy counter for the unexpected stub miss. |
| 744 RuntimeCallCounter UnexpectedStubMiss = {"UnexpectedStubMiss"}; |
| 745 // Counter for runtime callbacks into JavaScript. |
| 746 RuntimeCallCounter RuntimeCallbacks = {"RuntimeCallback"}; |
713 #define CALL_RUNTIME_COUNTER(name, nargs, ressize) \ | 747 #define CALL_RUNTIME_COUNTER(name, nargs, ressize) \ |
714 RuntimeCallCounter Runtime_##name; | 748 RuntimeCallCounter Runtime_##name = {#name}; |
715 FOR_EACH_INTRINSIC(CALL_RUNTIME_COUNTER) | 749 FOR_EACH_INTRINSIC(CALL_RUNTIME_COUNTER) |
716 #undef CALL_RUNTIME_COUNTER | 750 #undef CALL_RUNTIME_COUNTER |
717 #define CALL_BUILTIN_COUNTER(name, type) RuntimeCallCounter Builtin_##name; | 751 #define CALL_BUILTIN_COUNTER(name, type) \ |
| 752 RuntimeCallCounter Builtin_##name = {#name}; |
718 BUILTIN_LIST_C(CALL_BUILTIN_COUNTER) | 753 BUILTIN_LIST_C(CALL_BUILTIN_COUNTER) |
719 #undef CALL_BUILTIN_COUNTER | 754 #undef CALL_BUILTIN_COUNTER |
720 | 755 |
721 // Dummy counter for the unexpected stub miss. | |
722 RuntimeCallCounter UnexpectedStubMiss; | |
723 // Counter to track recursive time events. | 756 // Counter to track recursive time events. |
724 RuntimeCallCounter* current_counter; | 757 TimerLink* current_timer_link_; |
725 | 758 |
726 // Starting measuring the time for a function. This will establish the | 759 // Starting measuring the time for a function. This will establish the |
727 // connection to the parent counter for properly calculating the own times. | 760 // connection to the parent counter for properly calculating the own times. |
728 void Enter(RuntimeCallCounter* counter); | 761 void Enter(RuntimeCallCounter* counter); |
729 // Leave a scope for a measured runtime function. This will properly add | 762 // Leave a scope for a measured runtime function. This will properly add |
730 // the time delta to the current_counter and subtract the delta from its | 763 // the time delta to the current_counter and subtract the delta from its |
731 // parent. | 764 // parent. |
732 void Leave(base::TimeDelta time); | 765 void Leave(); |
733 | 766 |
734 void Reset(); | 767 void Reset(); |
735 void Print(std::ostream& os); | 768 void Print(std::ostream& os); |
736 | 769 |
737 RuntimeCallStats() { Reset(); } | 770 RuntimeCallStats() { Reset(); } |
738 }; | 771 }; |
739 | 772 |
740 // This file contains all the v8 counters that are in use. | 773 // This file contains all the v8 counters that are in use. |
741 class Counters { | 774 class Counters { |
742 public: | 775 public: |
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
915 | 948 |
916 explicit Counters(Isolate* isolate); | 949 explicit Counters(Isolate* isolate); |
917 | 950 |
918 DISALLOW_IMPLICIT_CONSTRUCTORS(Counters); | 951 DISALLOW_IMPLICIT_CONSTRUCTORS(Counters); |
919 }; | 952 }; |
920 | 953 |
921 } // namespace internal | 954 } // namespace internal |
922 } // namespace v8 | 955 } // namespace v8 |
923 | 956 |
924 #endif // V8_COUNTERS_H_ | 957 #endif // V8_COUNTERS_H_ |
OLD | NEW |