7 #include "src/compiler/pipeline-statistics.h" 8 #include "src/compiler/zone-stats.h" 9 #include "src/objects/shared-function-info.h" 10 #include "src/objects/string.h" 11 #include "src/optimized-compilation-info.h" 17 void PipelineStatistics::CommonStats::Begin(
18 PipelineStatistics* pipeline_stats) {
20 scope_.reset(
new ZoneStats::StatsScope(pipeline_stats->zone_stats_));
22 outer_zone_initial_size_ = pipeline_stats->OuterZoneSize();
23 allocated_bytes_at_start_ =
24 outer_zone_initial_size_ -
25 pipeline_stats->total_stats_.outer_zone_initial_size_ +
26 pipeline_stats->zone_stats_->GetCurrentAllocatedBytes();
30 void PipelineStatistics::CommonStats::End(
31 PipelineStatistics* pipeline_stats,
32 CompilationStatistics::BasicStats* diff) {
34 diff->function_name_ = pipeline_stats->function_name_;
35 diff->delta_ = timer_.Elapsed();
36 size_t outer_zone_diff =
37 pipeline_stats->OuterZoneSize() - outer_zone_initial_size_;
38 diff->max_allocated_bytes_ = outer_zone_diff + scope_->GetMaxAllocatedBytes();
39 diff->absolute_max_allocated_bytes_ =
40 diff->max_allocated_bytes_ + allocated_bytes_at_start_;
41 diff->total_allocated_bytes_ =
42 outer_zone_diff + scope_->GetTotalAllocatedBytes();
47 PipelineStatistics::PipelineStatistics(OptimizedCompilationInfo* info,
48 CompilationStatistics* compilation_stats,
49 ZoneStats* zone_stats)
50 : outer_zone_(info->zone()),
51 zone_stats_(zone_stats),
52 compilation_stats_(compilation_stats),
54 phase_kind_name_(nullptr),
55 phase_name_(nullptr) {
56 if (info->has_shared_info()) {
57 source_size_ =
static_cast<size_t>(info->shared_info()->SourceSize());
58 std::unique_ptr<char[]> name =
59 info->shared_info()->DebugName()->ToCString();
60 function_name_ = name.get();
62 total_stats_.Begin(
this);
66 PipelineStatistics::~PipelineStatistics() {
67 if (InPhaseKind()) EndPhaseKind();
68 CompilationStatistics::BasicStats diff;
69 total_stats_.End(
this, &diff);
70 compilation_stats_->RecordTotalStats(source_size_, diff);
74 void PipelineStatistics::BeginPhaseKind(
const char* phase_kind_name) {
76 if (InPhaseKind()) EndPhaseKind();
77 phase_kind_name_ = phase_kind_name;
78 phase_kind_stats_.Begin(
this);
82 void PipelineStatistics::EndPhaseKind() {
84 CompilationStatistics::BasicStats diff;
85 phase_kind_stats_.End(
this, &diff);
86 compilation_stats_->RecordPhaseKindStats(phase_kind_name_, diff);
90 void PipelineStatistics::BeginPhase(
const char* name) {
91 DCHECK(InPhaseKind());
93 phase_stats_.Begin(
this);
97 void PipelineStatistics::EndPhase() {
98 DCHECK(InPhaseKind());
99 CompilationStatistics::BasicStats diff;
100 phase_stats_.End(
this, &diff);
101 compilation_stats_->RecordPhaseStats(phase_kind_name_, phase_name_, diff);