OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef V8_TRACING_CONTROLLER_H_ |
| 6 #define V8_TRACING_CONTROLLER_H_ |
| 7 |
| 8 #include "include/v8-sampler.h" |
| 9 #include "src/base/platform/elapsed-timer.h" |
| 10 |
| 11 namespace v8 { |
| 12 |
| 13 namespace internal { |
| 14 struct TickSample; |
| 15 } |
| 16 |
| 17 class Isolate; |
| 18 class Profiler; |
| 19 class Ticker; |
| 20 class TracingLogger; |
| 21 struct JitCodeEvent; |
| 22 |
| 23 class TracingController { |
| 24 public: |
| 25 static void SetUp() { |
| 26 if (!TracingController::mutex_) |
| 27 TracingController::mutex_ = new base::Mutex(); |
| 28 V8Sampler::SetUp(); |
| 29 } |
| 30 static void TearDown() { |
| 31 V8Sampler::TearDown(); |
| 32 delete mutex_; |
| 33 mutex_ = NULL; |
| 34 } |
| 35 static void StartTracing(Isolate* isolate); |
| 36 static void StopTracing(); |
| 37 static void SetInterval(int interval); |
| 38 |
| 39 Isolate* isolate() const { return isolate_; } |
| 40 bool IsTracing() const { return is_tracing_; } |
| 41 private: |
| 42 static void InstallJitCodeEventHandler(Isolate* isolate, void* data); |
| 43 static void HandleJitCodeEvent(const JitCodeEvent* event); |
| 44 void Start(); |
| 45 void Stop(); |
| 46 TracingController(Isolate* isolate); |
| 47 void LogSample(i::TickSample* sample, bool overflow); |
| 48 friend class Profiler; |
| 49 friend class Ticker; |
| 50 |
| 51 base::ElapsedTimer timer_; |
| 52 bool is_tracing_; |
| 53 Isolate* isolate_; |
| 54 Profiler* profiler_; |
| 55 Ticker* ticker_; |
| 56 TracingLogger* logger_; |
| 57 static base::Mutex* mutex_; |
| 58 static TracingController* tracing_controller_; |
| 59 }; |
| 60 |
| 61 } |
| 62 |
| 63 #endif // V8_TRACING_CONTROLLER_H_ |
OLD | NEW |