| 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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 INLINE(void UpdateCodeMap(CodeMap* code_map)); | 75 INLINE(void UpdateCodeMap(CodeMap* code_map)); |
| 76 }; | 76 }; |
| 77 | 77 |
| 78 | 78 |
| 79 class CodeDeoptEventRecord : public CodeEventRecord { | 79 class CodeDeoptEventRecord : public CodeEventRecord { |
| 80 public: | 80 public: |
| 81 Address start; | 81 Address start; |
| 82 const char* deopt_reason; | 82 const char* deopt_reason; |
| 83 SourcePosition position; | 83 SourcePosition position; |
| 84 int deopt_id; | 84 int deopt_id; |
| 85 void* pc; |
| 86 int fp_to_sp_delta; |
| 85 | 87 |
| 86 INLINE(void UpdateCodeMap(CodeMap* code_map)); | 88 INLINE(void UpdateCodeMap(CodeMap* code_map)); |
| 87 }; | 89 }; |
| 88 | 90 |
| 89 | 91 |
| 90 class ReportBuiltinEventRecord : public CodeEventRecord { | 92 class ReportBuiltinEventRecord : public CodeEventRecord { |
| 91 public: | 93 public: |
| 92 Address start; | 94 Address start; |
| 93 Builtins::Name builtin_id; | 95 Builtins::Name builtin_id; |
| 94 | 96 |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 182 | 184 |
| 183 #define PROFILE(IsolateGetter, Call) \ | 185 #define PROFILE(IsolateGetter, Call) \ |
| 184 do { \ | 186 do { \ |
| 185 Isolate* the_isolate = (IsolateGetter); \ | 187 Isolate* the_isolate = (IsolateGetter); \ |
| 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 { |
| 193 public: | 195 public: |
| 194 explicit CpuProfiler(Isolate* isolate); | 196 explicit CpuProfiler(Isolate* isolate); |
| 195 | 197 |
| 196 CpuProfiler(Isolate* isolate, | 198 CpuProfiler(Isolate* isolate, |
| 197 CpuProfilesCollection* test_collection, | 199 CpuProfilesCollection* test_collection, |
| 198 ProfileGenerator* test_generator, | 200 ProfileGenerator* test_generator, |
| 199 ProfilerEventsProcessor* test_processor); | 201 ProfilerEventsProcessor* test_processor); |
| 200 | 202 |
| 201 ~CpuProfiler() override; | 203 ~CpuProfiler(); |
| 202 | 204 |
| 203 void set_sampling_interval(base::TimeDelta value); | 205 void set_sampling_interval(base::TimeDelta value); |
| 204 void CollectSample(); | 206 void CollectSample(); |
| 205 void StartProfiling(const char* title, bool record_samples = false); | 207 void StartProfiling(const char* title, bool record_samples = false); |
| 206 void StartProfiling(String* title, bool record_samples); | 208 void StartProfiling(String* title, bool record_samples); |
| 207 CpuProfile* StopProfiling(const char* title); | 209 CpuProfile* StopProfiling(const char* title); |
| 208 CpuProfile* StopProfiling(String* title); | 210 CpuProfile* StopProfiling(String* title); |
| 209 int GetProfilesCount(); | 211 int GetProfilesCount(); |
| 210 CpuProfile* GetProfile(int index); | 212 CpuProfile* GetProfile(int index); |
| 211 void DeleteAllProfiles(); | 213 void DeleteAllProfiles(); |
| 212 void DeleteProfile(CpuProfile* profile); | 214 void DeleteProfile(CpuProfile* profile); |
| 213 | 215 |
| 216 void CodeEventHandler(const CodeEventsContainer& evt_rec); |
| 217 |
| 214 // Invoked from stack sampler (thread or signal handler.) | 218 // Invoked from stack sampler (thread or signal handler.) |
| 215 inline TickSample* StartTickSample(); | 219 inline TickSample* StartTickSample(); |
| 216 inline void FinishTickSample(); | 220 inline void FinishTickSample(); |
| 217 | 221 |
| 218 // Must be called via PROFILE macro, otherwise will crash when | |
| 219 // profiling is not enabled. | |
| 220 void CallbackEvent(Name* name, Address entry_point) override; | |
| 221 void CodeCreateEvent(Logger::LogEventsAndTags tag, AbstractCode* code, | |
| 222 const char* comment) override; | |
| 223 void CodeCreateEvent(Logger::LogEventsAndTags tag, AbstractCode* code, | |
| 224 Name* name) override; | |
| 225 void CodeCreateEvent(Logger::LogEventsAndTags tag, AbstractCode* code, | |
| 226 SharedFunctionInfo* shared, Name* script_name) override; | |
| 227 void CodeCreateEvent(Logger::LogEventsAndTags tag, AbstractCode* code, | |
| 228 SharedFunctionInfo* shared, Name* script_name, int line, | |
| 229 int column) override; | |
| 230 void CodeCreateEvent(Logger::LogEventsAndTags tag, AbstractCode* code, | |
| 231 int args_count) override; | |
| 232 void CodeMovingGCEvent() override {} | |
| 233 void CodeMoveEvent(AbstractCode* from, Address to) override; | |
| 234 void CodeDisableOptEvent(AbstractCode* code, | |
| 235 SharedFunctionInfo* shared) override; | |
| 236 void CodeDeoptEvent(Code* code, Address pc, int fp_to_sp_delta); | |
| 237 void GetterCallbackEvent(Name* name, Address entry_point) override; | |
| 238 void RegExpCodeCreateEvent(AbstractCode* code, String* source) override; | |
| 239 void SetterCallbackEvent(Name* name, Address entry_point) override; | |
| 240 void SharedFunctionInfoMoveEvent(Address from, Address to) override {} | |
| 241 | |
| 242 bool is_profiling() const { return is_profiling_; } | 222 bool is_profiling() const { return is_profiling_; } |
| 243 | 223 |
| 244 ProfileGenerator* generator() const { return generator_; } | 224 ProfileGenerator* generator() const { return generator_; } |
| 245 ProfilerEventsProcessor* processor() const { return processor_; } | 225 ProfilerEventsProcessor* processor() const { return processor_; } |
| 246 Isolate* isolate() const { return isolate_; } | 226 Isolate* isolate() const { return isolate_; } |
| 247 | 227 |
| 248 private: | 228 private: |
| 249 void StartProcessorIfNotStarted(); | 229 void StartProcessorIfNotStarted(); |
| 250 void StopProcessorIfLastProfile(const char* title); | 230 void StopProcessorIfLastProfile(const char* title); |
| 251 void StopProcessor(); | 231 void StopProcessor(); |
| 252 void ResetProfiles(); | 232 void ResetProfiles(); |
| 253 void LogBuiltins(); | 233 void LogBuiltins(); |
| 254 void RecordInliningInfo(CodeEntry* entry, AbstractCode* abstract_code); | |
| 255 void RecordDeoptInlinedFrames(CodeEntry* entry, AbstractCode* abstract_code); | |
| 256 Name* InferScriptName(Name* name, SharedFunctionInfo* info); | |
| 257 | 234 |
| 258 Isolate* isolate_; | 235 Isolate* isolate_; |
| 259 base::TimeDelta sampling_interval_; | 236 base::TimeDelta sampling_interval_; |
| 260 CpuProfilesCollection* profiles_; | 237 CpuProfilesCollection* profiles_; |
| 261 ProfileGenerator* generator_; | 238 ProfileGenerator* generator_; |
| 262 ProfilerEventsProcessor* processor_; | 239 ProfilerEventsProcessor* processor_; |
| 263 bool saved_is_logging_; | 240 bool saved_is_logging_; |
| 264 bool is_profiling_; | 241 bool is_profiling_; |
| 242 bool is_testing_; |
| 265 | 243 |
| 266 DISALLOW_COPY_AND_ASSIGN(CpuProfiler); | 244 DISALLOW_COPY_AND_ASSIGN(CpuProfiler); |
| 267 }; | 245 }; |
| 268 | 246 |
| 269 } // namespace internal | 247 } // namespace internal |
| 270 } // namespace v8 | 248 } // namespace v8 |
| 271 | 249 |
| 272 | 250 |
| 273 #endif // V8_PROFILER_CPU_PROFILER_H_ | 251 #endif // V8_PROFILER_CPU_PROFILER_H_ |
| OLD | NEW |