OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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_PROFILE_GENERATOR_H_ | 5 #ifndef V8_PROFILE_GENERATOR_H_ |
6 #define V8_PROFILE_GENERATOR_H_ | 6 #define V8_PROFILE_GENERATOR_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include "include/v8-profiler.h" | 9 #include "include/v8-profiler.h" |
10 #include "src/allocation.h" | 10 #include "src/allocation.h" |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 const char* resource_name() const { return resource_name_; } | 83 const char* resource_name() const { return resource_name_; } |
84 int line_number() const { return line_number_; } | 84 int line_number() const { return line_number_; } |
85 int column_number() const { return column_number_; } | 85 int column_number() const { return column_number_; } |
86 const JITLineInfoTable* line_info() const { return line_info_; } | 86 const JITLineInfoTable* line_info() const { return line_info_; } |
87 void set_shared_id(int shared_id) { shared_id_ = shared_id; } | 87 void set_shared_id(int shared_id) { shared_id_ = shared_id; } |
88 int script_id() const { return script_id_; } | 88 int script_id() const { return script_id_; } |
89 void set_script_id(int script_id) { script_id_ = script_id; } | 89 void set_script_id(int script_id) { script_id_ = script_id; } |
90 void set_bailout_reason(const char* bailout_reason) { | 90 void set_bailout_reason(const char* bailout_reason) { |
91 bailout_reason_ = bailout_reason; | 91 bailout_reason_ = bailout_reason; |
92 } | 92 } |
93 void set_deopt_reason(const char* deopt_reason) { | 93 const char* bailout_reason() const { return bailout_reason_; } |
| 94 |
| 95 void set_deopt_info(const char* deopt_reason, int location) { |
| 96 DCHECK(deopt_reason_ == kNoDeoptReason); |
| 97 DCHECK(!deopt_location_); |
94 deopt_reason_ = deopt_reason; | 98 deopt_reason_ = deopt_reason; |
| 99 deopt_location_ = location; |
95 } | 100 } |
96 void set_deopt_location(int location) { deopt_location_ = location; } | 101 const char* deopt_reason() const { return deopt_reason_; } |
97 const char* bailout_reason() const { return bailout_reason_; } | 102 int deopt_location() const { return deopt_location_; } |
| 103 bool has_deopt_info() const { return deopt_reason_ != kNoDeoptReason; } |
| 104 void clear_deopt_info() { |
| 105 deopt_reason_ = kNoDeoptReason; |
| 106 deopt_location_ = 0; |
| 107 } |
98 | 108 |
99 static inline bool is_js_function_tag(Logger::LogEventsAndTags tag); | 109 static inline bool is_js_function_tag(Logger::LogEventsAndTags tag); |
100 | 110 |
101 List<OffsetRange>* no_frame_ranges() const { return no_frame_ranges_; } | 111 List<OffsetRange>* no_frame_ranges() const { return no_frame_ranges_; } |
102 void set_no_frame_ranges(List<OffsetRange>* ranges) { | 112 void set_no_frame_ranges(List<OffsetRange>* ranges) { |
103 no_frame_ranges_ = ranges; | 113 no_frame_ranges_ = ranges; |
104 } | 114 } |
105 | 115 |
106 void SetBuiltinId(Builtins::Name id); | 116 void SetBuiltinId(Builtins::Name id); |
107 Builtins::Name builtin_id() const { | 117 Builtins::Name builtin_id() const { |
108 return BuiltinIdField::decode(bit_field_); | 118 return BuiltinIdField::decode(bit_field_); |
109 } | 119 } |
110 | 120 |
111 uint32_t GetCallUid() const; | 121 uint32_t GetCallUid() const; |
112 bool IsSameAs(CodeEntry* entry) const; | 122 bool IsSameAs(CodeEntry* entry) const; |
113 | 123 |
114 int GetSourceLine(int pc_offset) const; | 124 int GetSourceLine(int pc_offset) const; |
115 | 125 |
116 Address instruction_start() const { return instruction_start_; } | 126 Address instruction_start() const { return instruction_start_; } |
117 | 127 |
118 static const char* const kEmptyNamePrefix; | 128 static const char* const kEmptyNamePrefix; |
119 static const char* const kEmptyResourceName; | 129 static const char* const kEmptyResourceName; |
120 static const char* const kEmptyBailoutReason; | 130 static const char* const kEmptyBailoutReason; |
| 131 static const char* const kNoDeoptReason; |
121 | 132 |
122 private: | 133 private: |
123 class TagField : public BitField<Logger::LogEventsAndTags, 0, 8> {}; | 134 class TagField : public BitField<Logger::LogEventsAndTags, 0, 8> {}; |
124 class BuiltinIdField : public BitField<Builtins::Name, 8, 8> {}; | 135 class BuiltinIdField : public BitField<Builtins::Name, 8, 8> {}; |
125 Logger::LogEventsAndTags tag() const { return TagField::decode(bit_field_); } | 136 Logger::LogEventsAndTags tag() const { return TagField::decode(bit_field_); } |
126 | 137 |
127 uint32_t bit_field_; | 138 uint32_t bit_field_; |
128 const char* name_prefix_; | 139 const char* name_prefix_; |
129 const char* name_; | 140 const char* name_; |
130 const char* resource_name_; | 141 const char* resource_name_; |
131 int line_number_; | 142 int line_number_; |
132 int column_number_; | 143 int column_number_; |
133 int shared_id_; | 144 int shared_id_; |
134 int script_id_; | 145 int script_id_; |
135 List<OffsetRange>* no_frame_ranges_; | 146 List<OffsetRange>* no_frame_ranges_; |
136 const char* bailout_reason_; | 147 const char* bailout_reason_; |
137 const char* deopt_reason_; | 148 const char* deopt_reason_; |
138 int deopt_location_; | 149 int deopt_location_; |
139 JITLineInfoTable* line_info_; | 150 JITLineInfoTable* line_info_; |
140 Address instruction_start_; | 151 Address instruction_start_; |
141 | 152 |
142 DISALLOW_COPY_AND_ASSIGN(CodeEntry); | 153 DISALLOW_COPY_AND_ASSIGN(CodeEntry); |
143 }; | 154 }; |
144 | 155 |
145 | 156 |
146 class ProfileTree; | 157 class ProfileTree; |
147 | 158 |
148 class ProfileNode { | 159 class ProfileNode { |
| 160 private: |
| 161 struct DeoptInfo { |
| 162 DeoptInfo(const char* deopt_reason, int deopt_location) |
| 163 : deopt_reason(deopt_reason), deopt_location(deopt_location) {} |
| 164 DeoptInfo(const DeoptInfo& info) |
| 165 : deopt_reason(info.deopt_reason), |
| 166 deopt_location(info.deopt_location) {} |
| 167 const char* deopt_reason; |
| 168 int deopt_location; |
| 169 }; |
| 170 |
149 public: | 171 public: |
150 inline ProfileNode(ProfileTree* tree, CodeEntry* entry); | 172 inline ProfileNode(ProfileTree* tree, CodeEntry* entry); |
151 | 173 |
152 ProfileNode* FindChild(CodeEntry* entry); | 174 ProfileNode* FindChild(CodeEntry* entry); |
153 ProfileNode* FindOrAddChild(CodeEntry* entry); | 175 ProfileNode* FindOrAddChild(CodeEntry* entry); |
154 void IncrementSelfTicks() { ++self_ticks_; } | 176 void IncrementSelfTicks() { ++self_ticks_; } |
155 void IncreaseSelfTicks(unsigned amount) { self_ticks_ += amount; } | 177 void IncreaseSelfTicks(unsigned amount) { self_ticks_ += amount; } |
156 void IncrementLineTicks(int src_line); | 178 void IncrementLineTicks(int src_line); |
157 | 179 |
158 CodeEntry* entry() const { return entry_; } | 180 CodeEntry* entry() const { return entry_; } |
159 unsigned self_ticks() const { return self_ticks_; } | 181 unsigned self_ticks() const { return self_ticks_; } |
160 const List<ProfileNode*>* children() const { return &children_list_; } | 182 const List<ProfileNode*>* children() const { return &children_list_; } |
161 unsigned id() const { return id_; } | 183 unsigned id() const { return id_; } |
162 unsigned int GetHitLineCount() const { return line_ticks_.occupancy(); } | 184 unsigned int GetHitLineCount() const { return line_ticks_.occupancy(); } |
163 bool GetLineTicks(v8::CpuProfileNode::LineTick* entries, | 185 bool GetLineTicks(v8::CpuProfileNode::LineTick* entries, |
164 unsigned int length) const; | 186 unsigned int length) const; |
| 187 void CollectDeoptInfo(CodeEntry* entry); |
| 188 const List<DeoptInfo>& deopt_infos() const { return deopt_infos_; } |
165 | 189 |
166 void Print(int indent); | 190 void Print(int indent); |
167 | 191 |
168 private: | 192 private: |
169 static bool CodeEntriesMatch(void* entry1, void* entry2) { | 193 static bool CodeEntriesMatch(void* entry1, void* entry2) { |
170 return reinterpret_cast<CodeEntry*>(entry1)->IsSameAs( | 194 return reinterpret_cast<CodeEntry*>(entry1)->IsSameAs( |
171 reinterpret_cast<CodeEntry*>(entry2)); | 195 reinterpret_cast<CodeEntry*>(entry2)); |
172 } | 196 } |
173 | 197 |
174 static uint32_t CodeEntryHash(CodeEntry* entry) { | 198 static uint32_t CodeEntryHash(CodeEntry* entry) { |
175 return entry->GetCallUid(); | 199 return entry->GetCallUid(); |
176 } | 200 } |
177 | 201 |
178 static bool LineTickMatch(void* a, void* b) { return a == b; } | 202 static bool LineTickMatch(void* a, void* b) { return a == b; } |
179 | 203 |
180 ProfileTree* tree_; | 204 ProfileTree* tree_; |
181 CodeEntry* entry_; | 205 CodeEntry* entry_; |
182 unsigned self_ticks_; | 206 unsigned self_ticks_; |
183 // Mapping from CodeEntry* to ProfileNode* | 207 // Mapping from CodeEntry* to ProfileNode* |
184 HashMap children_; | 208 HashMap children_; |
185 List<ProfileNode*> children_list_; | 209 List<ProfileNode*> children_list_; |
186 unsigned id_; | 210 unsigned id_; |
187 HashMap line_ticks_; | 211 HashMap line_ticks_; |
188 | 212 |
| 213 List<DeoptInfo> deopt_infos_; |
189 DISALLOW_COPY_AND_ASSIGN(ProfileNode); | 214 DISALLOW_COPY_AND_ASSIGN(ProfileNode); |
190 }; | 215 }; |
191 | 216 |
192 | 217 |
193 class ProfileTree { | 218 class ProfileTree { |
194 public: | 219 public: |
195 ProfileTree(); | 220 ProfileTree(); |
196 ~ProfileTree(); | 221 ~ProfileTree(); |
197 | 222 |
198 ProfileNode* AddPathFromEnd( | 223 ProfileNode* AddPathFromEnd( |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
377 CodeEntry* gc_entry_; | 402 CodeEntry* gc_entry_; |
378 CodeEntry* unresolved_entry_; | 403 CodeEntry* unresolved_entry_; |
379 | 404 |
380 DISALLOW_COPY_AND_ASSIGN(ProfileGenerator); | 405 DISALLOW_COPY_AND_ASSIGN(ProfileGenerator); |
381 }; | 406 }; |
382 | 407 |
383 | 408 |
384 } } // namespace v8::internal | 409 } } // namespace v8::internal |
385 | 410 |
386 #endif // V8_PROFILE_GENERATOR_H_ | 411 #endif // V8_PROFILE_GENERATOR_H_ |
OLD | NEW |