| 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 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 // Default to ring recorder being enabled. | 73 // Default to ring recorder being enabled. |
| 74 const bool use_ring_recorder = true; | 74 const bool use_ring_recorder = true; |
| 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_.Init("VM", EnableStreamByDefault("VM"), NULL); |
| 84 vm_stream_->Init("VM", EnableStreamByDefault("VM"), NULL); | 84 vm_api_stream_.Init("API", |
| 85 vm_api_stream_ = new TimelineStream(); | 85 EnableStreamByDefault("API"), |
| 86 vm_api_stream_->Init("API", | 86 &stream_API_enabled_); |
| 87 EnableStreamByDefault("API"), | |
| 88 &stream_API_enabled_); | |
| 89 // Global overrides. | 87 // Global overrides. |
| 90 #define ISOLATE_TIMELINE_STREAM_FLAG_DEFAULT(name, not_used) \ | 88 #define ISOLATE_TIMELINE_STREAM_FLAG_DEFAULT(name, not_used) \ |
| 91 stream_##name##_enabled_ = EnableStreamByDefault(#name); | 89 stream_##name##_enabled_ = EnableStreamByDefault(#name); |
| 92 ISOLATE_TIMELINE_STREAM_LIST(ISOLATE_TIMELINE_STREAM_FLAG_DEFAULT) | 90 ISOLATE_TIMELINE_STREAM_LIST(ISOLATE_TIMELINE_STREAM_FLAG_DEFAULT) |
| 93 #undef ISOLATE_TIMELINE_STREAM_FLAG_DEFAULT | 91 #undef ISOLATE_TIMELINE_STREAM_FLAG_DEFAULT |
| 94 } | 92 } |
| 95 | 93 |
| 96 | 94 |
| 97 void Timeline::Shutdown() { | 95 void Timeline::Shutdown() { |
| 98 ASSERT(recorder_ != NULL); | 96 ASSERT(recorder_ != NULL); |
| 99 if (FLAG_timeline_dir != NULL) { | 97 if (FLAG_timeline_dir != NULL) { |
| 100 recorder_->WriteTo(FLAG_timeline_dir); | 98 recorder_->WriteTo(FLAG_timeline_dir); |
| 101 } | 99 } |
| 100 // Disable global streams. |
| 101 vm_stream_.set_enabled(false); |
| 102 vm_api_stream_.set_enabled(false); |
| 103 #define ISOLATE_TIMELINE_STREAM_DISABLE(name, not_used) \ |
| 104 stream_##name##_enabled_ = false; |
| 105 ISOLATE_TIMELINE_STREAM_LIST(ISOLATE_TIMELINE_STREAM_DISABLE) |
| 106 #undef ISOLATE_TIMELINE_STREAM_DISABLE |
| 102 delete recorder_; | 107 delete recorder_; |
| 103 recorder_ = NULL; | 108 recorder_ = NULL; |
| 104 delete vm_stream_; | |
| 105 vm_stream_ = NULL; | |
| 106 delete vm_api_stream_; | |
| 107 vm_api_stream_ = NULL; | |
| 108 } | 109 } |
| 109 | 110 |
| 110 | 111 |
| 111 TimelineEventRecorder* Timeline::recorder() { | 112 TimelineEventRecorder* Timeline::recorder() { |
| 112 return recorder_; | 113 return recorder_; |
| 113 } | 114 } |
| 114 | 115 |
| 115 | 116 |
| 116 bool Timeline::EnableStreamByDefault(const char* stream_name) { | 117 bool Timeline::EnableStreamByDefault(const char* stream_name) { |
| 117 // TODO(johnmccutchan): Allow for command line control over streams. | 118 // TODO(johnmccutchan): Allow for command line control over streams. |
| 118 return (FLAG_timeline_dir != NULL) || FLAG_timing || FLAG_complete_timeline; | 119 return (FLAG_timeline_dir != NULL) || FLAG_timing || FLAG_complete_timeline; |
| 119 } | 120 } |
| 120 | 121 |
| 121 | 122 |
| 122 TimelineStream* Timeline::GetVMStream() { | 123 TimelineStream* Timeline::GetVMStream() { |
| 123 ASSERT(vm_stream_ != NULL); | 124 return &vm_stream_; |
| 124 return vm_stream_; | |
| 125 } | 125 } |
| 126 | 126 |
| 127 | 127 |
| 128 TimelineStream* Timeline::GetVMApiStream() { | 128 TimelineStream* Timeline::GetVMApiStream() { |
| 129 ASSERT(vm_api_stream_ != NULL); | 129 return &vm_api_stream_; |
| 130 return vm_api_stream_; | |
| 131 } | 130 } |
| 132 | 131 |
| 133 | 132 |
| 134 void Timeline::ReclaimCachedBlocksFromThreads() { | 133 void Timeline::ReclaimCachedBlocksFromThreads() { |
| 135 TimelineEventRecorder* recorder = Timeline::recorder(); | 134 TimelineEventRecorder* recorder = Timeline::recorder(); |
| 136 if (recorder == NULL) { | 135 if (recorder == NULL) { |
| 137 return; | 136 return; |
| 138 } | 137 } |
| 139 | 138 |
| 140 // Iterate over threads. | 139 // Iterate over threads. |
| (...skipping 16 matching lines...) Expand all Loading... |
| 157 TimelineEventRecorder* recorder = Timeline::recorder(); | 156 TimelineEventRecorder* recorder = Timeline::recorder(); |
| 158 if (recorder == NULL) { | 157 if (recorder == NULL) { |
| 159 return; | 158 return; |
| 160 } | 159 } |
| 161 ReclaimCachedBlocksFromThreads(); | 160 ReclaimCachedBlocksFromThreads(); |
| 162 recorder->Clear(); | 161 recorder->Clear(); |
| 163 } | 162 } |
| 164 | 163 |
| 165 | 164 |
| 166 TimelineEventRecorder* Timeline::recorder_ = NULL; | 165 TimelineEventRecorder* Timeline::recorder_ = NULL; |
| 167 TimelineStream* Timeline::vm_stream_ = NULL; | 166 TimelineStream Timeline::vm_stream_; |
| 168 TimelineStream* Timeline::vm_api_stream_ = NULL; | 167 TimelineStream Timeline::vm_api_stream_; |
| 169 | 168 |
| 170 #define ISOLATE_TIMELINE_STREAM_DEFINE_FLAG(name, enabled_by_default) \ | 169 #define ISOLATE_TIMELINE_STREAM_DEFINE_FLAG(name, enabled_by_default) \ |
| 171 bool Timeline::stream_##name##_enabled_ = enabled_by_default; | 170 bool Timeline::stream_##name##_enabled_ = enabled_by_default; |
| 172 ISOLATE_TIMELINE_STREAM_LIST(ISOLATE_TIMELINE_STREAM_DEFINE_FLAG) | 171 ISOLATE_TIMELINE_STREAM_LIST(ISOLATE_TIMELINE_STREAM_DEFINE_FLAG) |
| 173 #undef ISOLATE_TIMELINE_STREAM_DEFINE_FLAG | 172 #undef ISOLATE_TIMELINE_STREAM_DEFINE_FLAG |
| 174 | 173 |
| 175 TimelineEvent::TimelineEvent() | 174 TimelineEvent::TimelineEvent() |
| 176 : timestamp0_(0), | 175 : timestamp0_(0), |
| 177 timestamp1_(0), | 176 timestamp1_(0), |
| 178 arguments_(NULL), | 177 arguments_(NULL), |
| (...skipping 1140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1319 | 1318 |
| 1320 | 1319 |
| 1321 TimelineEventBlock* TimelineEventBlockIterator::Next() { | 1320 TimelineEventBlock* TimelineEventBlockIterator::Next() { |
| 1322 ASSERT(current_ != NULL); | 1321 ASSERT(current_ != NULL); |
| 1323 TimelineEventBlock* r = current_; | 1322 TimelineEventBlock* r = current_; |
| 1324 current_ = current_->next(); | 1323 current_ = current_->next(); |
| 1325 return r; | 1324 return r; |
| 1326 } | 1325 } |
| 1327 | 1326 |
| 1328 } // namespace dart | 1327 } // namespace dart |
| OLD | NEW |