| 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" |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 // Forward declarations. | 21 // Forward declarations. |
| 22 class Code; | 22 class Code; |
| 23 class Function; | 23 class Function; |
| 24 class JSONArray; | 24 class JSONArray; |
| 25 class JSONStream; | 25 class JSONStream; |
| 26 class ProfileFunctionTable; | 26 class ProfileFunctionTable; |
| 27 class ProfileCodeTable; | 27 class ProfileCodeTable; |
| 28 class RawCode; | 28 class RawCode; |
| 29 class RawFunction; | 29 class RawFunction; |
| 30 class SampleFilter; | 30 class SampleFilter; |
| 31 class ProcessedSampleBuffer; |
| 31 | 32 |
| 32 // Profile data related to a |Function|. | 33 // Profile data related to a |Function|. |
| 33 class ProfileFunction : public ZoneAllocated { | 34 class ProfileFunction : public ZoneAllocated { |
| 34 public: | 35 public: |
| 35 enum Kind { | 36 enum Kind { |
| 36 kDartFunction, // Dart function. | 37 kDartFunction, // Dart function. |
| 37 kNativeFunction, // Synthetic function for Native (C/C++). | 38 kNativeFunction, // Synthetic function for Native (C/C++). |
| 38 kTagFunction, // Synthetic function for a VM or User tag. | 39 kTagFunction, // Synthetic function for a VM or User tag. |
| 39 kStubFunction, // Synthetic function for stub code. | 40 kStubFunction, // Synthetic function for stub code. |
| 40 kUnknownFunction, // A singleton function for unknown objects. | 41 kUnknownFunction, // A singleton function for unknown objects. |
| (...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 243 intptr_t NumChildren() const { | 244 intptr_t NumChildren() const { |
| 244 return children_.length(); | 245 return children_.length(); |
| 245 } | 246 } |
| 246 | 247 |
| 247 ProfileTrieNode* At(intptr_t i) { | 248 ProfileTrieNode* At(intptr_t i) { |
| 248 return children_.At(i); | 249 return children_.At(i); |
| 249 } | 250 } |
| 250 | 251 |
| 251 intptr_t IndexOf(ProfileTrieNode* node); | 252 intptr_t IndexOf(ProfileTrieNode* node); |
| 252 | 253 |
| 254 intptr_t frame_id() const { return frame_id_; } |
| 255 void set_frame_id(intptr_t id) { |
| 256 ASSERT(frame_id_ == -1); |
| 257 frame_id_ = id; |
| 258 } |
| 259 |
| 253 protected: | 260 protected: |
| 254 void SortChildren(); | 261 void SortChildren(); |
| 255 | 262 |
| 256 static int ProfileTrieNodeCompare(ProfileTrieNode* const* a, | 263 static int ProfileTrieNodeCompare(ProfileTrieNode* const* a, |
| 257 ProfileTrieNode* const* b) { | 264 ProfileTrieNode* const* b) { |
| 258 ASSERT(a != NULL); | 265 ASSERT(a != NULL); |
| 259 ASSERT(b != NULL); | 266 ASSERT(b != NULL); |
| 260 return (*b)->count() - (*a)->count(); | 267 return (*b)->count() - (*a)->count(); |
| 261 } | 268 } |
| 262 | 269 |
| 263 | 270 |
| 264 intptr_t table_index_; | 271 intptr_t table_index_; |
| 265 intptr_t count_; | 272 intptr_t count_; |
| 266 ZoneGrowableArray<ProfileTrieNode*> children_; | 273 ZoneGrowableArray<ProfileTrieNode*> children_; |
| 274 intptr_t frame_id_; |
| 267 | 275 |
| 268 friend class ProfileBuilder; | 276 friend class ProfileBuilder; |
| 269 }; | 277 }; |
| 270 | 278 |
| 271 | 279 |
| 272 // The model for a profile. Most of the model is zone allocated, therefore | 280 // The model for a profile. Most of the model is zone allocated, therefore |
| 273 // a zone must be created that lives longer than this object. | 281 // a zone must be created that lives longer than this object. |
| 274 class Profile : public ValueObject { | 282 class Profile : public ValueObject { |
| 275 public: | 283 public: |
| 276 enum TagOrder { | 284 enum TagOrder { |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 308 int64_t max_time() const { return max_time_; } | 316 int64_t max_time() const { return max_time_; } |
| 309 int64_t GetTimeSpan() const { | 317 int64_t GetTimeSpan() const { |
| 310 return max_time() - min_time(); | 318 return max_time() - min_time(); |
| 311 } | 319 } |
| 312 intptr_t sample_count() const { return sample_count_; } | 320 intptr_t sample_count() const { return sample_count_; } |
| 313 | 321 |
| 314 ProfileFunction* GetFunction(intptr_t index); | 322 ProfileFunction* GetFunction(intptr_t index); |
| 315 ProfileCode* GetCode(intptr_t index); | 323 ProfileCode* GetCode(intptr_t index); |
| 316 ProfileTrieNode* GetTrieRoot(TrieKind trie_kind); | 324 ProfileTrieNode* GetTrieRoot(TrieKind trie_kind); |
| 317 | 325 |
| 318 void PrintJSON(JSONStream* stream); | 326 void PrintProfileJSON(JSONStream* stream); |
| 327 void PrintTimelineJSON(JSONStream* stream); |
| 319 | 328 |
| 320 private: | 329 private: |
| 330 void PrintHeaderJSON(JSONObject* obj); |
| 331 void PrintTimelineFrameJSON(JSONObject* frames, |
| 332 ProfileTrieNode* current, |
| 333 ProfileTrieNode* parent, |
| 334 intptr_t* next_id); |
| 335 |
| 321 Isolate* isolate_; | 336 Isolate* isolate_; |
| 337 Zone* zone_; |
| 338 ProcessedSampleBuffer* samples_; |
| 322 ProfileCodeTable* live_code_; | 339 ProfileCodeTable* live_code_; |
| 323 ProfileCodeTable* dead_code_; | 340 ProfileCodeTable* dead_code_; |
| 324 ProfileCodeTable* tag_code_; | 341 ProfileCodeTable* tag_code_; |
| 325 ProfileFunctionTable* functions_; | 342 ProfileFunctionTable* functions_; |
| 326 intptr_t dead_code_index_offset_; | 343 intptr_t dead_code_index_offset_; |
| 327 intptr_t tag_code_index_offset_; | 344 intptr_t tag_code_index_offset_; |
| 328 | 345 |
| 329 ProfileTrieNode* roots_[kNumTrieKinds]; | 346 ProfileTrieNode* roots_[kNumTrieKinds]; |
| 330 | 347 |
| 331 int64_t min_time_; | 348 int64_t min_time_; |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 378 }; | 395 }; |
| 379 | 396 |
| 380 static void PrintJSON(JSONStream* stream, | 397 static void PrintJSON(JSONStream* stream, |
| 381 Profile::TagOrder tag_order, | 398 Profile::TagOrder tag_order, |
| 382 intptr_t extra_tags); | 399 intptr_t extra_tags); |
| 383 | 400 |
| 384 static void PrintAllocationJSON(JSONStream* stream, | 401 static void PrintAllocationJSON(JSONStream* stream, |
| 385 Profile::TagOrder tag_order, | 402 Profile::TagOrder tag_order, |
| 386 const Class& cls); | 403 const Class& cls); |
| 387 | 404 |
| 405 static void PrintTimelineJSON(JSONStream* stream, |
| 406 Profile::TagOrder tag_order); |
| 407 |
| 388 static void ClearSamples(); | 408 static void ClearSamples(); |
| 389 | 409 |
| 390 private: | 410 private: |
| 391 static void PrintJSONImpl(Thread* thread, | 411 static void PrintJSONImpl(Thread* thread, |
| 392 JSONStream* stream, | 412 JSONStream* stream, |
| 393 Profile::TagOrder tag_order, | 413 Profile::TagOrder tag_order, |
| 394 intptr_t extra_tags, | 414 intptr_t extra_tags, |
| 395 SampleFilter* filter); | 415 SampleFilter* filter, |
| 416 bool as_timline); |
| 396 }; | 417 }; |
| 397 | 418 |
| 398 } // namespace dart | 419 } // namespace dart |
| 399 | 420 |
| 400 #endif // VM_PROFILER_SERVICE_H_ | 421 #endif // VM_PROFILER_SERVICE_H_ |
| OLD | NEW |