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> | |
9 | |
8 #include "src/allocation.h" | 10 #include "src/allocation.h" |
9 #include "src/base/atomic-utils.h" | 11 #include "src/base/atomic-utils.h" |
10 #include "src/base/atomicops.h" | 12 #include "src/base/atomicops.h" |
11 #include "src/base/platform/time.h" | 13 #include "src/base/platform/time.h" |
12 #include "src/compiler.h" | 14 #include "src/compiler.h" |
13 #include "src/libsampler/v8-sampler.h" | 15 #include "src/libsampler/v8-sampler.h" |
14 #include "src/locked-queue.h" | 16 #include "src/locked-queue.h" |
15 #include "src/profiler/circular-queue.h" | 17 #include "src/profiler/circular-queue.h" |
16 #include "src/profiler/tick-sample.h" | 18 #include "src/profiler/tick-sample.h" |
17 | 19 |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
186 v8::internal::Logger* logger = the_isolate->logger(); \ | 188 v8::internal::Logger* logger = the_isolate->logger(); \ |
187 if (logger->is_logging_code_events() || the_isolate->is_profiling()) { \ | 189 if (logger->is_logging_code_events() || the_isolate->is_profiling()) { \ |
188 logger->Call; \ | 190 logger->Call; \ |
189 } \ | 191 } \ |
190 } while (false) | 192 } while (false) |
191 | 193 |
192 class CpuProfiler : public CodeEventListener { | 194 class CpuProfiler : public CodeEventListener { |
193 public: | 195 public: |
194 explicit CpuProfiler(Isolate* isolate); | 196 explicit CpuProfiler(Isolate* isolate); |
195 | 197 |
196 CpuProfiler(Isolate* isolate, | 198 CpuProfiler(Isolate* isolate, CpuProfilesCollection* profiles, |
197 CpuProfilesCollection* test_collection, | |
198 ProfileGenerator* test_generator, | 199 ProfileGenerator* test_generator, |
199 ProfilerEventsProcessor* test_processor); | 200 ProfilerEventsProcessor* test_processor); |
200 | 201 |
201 ~CpuProfiler() override; | 202 ~CpuProfiler() override; |
202 | 203 |
203 void set_sampling_interval(base::TimeDelta value); | 204 void set_sampling_interval(base::TimeDelta value); |
204 void CollectSample(); | 205 void CollectSample(); |
205 void StartProfiling(const char* title, bool record_samples = false); | 206 void StartProfiling(const char* title, bool record_samples = false); |
206 void StartProfiling(String* title, bool record_samples); | 207 void StartProfiling(String* title, bool record_samples); |
207 CpuProfile* StopProfiling(const char* title); | 208 CpuProfile* StopProfiling(const char* title); |
(...skipping 26 matching lines...) Expand all Loading... | |
234 void CodeDisableOptEvent(AbstractCode* code, | 235 void CodeDisableOptEvent(AbstractCode* code, |
235 SharedFunctionInfo* shared) override; | 236 SharedFunctionInfo* shared) override; |
236 void CodeDeoptEvent(Code* code, Address pc, int fp_to_sp_delta); | 237 void CodeDeoptEvent(Code* code, Address pc, int fp_to_sp_delta); |
237 void GetterCallbackEvent(Name* name, Address entry_point) override; | 238 void GetterCallbackEvent(Name* name, Address entry_point) override; |
238 void RegExpCodeCreateEvent(AbstractCode* code, String* source) override; | 239 void RegExpCodeCreateEvent(AbstractCode* code, String* source) override; |
239 void SetterCallbackEvent(Name* name, Address entry_point) override; | 240 void SetterCallbackEvent(Name* name, Address entry_point) override; |
240 void SharedFunctionInfoMoveEvent(Address from, Address to) override {} | 241 void SharedFunctionInfoMoveEvent(Address from, Address to) override {} |
241 | 242 |
242 bool is_profiling() const { return is_profiling_; } | 243 bool is_profiling() const { return is_profiling_; } |
243 | 244 |
244 ProfileGenerator* generator() const { return generator_; } | 245 ProfileGenerator* generator() const { return generator_.get(); } |
245 ProfilerEventsProcessor* processor() const { return processor_; } | 246 ProfilerEventsProcessor* processor() const { return processor_.get(); } |
246 Isolate* isolate() const { return isolate_; } | 247 Isolate* isolate() const { return isolate_; } |
247 | 248 |
248 private: | 249 private: |
249 void StartProcessorIfNotStarted(); | 250 void StartProcessorIfNotStarted(); |
250 void StopProcessorIfLastProfile(const char* title); | 251 void StopProcessorIfLastProfile(const char* title); |
251 void StopProcessor(); | 252 void StopProcessor(); |
252 void ResetProfiles(); | 253 void ResetProfiles(); |
253 void LogBuiltins(); | 254 void LogBuiltins(); |
254 void RecordInliningInfo(CodeEntry* entry, AbstractCode* abstract_code); | 255 void RecordInliningInfo(CodeEntry* entry, AbstractCode* abstract_code); |
255 void RecordDeoptInlinedFrames(CodeEntry* entry, AbstractCode* abstract_code); | 256 void RecordDeoptInlinedFrames(CodeEntry* entry, AbstractCode* abstract_code); |
256 Name* InferScriptName(Name* name, SharedFunctionInfo* info); | 257 Name* InferScriptName(Name* name, SharedFunctionInfo* info); |
257 | 258 |
258 Isolate* isolate_; | 259 Isolate* const isolate_; |
259 base::TimeDelta sampling_interval_; | 260 base::TimeDelta sampling_interval_; |
260 CpuProfilesCollection* profiles_; | 261 std::unique_ptr<CpuProfilesCollection> profiles_; |
Yang
2016/06/14 13:04:16
We don't use unique_ptr in V8 until now. Is there
alph
2016/06/14 15:47:15
std::unique_ptr is allowed in Chromium C++ style g
| |
261 ProfileGenerator* generator_; | 262 std::unique_ptr<ProfileGenerator> generator_; |
262 ProfilerEventsProcessor* processor_; | 263 std::unique_ptr<ProfilerEventsProcessor> processor_; |
263 bool saved_is_logging_; | 264 bool saved_is_logging_; |
264 bool is_profiling_; | 265 bool is_profiling_; |
265 | 266 |
266 DISALLOW_COPY_AND_ASSIGN(CpuProfiler); | 267 DISALLOW_COPY_AND_ASSIGN(CpuProfiler); |
267 }; | 268 }; |
268 | 269 |
269 } // namespace internal | 270 } // namespace internal |
270 } // namespace v8 | 271 } // namespace v8 |
271 | 272 |
272 | 273 |
273 #endif // V8_PROFILER_CPU_PROFILER_H_ | 274 #endif // V8_PROFILER_CPU_PROFILER_H_ |
OLD | NEW |