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" |
11 #include "src/circular-queue.h" | 11 #include "src/circular-queue.h" |
12 #include "src/sampler.h" | 12 #include "src/sampler.h" |
13 #include "src/unbound-queue.h" | 13 #include "src/unbound-queue.h" |
14 | 14 |
15 namespace v8 { | 15 namespace v8 { |
16 namespace internal { | 16 namespace internal { |
17 | 17 |
18 // Forward declarations. | 18 // Forward declarations. |
19 class CodeEntry; | 19 class CodeEntry; |
20 class CodeMap; | 20 class CodeMap; |
21 class CompilationInfo; | 21 class CompilationInfo; |
22 class CpuProfile; | 22 class CpuProfile; |
23 class CpuProfilesCollection; | 23 class CpuProfilesCollection; |
24 class ProfileGenerator; | 24 class ProfileGenerator; |
25 | 25 |
26 #define CODE_EVENTS_TYPE_LIST(V) \ | 26 #define CODE_EVENTS_TYPE_LIST(V) \ |
27 V(CODE_CREATION, CodeCreateEventRecord) \ | 27 V(CODE_CREATION, CodeCreateEventRecord) \ |
28 V(CODE_MOVE, CodeMoveEventRecord) \ | 28 V(CODE_MOVE, CodeMoveEventRecord) \ |
29 V(CODE_DISABLE_OPT, CodeDisableOptEventRecord) \ | 29 V(CODE_DISABLE_OPT, CodeDisableOptEventRecord) \ |
30 V(SHARED_FUNC_MOVE, SharedFunctionInfoMoveEventRecord) \ | 30 V(CODE_DEOPT, CodeDeoptEventRecord) \ |
31 V(REPORT_BUILTIN, ReportBuiltinEventRecord) | 31 V(SHARED_FUNC_MOVE, SharedFunctionInfoMoveEventRecord) \ |
| 32 V(REPORT_BUILTIN, ReportBuiltinEventRecord) |
32 | 33 |
33 | 34 |
34 class CodeEventRecord { | 35 class CodeEventRecord { |
35 public: | 36 public: |
36 #define DECLARE_TYPE(type, ignore) type, | 37 #define DECLARE_TYPE(type, ignore) type, |
37 enum Type { | 38 enum Type { |
38 NONE = 0, | 39 NONE = 0, |
39 CODE_EVENTS_TYPE_LIST(DECLARE_TYPE) | 40 CODE_EVENTS_TYPE_LIST(DECLARE_TYPE) |
40 NUMBER_OF_TYPES | 41 NUMBER_OF_TYPES |
41 }; | 42 }; |
(...skipping 26 matching lines...) Expand all Loading... |
68 | 69 |
69 class CodeDisableOptEventRecord : public CodeEventRecord { | 70 class CodeDisableOptEventRecord : public CodeEventRecord { |
70 public: | 71 public: |
71 Address start; | 72 Address start; |
72 const char* bailout_reason; | 73 const char* bailout_reason; |
73 | 74 |
74 INLINE(void UpdateCodeMap(CodeMap* code_map)); | 75 INLINE(void UpdateCodeMap(CodeMap* code_map)); |
75 }; | 76 }; |
76 | 77 |
77 | 78 |
| 79 class CodeDeoptEventRecord : public CodeEventRecord { |
| 80 public: |
| 81 Address start; |
| 82 const char* deopt_reason; |
| 83 int raw_position; |
| 84 |
| 85 INLINE(void UpdateCodeMap(CodeMap* code_map)); |
| 86 }; |
| 87 |
| 88 |
78 class SharedFunctionInfoMoveEventRecord : public CodeEventRecord { | 89 class SharedFunctionInfoMoveEventRecord : public CodeEventRecord { |
79 public: | 90 public: |
80 Address from; | 91 Address from; |
81 Address to; | 92 Address to; |
82 | 93 |
83 INLINE(void UpdateCodeMap(CodeMap* code_map)); | 94 INLINE(void UpdateCodeMap(CodeMap* code_map)); |
84 }; | 95 }; |
85 | 96 |
86 | 97 |
87 class ReportBuiltinEventRecord : public CodeEventRecord { | 98 class ReportBuiltinEventRecord : public CodeEventRecord { |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 virtual ~ProfilerEventsProcessor() {} | 141 virtual ~ProfilerEventsProcessor() {} |
131 | 142 |
132 // Thread control. | 143 // Thread control. |
133 virtual void Run(); | 144 virtual void Run(); |
134 void StopSynchronously(); | 145 void StopSynchronously(); |
135 INLINE(bool running()) { return !!base::NoBarrier_Load(&running_); } | 146 INLINE(bool running()) { return !!base::NoBarrier_Load(&running_); } |
136 void Enqueue(const CodeEventsContainer& event); | 147 void Enqueue(const CodeEventsContainer& event); |
137 | 148 |
138 // Puts current stack into tick sample events buffer. | 149 // Puts current stack into tick sample events buffer. |
139 void AddCurrentStack(Isolate* isolate); | 150 void AddCurrentStack(Isolate* isolate); |
| 151 void AddDeoptStack(Isolate* isolate, Address from, int fp_to_sp_delta); |
140 | 152 |
141 // Tick sample events are filled directly in the buffer of the circular | 153 // 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 | 154 // 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 | 155 // stack frame entries are filled.) This method returns a pointer to the |
144 // next record of the buffer. | 156 // next record of the buffer. |
145 inline TickSample* StartTickSample(); | 157 inline TickSample* StartTickSample(); |
146 inline void FinishTickSample(); | 158 inline void FinishTickSample(); |
147 | 159 |
148 // SamplingCircularQueue has stricter alignment requirements than a normal new | 160 // SamplingCircularQueue has stricter alignment requirements than a normal new |
149 // can fulfil, so we need to provide our own new/delete here. | 161 // can fulfil, so we need to provide our own new/delete here. |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
226 CompilationInfo* info, Name* script_name); | 238 CompilationInfo* info, Name* script_name); |
227 virtual void CodeCreateEvent(Logger::LogEventsAndTags tag, Code* code, | 239 virtual void CodeCreateEvent(Logger::LogEventsAndTags tag, Code* code, |
228 SharedFunctionInfo* shared, | 240 SharedFunctionInfo* shared, |
229 CompilationInfo* info, Name* script_name, | 241 CompilationInfo* info, Name* script_name, |
230 int line, int column); | 242 int line, int column); |
231 virtual void CodeCreateEvent(Logger::LogEventsAndTags tag, | 243 virtual void CodeCreateEvent(Logger::LogEventsAndTags tag, |
232 Code* code, int args_count); | 244 Code* code, int args_count); |
233 virtual void CodeMovingGCEvent() {} | 245 virtual void CodeMovingGCEvent() {} |
234 virtual void CodeMoveEvent(Address from, Address to); | 246 virtual void CodeMoveEvent(Address from, Address to); |
235 virtual void CodeDisableOptEvent(Code* code, SharedFunctionInfo* shared); | 247 virtual void CodeDisableOptEvent(Code* code, SharedFunctionInfo* shared); |
| 248 virtual void CodeDeoptEvent(Code* code, int bailout_id, Address pc, |
| 249 int fp_to_sp_delta); |
236 virtual void CodeDeleteEvent(Address from); | 250 virtual void CodeDeleteEvent(Address from); |
237 virtual void GetterCallbackEvent(Name* name, Address entry_point); | 251 virtual void GetterCallbackEvent(Name* name, Address entry_point); |
238 virtual void RegExpCodeCreateEvent(Code* code, String* source); | 252 virtual void RegExpCodeCreateEvent(Code* code, String* source); |
239 virtual void SetterCallbackEvent(Name* name, Address entry_point); | 253 virtual void SetterCallbackEvent(Name* name, Address entry_point); |
240 virtual void SharedFunctionInfoMoveEvent(Address from, Address to); | 254 virtual void SharedFunctionInfoMoveEvent(Address from, Address to); |
241 | 255 |
242 INLINE(bool is_profiling() const) { return is_profiling_; } | 256 INLINE(bool is_profiling() const) { return is_profiling_; } |
243 bool* is_profiling_address() { | 257 bool* is_profiling_address() { |
244 return &is_profiling_; | 258 return &is_profiling_; |
245 } | 259 } |
(...skipping 17 matching lines...) Expand all Loading... |
263 bool saved_is_logging_; | 277 bool saved_is_logging_; |
264 bool is_profiling_; | 278 bool is_profiling_; |
265 | 279 |
266 DISALLOW_COPY_AND_ASSIGN(CpuProfiler); | 280 DISALLOW_COPY_AND_ASSIGN(CpuProfiler); |
267 }; | 281 }; |
268 | 282 |
269 } } // namespace v8::internal | 283 } } // namespace v8::internal |
270 | 284 |
271 | 285 |
272 #endif // V8_CPU_PROFILER_H_ | 286 #endif // V8_CPU_PROFILER_H_ |
OLD | NEW |