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_TIMELINE_H_ | 5 #ifndef VM_TIMELINE_H_ |
6 #define VM_TIMELINE_H_ | 6 #define VM_TIMELINE_H_ |
7 | 7 |
8 #include "vm/allocation.h" | 8 #include "vm/allocation.h" |
9 #include "vm/bitfield.h" | 9 #include "vm/bitfield.h" |
10 | 10 |
(...skipping 472 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
483 // Recorder of |TimelineEvent|s. | 483 // Recorder of |TimelineEvent|s. |
484 class TimelineEventRecorder { | 484 class TimelineEventRecorder { |
485 public: | 485 public: |
486 TimelineEventRecorder(); | 486 TimelineEventRecorder(); |
487 virtual ~TimelineEventRecorder() {} | 487 virtual ~TimelineEventRecorder() {} |
488 | 488 |
489 TimelineEventBlock* GetNewBlock(); | 489 TimelineEventBlock* GetNewBlock(); |
490 | 490 |
491 // Interface method(s) which must be implemented. | 491 // Interface method(s) which must be implemented. |
492 virtual void PrintJSON(JSONStream* js, TimelineEventFilter* filter) = 0; | 492 virtual void PrintJSON(JSONStream* js, TimelineEventFilter* filter) = 0; |
| 493 virtual void PrintTraceEvent(JSONStream* js, TimelineEventFilter* filter) = 0; |
493 | 494 |
494 int64_t GetNextAsyncId(); | 495 int64_t GetNextAsyncId(); |
495 | 496 |
496 void FinishBlock(TimelineEventBlock* block); | 497 void FinishBlock(TimelineEventBlock* block); |
497 | 498 |
498 protected: | 499 protected: |
499 void WriteTo(const char* directory); | 500 void WriteTo(const char* directory); |
500 | 501 |
501 // Interface method(s) which must be implemented. | 502 // Interface method(s) which must be implemented. |
502 virtual TimelineEvent* StartEvent() = 0; | 503 virtual TimelineEvent* StartEvent() = 0; |
(...skipping 26 matching lines...) Expand all Loading... |
529 | 530 |
530 // A recorder that stores events in a ring buffer of fixed capacity. | 531 // A recorder that stores events in a ring buffer of fixed capacity. |
531 class TimelineEventRingRecorder : public TimelineEventRecorder { | 532 class TimelineEventRingRecorder : public TimelineEventRecorder { |
532 public: | 533 public: |
533 static const intptr_t kDefaultCapacity = 8192; | 534 static const intptr_t kDefaultCapacity = 8192; |
534 | 535 |
535 explicit TimelineEventRingRecorder(intptr_t capacity = kDefaultCapacity); | 536 explicit TimelineEventRingRecorder(intptr_t capacity = kDefaultCapacity); |
536 ~TimelineEventRingRecorder(); | 537 ~TimelineEventRingRecorder(); |
537 | 538 |
538 void PrintJSON(JSONStream* js, TimelineEventFilter* filter); | 539 void PrintJSON(JSONStream* js, TimelineEventFilter* filter); |
| 540 void PrintTraceEvent(JSONStream* js, TimelineEventFilter* filter); |
539 | 541 |
540 protected: | 542 protected: |
541 TimelineEvent* StartEvent(); | 543 TimelineEvent* StartEvent(); |
542 void CompleteEvent(TimelineEvent* event); | 544 void CompleteEvent(TimelineEvent* event); |
543 TimelineEventBlock* GetHeadBlockLocked(); | 545 TimelineEventBlock* GetHeadBlockLocked(); |
544 intptr_t FindOldestBlockIndex() const; | 546 intptr_t FindOldestBlockIndex() const; |
545 TimelineEventBlock* GetNewBlockLocked(Isolate* isolate); | 547 TimelineEventBlock* GetNewBlockLocked(Isolate* isolate); |
546 | 548 |
547 void PrintJSONEvents(JSONArray* array, TimelineEventFilter* filter) const; | 549 void PrintJSONEvents(JSONArray* array, TimelineEventFilter* filter) const; |
548 | 550 |
549 TimelineEventBlock** blocks_; | 551 TimelineEventBlock** blocks_; |
550 intptr_t capacity_; | 552 intptr_t capacity_; |
551 intptr_t num_blocks_; | 553 intptr_t num_blocks_; |
552 intptr_t block_cursor_; | 554 intptr_t block_cursor_; |
553 }; | 555 }; |
554 | 556 |
555 | 557 |
556 // An abstract recorder that calls |StreamEvent| whenever an event is complete. | 558 // An abstract recorder that calls |StreamEvent| whenever an event is complete. |
557 class TimelineEventStreamingRecorder : public TimelineEventRecorder { | 559 class TimelineEventStreamingRecorder : public TimelineEventRecorder { |
558 public: | 560 public: |
559 TimelineEventStreamingRecorder(); | 561 TimelineEventStreamingRecorder(); |
560 ~TimelineEventStreamingRecorder(); | 562 ~TimelineEventStreamingRecorder(); |
561 | 563 |
562 void PrintJSON(JSONStream* js, TimelineEventFilter* filter); | 564 void PrintJSON(JSONStream* js, TimelineEventFilter* filter); |
| 565 void PrintTraceEvent(JSONStream* js, TimelineEventFilter* filter); |
563 | 566 |
564 // Called when |event| is ready to be streamed. It is unsafe to keep a | 567 // Called when |event| is ready to be streamed. It is unsafe to keep a |
565 // reference to |event| as it may be freed as soon as this function returns. | 568 // reference to |event| as it may be freed as soon as this function returns. |
566 virtual void StreamEvent(TimelineEvent* event) = 0; | 569 virtual void StreamEvent(TimelineEvent* event) = 0; |
567 | 570 |
568 protected: | 571 protected: |
569 TimelineEventBlock* GetNewBlockLocked(Isolate* isolate) { | 572 TimelineEventBlock* GetNewBlockLocked(Isolate* isolate) { |
570 return NULL; | 573 return NULL; |
571 } | 574 } |
572 TimelineEventBlock* GetHeadBlockLocked() { | 575 TimelineEventBlock* GetHeadBlockLocked() { |
573 return NULL; | 576 return NULL; |
574 } | 577 } |
575 TimelineEvent* StartEvent(); | 578 TimelineEvent* StartEvent(); |
576 void CompleteEvent(TimelineEvent* event); | 579 void CompleteEvent(TimelineEvent* event); |
577 }; | 580 }; |
578 | 581 |
579 | 582 |
580 // A recorder that stores events in chains of blocks of events. | 583 // A recorder that stores events in chains of blocks of events. |
581 // NOTE: This recorder will continue to allocate blocks until it exhausts | 584 // NOTE: This recorder will continue to allocate blocks until it exhausts |
582 // memory. | 585 // memory. |
583 class TimelineEventEndlessRecorder : public TimelineEventRecorder { | 586 class TimelineEventEndlessRecorder : public TimelineEventRecorder { |
584 public: | 587 public: |
585 TimelineEventEndlessRecorder(); | 588 TimelineEventEndlessRecorder(); |
586 | 589 |
587 // NOTE: Calling this while threads are filling in their blocks is not safe | |
588 // and there are no checks in place to ensure that doesn't happen. | |
589 // TODO(koda): Add isolate count to |ThreadRegistry| and verify that it is 1. | |
590 void PrintJSON(JSONStream* js, TimelineEventFilter* filter); | 590 void PrintJSON(JSONStream* js, TimelineEventFilter* filter); |
| 591 void PrintTraceEvent(JSONStream* js, TimelineEventFilter* filter); |
591 | 592 |
592 protected: | 593 protected: |
593 TimelineEvent* StartEvent(); | 594 TimelineEvent* StartEvent(); |
594 void CompleteEvent(TimelineEvent* event); | 595 void CompleteEvent(TimelineEvent* event); |
595 TimelineEventBlock* GetNewBlockLocked(Isolate* isolate); | 596 TimelineEventBlock* GetNewBlockLocked(Isolate* isolate); |
596 TimelineEventBlock* GetHeadBlockLocked(); | 597 TimelineEventBlock* GetHeadBlockLocked(); |
597 | 598 |
598 void PrintJSONEvents(JSONArray* array, TimelineEventFilter* filter) const; | 599 void PrintJSONEvents(JSONArray* array, TimelineEventFilter* filter) const; |
599 | 600 |
600 // Useful only for testing. Only works for one thread. | 601 // Useful only for testing. Only works for one thread. |
(...skipping 21 matching lines...) Expand all Loading... |
622 TimelineEventBlock* Next(); | 623 TimelineEventBlock* Next(); |
623 | 624 |
624 private: | 625 private: |
625 TimelineEventBlock* current_; | 626 TimelineEventBlock* current_; |
626 TimelineEventRecorder* recorder_; | 627 TimelineEventRecorder* recorder_; |
627 }; | 628 }; |
628 | 629 |
629 } // namespace dart | 630 } // namespace dart |
630 | 631 |
631 #endif // VM_TIMELINE_H_ | 632 #endif // VM_TIMELINE_H_ |
OLD | NEW |