LCOV - code coverage report
Current view: top level - src/compiler - pipeline-statistics.cc (source / functions) Hit Total Coverage
Test: app.info Lines: 1 48 2.1 %
Date: 2019-02-19 Functions: 2 10 20.0 %

          Line data    Source code
       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             : #include <memory>
       6             : 
       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"
      12             : 
      13             : namespace v8 {
      14             : namespace internal {
      15             : namespace compiler {
      16             : 
      17           0 : void PipelineStatistics::CommonStats::Begin(
      18           0 :     PipelineStatistics* pipeline_stats) {
      19             :   DCHECK(!scope_);
      20           0 :   scope_.reset(new ZoneStats::StatsScope(pipeline_stats->zone_stats_));
      21             :   timer_.Start();
      22           0 :   outer_zone_initial_size_ = pipeline_stats->OuterZoneSize();
      23             :   allocated_bytes_at_start_ =
      24           0 :       outer_zone_initial_size_ -
      25           0 :       pipeline_stats->total_stats_.outer_zone_initial_size_ +
      26           0 :       pipeline_stats->zone_stats_->GetCurrentAllocatedBytes();
      27           0 : }
      28             : 
      29             : 
      30           0 : void PipelineStatistics::CommonStats::End(
      31           0 :     PipelineStatistics* pipeline_stats,
      32             :     CompilationStatistics::BasicStats* diff) {
      33             :   DCHECK(scope_);
      34           0 :   diff->function_name_ = pipeline_stats->function_name_;
      35           0 :   diff->delta_ = timer_.Elapsed();
      36             :   size_t outer_zone_diff =
      37           0 :       pipeline_stats->OuterZoneSize() - outer_zone_initial_size_;
      38           0 :   diff->max_allocated_bytes_ = outer_zone_diff + scope_->GetMaxAllocatedBytes();
      39             :   diff->absolute_max_allocated_bytes_ =
      40           0 :       diff->max_allocated_bytes_ + allocated_bytes_at_start_;
      41             :   diff->total_allocated_bytes_ =
      42           0 :       outer_zone_diff + scope_->GetTotalAllocatedBytes();
      43             :   scope_.reset();
      44             :   timer_.Stop();
      45           0 : }
      46             : 
      47           0 : 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),
      53             :       source_size_(0),
      54             :       phase_kind_name_(nullptr),
      55           0 :       phase_name_(nullptr) {
      56           0 :   if (info->has_shared_info()) {
      57           0 :     source_size_ = static_cast<size_t>(info->shared_info()->SourceSize());
      58             :     std::unique_ptr<char[]> name =
      59           0 :         info->shared_info()->DebugName()->ToCString();
      60           0 :     function_name_ = name.get();
      61             :   }
      62           0 :   total_stats_.Begin(this);
      63           0 : }
      64             : 
      65             : 
      66           0 : PipelineStatistics::~PipelineStatistics() {
      67           0 :   if (InPhaseKind()) EndPhaseKind();
      68             :   CompilationStatistics::BasicStats diff;
      69           0 :   total_stats_.End(this, &diff);
      70           0 :   compilation_stats_->RecordTotalStats(source_size_, diff);
      71           0 : }
      72             : 
      73             : 
      74           0 : void PipelineStatistics::BeginPhaseKind(const char* phase_kind_name) {
      75             :   DCHECK(!InPhase());
      76           0 :   if (InPhaseKind()) EndPhaseKind();
      77           0 :   phase_kind_name_ = phase_kind_name;
      78           0 :   phase_kind_stats_.Begin(this);
      79           0 : }
      80             : 
      81             : 
      82           0 : void PipelineStatistics::EndPhaseKind() {
      83             :   DCHECK(!InPhase());
      84             :   CompilationStatistics::BasicStats diff;
      85           0 :   phase_kind_stats_.End(this, &diff);
      86           0 :   compilation_stats_->RecordPhaseKindStats(phase_kind_name_, diff);
      87           0 : }
      88             : 
      89             : 
      90           0 : void PipelineStatistics::BeginPhase(const char* name) {
      91             :   DCHECK(InPhaseKind());
      92           0 :   phase_name_ = name;
      93           0 :   phase_stats_.Begin(this);
      94           0 : }
      95             : 
      96             : 
      97           0 : void PipelineStatistics::EndPhase() {
      98             :   DCHECK(InPhaseKind());
      99             :   CompilationStatistics::BasicStats diff;
     100           0 :   phase_stats_.End(this, &diff);
     101           0 :   compilation_stats_->RecordPhaseStats(phase_kind_name_, phase_name_, diff);
     102           0 : }
     103             : 
     104             : }  // namespace compiler
     105             : }  // namespace internal
     106      178779 : }  // namespace v8

Generated by: LCOV version 1.10