Chromium Code Reviews| 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 #include "src/compiler.h" | |
| 6 #include "src/compiler/pipeline-statistics.h" | |
| 7 #include "src/compiler/zone-pool.h" | |
| 8 | |
| 9 namespace v8 { | |
| 10 namespace internal { | |
| 11 namespace compiler { | |
| 12 | |
| 13 void PipelineStatistics::CommonStats::Begin( | |
| 14 PipelineStatistics* pipeline_stats) { | |
| 15 DCHECK(scope_.is_empty()); | |
| 16 scope_.Reset(new ZonePool::StatsScope(pipeline_stats->zone_pool_)); | |
|
Jarin
2014/10/23 09:03:01
This dynamic allocation is a bit ugly, but I do no
| |
| 17 timer_.Start(); | |
| 18 outer_zone_initial_size_ = pipeline_stats->OuterZoneSize(); | |
| 19 } | |
| 20 | |
| 21 | |
| 22 void PipelineStatistics::CommonStats::End( | |
| 23 PipelineStatistics* pipeline_stats, | |
| 24 CompilationStatistics::BasicStats* diff) { | |
| 25 DCHECK(!scope_.is_empty()); | |
| 26 diff->function_name_ = pipeline_stats->function_name_; | |
| 27 diff->delta_ = timer_.Elapsed(); | |
| 28 size_t outer_zone_diff = | |
| 29 pipeline_stats->OuterZoneSize() - outer_zone_initial_size_; | |
| 30 diff->max_allocated_bytes_ = outer_zone_diff + scope_->GetMaxAllocatedBytes(); | |
| 31 diff->total_allocated_bytes_ = | |
| 32 outer_zone_diff + scope_->GetTotalAllocatedBytes(); | |
| 33 scope_.Reset(NULL); | |
| 34 timer_.Stop(); | |
| 35 } | |
| 36 | |
| 37 | |
| 38 PipelineStatistics::PipelineStatistics(CompilationInfo* info, | |
| 39 ZonePool* zone_pool) | |
| 40 : isolate_(info->zone()->isolate()), | |
| 41 outer_zone_(info->zone()), | |
| 42 zone_pool_(zone_pool), | |
| 43 compilation_stats_(isolate_->GetTStatistics()), | |
| 44 source_size_(0), | |
| 45 phase_kind_name_(NULL), | |
| 46 phase_name_(NULL) { | |
| 47 if (!info->shared_info().is_null()) { | |
| 48 source_size_ = static_cast<size_t>(info->shared_info()->SourceSize()); | |
| 49 SmartArrayPointer<char> name = | |
| 50 info->shared_info()->DebugName()->ToCString(); | |
| 51 function_name_ = name.get(); | |
| 52 } | |
| 53 total_stats_.Begin(this); | |
| 54 } | |
| 55 | |
| 56 | |
| 57 PipelineStatistics::~PipelineStatistics() { | |
| 58 if (InPhaseKind()) EndPhaseKind(); | |
| 59 CompilationStatistics::BasicStats diff; | |
| 60 total_stats_.End(this, &diff); | |
| 61 compilation_stats_->RecordTotalStats(source_size_, diff); | |
| 62 } | |
| 63 | |
| 64 | |
| 65 void PipelineStatistics::BeginPhaseKind(const char* phase_kind_name) { | |
| 66 DCHECK(!InPhase()); | |
| 67 if (InPhaseKind()) EndPhaseKind(); | |
| 68 phase_kind_name_ = phase_kind_name; | |
| 69 phase_kind_stats_.Begin(this); | |
| 70 } | |
| 71 | |
| 72 | |
| 73 void PipelineStatistics::EndPhaseKind() { | |
| 74 DCHECK(!InPhase()); | |
| 75 CompilationStatistics::BasicStats diff; | |
| 76 phase_kind_stats_.End(this, &diff); | |
| 77 compilation_stats_->RecordPhaseKindStats(phase_kind_name_, diff); | |
| 78 } | |
| 79 | |
| 80 | |
| 81 void PipelineStatistics::BeginPhase(const char* name) { | |
| 82 DCHECK(InPhaseKind()); | |
| 83 phase_name_ = name; | |
| 84 phase_stats_.Begin(this); | |
| 85 } | |
| 86 | |
| 87 | |
| 88 void PipelineStatistics::EndPhase() { | |
| 89 DCHECK(InPhaseKind()); | |
| 90 CompilationStatistics::BasicStats diff; | |
| 91 phase_stats_.End(this, &diff); | |
| 92 compilation_stats_->RecordPhaseStats(phase_kind_name_, phase_name_, diff); | |
| 93 } | |
| 94 | |
| 95 } // namespace compiler | |
| 96 } // namespace internal | |
| 97 } // namespace v8 | |
| OLD | NEW |