V8 API Reference, 7.2.502.16 (for Deno 0.2.4)
pipeline-statistics.h
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 <memory>
9 #include <string>
10 
11 #include "src/base/platform/elapsed-timer.h"
12 #include "src/compilation-statistics.h"
13 #include "src/compiler/zone-stats.h"
14 
15 namespace v8 {
16 namespace internal {
17 namespace compiler {
18 
19 class PhaseScope;
20 
21 class PipelineStatistics : public Malloced {
22  public:
24  CompilationStatistics* turbo_stats, ZoneStats* zone_stats);
26 
27  void BeginPhaseKind(const char* phase_kind_name);
28  void EndPhaseKind();
29 
30  private:
31  size_t OuterZoneSize() {
32  return static_cast<size_t>(outer_zone_->allocation_size());
33  }
34 
35  class CommonStats {
36  public:
37  CommonStats() : outer_zone_initial_size_(0) {}
38 
39  void Begin(PipelineStatistics* pipeline_stats);
40  void End(PipelineStatistics* pipeline_stats,
42 
43  std::unique_ptr<ZoneStats::StatsScope> scope_;
44  base::ElapsedTimer timer_;
45  size_t outer_zone_initial_size_;
46  size_t allocated_bytes_at_start_;
47 
48  private:
49  DISALLOW_COPY_AND_ASSIGN(CommonStats);
50  };
51 
52  bool InPhaseKind() { return !!phase_kind_stats_.scope_; }
53 
54  friend class PhaseScope;
55  bool InPhase() { return !!phase_stats_.scope_; }
56  void BeginPhase(const char* name);
57  void EndPhase();
58 
59  Zone* outer_zone_;
60  ZoneStats* zone_stats_;
61  CompilationStatistics* compilation_stats_;
62  std::string function_name_;
63 
64  // Stats for the entire compilation.
65  CommonStats total_stats_;
66  size_t source_size_;
67 
68  // Stats for phase kind.
69  const char* phase_kind_name_;
70  CommonStats phase_kind_stats_;
71 
72  // Stats for phase.
73  const char* phase_name_;
74  CommonStats phase_stats_;
75 
76  DISALLOW_COPY_AND_ASSIGN(PipelineStatistics);
77 };
78 
79 
80 class PhaseScope {
81  public:
82  PhaseScope(PipelineStatistics* pipeline_stats, const char* name)
83  : pipeline_stats_(pipeline_stats) {
84  if (pipeline_stats_ != nullptr) pipeline_stats_->BeginPhase(name);
85  }
86  ~PhaseScope() {
87  if (pipeline_stats_ != nullptr) pipeline_stats_->EndPhase();
88  }
89 
90  private:
91  PipelineStatistics* const pipeline_stats_;
92 
93  DISALLOW_COPY_AND_ASSIGN(PhaseScope);
94 };
95 
96 } // namespace compiler
97 } // namespace internal
98 } // namespace v8
99 
100 #endif // V8_COMPILER_PIPELINE_STATISTICS_H_
Definition: libplatform.h:13