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.
5 #ifndef V8_COMPILER_PIPELINE_STATISTICS_H_
6 #define V8_COMPILER_PIPELINE_STATISTICS_H_
10 #include "src/compilation-statistics.h"
11 #include "src/compiler/zone-pool.h"
19 class PipelineStatistics : public Malloced {
21 PipelineStatistics(CompilationInfo* info, ZonePool* zone_pool);
22 ~PipelineStatistics();
24 void BeginPhaseKind(const char* phase_kind_name);
27 size_t OuterZoneSize() {
28 return static_cast<size_t>(outer_zone_->allocation_size());
33 CommonStats() : outer_zone_initial_size_(0) {}
35 void Begin(PipelineStatistics* pipeline_stats);
36 void End(PipelineStatistics* pipeline_stats,
37 CompilationStatistics::BasicStats* diff);
39 SmartPointer<ZonePool::StatsScope> scope_;
40 base::ElapsedTimer timer_;
41 size_t outer_zone_initial_size_;
42 size_t allocated_bytes_at_start_;
45 bool InPhaseKind() { return !phase_kind_stats_.scope_.is_empty(); }
48 friend class PhaseScope;
49 bool InPhase() { return !phase_stats_.scope_.is_empty(); }
50 void BeginPhase(const char* name);
56 CompilationStatistics* compilation_stats_;
57 std::string function_name_;
59 // Stats for the entire compilation.
60 CommonStats total_stats_;
63 // Stats for phase kind.
64 const char* phase_kind_name_;
65 CommonStats phase_kind_stats_;
68 const char* phase_name_;
69 CommonStats phase_stats_;
71 DISALLOW_COPY_AND_ASSIGN(PipelineStatistics);
77 PhaseScope(PipelineStatistics* pipeline_stats, const char* name)
78 : pipeline_stats_(pipeline_stats) {
79 if (pipeline_stats_ != NULL) pipeline_stats_->BeginPhase(name);
82 if (pipeline_stats_ != NULL) pipeline_stats_->EndPhase();
86 PipelineStatistics* const pipeline_stats_;
88 DISALLOW_COPY_AND_ASSIGN(PhaseScope);
91 } // namespace compiler
92 } // namespace internal