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 RUNTIME_VM_TIMELINE_H_ | 5 #ifndef RUNTIME_VM_TIMELINE_H_ |
| 6 #define RUNTIME_VM_TIMELINE_H_ | 6 #define RUNTIME_VM_TIMELINE_H_ |
| 7 | 7 |
| 8 #include "include/dart_tools_api.h" | 8 #include "include/dart_tools_api.h" |
| 9 | 9 |
| 10 #include "vm/allocation.h" | 10 #include "vm/allocation.h" |
| (...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 311 | 311 |
| 312 const char* GetSerializedJSON() const; | 312 const char* GetSerializedJSON() const; |
| 313 | 313 |
| 314 void set_owns_label(bool owns_label) { | 314 void set_owns_label(bool owns_label) { |
| 315 state_ = OwnsLabelBit::update(owns_label, state_); | 315 state_ = OwnsLabelBit::update(owns_label, state_); |
| 316 } | 316 } |
| 317 | 317 |
| 318 // Returns the number of bytes written into |buffer|. | 318 // Returns the number of bytes written into |buffer|. |
| 319 intptr_t PrintSystrace(char* buffer, intptr_t buffer_size); | 319 intptr_t PrintSystrace(char* buffer, intptr_t buffer_size); |
| 320 | 320 |
| 321 #if defined(HOST_OS_FUCHSIA) | |
| 322 void EmitFuchsiaEvent(); | |
| 323 #endif | |
| 324 | |
| 321 private: | 325 private: |
| 322 void FreeArguments(); | 326 void FreeArguments(); |
| 323 | 327 |
| 324 void StreamInit(TimelineStream* stream); | 328 void StreamInit(TimelineStream* stream); |
| 325 void Init(EventType event_type, const char* label); | 329 void Init(EventType event_type, const char* label); |
| 326 | 330 |
| 327 void set_event_type(EventType event_type) { | 331 void set_event_type(EventType event_type) { |
| 328 // We only reserve 4 bits to hold the event type. | 332 // We only reserve 4 bits to hold the event type. |
| 329 COMPILE_ASSERT(kNumEventTypes < 16); | 333 COMPILE_ASSERT(kNumEventTypes < 16); |
| 330 state_ = EventTypeField::update(event_type, state_); | 334 state_ = EventTypeField::update(event_type, state_); |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 379 const char* label_; | 383 const char* label_; |
| 380 const char* category_; | 384 const char* category_; |
| 381 ThreadId thread_; | 385 ThreadId thread_; |
| 382 Dart_Port isolate_id_; | 386 Dart_Port isolate_id_; |
| 383 | 387 |
| 384 friend class TimelineEventRecorder; | 388 friend class TimelineEventRecorder; |
| 385 friend class TimelineEventEndlessRecorder; | 389 friend class TimelineEventEndlessRecorder; |
| 386 friend class TimelineEventRingRecorder; | 390 friend class TimelineEventRingRecorder; |
| 387 friend class TimelineEventStartupRecorder; | 391 friend class TimelineEventStartupRecorder; |
| 388 friend class TimelineEventSystraceRecorder; | 392 friend class TimelineEventSystraceRecorder; |
| 393 friend class TimelineEventFuchsiaRecorder; | |
| 389 friend class TimelineStream; | 394 friend class TimelineStream; |
| 390 friend class TimelineTestHelper; | 395 friend class TimelineTestHelper; |
| 391 DISALLOW_COPY_AND_ASSIGN(TimelineEvent); | 396 DISALLOW_COPY_AND_ASSIGN(TimelineEvent); |
| 392 }; | 397 }; |
| 393 | 398 |
| 394 | 399 |
| 395 #ifndef PRODUCT | 400 #ifndef PRODUCT |
| 396 #define TIMELINE_FUNCTION_COMPILATION_DURATION(thread, name, function) \ | 401 #define TIMELINE_FUNCTION_COMPILATION_DURATION(thread, name, function) \ |
| 397 TimelineDurationScope tds(thread, Timeline::GetCompilerStream(), name); \ | 402 TimelineDurationScope tds(thread, Timeline::GetCompilerStream(), name); \ |
| 398 if (tds.enabled()) { \ | 403 if (tds.enabled()) { \ |
| (...skipping 27 matching lines...) Expand all Loading... | |
| 426 TimelineEventScope(TimelineStream* stream, const char* label); | 431 TimelineEventScope(TimelineStream* stream, const char* label); |
| 427 | 432 |
| 428 TimelineEventScope(Thread* thread, TimelineStream* stream, const char* label); | 433 TimelineEventScope(Thread* thread, TimelineStream* stream, const char* label); |
| 429 | 434 |
| 430 bool ShouldEmitEvent() const { return enabled_; } | 435 bool ShouldEmitEvent() const { return enabled_; } |
| 431 | 436 |
| 432 void set_enabled(bool enabled) { enabled_ = enabled; } | 437 void set_enabled(bool enabled) { enabled_ = enabled; } |
| 433 | 438 |
| 434 const char* label() const { return label_; } | 439 const char* label() const { return label_; } |
| 435 | 440 |
| 441 TimelineEventArgument* arguments() const { return arguments_; } | |
| 442 | |
| 443 intptr_t arguments_length() const { return arguments_length_; } | |
| 444 | |
| 436 TimelineStream* stream() const { return stream_; } | 445 TimelineStream* stream() const { return stream_; } |
| 437 | 446 |
| 438 virtual ~TimelineEventScope(); | 447 virtual ~TimelineEventScope(); |
| 439 | 448 |
| 440 void StealArguments(TimelineEvent* event); | 449 void StealArguments(TimelineEvent* event); |
| 441 | 450 |
| 442 private: | 451 private: |
| 443 void Init(); | 452 void Init(); |
| 444 void FreeArguments(); | 453 void FreeArguments(); |
| 445 | 454 |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 553 | 562 |
| 554 void Open(); | 563 void Open(); |
| 555 void Finish(); | 564 void Finish(); |
| 556 | 565 |
| 557 friend class Thread; | 566 friend class Thread; |
| 558 friend class TimelineEventRecorder; | 567 friend class TimelineEventRecorder; |
| 559 friend class TimelineEventEndlessRecorder; | 568 friend class TimelineEventEndlessRecorder; |
| 560 friend class TimelineEventRingRecorder; | 569 friend class TimelineEventRingRecorder; |
| 561 friend class TimelineEventStartupRecorder; | 570 friend class TimelineEventStartupRecorder; |
| 562 friend class TimelineEventSystraceRecorder; | 571 friend class TimelineEventSystraceRecorder; |
| 572 friend class TimelineEventFuchsiaRecorder; | |
| 563 friend class TimelineTestHelper; | 573 friend class TimelineTestHelper; |
| 564 friend class JSONStream; | 574 friend class JSONStream; |
| 565 | 575 |
| 566 private: | 576 private: |
| 567 DISALLOW_COPY_AND_ASSIGN(TimelineEventBlock); | 577 DISALLOW_COPY_AND_ASSIGN(TimelineEventBlock); |
| 568 }; | 578 }; |
| 569 | 579 |
| 570 | 580 |
| 571 class TimelineEventFilter : public ValueObject { | 581 class TimelineEventFilter : public ValueObject { |
| 572 public: | 582 public: |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 728 const char* name() const { return "Systrace"; } | 738 const char* name() const { return "Systrace"; } |
| 729 | 739 |
| 730 protected: | 740 protected: |
| 731 TimelineEventBlock* GetNewBlockLocked(); | 741 TimelineEventBlock* GetNewBlockLocked(); |
| 732 void CompleteEvent(TimelineEvent* event); | 742 void CompleteEvent(TimelineEvent* event); |
| 733 | 743 |
| 734 int systrace_fd_; | 744 int systrace_fd_; |
| 735 }; | 745 }; |
| 736 | 746 |
| 737 | 747 |
| 748 #if defined(HOST_OS_FUCHSIA) | |
| 749 // A recorder that sends events to Fuchsia's tracing app. Events are also stored | |
| 750 // in a buffer of fixed capacity. When the buffer is full, new events overwrite | |
| 751 // old events. | |
| 752 class TimelineEventFuchsiaRecorder : public TimelineEventFixedBufferRecorder { | |
|
rmacnak
2017/07/11 20:04:47
Reference https://fuchsia.googlesource.com/tracing
zra
2017/07/11 20:39:59
Done.
| |
| 753 public: | |
| 754 explicit TimelineEventFuchsiaRecorder(intptr_t capacity = kDefaultCapacity); | |
| 755 virtual ~TimelineEventFuchsiaRecorder() {} | |
| 756 | |
| 757 const char* name() const { return "Fuchsia"; } | |
| 758 | |
| 759 protected: | |
| 760 TimelineEventBlock* GetNewBlockLocked(); | |
| 761 void CompleteEvent(TimelineEvent* event); | |
| 762 }; | |
| 763 #endif // defined(HOST_OS_FUCHSIA) | |
| 764 | |
| 765 | |
| 738 // A recorder that stores events in a buffer of fixed capacity. When the buffer | 766 // A recorder that stores events in a buffer of fixed capacity. When the buffer |
| 739 // is full, new events are dropped. | 767 // is full, new events are dropped. |
| 740 class TimelineEventStartupRecorder : public TimelineEventFixedBufferRecorder { | 768 class TimelineEventStartupRecorder : public TimelineEventFixedBufferRecorder { |
| 741 public: | 769 public: |
| 742 explicit TimelineEventStartupRecorder(intptr_t capacity = kDefaultCapacity) | 770 explicit TimelineEventStartupRecorder(intptr_t capacity = kDefaultCapacity) |
| 743 : TimelineEventFixedBufferRecorder(capacity) {} | 771 : TimelineEventFixedBufferRecorder(capacity) {} |
| 744 virtual ~TimelineEventStartupRecorder() {} | 772 virtual ~TimelineEventStartupRecorder() {} |
| 745 | 773 |
| 746 const char* name() const { return "Startup"; } | 774 const char* name() const { return "Startup"; } |
| 747 | 775 |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 820 | 848 |
| 821 private: | 849 private: |
| 822 TimelineEventBlock* current_; | 850 TimelineEventBlock* current_; |
| 823 TimelineEventRecorder* recorder_; | 851 TimelineEventRecorder* recorder_; |
| 824 }; | 852 }; |
| 825 | 853 |
| 826 | 854 |
| 827 } // namespace dart | 855 } // namespace dart |
| 828 | 856 |
| 829 #endif // RUNTIME_VM_TIMELINE_H_ | 857 #endif // RUNTIME_VM_TIMELINE_H_ |
| OLD | NEW |