| 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 #ifndef V8_COMPILER_DISPATCHER_COMPILER_DISPATCHER_TRACER_H_ | 5 #ifndef V8_COMPILER_DISPATCHER_COMPILER_DISPATCHER_TRACER_H_ |
| 6 #define V8_COMPILER_DISPATCHER_COMPILER_DISPATCHER_TRACER_H_ | 6 #define V8_COMPILER_DISPATCHER_COMPILER_DISPATCHER_TRACER_H_ |
| 7 | 7 |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "src/base/macros.h" | 10 #include "src/base/macros.h" |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 | 28 |
| 29 #define COMPILER_DISPATCHER_TRACE_SCOPE(tracer, scope_id) \ | 29 #define COMPILER_DISPATCHER_TRACE_SCOPE(tracer, scope_id) \ |
| 30 COMPILER_DISPATCHER_TRACE_SCOPE_WITH_NUM(tracer, scope_id, 0) | 30 COMPILER_DISPATCHER_TRACE_SCOPE_WITH_NUM(tracer, scope_id, 0) |
| 31 | 31 |
| 32 class V8_EXPORT_PRIVATE CompilerDispatcherTracer { | 32 class V8_EXPORT_PRIVATE CompilerDispatcherTracer { |
| 33 public: | 33 public: |
| 34 enum class ScopeID { | 34 enum class ScopeID { |
| 35 kPrepareToParse, | 35 kPrepareToParse, |
| 36 kParse, | 36 kParse, |
| 37 kFinalizeParsing, | 37 kFinalizeParsing, |
| 38 kAnalyze, |
| 38 kPrepareToCompile, | 39 kPrepareToCompile, |
| 39 kCompile, | 40 kCompile, |
| 40 kFinalizeCompiling | 41 kFinalizeCompiling |
| 41 }; | 42 }; |
| 42 | 43 |
| 43 class Scope { | 44 class Scope { |
| 44 public: | 45 public: |
| 45 Scope(CompilerDispatcherTracer* tracer, ScopeID scope_id, size_t num = 0); | 46 Scope(CompilerDispatcherTracer* tracer, ScopeID scope_id, size_t num = 0); |
| 46 ~Scope(); | 47 ~Scope(); |
| 47 | 48 |
| 48 static const char* Name(ScopeID scoped_id); | 49 static const char* Name(ScopeID scoped_id); |
| 49 | 50 |
| 50 private: | 51 private: |
| 51 CompilerDispatcherTracer* tracer_; | 52 CompilerDispatcherTracer* tracer_; |
| 52 ScopeID scope_id_; | 53 ScopeID scope_id_; |
| 53 size_t num_; | 54 size_t num_; |
| 54 double start_time_; | 55 double start_time_; |
| 55 | 56 |
| 56 DISALLOW_COPY_AND_ASSIGN(Scope); | 57 DISALLOW_COPY_AND_ASSIGN(Scope); |
| 57 }; | 58 }; |
| 58 | 59 |
| 59 explicit CompilerDispatcherTracer(Isolate* isolate); | 60 explicit CompilerDispatcherTracer(Isolate* isolate); |
| 60 ~CompilerDispatcherTracer(); | 61 ~CompilerDispatcherTracer(); |
| 61 | 62 |
| 62 void RecordPrepareToParse(double duration_ms); | 63 void RecordPrepareToParse(double duration_ms); |
| 63 void RecordParse(double duration_ms, size_t source_length); | 64 void RecordParse(double duration_ms, size_t source_length); |
| 64 void RecordFinalizeParsing(double duration_ms); | 65 void RecordFinalizeParsing(double duration_ms); |
| 66 void RecordAnalyze(double duration_ms); |
| 65 void RecordPrepareToCompile(double duration_ms); | 67 void RecordPrepareToCompile(double duration_ms); |
| 66 void RecordCompile(double duration_ms, size_t ast_size_in_bytes); | 68 void RecordCompile(double duration_ms, size_t ast_size_in_bytes); |
| 67 void RecordFinalizeCompiling(double duration_ms); | 69 void RecordFinalizeCompiling(double duration_ms); |
| 68 | 70 |
| 69 double EstimatePrepareToParseInMs() const; | 71 double EstimatePrepareToParseInMs() const; |
| 70 double EstimateParseInMs(size_t source_length) const; | 72 double EstimateParseInMs(size_t source_length) const; |
| 71 double EstimateFinalizeParsingInMs() const; | 73 double EstimateFinalizeParsingInMs() const; |
| 74 double EstimateAnalyzeInMs() const; |
| 72 double EstimatePrepareToCompileInMs() const; | 75 double EstimatePrepareToCompileInMs() const; |
| 73 double EstimateCompileInMs(size_t ast_size_in_bytes) const; | 76 double EstimateCompileInMs(size_t ast_size_in_bytes) const; |
| 74 double EstimateFinalizeCompilingInMs() const; | 77 double EstimateFinalizeCompilingInMs() const; |
| 75 | 78 |
| 76 void DumpStatistics() const; | 79 void DumpStatistics() const; |
| 77 | 80 |
| 78 private: | 81 private: |
| 79 static double Average(const base::RingBuffer<double>& buffer); | 82 static double Average(const base::RingBuffer<double>& buffer); |
| 80 static double Estimate( | 83 static double Estimate( |
| 81 const base::RingBuffer<std::pair<size_t, double>>& buffer, size_t num); | 84 const base::RingBuffer<std::pair<size_t, double>>& buffer, size_t num); |
| 82 | 85 |
| 83 mutable base::Mutex mutex_; | 86 mutable base::Mutex mutex_; |
| 84 base::RingBuffer<double> prepare_parse_events_; | 87 base::RingBuffer<double> prepare_parse_events_; |
| 85 base::RingBuffer<std::pair<size_t, double>> parse_events_; | 88 base::RingBuffer<std::pair<size_t, double>> parse_events_; |
| 86 base::RingBuffer<double> finalize_parsing_events_; | 89 base::RingBuffer<double> finalize_parsing_events_; |
| 90 base::RingBuffer<double> analyze_events_; |
| 87 base::RingBuffer<double> prepare_compile_events_; | 91 base::RingBuffer<double> prepare_compile_events_; |
| 88 base::RingBuffer<std::pair<size_t, double>> compile_events_; | 92 base::RingBuffer<std::pair<size_t, double>> compile_events_; |
| 89 base::RingBuffer<double> finalize_compiling_events_; | 93 base::RingBuffer<double> finalize_compiling_events_; |
| 90 | 94 |
| 91 RuntimeCallStats* runtime_call_stats_; | 95 RuntimeCallStats* runtime_call_stats_; |
| 92 | 96 |
| 93 DISALLOW_COPY_AND_ASSIGN(CompilerDispatcherTracer); | 97 DISALLOW_COPY_AND_ASSIGN(CompilerDispatcherTracer); |
| 94 }; | 98 }; |
| 95 | 99 |
| 96 } // namespace internal | 100 } // namespace internal |
| 97 } // namespace v8 | 101 } // namespace v8 |
| 98 | 102 |
| 99 #endif // V8_COMPILER_DISPATCHER_COMPILER_DISPATCHER_TRACER_H_ | 103 #endif // V8_COMPILER_DISPATCHER_COMPILER_DISPATCHER_TRACER_H_ |
| OLD | NEW |