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 #include <cstdlib> | 5 #include <cstdlib> |
6 | 6 |
7 #include "vm/atomic.h" | 7 #include "vm/atomic.h" |
8 #include "vm/isolate.h" | 8 #include "vm/isolate.h" |
9 #include "vm/json_stream.h" | 9 #include "vm/json_stream.h" |
10 #include "vm/lockers.h" | 10 #include "vm/lockers.h" |
11 #include "vm/log.h" | 11 #include "vm/log.h" |
12 #include "vm/object.h" | 12 #include "vm/object.h" |
13 #include "vm/thread.h" | 13 #include "vm/thread.h" |
14 #include "vm/timeline.h" | 14 #include "vm/timeline.h" |
15 | 15 |
16 namespace dart { | 16 namespace dart { |
17 | 17 |
| 18 #ifndef PRODUCT |
| 19 |
18 DEFINE_FLAG(bool, complete_timeline, false, "Record the complete timeline"); | 20 DEFINE_FLAG(bool, complete_timeline, false, "Record the complete timeline"); |
19 DEFINE_FLAG(bool, trace_timeline, false, | 21 DEFINE_FLAG(bool, trace_timeline, false, |
20 "Trace timeline backend"); | 22 "Trace timeline backend"); |
21 DEFINE_FLAG(bool, trace_timeline_analysis, false, | 23 DEFINE_FLAG(bool, trace_timeline_analysis, false, |
22 "Trace timeline analysis backend"); | 24 "Trace timeline analysis backend"); |
23 DEFINE_FLAG(bool, timing, false, | 25 DEFINE_FLAG(bool, timing, false, |
24 "Dump isolate timing information from timeline."); | 26 "Dump isolate timing information from timeline."); |
25 DEFINE_FLAG(charp, timeline_dir, NULL, | 27 DEFINE_FLAG(charp, timeline_dir, NULL, |
26 "Enable all timeline trace streams and output VM global trace " | 28 "Enable all timeline trace streams and output VM global trace " |
27 "into specified directory."); | 29 "into specified directory."); |
(...skipping 633 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
661 } | 663 } |
662 event->StealArguments(arguments_length_, arguments_); | 664 event->StealArguments(arguments_length_, arguments_); |
663 arguments_length_ = 0; | 665 arguments_length_ = 0; |
664 arguments_ = NULL; | 666 arguments_ = NULL; |
665 } | 667 } |
666 | 668 |
667 | 669 |
668 TimelineDurationScope::TimelineDurationScope(TimelineStream* stream, | 670 TimelineDurationScope::TimelineDurationScope(TimelineStream* stream, |
669 const char* label) | 671 const char* label) |
670 : TimelineEventScope(stream, label) { | 672 : TimelineEventScope(stream, label) { |
| 673 if (!FLAG_support_timeline) { |
| 674 return; |
| 675 } |
671 timestamp_ = OS::GetCurrentMonotonicMicros(); | 676 timestamp_ = OS::GetCurrentMonotonicMicros(); |
672 } | 677 } |
673 | 678 |
674 | 679 |
675 TimelineDurationScope::TimelineDurationScope(Thread* thread, | 680 TimelineDurationScope::TimelineDurationScope(Thread* thread, |
676 TimelineStream* stream, | 681 TimelineStream* stream, |
677 const char* label) | 682 const char* label) |
678 : TimelineEventScope(thread, stream, label) { | 683 : TimelineEventScope(thread, stream, label) { |
| 684 if (!FLAG_support_timeline) { |
| 685 return; |
| 686 } |
679 timestamp_ = OS::GetCurrentMonotonicMicros(); | 687 timestamp_ = OS::GetCurrentMonotonicMicros(); |
680 } | 688 } |
681 | 689 |
682 | 690 |
683 TimelineDurationScope::~TimelineDurationScope() { | 691 TimelineDurationScope::~TimelineDurationScope() { |
| 692 if (!FLAG_support_timeline) { |
| 693 return; |
| 694 } |
684 if (!ShouldEmitEvent()) { | 695 if (!ShouldEmitEvent()) { |
685 return; | 696 return; |
686 } | 697 } |
687 TimelineEvent* event = stream()->StartEvent(); | 698 TimelineEvent* event = stream()->StartEvent(); |
688 if (event == NULL) { | 699 if (event == NULL) { |
689 // Stream is now disabled. | 700 // Stream is now disabled. |
690 return; | 701 return; |
691 } | 702 } |
692 ASSERT(event != NULL); | 703 ASSERT(event != NULL); |
693 // Emit a duration event. | 704 // Emit a duration event. |
694 event->Duration(label(), timestamp_, OS::GetCurrentMonotonicMicros()); | 705 event->Duration(label(), timestamp_, OS::GetCurrentMonotonicMicros()); |
695 StealArguments(event); | 706 StealArguments(event); |
696 event->Complete(); | 707 event->Complete(); |
697 } | 708 } |
698 | 709 |
699 | 710 |
700 TimelineBeginEndScope::TimelineBeginEndScope(TimelineStream* stream, | 711 TimelineBeginEndScope::TimelineBeginEndScope(TimelineStream* stream, |
701 const char* label) | 712 const char* label) |
702 : TimelineEventScope(stream, label) { | 713 : TimelineEventScope(stream, label) { |
| 714 if (!FLAG_support_timeline) { |
| 715 return; |
| 716 } |
703 EmitBegin(); | 717 EmitBegin(); |
704 } | 718 } |
705 | 719 |
706 | 720 |
707 TimelineBeginEndScope::TimelineBeginEndScope(Thread* thread, | 721 TimelineBeginEndScope::TimelineBeginEndScope(Thread* thread, |
708 TimelineStream* stream, | 722 TimelineStream* stream, |
709 const char* label) | 723 const char* label) |
710 : TimelineEventScope(thread, stream, label) { | 724 : TimelineEventScope(thread, stream, label) { |
| 725 if (!FLAG_support_timeline) { |
| 726 return; |
| 727 } |
711 EmitBegin(); | 728 EmitBegin(); |
712 } | 729 } |
713 | 730 |
714 | 731 |
715 TimelineBeginEndScope::~TimelineBeginEndScope() { | 732 TimelineBeginEndScope::~TimelineBeginEndScope() { |
| 733 if (!FLAG_support_timeline) { |
| 734 return; |
| 735 } |
716 EmitEnd(); | 736 EmitEnd(); |
717 } | 737 } |
718 | 738 |
719 | 739 |
720 void TimelineBeginEndScope::EmitBegin() { | 740 void TimelineBeginEndScope::EmitBegin() { |
| 741 if (!FLAG_support_timeline) { |
| 742 return; |
| 743 } |
721 if (!ShouldEmitEvent()) { | 744 if (!ShouldEmitEvent()) { |
722 return; | 745 return; |
723 } | 746 } |
724 TimelineEvent* event = stream()->StartEvent(); | 747 TimelineEvent* event = stream()->StartEvent(); |
725 if (event == NULL) { | 748 if (event == NULL) { |
726 // Stream is now disabled. | 749 // Stream is now disabled. |
727 set_enabled(false); | 750 set_enabled(false); |
728 return; | 751 return; |
729 } | 752 } |
730 ASSERT(event != NULL); | 753 ASSERT(event != NULL); |
731 // Emit a begin event. | 754 // Emit a begin event. |
732 event->Begin(label()); | 755 event->Begin(label()); |
733 event->Complete(); | 756 event->Complete(); |
734 } | 757 } |
735 | 758 |
736 | 759 |
737 void TimelineBeginEndScope::EmitEnd() { | 760 void TimelineBeginEndScope::EmitEnd() { |
| 761 if (!FLAG_support_timeline) { |
| 762 return; |
| 763 } |
738 if (!ShouldEmitEvent()) { | 764 if (!ShouldEmitEvent()) { |
739 return; | 765 return; |
740 } | 766 } |
741 TimelineEvent* event = stream()->StartEvent(); | 767 TimelineEvent* event = stream()->StartEvent(); |
742 if (event == NULL) { | 768 if (event == NULL) { |
743 // Stream is now disabled. | 769 // Stream is now disabled. |
744 set_enabled(false); | 770 set_enabled(false); |
745 return; | 771 return; |
746 } | 772 } |
747 ASSERT(event != NULL); | 773 ASSERT(event != NULL); |
(...skipping 625 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1373 } | 1399 } |
1374 | 1400 |
1375 | 1401 |
1376 TimelineEventBlock* TimelineEventBlockIterator::Next() { | 1402 TimelineEventBlock* TimelineEventBlockIterator::Next() { |
1377 ASSERT(current_ != NULL); | 1403 ASSERT(current_ != NULL); |
1378 TimelineEventBlock* r = current_; | 1404 TimelineEventBlock* r = current_; |
1379 current_ = current_->next(); | 1405 current_ = current_->next(); |
1380 return r; | 1406 return r; |
1381 } | 1407 } |
1382 | 1408 |
| 1409 #endif // !PRODUCT |
| 1410 |
1383 } // namespace dart | 1411 } // namespace dart |
OLD | NEW |