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 11 matching lines...) Expand all Loading... |
22 // Forward declarations. | 22 // Forward declarations. |
23 class Code; | 23 class Code; |
24 class Function; | 24 class Function; |
25 class JSONArray; | 25 class JSONArray; |
26 class JSONStream; | 26 class JSONStream; |
27 class ProfileFunctionTable; | 27 class ProfileFunctionTable; |
28 class ProfileCodeTable; | 28 class ProfileCodeTable; |
29 class RawCode; | 29 class RawCode; |
30 class RawFunction; | 30 class RawFunction; |
31 class SampleFilter; | 31 class SampleFilter; |
32 class ProcessedSample; | |
33 class ProcessedSampleBuffer; | 32 class ProcessedSampleBuffer; |
34 | 33 |
35 class ProfileFunctionSourcePosition { | 34 class ProfileFunctionSourcePosition { |
36 public: | 35 public: |
37 explicit ProfileFunctionSourcePosition(TokenPosition token_pos); | 36 explicit ProfileFunctionSourcePosition(TokenPosition token_pos); |
38 | 37 |
39 void Tick(bool exclusive); | 38 void Tick(bool exclusive); |
40 | 39 |
41 TokenPosition token_pos() const { return token_pos_; } | 40 TokenPosition token_pos() const { return token_pos_; } |
42 intptr_t exclusive_ticks() const { return exclusive_ticks_; } | 41 intptr_t exclusive_ticks() const { return exclusive_ticks_; } |
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
251 explicit ProfileTrieNode(intptr_t index); | 250 explicit ProfileTrieNode(intptr_t index); |
252 virtual ~ProfileTrieNode(); | 251 virtual ~ProfileTrieNode(); |
253 | 252 |
254 virtual void PrintToJSONArray(JSONArray* array) const = 0; | 253 virtual void PrintToJSONArray(JSONArray* array) const = 0; |
255 | 254 |
256 // Index into function or code tables. | 255 // Index into function or code tables. |
257 intptr_t table_index() const { return table_index_; } | 256 intptr_t table_index() const { return table_index_; } |
258 | 257 |
259 intptr_t count() const { return count_; } | 258 intptr_t count() const { return count_; } |
260 | 259 |
261 void Tick(ProcessedSample* sample, bool exclusive = false); | 260 void Tick() { count_++; } |
262 | |
263 void IncrementAllocation(intptr_t allocation, bool exclusive) { | |
264 ASSERT(allocation >= 0); | |
265 if (exclusive) { | |
266 exclusive_allocations_ += allocation; | |
267 } | |
268 inclusive_allocations_ += allocation; | |
269 } | |
270 | |
271 intptr_t inclusive_allocations() const { return inclusive_allocations_; } | |
272 intptr_t exclusive_allocations() const { return exclusive_allocations_; } | |
273 | 261 |
274 intptr_t NumChildren() const { return children_.length(); } | 262 intptr_t NumChildren() const { return children_.length(); } |
275 | 263 |
276 ProfileTrieNode* At(intptr_t i) { return children_.At(i); } | 264 ProfileTrieNode* At(intptr_t i) { return children_.At(i); } |
277 | 265 |
278 intptr_t IndexOf(ProfileTrieNode* node); | 266 intptr_t IndexOf(ProfileTrieNode* node); |
279 | 267 |
280 intptr_t frame_id() const { return frame_id_; } | 268 intptr_t frame_id() const { return frame_id_; } |
281 void set_frame_id(intptr_t id) { | 269 void set_frame_id(intptr_t id) { |
282 ASSERT(frame_id_ == -1); | 270 ASSERT(frame_id_ == -1); |
283 frame_id_ = id; | 271 frame_id_ = id; |
284 } | 272 } |
285 | 273 |
286 protected: | 274 protected: |
287 void SortChildren(); | 275 void SortChildren(); |
288 | 276 |
289 static int ProfileTrieNodeCompare(ProfileTrieNode* const* a, | 277 static int ProfileTrieNodeCompare(ProfileTrieNode* const* a, |
290 ProfileTrieNode* const* b) { | 278 ProfileTrieNode* const* b) { |
291 ASSERT(a != NULL); | 279 ASSERT(a != NULL); |
292 ASSERT(b != NULL); | 280 ASSERT(b != NULL); |
293 return (*b)->count() - (*a)->count(); | 281 return (*b)->count() - (*a)->count(); |
294 } | 282 } |
295 | 283 |
296 | 284 |
297 intptr_t table_index_; | 285 intptr_t table_index_; |
298 intptr_t count_; | 286 intptr_t count_; |
299 intptr_t exclusive_allocations_; | |
300 intptr_t inclusive_allocations_; | |
301 ZoneGrowableArray<ProfileTrieNode*> children_; | 287 ZoneGrowableArray<ProfileTrieNode*> children_; |
302 intptr_t frame_id_; | 288 intptr_t frame_id_; |
303 | 289 |
304 friend class ProfileBuilder; | 290 friend class ProfileBuilder; |
305 }; | 291 }; |
306 | 292 |
307 | 293 |
308 // The model for a profile. Most of the model is zone allocated, therefore | 294 // The model for a profile. Most of the model is zone allocated, therefore |
309 // a zone must be created that lives longer than this object. | 295 // a zone must be created that lives longer than this object. |
310 class Profile : public ValueObject { | 296 class Profile : public ValueObject { |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
385 ASSERT(profile_ != NULL); | 371 ASSERT(profile_ != NULL); |
386 } | 372 } |
387 | 373 |
388 void Reset(Profile::TrieKind trie_kind); | 374 void Reset(Profile::TrieKind trie_kind); |
389 | 375 |
390 const char* CurrentName(); | 376 const char* CurrentName(); |
391 // Return the current node's peer's inclusive tick count. | 377 // Return the current node's peer's inclusive tick count. |
392 intptr_t CurrentInclusiveTicks(); | 378 intptr_t CurrentInclusiveTicks(); |
393 // Return the current node's peer's exclusive tick count. | 379 // Return the current node's peer's exclusive tick count. |
394 intptr_t CurrentExclusiveTicks(); | 380 intptr_t CurrentExclusiveTicks(); |
395 // Return the current node's inclusive allocation count. | |
396 intptr_t CurrentInclusiveAllocations(); | |
397 // Return the current node's exclusive allocation count. | |
398 intptr_t CurrentExclusiveAllocations(); | |
399 // Return the current node's tick count. | 381 // Return the current node's tick count. |
400 intptr_t CurrentNodeTickCount(); | 382 intptr_t CurrentNodeTickCount(); |
401 // Return the number siblings (including yourself). | 383 // Return the number siblings (including yourself). |
402 intptr_t SiblingCount(); | 384 intptr_t SiblingCount(); |
403 | 385 |
404 // If the following conditions are met returns the current token: | 386 // If the following conditions are met returns the current token: |
405 // 1) This is a function trie. | 387 // 1) This is a function trie. |
406 // 2) There is only one token position for a given function. | 388 // 2) There is only one token position for a given function. |
407 // Will return NULL otherwise. | 389 // Will return NULL otherwise. |
408 const char* CurrentToken(); | 390 const char* CurrentToken(); |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
454 JSONStream* stream, | 436 JSONStream* stream, |
455 Profile::TagOrder tag_order, | 437 Profile::TagOrder tag_order, |
456 intptr_t extra_tags, | 438 intptr_t extra_tags, |
457 SampleFilter* filter, | 439 SampleFilter* filter, |
458 bool as_timline); | 440 bool as_timline); |
459 }; | 441 }; |
460 | 442 |
461 } // namespace dart | 443 } // namespace dart |
462 | 444 |
463 #endif // RUNTIME_VM_PROFILER_SERVICE_H_ | 445 #endif // RUNTIME_VM_PROFILER_SERVICE_H_ |
OLD | NEW |