Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4)

Side by Side Diff: src/profile-generator.h

Issue 941973002: CpuProfiler: eliminate cpu-profiler dependency from heap-inl.h (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: comments addressed Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/ppc/lithium-codegen-ppc.cc ('k') | src/profile-generator.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 ~CodeEntry(); 77 ~CodeEntry();
78 78
79 bool is_js_function() const { return is_js_function_tag(tag()); } 79 bool is_js_function() const { return is_js_function_tag(tag()); }
80 const char* name_prefix() const { return name_prefix_; } 80 const char* name_prefix() const { return name_prefix_; }
81 bool has_name_prefix() const { return name_prefix_[0] != '\0'; } 81 bool has_name_prefix() const { return name_prefix_[0] != '\0'; }
82 const char* name() const { return name_; } 82 const char* name() const { return name_; }
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; }
88 int script_id() const { return script_id_; } 87 int script_id() const { return script_id_; }
89 void set_script_id(int script_id) { script_id_ = script_id; } 88 void set_script_id(int script_id) { script_id_ = script_id; }
89 int position() const { return position_; }
90 void set_position(int position) { position_ = position; }
90 void set_bailout_reason(const char* bailout_reason) { 91 void set_bailout_reason(const char* bailout_reason) {
91 bailout_reason_ = bailout_reason; 92 bailout_reason_ = bailout_reason;
92 } 93 }
93 const char* bailout_reason() const { return bailout_reason_; } 94 const char* bailout_reason() const { return bailout_reason_; }
94 95
95 void set_deopt_info(const char* deopt_reason, int location) { 96 void set_deopt_info(const char* deopt_reason, int location) {
96 DCHECK(!deopt_location_); 97 DCHECK(!deopt_location_);
97 deopt_reason_ = deopt_reason; 98 deopt_reason_ = deopt_reason;
98 deopt_location_ = location; 99 deopt_location_ = location;
99 } 100 }
100 const char* deopt_reason() const { return deopt_reason_; } 101 const char* deopt_reason() const { return deopt_reason_; }
101 int deopt_location() const { return deopt_location_; } 102 int deopt_location() const { return deopt_location_; }
102 bool has_deopt_info() const { return deopt_location_; } 103 bool has_deopt_info() const { return deopt_location_; }
103 void clear_deopt_info() { 104 void clear_deopt_info() {
104 deopt_reason_ = kNoDeoptReason; 105 deopt_reason_ = kNoDeoptReason;
105 deopt_location_ = 0; 106 deopt_location_ = 0;
106 } 107 }
107 108
109 void FillFunctionInfo(SharedFunctionInfo* shared);
110
108 static inline bool is_js_function_tag(Logger::LogEventsAndTags tag); 111 static inline bool is_js_function_tag(Logger::LogEventsAndTags tag);
109 112
110 List<OffsetRange>* no_frame_ranges() const { return no_frame_ranges_; } 113 List<OffsetRange>* no_frame_ranges() const { return no_frame_ranges_; }
111 void set_no_frame_ranges(List<OffsetRange>* ranges) { 114 void set_no_frame_ranges(List<OffsetRange>* ranges) {
112 no_frame_ranges_ = ranges; 115 no_frame_ranges_ = ranges;
113 } 116 }
114 117
115 void SetBuiltinId(Builtins::Name id); 118 void SetBuiltinId(Builtins::Name id);
116 Builtins::Name builtin_id() const { 119 Builtins::Name builtin_id() const {
117 return BuiltinIdField::decode(bit_field_); 120 return BuiltinIdField::decode(bit_field_);
118 } 121 }
119 122
120 uint32_t GetCallUid() const; 123 uint32_t GetHash() const;
121 bool IsSameAs(CodeEntry* entry) const; 124 bool IsSameFunctionAs(CodeEntry* entry) const;
122 125
123 int GetSourceLine(int pc_offset) const; 126 int GetSourceLine(int pc_offset) const;
124 127
125 Address instruction_start() const { return instruction_start_; } 128 Address instruction_start() const { return instruction_start_; }
126 129
127 static const char* const kEmptyNamePrefix; 130 static const char* const kEmptyNamePrefix;
128 static const char* const kEmptyResourceName; 131 static const char* const kEmptyResourceName;
129 static const char* const kEmptyBailoutReason; 132 static const char* const kEmptyBailoutReason;
130 static const char* const kNoDeoptReason; 133 static const char* const kNoDeoptReason;
131 134
132 private: 135 private:
133 class TagField : public BitField<Logger::LogEventsAndTags, 0, 8> {}; 136 class TagField : public BitField<Logger::LogEventsAndTags, 0, 8> {};
134 class BuiltinIdField : public BitField<Builtins::Name, 8, 8> {}; 137 class BuiltinIdField : public BitField<Builtins::Name, 8, 8> {};
135 Logger::LogEventsAndTags tag() const { return TagField::decode(bit_field_); } 138 Logger::LogEventsAndTags tag() const { return TagField::decode(bit_field_); }
136 139
137 uint32_t bit_field_; 140 uint32_t bit_field_;
138 const char* name_prefix_; 141 const char* name_prefix_;
139 const char* name_; 142 const char* name_;
140 const char* resource_name_; 143 const char* resource_name_;
141 int line_number_; 144 int line_number_;
142 int column_number_; 145 int column_number_;
143 int shared_id_;
144 int script_id_; 146 int script_id_;
147 int position_;
145 List<OffsetRange>* no_frame_ranges_; 148 List<OffsetRange>* no_frame_ranges_;
146 const char* bailout_reason_; 149 const char* bailout_reason_;
147 const char* deopt_reason_; 150 const char* deopt_reason_;
148 int deopt_location_; 151 int deopt_location_;
149 JITLineInfoTable* line_info_; 152 JITLineInfoTable* line_info_;
150 Address instruction_start_; 153 Address instruction_start_;
151 154
152 DISALLOW_COPY_AND_ASSIGN(CodeEntry); 155 DISALLOW_COPY_AND_ASSIGN(CodeEntry);
153 }; 156 };
154 157
(...skipping 18 matching lines...) Expand all
173 ProfileNode* FindChild(CodeEntry* entry); 176 ProfileNode* FindChild(CodeEntry* entry);
174 ProfileNode* FindOrAddChild(CodeEntry* entry); 177 ProfileNode* FindOrAddChild(CodeEntry* entry);
175 void IncrementSelfTicks() { ++self_ticks_; } 178 void IncrementSelfTicks() { ++self_ticks_; }
176 void IncreaseSelfTicks(unsigned amount) { self_ticks_ += amount; } 179 void IncreaseSelfTicks(unsigned amount) { self_ticks_ += amount; }
177 void IncrementLineTicks(int src_line); 180 void IncrementLineTicks(int src_line);
178 181
179 CodeEntry* entry() const { return entry_; } 182 CodeEntry* entry() const { return entry_; }
180 unsigned self_ticks() const { return self_ticks_; } 183 unsigned self_ticks() const { return self_ticks_; }
181 const List<ProfileNode*>* children() const { return &children_list_; } 184 const List<ProfileNode*>* children() const { return &children_list_; }
182 unsigned id() const { return id_; } 185 unsigned id() const { return id_; }
186 unsigned function_id() const;
183 unsigned int GetHitLineCount() const { return line_ticks_.occupancy(); } 187 unsigned int GetHitLineCount() const { return line_ticks_.occupancy(); }
184 bool GetLineTicks(v8::CpuProfileNode::LineTick* entries, 188 bool GetLineTicks(v8::CpuProfileNode::LineTick* entries,
185 unsigned int length) const; 189 unsigned int length) const;
186 void CollectDeoptInfo(CodeEntry* entry); 190 void CollectDeoptInfo(CodeEntry* entry);
187 const List<DeoptInfo>& deopt_infos() const { return deopt_infos_; } 191 const List<DeoptInfo>& deopt_infos() const { return deopt_infos_; }
188 192
189 void Print(int indent); 193 void Print(int indent);
190 194
191 private:
192 static bool CodeEntriesMatch(void* entry1, void* entry2) { 195 static bool CodeEntriesMatch(void* entry1, void* entry2) {
193 return reinterpret_cast<CodeEntry*>(entry1)->IsSameAs( 196 return reinterpret_cast<CodeEntry*>(entry1)
194 reinterpret_cast<CodeEntry*>(entry2)); 197 ->IsSameFunctionAs(reinterpret_cast<CodeEntry*>(entry2));
195 } 198 }
196 199
197 static uint32_t CodeEntryHash(CodeEntry* entry) { 200 private:
198 return entry->GetCallUid(); 201 static uint32_t CodeEntryHash(CodeEntry* entry) { return entry->GetHash(); }
199 }
200 202
201 static bool LineTickMatch(void* a, void* b) { return a == b; } 203 static bool LineTickMatch(void* a, void* b) { return a == b; }
202 204
203 ProfileTree* tree_; 205 ProfileTree* tree_;
204 CodeEntry* entry_; 206 CodeEntry* entry_;
205 unsigned self_ticks_; 207 unsigned self_ticks_;
206 // Mapping from CodeEntry* to ProfileNode* 208 // Mapping from CodeEntry* to ProfileNode*
207 HashMap children_; 209 HashMap children_;
208 List<ProfileNode*> children_list_; 210 List<ProfileNode*> children_list_;
209 unsigned id_; 211 unsigned id_;
210 HashMap line_ticks_; 212 HashMap line_ticks_;
211 213
212 List<DeoptInfo> deopt_infos_; 214 List<DeoptInfo> deopt_infos_;
213 DISALLOW_COPY_AND_ASSIGN(ProfileNode); 215 DISALLOW_COPY_AND_ASSIGN(ProfileNode);
214 }; 216 };
215 217
216 218
217 class ProfileTree { 219 class ProfileTree {
218 public: 220 public:
219 ProfileTree(); 221 ProfileTree();
220 ~ProfileTree(); 222 ~ProfileTree();
221 223
222 ProfileNode* AddPathFromEnd( 224 ProfileNode* AddPathFromEnd(
223 const Vector<CodeEntry*>& path, 225 const Vector<CodeEntry*>& path,
224 int src_line = v8::CpuProfileNode::kNoLineNumberInfo); 226 int src_line = v8::CpuProfileNode::kNoLineNumberInfo);
225 ProfileNode* root() const { return root_; } 227 ProfileNode* root() const { return root_; }
226 unsigned next_node_id() { return next_node_id_++; } 228 unsigned next_node_id() { return next_node_id_++; }
229 unsigned GetFunctionId(const ProfileNode* node);
227 230
228 void Print() { 231 void Print() {
229 root_->Print(0); 232 root_->Print(0);
230 } 233 }
231 234
232 private: 235 private:
233 template <typename Callback> 236 template <typename Callback>
234 void TraverseDepthFirst(Callback* callback); 237 void TraverseDepthFirst(Callback* callback);
235 238
236 CodeEntry root_entry_; 239 CodeEntry root_entry_;
237 unsigned next_node_id_; 240 unsigned next_node_id_;
238 ProfileNode* root_; 241 ProfileNode* root_;
239 242
243 unsigned next_function_id_;
244 HashMap function_ids_;
245
240 DISALLOW_COPY_AND_ASSIGN(ProfileTree); 246 DISALLOW_COPY_AND_ASSIGN(ProfileTree);
241 }; 247 };
242 248
243 249
244 class CpuProfile { 250 class CpuProfile {
245 public: 251 public:
246 CpuProfile(const char* title, bool record_samples); 252 CpuProfile(const char* title, bool record_samples);
247 253
248 // Add pc -> ... -> main() call path to the profile. 254 // Add pc -> ... -> main() call path to the profile.
249 void AddPath(base::TimeTicks timestamp, const Vector<CodeEntry*>& path, 255 void AddPath(base::TimeTicks timestamp, const Vector<CodeEntry*>& path,
(...skipping 24 matching lines...) Expand all
274 List<ProfileNode*> samples_; 280 List<ProfileNode*> samples_;
275 List<base::TimeTicks> timestamps_; 281 List<base::TimeTicks> timestamps_;
276 ProfileTree top_down_; 282 ProfileTree top_down_;
277 283
278 DISALLOW_COPY_AND_ASSIGN(CpuProfile); 284 DISALLOW_COPY_AND_ASSIGN(CpuProfile);
279 }; 285 };
280 286
281 287
282 class CodeMap { 288 class CodeMap {
283 public: 289 public:
284 CodeMap() : next_shared_id_(1) { } 290 CodeMap() {}
285 void AddCode(Address addr, CodeEntry* entry, unsigned size); 291 void AddCode(Address addr, CodeEntry* entry, unsigned size);
286 void MoveCode(Address from, Address to); 292 void MoveCode(Address from, Address to);
287 CodeEntry* FindEntry(Address addr, Address* start = NULL); 293 CodeEntry* FindEntry(Address addr, Address* start = NULL);
288 int GetSharedId(Address addr); 294 int GetSharedId(Address addr);
289 295
290 void Print(); 296 void Print();
291 297
292 private: 298 private:
293 struct CodeEntryInfo { 299 struct CodeEntryInfo {
294 CodeEntryInfo(CodeEntry* an_entry, unsigned a_size) 300 CodeEntryInfo(CodeEntry* an_entry, unsigned a_size)
(...skipping 13 matching lines...) Expand all
308 }; 314 };
309 typedef SplayTree<CodeTreeConfig> CodeTree; 315 typedef SplayTree<CodeTreeConfig> CodeTree;
310 316
311 class CodeTreePrinter { 317 class CodeTreePrinter {
312 public: 318 public:
313 void Call(const Address& key, const CodeEntryInfo& value); 319 void Call(const Address& key, const CodeEntryInfo& value);
314 }; 320 };
315 321
316 void DeleteAllCoveredCode(Address start, Address end); 322 void DeleteAllCoveredCode(Address start, Address end);
317 323
318 // Fake CodeEntry pointer to distinguish shared function entries.
319 static CodeEntry* const kSharedFunctionCodeEntry;
320
321 CodeTree tree_; 324 CodeTree tree_;
322 int next_shared_id_;
323 325
324 DISALLOW_COPY_AND_ASSIGN(CodeMap); 326 DISALLOW_COPY_AND_ASSIGN(CodeMap);
325 }; 327 };
326 328
327 329
328 class CpuProfilesCollection { 330 class CpuProfilesCollection {
329 public: 331 public:
330 explicit CpuProfilesCollection(Heap* heap); 332 explicit CpuProfilesCollection(Heap* heap);
331 ~CpuProfilesCollection(); 333 ~CpuProfilesCollection();
332 334
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
401 CodeEntry* gc_entry_; 403 CodeEntry* gc_entry_;
402 CodeEntry* unresolved_entry_; 404 CodeEntry* unresolved_entry_;
403 405
404 DISALLOW_COPY_AND_ASSIGN(ProfileGenerator); 406 DISALLOW_COPY_AND_ASSIGN(ProfileGenerator);
405 }; 407 };
406 408
407 409
408 } } // namespace v8::internal 410 } } // namespace v8::internal
409 411
410 #endif // V8_PROFILE_GENERATOR_H_ 412 #endif // V8_PROFILE_GENERATOR_H_
OLDNEW
« no previous file with comments | « src/ppc/lithium-codegen-ppc.cc ('k') | src/profile-generator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698