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" |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 // Some flags require that we use the endless recorder. | 75 // Some flags require that we use the endless recorder. |
76 const bool use_endless_recorder = | 76 const bool use_endless_recorder = |
77 (FLAG_timeline_dir != NULL) || FLAG_timing || FLAG_complete_timeline; | 77 (FLAG_timeline_dir != NULL) || FLAG_timing || FLAG_complete_timeline; |
78 if (use_endless_recorder) { | 78 if (use_endless_recorder) { |
79 recorder_ = new TimelineEventEndlessRecorder(); | 79 recorder_ = new TimelineEventEndlessRecorder(); |
80 } else if (use_ring_recorder) { | 80 } else if (use_ring_recorder) { |
81 recorder_ = new TimelineEventRingRecorder(); | 81 recorder_ = new TimelineEventRingRecorder(); |
82 } | 82 } |
83 vm_stream_ = new TimelineStream(); | 83 vm_stream_ = new TimelineStream(); |
84 vm_stream_->Init("VM", EnableStreamByDefault("VM"), NULL); | 84 vm_stream_->Init("VM", EnableStreamByDefault("VM"), NULL); |
| 85 vm_api_stream_ = new TimelineStream(); |
| 86 vm_api_stream_->Init("API", |
| 87 EnableStreamByDefault("API"), |
| 88 &stream_API_enabled_); |
85 // Global overrides. | 89 // Global overrides. |
86 #define ISOLATE_TIMELINE_STREAM_FLAG_DEFAULT(name, not_used) \ | 90 #define ISOLATE_TIMELINE_STREAM_FLAG_DEFAULT(name, not_used) \ |
87 stream_##name##_enabled_ = EnableStreamByDefault(#name); | 91 stream_##name##_enabled_ = EnableStreamByDefault(#name); |
88 ISOLATE_TIMELINE_STREAM_LIST(ISOLATE_TIMELINE_STREAM_FLAG_DEFAULT) | 92 ISOLATE_TIMELINE_STREAM_LIST(ISOLATE_TIMELINE_STREAM_FLAG_DEFAULT) |
89 #undef ISOLATE_TIMELINE_STREAM_FLAG_DEFAULT | 93 #undef ISOLATE_TIMELINE_STREAM_FLAG_DEFAULT |
90 } | 94 } |
91 | 95 |
92 | 96 |
93 void Timeline::Shutdown() { | 97 void Timeline::Shutdown() { |
94 ASSERT(recorder_ != NULL); | 98 ASSERT(recorder_ != NULL); |
95 if (FLAG_timeline_dir != NULL) { | 99 if (FLAG_timeline_dir != NULL) { |
96 recorder_->WriteTo(FLAG_timeline_dir); | 100 recorder_->WriteTo(FLAG_timeline_dir); |
97 } | 101 } |
98 delete recorder_; | 102 delete recorder_; |
99 recorder_ = NULL; | 103 recorder_ = NULL; |
100 delete vm_stream_; | 104 delete vm_stream_; |
101 vm_stream_ = NULL; | 105 vm_stream_ = NULL; |
| 106 delete vm_api_stream_; |
| 107 vm_api_stream_ = NULL; |
102 } | 108 } |
103 | 109 |
104 | 110 |
105 TimelineEventRecorder* Timeline::recorder() { | 111 TimelineEventRecorder* Timeline::recorder() { |
106 return recorder_; | 112 return recorder_; |
107 } | 113 } |
108 | 114 |
109 | 115 |
110 bool Timeline::EnableStreamByDefault(const char* stream_name) { | 116 bool Timeline::EnableStreamByDefault(const char* stream_name) { |
111 // TODO(johnmccutchan): Allow for command line control over streams. | 117 // TODO(johnmccutchan): Allow for command line control over streams. |
112 return (FLAG_timeline_dir != NULL) || FLAG_timing || FLAG_complete_timeline; | 118 return (FLAG_timeline_dir != NULL) || FLAG_timing || FLAG_complete_timeline; |
113 } | 119 } |
114 | 120 |
115 | 121 |
116 TimelineStream* Timeline::GetVMStream() { | 122 TimelineStream* Timeline::GetVMStream() { |
117 ASSERT(vm_stream_ != NULL); | 123 ASSERT(vm_stream_ != NULL); |
118 return vm_stream_; | 124 return vm_stream_; |
119 } | 125 } |
120 | 126 |
121 | 127 |
| 128 TimelineStream* Timeline::GetVMApiStream() { |
| 129 ASSERT(vm_api_stream_ != NULL); |
| 130 return vm_api_stream_; |
| 131 } |
| 132 |
| 133 |
122 void Timeline::ReclaimCachedBlocksFromThreads() { | 134 void Timeline::ReclaimCachedBlocksFromThreads() { |
123 TimelineEventRecorder* recorder = Timeline::recorder(); | 135 TimelineEventRecorder* recorder = Timeline::recorder(); |
124 if (recorder == NULL) { | 136 if (recorder == NULL) { |
125 return; | 137 return; |
126 } | 138 } |
127 | 139 |
128 // Iterate over threads. | 140 // Iterate over threads. |
129 OSThreadIterator it; | 141 OSThreadIterator it; |
130 while (it.HasNext()) { | 142 while (it.HasNext()) { |
131 OSThread* thread = it.Next(); | 143 OSThread* thread = it.Next(); |
(...skipping 14 matching lines...) Expand all Loading... |
146 if (recorder == NULL) { | 158 if (recorder == NULL) { |
147 return; | 159 return; |
148 } | 160 } |
149 ReclaimCachedBlocksFromThreads(); | 161 ReclaimCachedBlocksFromThreads(); |
150 recorder->Clear(); | 162 recorder->Clear(); |
151 } | 163 } |
152 | 164 |
153 | 165 |
154 TimelineEventRecorder* Timeline::recorder_ = NULL; | 166 TimelineEventRecorder* Timeline::recorder_ = NULL; |
155 TimelineStream* Timeline::vm_stream_ = NULL; | 167 TimelineStream* Timeline::vm_stream_ = NULL; |
| 168 TimelineStream* Timeline::vm_api_stream_ = NULL; |
156 | 169 |
157 #define ISOLATE_TIMELINE_STREAM_DEFINE_FLAG(name, enabled_by_default) \ | 170 #define ISOLATE_TIMELINE_STREAM_DEFINE_FLAG(name, enabled_by_default) \ |
158 bool Timeline::stream_##name##_enabled_ = enabled_by_default; | 171 bool Timeline::stream_##name##_enabled_ = enabled_by_default; |
159 ISOLATE_TIMELINE_STREAM_LIST(ISOLATE_TIMELINE_STREAM_DEFINE_FLAG) | 172 ISOLATE_TIMELINE_STREAM_LIST(ISOLATE_TIMELINE_STREAM_DEFINE_FLAG) |
160 #undef ISOLATE_TIMELINE_STREAM_DEFINE_FLAG | 173 #undef ISOLATE_TIMELINE_STREAM_DEFINE_FLAG |
161 | 174 |
162 TimelineEvent::TimelineEvent() | 175 TimelineEvent::TimelineEvent() |
163 : timestamp0_(0), | 176 : timestamp0_(0), |
164 timestamp1_(0), | 177 timestamp1_(0), |
165 arguments_(NULL), | 178 arguments_(NULL), |
(...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
504 | 517 |
505 TimelineEventScope::TimelineEventScope(Thread* thread, | 518 TimelineEventScope::TimelineEventScope(Thread* thread, |
506 TimelineStream* stream, | 519 TimelineStream* stream, |
507 const char* label) | 520 const char* label) |
508 : StackResource(thread), | 521 : StackResource(thread), |
509 stream_(stream), | 522 stream_(stream), |
510 label_(label), | 523 label_(label), |
511 arguments_(NULL), | 524 arguments_(NULL), |
512 arguments_length_(0), | 525 arguments_length_(0), |
513 enabled_(false) { | 526 enabled_(false) { |
514 ASSERT(thread != NULL); | |
515 Init(); | 527 Init(); |
516 } | 528 } |
517 | 529 |
518 | 530 |
519 TimelineEventScope::~TimelineEventScope() { | 531 TimelineEventScope::~TimelineEventScope() { |
520 FreeArguments(); | 532 FreeArguments(); |
521 } | 533 } |
522 | 534 |
523 | 535 |
524 void TimelineEventScope::Init() { | 536 void TimelineEventScope::Init() { |
(...skipping 739 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1264 | 1276 |
1265 | 1277 |
1266 TimelineEventBlock* TimelineEventBlockIterator::Next() { | 1278 TimelineEventBlock* TimelineEventBlockIterator::Next() { |
1267 ASSERT(current_ != NULL); | 1279 ASSERT(current_ != NULL); |
1268 TimelineEventBlock* r = current_; | 1280 TimelineEventBlock* r = current_; |
1269 current_ = current_->next(); | 1281 current_ = current_->next(); |
1270 return r; | 1282 return r; |
1271 } | 1283 } |
1272 | 1284 |
1273 } // namespace dart | 1285 } // namespace dart |
OLD | NEW |