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 } // namespace | 19 } // namespace |
20 | 20 |
21 CompilerDispatcherTracer::Scope::Scope(CompilerDispatcherTracer* tracer, | 21 CompilerDispatcherTracer::Scope::Scope(CompilerDispatcherTracer* tracer, |
22 ScopeID scope_id, size_t num) | 22 ScopeID scope_id, size_t num) |
23 : tracer_(tracer), scope_id_(scope_id), num_(num) { | 23 : tracer_(tracer), scope_id_(scope_id), num_(num) { |
24 start_time_ = MonotonicallyIncreasingTimeInMs(); | 24 start_time_ = MonotonicallyIncreasingTimeInMs(); |
25 // TODO(cbruni): remove once we fully moved to a trace-based system. | 25 // TODO(cbruni): remove once we fully moved to a trace-based system. |
26 if (TRACE_EVENT_RUNTIME_CALL_STATS_TRACING_ENABLED() || | 26 if (V8_UNLIKELY(FLAG_runtime_stats)) { |
27 FLAG_runtime_call_stats) { | |
28 RuntimeCallStats::Enter(tracer_->runtime_call_stats_, &timer_, | 27 RuntimeCallStats::Enter(tracer_->runtime_call_stats_, &timer_, |
29 &RuntimeCallStats::CompilerDispatcher); | 28 &RuntimeCallStats::CompilerDispatcher); |
30 } | 29 } |
31 } | 30 } |
32 | 31 |
33 CompilerDispatcherTracer::Scope::~Scope() { | 32 CompilerDispatcherTracer::Scope::~Scope() { |
34 double elapsed = MonotonicallyIncreasingTimeInMs() - start_time_; | 33 double elapsed = MonotonicallyIncreasingTimeInMs() - start_time_; |
35 switch (scope_id_) { | 34 switch (scope_id_) { |
36 case ScopeID::kPrepareToParse: | 35 case ScopeID::kPrepareToParse: |
37 tracer_->RecordPrepareToParse(elapsed); | 36 tracer_->RecordPrepareToParse(elapsed); |
38 break; | 37 break; |
39 case ScopeID::kParse: | 38 case ScopeID::kParse: |
40 tracer_->RecordParse(elapsed, num_); | 39 tracer_->RecordParse(elapsed, num_); |
41 break; | 40 break; |
42 case ScopeID::kFinalizeParsing: | 41 case ScopeID::kFinalizeParsing: |
43 tracer_->RecordFinalizeParsing(elapsed); | 42 tracer_->RecordFinalizeParsing(elapsed); |
44 break; | 43 break; |
45 case ScopeID::kPrepareToCompile: | 44 case ScopeID::kPrepareToCompile: |
46 tracer_->RecordPrepareToCompile(elapsed); | 45 tracer_->RecordPrepareToCompile(elapsed); |
47 break; | 46 break; |
48 case ScopeID::kCompile: | 47 case ScopeID::kCompile: |
49 tracer_->RecordCompile(elapsed, num_); | 48 tracer_->RecordCompile(elapsed, num_); |
50 break; | 49 break; |
51 case ScopeID::kFinalizeCompiling: | 50 case ScopeID::kFinalizeCompiling: |
52 tracer_->RecordFinalizeCompiling(elapsed); | 51 tracer_->RecordFinalizeCompiling(elapsed); |
53 break; | 52 break; |
54 } | 53 } |
55 // TODO(cbruni): remove once we fully moved to a trace-based system. | 54 // TODO(cbruni): remove once we fully moved to a trace-based system. |
56 if (TRACE_EVENT_RUNTIME_CALL_STATS_TRACING_ENABLED() || | 55 if (V8_UNLIKELY(FLAG_runtime_stats)) { |
57 FLAG_runtime_call_stats) { | |
58 RuntimeCallStats::Leave(tracer_->runtime_call_stats_, &timer_); | 56 RuntimeCallStats::Leave(tracer_->runtime_call_stats_, &timer_); |
59 } | 57 } |
60 } | 58 } |
61 | 59 |
62 // static | 60 // static |
63 const char* CompilerDispatcherTracer::Scope::Name(ScopeID scope_id) { | 61 const char* CompilerDispatcherTracer::Scope::Name(ScopeID scope_id) { |
64 switch (scope_id) { | 62 switch (scope_id) { |
65 case ScopeID::kPrepareToParse: | 63 case ScopeID::kPrepareToParse: |
66 return "V8.BackgroundCompile_PrepareToParse"; | 64 return "V8.BackgroundCompile_PrepareToParse"; |
67 case ScopeID::kParse: | 65 case ScopeID::kParse: |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
164 std::pair<size_t, double> sum = buffer.Sum( | 162 std::pair<size_t, double> sum = buffer.Sum( |
165 [](std::pair<size_t, double> a, std::pair<size_t, double> b) { | 163 [](std::pair<size_t, double> a, std::pair<size_t, double> b) { |
166 return std::make_pair(a.first + b.first, a.second + b.second); | 164 return std::make_pair(a.first + b.first, a.second + b.second); |
167 }, | 165 }, |
168 std::make_pair(0, 0.0)); | 166 std::make_pair(0, 0.0)); |
169 return num * (sum.second / sum.first); | 167 return num * (sum.second / sum.first); |
170 } | 168 } |
171 | 169 |
172 } // namespace internal | 170 } // namespace internal |
173 } // namespace v8 | 171 } // namespace v8 |
OLD | NEW |