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 "src/allocation.h" | 8 #include "src/allocation.h" |
9 #include "src/base/atomic-utils.h" | 9 #include "src/base/atomic-utils.h" |
10 #include "src/base/atomicops.h" | 10 #include "src/base/atomicops.h" |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
173 static const size_t kTickSampleBufferSize = 1 * MB; | 173 static const size_t kTickSampleBufferSize = 1 * MB; |
174 static const size_t kTickSampleQueueLength = | 174 static const size_t kTickSampleQueueLength = |
175 kTickSampleBufferSize / sizeof(TickSampleEventRecord); | 175 kTickSampleBufferSize / sizeof(TickSampleEventRecord); |
176 SamplingCircularQueue<TickSampleEventRecord, | 176 SamplingCircularQueue<TickSampleEventRecord, |
177 kTickSampleQueueLength> ticks_buffer_; | 177 kTickSampleQueueLength> ticks_buffer_; |
178 LockedQueue<TickSampleEventRecord> ticks_from_vm_buffer_; | 178 LockedQueue<TickSampleEventRecord> ticks_from_vm_buffer_; |
179 base::AtomicNumber<unsigned> last_code_event_id_; | 179 base::AtomicNumber<unsigned> last_code_event_id_; |
180 unsigned last_processed_code_event_id_; | 180 unsigned last_processed_code_event_id_; |
181 }; | 181 }; |
182 | 182 |
183 | 183 #define PROFILE(IsolateGetter, Call) \ |
184 #define PROFILE(IsolateGetter, Call) \ | 184 do { \ |
185 do { \ | 185 Isolate* the_isolate = (IsolateGetter); \ |
186 Isolate* cpu_profiler_isolate = (IsolateGetter); \ | 186 v8::internal::Logger* logger = the_isolate->logger(); \ |
187 v8::internal::Logger* logger = cpu_profiler_isolate->logger(); \ | 187 if (logger->is_logging_code_events() || the_isolate->is_profiling()) { \ |
188 CpuProfiler* cpu_profiler = cpu_profiler_isolate->cpu_profiler(); \ | 188 logger->Call; \ |
189 if (logger->is_logging_code_events() || cpu_profiler->is_profiling()) { \ | 189 } \ |
190 logger->Call; \ | |
191 } \ | |
192 } while (false) | 190 } while (false) |
193 | 191 |
194 | |
195 class CpuProfiler : public CodeEventListener { | 192 class CpuProfiler : public CodeEventListener { |
196 public: | 193 public: |
197 explicit CpuProfiler(Isolate* isolate); | 194 explicit CpuProfiler(Isolate* isolate); |
198 | 195 |
199 CpuProfiler(Isolate* isolate, | 196 CpuProfiler(Isolate* isolate, |
200 CpuProfilesCollection* test_collection, | 197 CpuProfilesCollection* test_collection, |
201 ProfileGenerator* test_generator, | 198 ProfileGenerator* test_generator, |
202 ProfilerEventsProcessor* test_processor); | 199 ProfilerEventsProcessor* test_processor); |
203 | 200 |
204 ~CpuProfiler() override; | 201 ~CpuProfiler() override; |
(...skipping 30 matching lines...) Expand all Loading... |
235 void CodeMovingGCEvent() override {} | 232 void CodeMovingGCEvent() override {} |
236 void CodeMoveEvent(AbstractCode* from, Address to) override; | 233 void CodeMoveEvent(AbstractCode* from, Address to) override; |
237 void CodeDisableOptEvent(AbstractCode* code, | 234 void CodeDisableOptEvent(AbstractCode* code, |
238 SharedFunctionInfo* shared) override; | 235 SharedFunctionInfo* shared) override; |
239 void CodeDeoptEvent(Code* code, Address pc, int fp_to_sp_delta); | 236 void CodeDeoptEvent(Code* code, Address pc, int fp_to_sp_delta); |
240 void GetterCallbackEvent(Name* name, Address entry_point) override; | 237 void GetterCallbackEvent(Name* name, Address entry_point) override; |
241 void RegExpCodeCreateEvent(AbstractCode* code, String* source) override; | 238 void RegExpCodeCreateEvent(AbstractCode* code, String* source) override; |
242 void SetterCallbackEvent(Name* name, Address entry_point) override; | 239 void SetterCallbackEvent(Name* name, Address entry_point) override; |
243 void SharedFunctionInfoMoveEvent(Address from, Address to) override {} | 240 void SharedFunctionInfoMoveEvent(Address from, Address to) override {} |
244 | 241 |
245 INLINE(bool is_profiling() const) { return is_profiling_; } | 242 bool is_profiling() const { return is_profiling_; } |
246 bool* is_profiling_address() { | |
247 return &is_profiling_; | |
248 } | |
249 | 243 |
250 ProfileGenerator* generator() const { return generator_; } | 244 ProfileGenerator* generator() const { return generator_; } |
251 ProfilerEventsProcessor* processor() const { return processor_; } | 245 ProfilerEventsProcessor* processor() const { return processor_; } |
252 Isolate* isolate() const { return isolate_; } | 246 Isolate* isolate() const { return isolate_; } |
253 | 247 |
254 private: | 248 private: |
255 void StartProcessorIfNotStarted(); | 249 void StartProcessorIfNotStarted(); |
256 void StopProcessorIfLastProfile(const char* title); | 250 void StopProcessorIfLastProfile(const char* title); |
257 void StopProcessor(); | 251 void StopProcessor(); |
258 void ResetProfiles(); | 252 void ResetProfiles(); |
(...skipping 11 matching lines...) Expand all Loading... |
270 bool is_profiling_; | 264 bool is_profiling_; |
271 | 265 |
272 DISALLOW_COPY_AND_ASSIGN(CpuProfiler); | 266 DISALLOW_COPY_AND_ASSIGN(CpuProfiler); |
273 }; | 267 }; |
274 | 268 |
275 } // namespace internal | 269 } // namespace internal |
276 } // namespace v8 | 270 } // namespace v8 |
277 | 271 |
278 | 272 |
279 #endif // V8_PROFILER_CPU_PROFILER_H_ | 273 #endif // V8_PROFILER_CPU_PROFILER_H_ |
OLD | NEW |