OLD | NEW |
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 #ifndef RUNTIME_VM_PROFILER_SERVICE_H_ | 5 #ifndef RUNTIME_VM_PROFILER_SERVICE_H_ |
6 #define RUNTIME_VM_PROFILER_SERVICE_H_ | 6 #define RUNTIME_VM_PROFILER_SERVICE_H_ |
7 | 7 |
8 #include "vm/allocation.h" | 8 #include "vm/allocation.h" |
9 #include "vm/code_observers.h" | 9 #include "vm/code_observers.h" |
10 #include "vm/globals.h" | 10 #include "vm/globals.h" |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 intptr_t inclusive_ticks() const { return inclusive_ticks_; } | 43 intptr_t inclusive_ticks() const { return inclusive_ticks_; } |
44 | 44 |
45 private: | 45 private: |
46 TokenPosition token_pos_; | 46 TokenPosition token_pos_; |
47 intptr_t exclusive_ticks_; | 47 intptr_t exclusive_ticks_; |
48 intptr_t inclusive_ticks_; | 48 intptr_t inclusive_ticks_; |
49 | 49 |
50 DISALLOW_ALLOCATION(); | 50 DISALLOW_ALLOCATION(); |
51 }; | 51 }; |
52 | 52 |
53 | |
54 // Profile data related to a |Function|. | 53 // Profile data related to a |Function|. |
55 class ProfileFunction : public ZoneAllocated { | 54 class ProfileFunction : public ZoneAllocated { |
56 public: | 55 public: |
57 enum Kind { | 56 enum Kind { |
58 kDartFunction, // Dart function. | 57 kDartFunction, // Dart function. |
59 kNativeFunction, // Synthetic function for Native (C/C++). | 58 kNativeFunction, // Synthetic function for Native (C/C++). |
60 kTagFunction, // Synthetic function for a VM or User tag. | 59 kTagFunction, // Synthetic function for a VM or User tag. |
61 kStubFunction, // Synthetic function for stub code. | 60 kStubFunction, // Synthetic function for stub code. |
62 kUnknownFunction, // A singleton function for unknown objects. | 61 kUnknownFunction, // A singleton function for unknown objects. |
63 }; | 62 }; |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 intptr_t inclusive_serial_; | 120 intptr_t inclusive_serial_; |
122 | 121 |
123 void PrintToJSONObject(JSONObject* func); | 122 void PrintToJSONObject(JSONObject* func); |
124 // A |ProfileCode| that contains this function. | 123 // A |ProfileCode| that contains this function. |
125 void AddProfileCode(intptr_t code_table_index); | 124 void AddProfileCode(intptr_t code_table_index); |
126 | 125 |
127 friend class ProfileCode; | 126 friend class ProfileCode; |
128 friend class ProfileBuilder; | 127 friend class ProfileBuilder; |
129 }; | 128 }; |
130 | 129 |
131 | |
132 class ProfileCodeAddress { | 130 class ProfileCodeAddress { |
133 public: | 131 public: |
134 explicit ProfileCodeAddress(uword pc); | 132 explicit ProfileCodeAddress(uword pc); |
135 | 133 |
136 void Tick(bool exclusive); | 134 void Tick(bool exclusive); |
137 | 135 |
138 uword pc() const { return pc_; } | 136 uword pc() const { return pc_; } |
139 intptr_t exclusive_ticks() const { return exclusive_ticks_; } | 137 intptr_t exclusive_ticks() const { return exclusive_ticks_; } |
140 intptr_t inclusive_ticks() const { return inclusive_ticks_; } | 138 intptr_t inclusive_ticks() const { return inclusive_ticks_; } |
141 | 139 |
142 private: | 140 private: |
143 uword pc_; | 141 uword pc_; |
144 intptr_t exclusive_ticks_; | 142 intptr_t exclusive_ticks_; |
145 intptr_t inclusive_ticks_; | 143 intptr_t inclusive_ticks_; |
146 }; | 144 }; |
147 | 145 |
148 | |
149 // Profile data related to a |Code|. | 146 // Profile data related to a |Code|. |
150 class ProfileCode : public ZoneAllocated { | 147 class ProfileCode : public ZoneAllocated { |
151 public: | 148 public: |
152 enum Kind { | 149 enum Kind { |
153 kDartCode, // Live Dart code. | 150 kDartCode, // Live Dart code. |
154 kCollectedCode, // Dead Dart code. | 151 kCollectedCode, // Dead Dart code. |
155 kNativeCode, // Native code. | 152 kNativeCode, // Native code. |
156 kReusedCode, // Dead Dart code that has been reused by new kDartCode. | 153 kReusedCode, // Dead Dart code that has been reused by new kDartCode. |
157 kTagCode, // A special kind of code representing a tag. | 154 kTagCode, // A special kind of code representing a tag. |
158 }; | 155 }; |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
234 const Code& code_; | 231 const Code& code_; |
235 char* name_; | 232 char* name_; |
236 int64_t compile_timestamp_; | 233 int64_t compile_timestamp_; |
237 ProfileFunction* function_; | 234 ProfileFunction* function_; |
238 intptr_t code_table_index_; | 235 intptr_t code_table_index_; |
239 ZoneGrowableArray<ProfileCodeAddress> address_ticks_; | 236 ZoneGrowableArray<ProfileCodeAddress> address_ticks_; |
240 | 237 |
241 friend class ProfileBuilder; | 238 friend class ProfileBuilder; |
242 }; | 239 }; |
243 | 240 |
244 | |
245 class ProfileCodeTable : public ZoneAllocated { | 241 class ProfileCodeTable : public ZoneAllocated { |
246 public: | 242 public: |
247 ProfileCodeTable() : table_(8) {} | 243 ProfileCodeTable() : table_(8) {} |
248 | 244 |
249 intptr_t length() const { return table_.length(); } | 245 intptr_t length() const { return table_.length(); } |
250 | 246 |
251 ProfileCode* At(intptr_t index) const { | 247 ProfileCode* At(intptr_t index) const { |
252 ASSERT(index >= 0); | 248 ASSERT(index >= 0); |
253 ASSERT(index < length()); | 249 ASSERT(index < length()); |
254 return table_[index]; | 250 return table_[index]; |
(...skipping 21 matching lines...) Expand all Loading... |
276 intptr_t* hi, | 272 intptr_t* hi, |
277 ProfileCode** lo_code, | 273 ProfileCode** lo_code, |
278 ProfileCode** hi_code) const; | 274 ProfileCode** hi_code) const; |
279 | 275 |
280 void VerifyOrder(); | 276 void VerifyOrder(); |
281 void VerifyOverlap(); | 277 void VerifyOverlap(); |
282 | 278 |
283 ZoneGrowableArray<ProfileCode*> table_; | 279 ZoneGrowableArray<ProfileCode*> table_; |
284 }; | 280 }; |
285 | 281 |
286 | |
287 // Stack traces are organized in a trie. This holds information about one node | 282 // Stack traces are organized in a trie. This holds information about one node |
288 // in the trie. A node in a tree represents a stack frame and a path in the tree | 283 // in the trie. A node in a tree represents a stack frame and a path in the tree |
289 // represents a stack trace. Each unique stack trace appears in the tree once | 284 // represents a stack trace. Each unique stack trace appears in the tree once |
290 // and each node has a count indicating how many times this has been observed. | 285 // and each node has a count indicating how many times this has been observed. |
291 // The index can be used to look up a |ProfileFunction| or |ProfileCode|. | 286 // The index can be used to look up a |ProfileFunction| or |ProfileCode|. |
292 // A node can have zero or more children. Depending on the kind of trie the | 287 // A node can have zero or more children. Depending on the kind of trie the |
293 // children are callers or callees of the current node. | 288 // children are callers or callees of the current node. |
294 class ProfileTrieNode : public ZoneAllocated { | 289 class ProfileTrieNode : public ZoneAllocated { |
295 public: | 290 public: |
296 explicit ProfileTrieNode(intptr_t index); | 291 explicit ProfileTrieNode(intptr_t index); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
331 protected: | 326 protected: |
332 void SortChildren(); | 327 void SortChildren(); |
333 | 328 |
334 static int ProfileTrieNodeCompare(ProfileTrieNode* const* a, | 329 static int ProfileTrieNodeCompare(ProfileTrieNode* const* a, |
335 ProfileTrieNode* const* b) { | 330 ProfileTrieNode* const* b) { |
336 ASSERT(a != NULL); | 331 ASSERT(a != NULL); |
337 ASSERT(b != NULL); | 332 ASSERT(b != NULL); |
338 return (*b)->count() - (*a)->count(); | 333 return (*b)->count() - (*a)->count(); |
339 } | 334 } |
340 | 335 |
341 | |
342 intptr_t table_index_; | 336 intptr_t table_index_; |
343 intptr_t count_; | 337 intptr_t count_; |
344 intptr_t exclusive_allocations_; | 338 intptr_t exclusive_allocations_; |
345 intptr_t inclusive_allocations_; | 339 intptr_t inclusive_allocations_; |
346 ZoneGrowableArray<ProfileTrieNode*> children_; | 340 ZoneGrowableArray<ProfileTrieNode*> children_; |
347 intptr_t frame_id_; | 341 intptr_t frame_id_; |
348 | 342 |
349 friend class ProfileBuilder; | 343 friend class ProfileBuilder; |
350 }; | 344 }; |
351 | 345 |
352 | |
353 // The model for a profile. Most of the model is zone allocated, therefore | 346 // The model for a profile. Most of the model is zone allocated, therefore |
354 // a zone must be created that lives longer than this object. | 347 // a zone must be created that lives longer than this object. |
355 class Profile : public ValueObject { | 348 class Profile : public ValueObject { |
356 public: | 349 public: |
357 enum TagOrder { kNoTags, kUser, kUserVM, kVM, kVMUser }; | 350 enum TagOrder { kNoTags, kUser, kUserVM, kVM, kVMUser }; |
358 | 351 |
359 enum TrieKind { | 352 enum TrieKind { |
360 kExclusiveCode, | 353 kExclusiveCode, |
361 kExclusiveFunction, | 354 kExclusiveFunction, |
362 kInclusiveCode, | 355 kInclusiveCode, |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
416 ProfileTrieNode* roots_[kNumTrieKinds]; | 409 ProfileTrieNode* roots_[kNumTrieKinds]; |
417 | 410 |
418 int64_t min_time_; | 411 int64_t min_time_; |
419 int64_t max_time_; | 412 int64_t max_time_; |
420 | 413 |
421 intptr_t sample_count_; | 414 intptr_t sample_count_; |
422 | 415 |
423 friend class ProfileBuilder; | 416 friend class ProfileBuilder; |
424 }; | 417 }; |
425 | 418 |
426 | |
427 class ProfileTrieWalker : public ValueObject { | 419 class ProfileTrieWalker : public ValueObject { |
428 public: | 420 public: |
429 explicit ProfileTrieWalker(Profile* profile) | 421 explicit ProfileTrieWalker(Profile* profile) |
430 : profile_(profile), parent_(NULL), current_(NULL), code_trie_(false) { | 422 : profile_(profile), parent_(NULL), current_(NULL), code_trie_(false) { |
431 ASSERT(profile_ != NULL); | 423 ASSERT(profile_ != NULL); |
432 } | 424 } |
433 | 425 |
434 void Reset(Profile::TrieKind trie_kind); | 426 void Reset(Profile::TrieKind trie_kind); |
435 | 427 |
436 const char* CurrentName(); | 428 const char* CurrentName(); |
(...skipping 19 matching lines...) Expand all Loading... |
456 bool Down(); | 448 bool Down(); |
457 bool NextSibling(); | 449 bool NextSibling(); |
458 | 450 |
459 private: | 451 private: |
460 Profile* profile_; | 452 Profile* profile_; |
461 ProfileTrieNode* parent_; | 453 ProfileTrieNode* parent_; |
462 ProfileTrieNode* current_; | 454 ProfileTrieNode* current_; |
463 bool code_trie_; | 455 bool code_trie_; |
464 }; | 456 }; |
465 | 457 |
466 | |
467 class ProfilerService : public AllStatic { | 458 class ProfilerService : public AllStatic { |
468 public: | 459 public: |
469 enum { | 460 enum { |
470 kNoExtraTags = 0, | 461 kNoExtraTags = 0, |
471 kCodeTransitionTagsBit = (1 << 0), | 462 kCodeTransitionTagsBit = (1 << 0), |
472 }; | 463 }; |
473 | 464 |
474 static void PrintJSON(JSONStream* stream, | 465 static void PrintJSON(JSONStream* stream, |
475 Profile::TagOrder tag_order, | 466 Profile::TagOrder tag_order, |
476 intptr_t extra_tags, | 467 intptr_t extra_tags, |
(...skipping 24 matching lines...) Expand all Loading... |
501 Profile::TagOrder tag_order, | 492 Profile::TagOrder tag_order, |
502 intptr_t extra_tags, | 493 intptr_t extra_tags, |
503 SampleFilter* filter, | 494 SampleFilter* filter, |
504 SampleBuffer* sample_buffer, | 495 SampleBuffer* sample_buffer, |
505 bool as_timline); | 496 bool as_timline); |
506 }; | 497 }; |
507 | 498 |
508 } // namespace dart | 499 } // namespace dart |
509 | 500 |
510 #endif // RUNTIME_VM_PROFILER_SERVICE_H_ | 501 #endif // RUNTIME_VM_PROFILER_SERVICE_H_ |
OLD | NEW |