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_CPU_PROFILER_H_ | 5 #ifndef V8_CPU_PROFILER_H_ |
6 #define V8_CPU_PROFILER_H_ | 6 #define V8_CPU_PROFILER_H_ |
7 | 7 |
8 #include "src/allocation.h" | 8 #include "src/allocation.h" |
9 #include "src/base/atomicops.h" | 9 #include "src/base/atomicops.h" |
10 #include "src/base/platform/time.h" | 10 #include "src/base/platform/time.h" |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 class ProfilerEventsProcessor : public base::Thread { | 125 class ProfilerEventsProcessor : public base::Thread { |
126 public: | 126 public: |
127 ProfilerEventsProcessor(ProfileGenerator* generator, | 127 ProfilerEventsProcessor(ProfileGenerator* generator, |
128 Sampler* sampler, | 128 Sampler* sampler, |
129 base::TimeDelta period); | 129 base::TimeDelta period); |
130 virtual ~ProfilerEventsProcessor() {} | 130 virtual ~ProfilerEventsProcessor() {} |
131 | 131 |
132 // Thread control. | 132 // Thread control. |
133 virtual void Run(); | 133 virtual void Run(); |
134 void StopSynchronously(); | 134 void StopSynchronously(); |
135 INLINE(bool running()) { return running_; } | 135 INLINE(bool running()) { return !!base::NoBarrier_Load(&running_); } |
136 void Enqueue(const CodeEventsContainer& event); | 136 void Enqueue(const CodeEventsContainer& event); |
137 | 137 |
138 // Puts current stack into tick sample events buffer. | 138 // Puts current stack into tick sample events buffer. |
139 void AddCurrentStack(Isolate* isolate); | 139 void AddCurrentStack(Isolate* isolate); |
140 | 140 |
141 // Tick sample events are filled directly in the buffer of the circular | 141 // Tick sample events are filled directly in the buffer of the circular |
142 // queue (because the structure is of fixed width, but usually not all | 142 // queue (because the structure is of fixed width, but usually not all |
143 // stack frame entries are filled.) This method returns a pointer to the | 143 // stack frame entries are filled.) This method returns a pointer to the |
144 // next record of the buffer. | 144 // next record of the buffer. |
145 inline TickSample* StartTickSample(); | 145 inline TickSample* StartTickSample(); |
(...skipping 10 matching lines...) Expand all Loading... |
156 | 156 |
157 enum SampleProcessingResult { | 157 enum SampleProcessingResult { |
158 OneSampleProcessed, | 158 OneSampleProcessed, |
159 FoundSampleForNextCodeEvent, | 159 FoundSampleForNextCodeEvent, |
160 NoSamplesInQueue | 160 NoSamplesInQueue |
161 }; | 161 }; |
162 SampleProcessingResult ProcessOneSample(); | 162 SampleProcessingResult ProcessOneSample(); |
163 | 163 |
164 ProfileGenerator* generator_; | 164 ProfileGenerator* generator_; |
165 Sampler* sampler_; | 165 Sampler* sampler_; |
166 bool running_; | 166 base::Atomic32 running_; |
167 // Sampling period in microseconds. | 167 // Sampling period in microseconds. |
168 const base::TimeDelta period_; | 168 const base::TimeDelta period_; |
169 UnboundQueue<CodeEventsContainer> events_buffer_; | 169 UnboundQueue<CodeEventsContainer> events_buffer_; |
170 static const size_t kTickSampleBufferSize = 1 * MB; | 170 static const size_t kTickSampleBufferSize = 1 * MB; |
171 static const size_t kTickSampleQueueLength = | 171 static const size_t kTickSampleQueueLength = |
172 kTickSampleBufferSize / sizeof(TickSampleEventRecord); | 172 kTickSampleBufferSize / sizeof(TickSampleEventRecord); |
173 SamplingCircularQueue<TickSampleEventRecord, | 173 SamplingCircularQueue<TickSampleEventRecord, |
174 kTickSampleQueueLength> ticks_buffer_; | 174 kTickSampleQueueLength> ticks_buffer_; |
175 UnboundQueue<TickSampleEventRecord> ticks_from_vm_buffer_; | 175 UnboundQueue<TickSampleEventRecord> ticks_from_vm_buffer_; |
176 unsigned last_code_event_id_; | 176 unsigned last_code_event_id_; |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
263 bool saved_is_logging_; | 263 bool saved_is_logging_; |
264 bool is_profiling_; | 264 bool is_profiling_; |
265 | 265 |
266 DISALLOW_COPY_AND_ASSIGN(CpuProfiler); | 266 DISALLOW_COPY_AND_ASSIGN(CpuProfiler); |
267 }; | 267 }; |
268 | 268 |
269 } } // namespace v8::internal | 269 } } // namespace v8::internal |
270 | 270 |
271 | 271 |
272 #endif // V8_CPU_PROFILER_H_ | 272 #endif // V8_CPU_PROFILER_H_ |
OLD | NEW |