| OLD | NEW |
| 1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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_SAMPLER_H_ | 5 #ifndef V8_SAMPLER_H_ |
| 6 #define V8_SAMPLER_H_ | 6 #define V8_SAMPLER_H_ |
| 7 | 7 |
| 8 #include "include/v8.h" | 8 #include "include/v8.h" |
| 9 | 9 |
| 10 #include "src/base/atomicops.h" | 10 #include "src/base/atomicops.h" |
| 11 #include "src/frames.h" | 11 #include "src/frames.h" |
| 12 #include "src/globals.h" | 12 #include "src/globals.h" |
| 13 | 13 |
| 14 namespace v8 { | 14 namespace v8 { |
| 15 namespace internal { | 15 namespace internal { |
| 16 | 16 |
| 17 class Isolate; | 17 class Isolate; |
| 18 | 18 |
| 19 // ---------------------------------------------------------------------------- | 19 // ---------------------------------------------------------------------------- |
| 20 // Sampler | 20 // Sampler |
| 21 // | 21 // |
| 22 // A sampler periodically samples the state of the VM and optionally | 22 // A sampler periodically samples the state of the VM and optionally |
| 23 // (if used for profiling) the program counter and stack pointer for | 23 // (if used for profiling) the program counter and stack pointer for |
| 24 // the thread that created it. | 24 // the thread that created it. |
| 25 | 25 |
| 26 // TickSample captures the information collected for each sample. | 26 // TickSample captures the information collected for each sample. |
| 27 struct TickSample { | 27 struct TickSample { |
| 28 // Internal profiling (with --prof + tools/$OS-tick-processor) wants to |
| 29 // include the runtime function we're calling. Externally exposed tick |
| 30 // samples don't care. |
| 31 enum RecordCEntryFrame { kIncludeCEntryFrame, kSkipCEntryFrame }; |
| 32 |
| 28 TickSample() | 33 TickSample() |
| 29 : state(OTHER), | 34 : state(OTHER), |
| 30 pc(NULL), | 35 pc(NULL), |
| 31 external_callback(NULL), | 36 external_callback(NULL), |
| 32 frames_count(0), | 37 frames_count(0), |
| 33 has_external_callback(false), | 38 has_external_callback(false), |
| 34 top_frame_type(StackFrame::NONE) {} | 39 top_frame_type(StackFrame::NONE) {} |
| 35 void Init(Isolate* isolate, const v8::RegisterState& state); | 40 void Init(Isolate* isolate, const v8::RegisterState& state, |
| 41 RecordCEntryFrame record_c_entry_frame); |
| 36 static void GetStackSample(Isolate* isolate, const v8::RegisterState& state, | 42 static void GetStackSample(Isolate* isolate, const v8::RegisterState& state, |
| 43 RecordCEntryFrame record_c_entry_frame, |
| 37 void** frames, size_t frames_limit, | 44 void** frames, size_t frames_limit, |
| 38 v8::SampleInfo* sample_info); | 45 v8::SampleInfo* sample_info); |
| 39 StateTag state; // The state of the VM. | 46 StateTag state; // The state of the VM. |
| 40 Address pc; // Instruction pointer. | 47 Address pc; // Instruction pointer. |
| 41 union { | 48 union { |
| 42 Address tos; // Top stack value (*sp). | 49 Address tos; // Top stack value (*sp). |
| 43 Address external_callback; | 50 Address external_callback; |
| 44 }; | 51 }; |
| 45 static const unsigned kMaxFramesCountLog2 = 8; | 52 static const unsigned kMaxFramesCountLog2 = 8; |
| 46 static const unsigned kMaxFramesCount = (1 << kMaxFramesCountLog2) - 1; | 53 static const unsigned kMaxFramesCount = (1 << kMaxFramesCountLog2) - 1; |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 bool is_counting_samples_; | 125 bool is_counting_samples_; |
| 119 // Counts stack samples taken in JS VM state. | 126 // Counts stack samples taken in JS VM state. |
| 120 unsigned js_and_external_sample_count_; | 127 unsigned js_and_external_sample_count_; |
| 121 DISALLOW_IMPLICIT_CONSTRUCTORS(Sampler); | 128 DISALLOW_IMPLICIT_CONSTRUCTORS(Sampler); |
| 122 }; | 129 }; |
| 123 | 130 |
| 124 | 131 |
| 125 } } // namespace v8::internal | 132 } } // namespace v8::internal |
| 126 | 133 |
| 127 #endif // V8_SAMPLER_H_ | 134 #endif // V8_SAMPLER_H_ |
| OLD | NEW |