OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef V8_PROFILER_TICK_SAMPLE_H_ |
| 6 #define V8_PROFILER_TICK_SAMPLE_H_ |
| 7 |
| 8 #include "include/v8.h" |
| 9 |
| 10 #include "src/base/platform/time.h" |
| 11 #include "src/frames.h" |
| 12 |
| 13 namespace v8 { |
| 14 namespace internal { |
| 15 |
| 16 class Isolate; |
| 17 |
| 18 // ---------------------------------------------------------------------------- |
| 19 // Sampler |
| 20 // |
| 21 // A sampler periodically samples the state of the VM and optionally |
| 22 // (if used for profiling) the program counter and stack pointer for |
| 23 // the thread that created it. |
| 24 |
| 25 // TickSample captures the information collected for each sample. |
| 26 struct TickSample { |
| 27 // Internal profiling (with --prof + tools/$OS-tick-processor) wants to |
| 28 // include the runtime function we're calling. Externally exposed tick |
| 29 // samples don't care. |
| 30 enum RecordCEntryFrame { kIncludeCEntryFrame, kSkipCEntryFrame }; |
| 31 |
| 32 TickSample() |
| 33 : state(OTHER), |
| 34 pc(NULL), |
| 35 external_callback_entry(NULL), |
| 36 frames_count(0), |
| 37 has_external_callback(false), |
| 38 update_stats(true), |
| 39 top_frame_type(StackFrame::NONE) {} |
| 40 void Init(Isolate* isolate, const v8::RegisterState& state, |
| 41 RecordCEntryFrame record_c_entry_frame, bool update_stats); |
| 42 static void GetStackSample(Isolate* isolate, const v8::RegisterState& state, |
| 43 RecordCEntryFrame record_c_entry_frame, |
| 44 void** frames, size_t frames_limit, |
| 45 v8::SampleInfo* sample_info); |
| 46 StateTag state; // The state of the VM. |
| 47 Address pc; // Instruction pointer. |
| 48 union { |
| 49 Address tos; // Top stack value (*sp). |
| 50 Address external_callback_entry; |
| 51 }; |
| 52 static const unsigned kMaxFramesCountLog2 = 8; |
| 53 static const unsigned kMaxFramesCount = (1 << kMaxFramesCountLog2) - 1; |
| 54 Address stack[kMaxFramesCount]; // Call stack. |
| 55 base::TimeTicks timestamp; |
| 56 unsigned frames_count : kMaxFramesCountLog2; // Number of captured frames. |
| 57 bool has_external_callback : 1; |
| 58 bool update_stats : 1; // Whether the sample should update aggregated stats. |
| 59 StackFrame::Type top_frame_type : 5; |
| 60 }; |
| 61 |
| 62 |
| 63 } // namespace internal |
| 64 } // namespace v8 |
| 65 |
| 66 #endif // V8_PROFILER_TICK_SAMPLE_H_ |
OLD | NEW |