OLD | NEW |
---|---|
1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 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_V8_PROFILER_H_ | 5 #ifndef V8_V8_PROFILER_H_ |
6 #define V8_V8_PROFILER_H_ | 6 #define V8_V8_PROFILER_H_ |
7 | 7 |
8 #include <vector> | 8 #include <vector> |
9 #include "v8.h" // NOLINT(build/include) | 9 #include "v8.h" // NOLINT(build/include) |
10 | 10 |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
53 // samples don't care. | 53 // samples don't care. |
54 enum RecordCEntryFrame { kIncludeCEntryFrame, kSkipCEntryFrame }; | 54 enum RecordCEntryFrame { kIncludeCEntryFrame, kSkipCEntryFrame }; |
55 | 55 |
56 TickSample() | 56 TickSample() |
57 : state(OTHER), | 57 : state(OTHER), |
58 pc(nullptr), | 58 pc(nullptr), |
59 external_callback_entry(nullptr), | 59 external_callback_entry(nullptr), |
60 frames_count(0), | 60 frames_count(0), |
61 has_external_callback(false), | 61 has_external_callback(false), |
62 update_stats(true) {} | 62 update_stats(true) {} |
63 | |
64 /** | |
65 * Initialize a tick sample from the isolate. | |
66 * \param isolate The currect isolate. | |
67 * \param state Execution state. | |
68 * \param updated_state When running on simulator, this will be set to | |
69 the real register state used for sampling. | |
70 * \param record_c_entry_frame Include or skip the runtime function. | |
71 * \param update_stats Whether update the sample to the aggregated stats. | |
72 * \param use_first_state Force V8 to use the first register state to | |
73 collect sample, default value is false, unless | |
74 the first register state is absolutely correct, | |
75 otherwise don't use it. | |
76 */ | |
63 void Init(Isolate* isolate, const v8::RegisterState& state, | 77 void Init(Isolate* isolate, const v8::RegisterState& state, |
64 RecordCEntryFrame record_c_entry_frame, bool update_stats); | 78 RegisterState& updated_state, |
alph
2016/07/28 23:57:06
Hmm. Is it an output parameter? Where is it used?
| |
79 RecordCEntryFrame record_c_entry_frame, bool update_stats, | |
80 bool use_first_state = false); | |
alph
2016/07/28 23:57:06
The name looks a bit awkward. Not sure about a bet
| |
81 /** | |
82 * Get a call stack sample from the isolate. | |
83 * \param isolate The currect isolate. | |
84 * \param state Execution state. | |
85 * \param updated_state When running on simulator, this will be set to | |
86 the real register state used for sampling. | |
87 * \param record_c_entry_frame Include or skip the runtime function. | |
88 * \param frames Caller allocated buffer to store stack frames. | |
89 * \param frames_limit Maximum number of frames to capture. The buffer must | |
90 * be large enough to hold the number of frames. | |
91 * \param sample_info The sample info is filled up by the function | |
92 * provides number of actual captured stack frames and | |
93 * the current VM state. | |
94 * \param use_first_state Force V8 to use the first register state to | |
95 collect sample, default value is false, unless | |
96 the first register state is absolutely correct, | |
97 otherwise don't use it. | |
98 * \note GetStackSample should only be called when the JS thread is paused or | |
99 * interrupted. Otherwise the behavior is undefined. | |
100 */ | |
65 static bool GetStackSample(Isolate* isolate, const v8::RegisterState& state, | 101 static bool GetStackSample(Isolate* isolate, const v8::RegisterState& state, |
102 RegisterState& updated_state, | |
66 RecordCEntryFrame record_c_entry_frame, | 103 RecordCEntryFrame record_c_entry_frame, |
67 void** frames, size_t frames_limit, | 104 void** frames, size_t frames_limit, |
68 v8::SampleInfo* sample_info); | 105 v8::SampleInfo* sample_info, |
106 bool use_first_state = false); | |
69 StateTag state; // The state of the VM. | 107 StateTag state; // The state of the VM. |
70 void* pc; // Instruction pointer. | 108 void* pc; // Instruction pointer. |
71 union { | 109 union { |
72 void* tos; // Top stack value (*sp). | 110 void* tos; // Top stack value (*sp). |
73 void* external_callback_entry; | 111 void* external_callback_entry; |
74 }; | 112 }; |
75 static const unsigned kMaxFramesCountLog2 = 8; | 113 static const unsigned kMaxFramesCountLog2 = 8; |
76 static const unsigned kMaxFramesCount = (1 << kMaxFramesCountLog2) - 1; | 114 static const unsigned kMaxFramesCount = (1 << kMaxFramesCountLog2) - 1; |
77 void* stack[kMaxFramesCount]; // Call stack. | 115 void* stack[kMaxFramesCount]; // Call stack. |
78 unsigned frames_count : kMaxFramesCountLog2; // Number of captured frames. | 116 unsigned frames_count : kMaxFramesCountLog2; // Number of captured frames. |
(...skipping 744 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
823 uint32_t index; // Index of the time interval that was changed. | 861 uint32_t index; // Index of the time interval that was changed. |
824 uint32_t count; // New value of count field for the interval with this index. | 862 uint32_t count; // New value of count field for the interval with this index. |
825 uint32_t size; // New value of size field for the interval with this index. | 863 uint32_t size; // New value of size field for the interval with this index. |
826 }; | 864 }; |
827 | 865 |
828 | 866 |
829 } // namespace v8 | 867 } // namespace v8 |
830 | 868 |
831 | 869 |
832 #endif // V8_V8_PROFILER_H_ | 870 #endif // V8_V8_PROFILER_H_ |
OLD | NEW |