OLD | NEW |
(Empty) | |
| 1 // Copyright 2014 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef V8_COMPILER_PIPELINE_STATISTICS_H_ |
| 6 #define V8_COMPILER_PIPELINE_STATISTICS_H_ |
| 7 |
| 8 #include <string> |
| 9 |
| 10 #include "src/compilation-statistics.h" |
| 11 #include "src/compiler/zone-pool.h" |
| 12 |
| 13 namespace v8 { |
| 14 namespace internal { |
| 15 namespace compiler { |
| 16 |
| 17 class PhaseScope; |
| 18 |
| 19 class PipelineStatistics : public Malloced { |
| 20 public: |
| 21 PipelineStatistics(CompilationInfo* info, ZonePool* zone_pool); |
| 22 ~PipelineStatistics(); |
| 23 |
| 24 void BeginPhaseKind(const char* phase_kind_name); |
| 25 |
| 26 private: |
| 27 size_t OuterZoneSize() { |
| 28 return static_cast<size_t>(outer_zone_->allocation_size()); |
| 29 } |
| 30 |
| 31 class CommonStats { |
| 32 public: |
| 33 CommonStats() : outer_zone_initial_size_(0) {} |
| 34 |
| 35 void Begin(PipelineStatistics* pipeline_stats); |
| 36 void End(PipelineStatistics* pipeline_stats, |
| 37 CompilationStatistics::BasicStats* diff); |
| 38 |
| 39 SmartPointer<ZonePool::StatsScope> scope_; |
| 40 base::ElapsedTimer timer_; |
| 41 size_t outer_zone_initial_size_; |
| 42 }; |
| 43 |
| 44 bool InPhaseKind() { return !phase_kind_stats_.scope_.is_empty(); } |
| 45 void EndPhaseKind(); |
| 46 |
| 47 friend class PhaseScope; |
| 48 bool InPhase() { return !phase_stats_.scope_.is_empty(); } |
| 49 void BeginPhase(const char* name); |
| 50 void EndPhase(); |
| 51 |
| 52 Isolate* isolate_; |
| 53 Zone* outer_zone_; |
| 54 ZonePool* zone_pool_; |
| 55 CompilationStatistics* compilation_stats_; |
| 56 std::string function_name_; |
| 57 |
| 58 // Stats for the entire compilation. |
| 59 CommonStats total_stats_; |
| 60 size_t source_size_; |
| 61 |
| 62 // Stats for phase kind. |
| 63 const char* phase_kind_name_; |
| 64 CommonStats phase_kind_stats_; |
| 65 |
| 66 // Stats for phase. |
| 67 const char* phase_name_; |
| 68 CommonStats phase_stats_; |
| 69 |
| 70 DISALLOW_COPY_AND_ASSIGN(PipelineStatistics); |
| 71 }; |
| 72 |
| 73 |
| 74 class PhaseScope { |
| 75 public: |
| 76 PhaseScope(PipelineStatistics* pipeline_stats, const char* name) |
| 77 : pipeline_stats_(pipeline_stats) { |
| 78 if (pipeline_stats_ != NULL) pipeline_stats_->BeginPhase(name); |
| 79 } |
| 80 ~PhaseScope() { |
| 81 if (pipeline_stats_ != NULL) pipeline_stats_->EndPhase(); |
| 82 } |
| 83 |
| 84 private: |
| 85 PipelineStatistics* const pipeline_stats_; |
| 86 |
| 87 DISALLOW_COPY_AND_ASSIGN(PhaseScope); |
| 88 }; |
| 89 |
| 90 } // namespace compiler |
| 91 } // namespace internal |
| 92 } // namespace v8 |
| 93 |
| 94 #endif |
OLD | NEW |