Chromium Code Reviews| 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 VM_PROFILER_SERVICE_H_ | 5 #ifndef VM_PROFILER_SERVICE_H_ |
| 6 #define VM_PROFILER_SERVICE_H_ | 6 #define 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" |
| 11 #include "vm/growable_array.h" | 11 #include "vm/growable_array.h" |
| 12 #include "vm/object.h" | 12 #include "vm/object.h" |
| 13 #include "vm/tags.h" | 13 #include "vm/tags.h" |
| 14 #include "vm/thread_interrupter.h" | 14 #include "vm/thread_interrupter.h" |
| 15 #include "vm/token_position.h" | |
| 15 | 16 |
| 16 // CPU Profile model and service protocol bits. | 17 // CPU Profile model and service protocol bits. |
| 17 // NOTE: For sampling and stack walking related code, see profiler.h. | 18 // NOTE: For sampling and stack walking related code, see profiler.h. |
| 18 | 19 |
| 19 namespace dart { | 20 namespace dart { |
| 20 | 21 |
| 21 // Forward declarations. | 22 // Forward declarations. |
| 22 class Code; | 23 class Code; |
| 23 class Function; | 24 class Function; |
| 24 class JSONArray; | 25 class JSONArray; |
| 25 class JSONStream; | 26 class JSONStream; |
| 26 class ProfileFunctionTable; | 27 class ProfileFunctionTable; |
| 27 class ProfileCodeTable; | 28 class ProfileCodeTable; |
| 28 class RawCode; | 29 class RawCode; |
| 29 class RawFunction; | 30 class RawFunction; |
| 30 class SampleFilter; | 31 class SampleFilter; |
| 31 class ProcessedSampleBuffer; | 32 class ProcessedSampleBuffer; |
| 32 | 33 |
| 34 class ProfileFunctionSourcePosition { | |
| 35 public: | |
| 36 explicit ProfileFunctionSourcePosition(TokenPosition token_pos); | |
| 37 | |
| 38 void Tick(bool exclusive); | |
| 39 | |
| 40 TokenPosition token_pos() const { return token_pos_; } | |
| 41 intptr_t exclusive_ticks() const { return exclusive_ticks_; } | |
| 42 intptr_t inclusive_ticks() const { return inclusive_ticks_; } | |
| 43 | |
| 44 private: | |
| 45 TokenPosition token_pos_; | |
|
srdjan
2016/03/02 19:02:56
const
Cutch
2016/03/02 19:14:08
Done.
| |
| 46 intptr_t exclusive_ticks_; | |
| 47 intptr_t inclusive_ticks_; | |
|
srdjan
2016/03/02 19:02:55
DISALLOW_ALLOCATION
Cutch
2016/03/02 19:14:07
Done.
| |
| 48 }; | |
| 49 | |
| 50 | |
| 33 // Profile data related to a |Function|. | 51 // Profile data related to a |Function|. |
| 34 class ProfileFunction : public ZoneAllocated { | 52 class ProfileFunction : public ZoneAllocated { |
| 35 public: | 53 public: |
| 36 enum Kind { | 54 enum Kind { |
| 37 kDartFunction, // Dart function. | 55 kDartFunction, // Dart function. |
| 38 kNativeFunction, // Synthetic function for Native (C/C++). | 56 kNativeFunction, // Synthetic function for Native (C/C++). |
| 39 kTagFunction, // Synthetic function for a VM or User tag. | 57 kTagFunction, // Synthetic function for a VM or User tag. |
| 40 kStubFunction, // Synthetic function for stub code. | 58 kStubFunction, // Synthetic function for stub code. |
| 41 kUnknownFunction, // A singleton function for unknown objects. | 59 kUnknownFunction, // A singleton function for unknown objects. |
| 42 }; | 60 }; |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 65 return kind_; | 83 return kind_; |
| 66 } | 84 } |
| 67 | 85 |
| 68 intptr_t exclusive_ticks() const { return exclusive_ticks_; } | 86 intptr_t exclusive_ticks() const { return exclusive_ticks_; } |
| 69 intptr_t inclusive_ticks() const { return inclusive_ticks_; } | 87 intptr_t inclusive_ticks() const { return inclusive_ticks_; } |
| 70 | 88 |
| 71 void IncInclusiveTicks() { | 89 void IncInclusiveTicks() { |
| 72 inclusive_ticks_++; | 90 inclusive_ticks_++; |
| 73 } | 91 } |
| 74 | 92 |
| 75 void Tick(bool exclusive, intptr_t inclusive_serial); | 93 void Tick(bool exclusive, |
| 94 intptr_t inclusive_serial, | |
| 95 TokenPosition token_position); | |
| 76 | 96 |
| 77 static const char* KindToCString(Kind kind); | 97 static const char* KindToCString(Kind kind); |
| 78 | 98 |
| 79 void PrintToJSONArray(JSONArray* functions); | 99 void PrintToJSONArray(JSONArray* functions); |
| 80 | 100 |
| 101 bool GetSinglePosition(ProfileFunctionSourcePosition* pfsp); | |
|
srdjan
2016/03/02 19:02:56
Add comment about when is true/false returned.
Cutch
2016/03/02 19:14:07
Done.
| |
| 102 | |
| 103 void TickSourcePosition(TokenPosition token_position, bool exclusive); | |
| 104 | |
| 81 private: | 105 private: |
| 82 const Kind kind_; | 106 const Kind kind_; |
| 83 const char* name_; | 107 const char* name_; |
| 84 const Function& function_; | 108 const Function& function_; |
| 85 const intptr_t table_index_; | 109 const intptr_t table_index_; |
| 86 ZoneGrowableArray<intptr_t> profile_codes_; | 110 ZoneGrowableArray<intptr_t> profile_codes_; |
| 111 ZoneGrowableArray<ProfileFunctionSourcePosition> source_position_ticks_; | |
| 87 | 112 |
| 88 intptr_t exclusive_ticks_; | 113 intptr_t exclusive_ticks_; |
| 89 intptr_t inclusive_ticks_; | 114 intptr_t inclusive_ticks_; |
| 90 intptr_t inclusive_serial_; | 115 intptr_t inclusive_serial_; |
| 91 | 116 |
| 92 void PrintToJSONObject(JSONObject* func); | 117 void PrintToJSONObject(JSONObject* func); |
| 93 // A |ProfileCode| that contains this function. | 118 // A |ProfileCode| that contains this function. |
| 94 void AddProfileCode(intptr_t code_table_index); | 119 void AddProfileCode(intptr_t code_table_index); |
| 95 | 120 |
| 96 friend class ProfileCode; | 121 friend class ProfileCode; |
| (...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 369 const char* CurrentName(); | 394 const char* CurrentName(); |
| 370 // Return the current node's peer's inclusive tick count. | 395 // Return the current node's peer's inclusive tick count. |
| 371 intptr_t CurrentInclusiveTicks(); | 396 intptr_t CurrentInclusiveTicks(); |
| 372 // Return the current node's peer's exclusive tick count. | 397 // Return the current node's peer's exclusive tick count. |
| 373 intptr_t CurrentExclusiveTicks(); | 398 intptr_t CurrentExclusiveTicks(); |
| 374 // Return the current node's tick count. | 399 // Return the current node's tick count. |
| 375 intptr_t CurrentNodeTickCount(); | 400 intptr_t CurrentNodeTickCount(); |
| 376 // Return the number siblings (including yourself). | 401 // Return the number siblings (including yourself). |
| 377 intptr_t SiblingCount(); | 402 intptr_t SiblingCount(); |
| 378 | 403 |
| 404 // If the following conditions are met returns the current token: | |
| 405 // 1) This is a function trie. | |
| 406 // 2) There is only one token position for a given function. | |
| 407 // Will return NULL otherwise. | |
| 408 const char* CurrentToken(); | |
| 409 | |
| 379 bool Down(); | 410 bool Down(); |
| 380 bool NextSibling(); | 411 bool NextSibling(); |
| 381 | 412 |
| 382 private: | 413 private: |
| 383 Profile* profile_; | 414 Profile* profile_; |
| 384 ProfileTrieNode* parent_; | 415 ProfileTrieNode* parent_; |
| 385 ProfileTrieNode* current_; | 416 ProfileTrieNode* current_; |
| 386 bool code_trie_; | 417 bool code_trie_; |
| 387 }; | 418 }; |
| 388 | 419 |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 418 JSONStream* stream, | 449 JSONStream* stream, |
| 419 Profile::TagOrder tag_order, | 450 Profile::TagOrder tag_order, |
| 420 intptr_t extra_tags, | 451 intptr_t extra_tags, |
| 421 SampleFilter* filter, | 452 SampleFilter* filter, |
| 422 bool as_timline); | 453 bool as_timline); |
| 423 }; | 454 }; |
| 424 | 455 |
| 425 } // namespace dart | 456 } // namespace dart |
| 426 | 457 |
| 427 #endif // VM_PROFILER_SERVICE_H_ | 458 #endif // VM_PROFILER_SERVICE_H_ |
| OLD | NEW |