| OLD | NEW |
| 1 // Copyright 2016 the V8 project authors. All rights reserved. | 1 // Copyright 2016 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "src/compiler-dispatcher/compiler-dispatcher-tracer.h" | 5 #include "src/compiler-dispatcher/compiler-dispatcher-tracer.h" |
| 6 | 6 |
| 7 #include "src/isolate.h" | 7 #include "src/isolate.h" |
| 8 | 8 |
| 9 namespace v8 { | 9 namespace v8 { |
| 10 namespace internal { | 10 namespace internal { |
| 11 | 11 |
| 12 namespace { | 12 namespace { |
| 13 | 13 |
| 14 double MonotonicallyIncreasingTimeInMs() { | 14 double MonotonicallyIncreasingTimeInMs() { |
| 15 return V8::GetCurrentPlatform()->MonotonicallyIncreasingTime() * | 15 return V8::GetCurrentPlatform()->MonotonicallyIncreasingTime() * |
| 16 static_cast<double>(base::Time::kMillisecondsPerSecond); | 16 static_cast<double>(base::Time::kMillisecondsPerSecond); |
| 17 } | 17 } |
| 18 | 18 |
| 19 const double kEstimatedRuntimeWithoutData = 1.0; | 19 const double kEstimatedRuntimeWithoutData = 1.0; |
| 20 | 20 |
| 21 } // namespace | 21 } // namespace |
| 22 | 22 |
| 23 CompilerDispatcherTracer::Scope::Scope(CompilerDispatcherTracer* tracer, | 23 CompilerDispatcherTracer::Scope::Scope(CompilerDispatcherTracer* tracer, |
| 24 ScopeID scope_id, size_t num) | 24 ScopeID scope_id, size_t num) |
| 25 : tracer_(tracer), scope_id_(scope_id), num_(num) { | 25 : tracer_(tracer), scope_id_(scope_id), num_(num) { |
| 26 start_time_ = MonotonicallyIncreasingTimeInMs(); | 26 start_time_ = MonotonicallyIncreasingTimeInMs(); |
| 27 // TODO(cbruni): remove once we fully moved to a trace-based system. | |
| 28 if (V8_UNLIKELY(FLAG_runtime_stats)) { | |
| 29 RuntimeCallStats::Enter(tracer_->runtime_call_stats_, &timer_, | |
| 30 &RuntimeCallStats::CompilerDispatcher); | |
| 31 } | |
| 32 } | 27 } |
| 33 | 28 |
| 34 CompilerDispatcherTracer::Scope::~Scope() { | 29 CompilerDispatcherTracer::Scope::~Scope() { |
| 35 double elapsed = MonotonicallyIncreasingTimeInMs() - start_time_; | 30 double elapsed = MonotonicallyIncreasingTimeInMs() - start_time_; |
| 36 switch (scope_id_) { | 31 switch (scope_id_) { |
| 37 case ScopeID::kPrepareToParse: | 32 case ScopeID::kPrepareToParse: |
| 38 tracer_->RecordPrepareToParse(elapsed); | 33 tracer_->RecordPrepareToParse(elapsed); |
| 39 break; | 34 break; |
| 40 case ScopeID::kParse: | 35 case ScopeID::kParse: |
| 41 tracer_->RecordParse(elapsed, num_); | 36 tracer_->RecordParse(elapsed, num_); |
| 42 break; | 37 break; |
| 43 case ScopeID::kFinalizeParsing: | 38 case ScopeID::kFinalizeParsing: |
| 44 tracer_->RecordFinalizeParsing(elapsed); | 39 tracer_->RecordFinalizeParsing(elapsed); |
| 45 break; | 40 break; |
| 46 case ScopeID::kPrepareToCompile: | 41 case ScopeID::kPrepareToCompile: |
| 47 tracer_->RecordPrepareToCompile(elapsed); | 42 tracer_->RecordPrepareToCompile(elapsed); |
| 48 break; | 43 break; |
| 49 case ScopeID::kCompile: | 44 case ScopeID::kCompile: |
| 50 tracer_->RecordCompile(elapsed, num_); | 45 tracer_->RecordCompile(elapsed, num_); |
| 51 break; | 46 break; |
| 52 case ScopeID::kFinalizeCompiling: | 47 case ScopeID::kFinalizeCompiling: |
| 53 tracer_->RecordFinalizeCompiling(elapsed); | 48 tracer_->RecordFinalizeCompiling(elapsed); |
| 54 break; | 49 break; |
| 55 } | 50 } |
| 56 // TODO(cbruni): remove once we fully moved to a trace-based system. | |
| 57 if (V8_UNLIKELY(FLAG_runtime_stats)) { | |
| 58 RuntimeCallStats::Leave(tracer_->runtime_call_stats_, &timer_); | |
| 59 } | |
| 60 } | 51 } |
| 61 | 52 |
| 62 // static | 53 // static |
| 63 const char* CompilerDispatcherTracer::Scope::Name(ScopeID scope_id) { | 54 const char* CompilerDispatcherTracer::Scope::Name(ScopeID scope_id) { |
| 64 switch (scope_id) { | 55 switch (scope_id) { |
| 65 case ScopeID::kPrepareToParse: | 56 case ScopeID::kPrepareToParse: |
| 66 return "V8.BackgroundCompile_PrepareToParse"; | 57 return "V8.BackgroundCompile_PrepareToParse"; |
| 67 case ScopeID::kParse: | 58 case ScopeID::kParse: |
| 68 return "V8.BackgroundCompile_Parse"; | 59 return "V8.BackgroundCompile_Parse"; |
| 69 case ScopeID::kFinalizeParsing: | 60 case ScopeID::kFinalizeParsing: |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 165 std::pair<size_t, double> sum = buffer.Sum( | 156 std::pair<size_t, double> sum = buffer.Sum( |
| 166 [](std::pair<size_t, double> a, std::pair<size_t, double> b) { | 157 [](std::pair<size_t, double> a, std::pair<size_t, double> b) { |
| 167 return std::make_pair(a.first + b.first, a.second + b.second); | 158 return std::make_pair(a.first + b.first, a.second + b.second); |
| 168 }, | 159 }, |
| 169 std::make_pair(0, 0.0)); | 160 std::make_pair(0, 0.0)); |
| 170 return num * (sum.second / sum.first); | 161 return num * (sum.second / sum.first); |
| 171 } | 162 } |
| 172 | 163 |
| 173 } // namespace internal | 164 } // namespace internal |
| 174 } // namespace v8 | 165 } // namespace v8 |
| OLD | NEW |