| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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_PROFILER_CPU_PROFILER_H_ | 5 #ifndef V8_PROFILER_CPU_PROFILER_H_ |
| 6 #define V8_PROFILER_CPU_PROFILER_H_ | 6 #define V8_PROFILER_CPU_PROFILER_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 | 9 |
| 10 #include "include/v8-profiler.h" |
| 10 #include "src/allocation.h" | 11 #include "src/allocation.h" |
| 11 #include "src/base/atomic-utils.h" | 12 #include "src/base/atomic-utils.h" |
| 12 #include "src/base/atomicops.h" | 13 #include "src/base/atomicops.h" |
| 13 #include "src/base/platform/time.h" | 14 #include "src/base/platform/time.h" |
| 14 #include "src/compiler.h" | 15 #include "src/compiler.h" |
| 15 #include "src/isolate.h" | 16 #include "src/isolate.h" |
| 16 #include "src/libsampler/v8-sampler.h" | 17 #include "src/libsampler/v8-sampler.h" |
| 17 #include "src/locked-queue.h" | 18 #include "src/locked-queue.h" |
| 18 #include "src/profiler/circular-queue.h" | 19 #include "src/profiler/circular-queue.h" |
| 19 #include "src/profiler/profiler-listener.h" | 20 #include "src/profiler/profiler-listener.h" |
| 20 #include "src/profiler/tick-sample.h" | |
| 21 | 21 |
| 22 namespace v8 { | 22 namespace v8 { |
| 23 namespace internal { | 23 namespace internal { |
| 24 | 24 |
| 25 // Forward declarations. | 25 // Forward declarations. |
| 26 class CodeEntry; | 26 class CodeEntry; |
| 27 class CodeMap; | 27 class CodeMap; |
| 28 class CpuProfile; | 28 class CpuProfile; |
| 29 class CpuProfilesCollection; | 29 class CpuProfilesCollection; |
| 30 class ProfileGenerator; | 30 class ProfileGenerator; |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 | 103 |
| 104 | 104 |
| 105 class TickSampleEventRecord { | 105 class TickSampleEventRecord { |
| 106 public: | 106 public: |
| 107 // The parameterless constructor is used when we dequeue data from | 107 // The parameterless constructor is used when we dequeue data from |
| 108 // the ticks buffer. | 108 // the ticks buffer. |
| 109 TickSampleEventRecord() { } | 109 TickSampleEventRecord() { } |
| 110 explicit TickSampleEventRecord(unsigned order) : order(order) { } | 110 explicit TickSampleEventRecord(unsigned order) : order(order) { } |
| 111 | 111 |
| 112 unsigned order; | 112 unsigned order; |
| 113 TickSample sample; | 113 base::TimeTicks timestamp; |
| 114 v8::TickSample sample; |
| 114 }; | 115 }; |
| 115 | 116 |
| 116 | 117 |
| 117 class CodeEventsContainer { | 118 class CodeEventsContainer { |
| 118 public: | 119 public: |
| 119 explicit CodeEventsContainer( | 120 explicit CodeEventsContainer( |
| 120 CodeEventRecord::Type type = CodeEventRecord::NONE) { | 121 CodeEventRecord::Type type = CodeEventRecord::NONE) { |
| 121 generic.type = type; | 122 generic.type = type; |
| 122 } | 123 } |
| 123 union { | 124 union { |
| (...skipping 21 matching lines...) Expand all Loading... |
| 145 void Enqueue(const CodeEventsContainer& event); | 146 void Enqueue(const CodeEventsContainer& event); |
| 146 | 147 |
| 147 // Puts current stack into tick sample events buffer. | 148 // Puts current stack into tick sample events buffer. |
| 148 void AddCurrentStack(Isolate* isolate, bool update_stats = false); | 149 void AddCurrentStack(Isolate* isolate, bool update_stats = false); |
| 149 void AddDeoptStack(Isolate* isolate, Address from, int fp_to_sp_delta); | 150 void AddDeoptStack(Isolate* isolate, Address from, int fp_to_sp_delta); |
| 150 | 151 |
| 151 // Tick sample events are filled directly in the buffer of the circular | 152 // Tick sample events are filled directly in the buffer of the circular |
| 152 // queue (because the structure is of fixed width, but usually not all | 153 // queue (because the structure is of fixed width, but usually not all |
| 153 // stack frame entries are filled.) This method returns a pointer to the | 154 // stack frame entries are filled.) This method returns a pointer to the |
| 154 // next record of the buffer. | 155 // next record of the buffer. |
| 155 inline TickSample* StartTickSample(); | 156 inline v8::TickSample* StartTickSample(); |
| 156 inline void FinishTickSample(); | 157 inline void FinishTickSample(); |
| 157 | 158 |
| 158 // SamplingCircularQueue has stricter alignment requirements than a normal new | 159 // SamplingCircularQueue has stricter alignment requirements than a normal new |
| 159 // can fulfil, so we need to provide our own new/delete here. | 160 // can fulfil, so we need to provide our own new/delete here. |
| 160 void* operator new(size_t size); | 161 void* operator new(size_t size); |
| 161 void operator delete(void* ptr); | 162 void operator delete(void* ptr); |
| 162 | 163 |
| 163 private: | 164 private: |
| 164 // Called from events processing thread (Run() method.) | 165 // Called from events processing thread (Run() method.) |
| 165 bool ProcessCodeEvent(); | 166 bool ProcessCodeEvent(); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 203 CpuProfile* StopProfiling(const char* title); | 204 CpuProfile* StopProfiling(const char* title); |
| 204 CpuProfile* StopProfiling(String* title); | 205 CpuProfile* StopProfiling(String* title); |
| 205 int GetProfilesCount(); | 206 int GetProfilesCount(); |
| 206 CpuProfile* GetProfile(int index); | 207 CpuProfile* GetProfile(int index); |
| 207 void DeleteAllProfiles(); | 208 void DeleteAllProfiles(); |
| 208 void DeleteProfile(CpuProfile* profile); | 209 void DeleteProfile(CpuProfile* profile); |
| 209 | 210 |
| 210 void CodeEventHandler(const CodeEventsContainer& evt_rec) override; | 211 void CodeEventHandler(const CodeEventsContainer& evt_rec) override; |
| 211 | 212 |
| 212 // Invoked from stack sampler (thread or signal handler.) | 213 // Invoked from stack sampler (thread or signal handler.) |
| 213 inline TickSample* StartTickSample(); | 214 inline v8::TickSample* StartTickSample(); |
| 214 inline void FinishTickSample(); | 215 inline void FinishTickSample(); |
| 215 | 216 |
| 216 bool is_profiling() const { return is_profiling_; } | 217 bool is_profiling() const { return is_profiling_; } |
| 217 | 218 |
| 218 ProfileGenerator* generator() const { return generator_.get(); } | 219 ProfileGenerator* generator() const { return generator_.get(); } |
| 219 ProfilerEventsProcessor* processor() const { return processor_.get(); } | 220 ProfilerEventsProcessor* processor() const { return processor_.get(); } |
| 220 Isolate* isolate() const { return isolate_; } | 221 Isolate* isolate() const { return isolate_; } |
| 221 | 222 |
| 222 private: | 223 private: |
| 223 void StartProcessorIfNotStarted(); | 224 void StartProcessorIfNotStarted(); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 235 bool is_profiling_; | 236 bool is_profiling_; |
| 236 | 237 |
| 237 DISALLOW_COPY_AND_ASSIGN(CpuProfiler); | 238 DISALLOW_COPY_AND_ASSIGN(CpuProfiler); |
| 238 }; | 239 }; |
| 239 | 240 |
| 240 } // namespace internal | 241 } // namespace internal |
| 241 } // namespace v8 | 242 } // namespace v8 |
| 242 | 243 |
| 243 | 244 |
| 244 #endif // V8_PROFILER_CPU_PROFILER_H_ | 245 #endif // V8_PROFILER_CPU_PROFILER_H_ |
| OLD | NEW |