| 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 11 matching lines...) Expand all Loading... |
| 22 "Trace timeline backend"); | 22 "Trace timeline backend"); |
| 23 DEFINE_FLAG(bool, trace_timeline_analysis, false, | 23 DEFINE_FLAG(bool, trace_timeline_analysis, false, |
| 24 "Trace timeline analysis backend"); | 24 "Trace timeline analysis backend"); |
| 25 DEFINE_FLAG(bool, timing, false, | 25 DEFINE_FLAG(bool, timing, false, |
| 26 "Dump isolate timing information from timeline."); | 26 "Dump isolate timing information from timeline."); |
| 27 DEFINE_FLAG(charp, timeline_dir, NULL, | 27 DEFINE_FLAG(charp, timeline_dir, NULL, |
| 28 "Enable all timeline trace streams and output VM global trace " | 28 "Enable all timeline trace streams and output VM global trace " |
| 29 "into specified directory."); | 29 "into specified directory."); |
| 30 DEFINE_FLAG(charp, timeline_streams, NULL, | 30 DEFINE_FLAG(charp, timeline_streams, NULL, |
| 31 "Comma separated list of timeline streams to record. " | 31 "Comma separated list of timeline streams to record. " |
| 32 "Valid values: all, api, compiler, dart, debugger, embedder, " | 32 "Valid values: all, API, Compiler, Dart, Debugger, Embedder, " |
| 33 "gc, isolate, and vm."); | 33 "GC, Isolate, and VM."); |
| 34 | 34 |
| 35 // Implementation notes: | 35 // Implementation notes: |
| 36 // | 36 // |
| 37 // Writing events: | 37 // Writing events: |
| 38 // |TimelineEvent|s are written into |TimelineEventBlock|s. Each |Thread| caches | 38 // |TimelineEvent|s are written into |TimelineEventBlock|s. Each |Thread| caches |
| 39 // a |TimelineEventBlock| object so that it can write events without | 39 // a |TimelineEventBlock| object so that it can write events without |
| 40 // synchronizing with other threads in the system. Even though the |Thread| owns | 40 // synchronizing with other threads in the system. Even though the |Thread| owns |
| 41 // the |TimelineEventBlock| the block may need to be reclaimed by the reporting | 41 // the |TimelineEventBlock| the block may need to be reclaimed by the reporting |
| 42 // system. To support that, a |Thread| must hold its |timeline_block_lock_| | 42 // system. To support that, a |Thread| must hold its |timeline_block_lock_| |
| 43 // when operating on the |TimelineEventBlock|. This lock will only ever be | 43 // when operating on the |TimelineEventBlock|. This lock will only ever be |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 } | 108 } |
| 109 | 109 |
| 110 | 110 |
| 111 // Returns true if |streams| contains |stream| or "all". Not case sensitive. | 111 // Returns true if |streams| contains |stream| or "all". Not case sensitive. |
| 112 static bool HasStream(MallocGrowableArray<char*>* streams, const char* stream) { | 112 static bool HasStream(MallocGrowableArray<char*>* streams, const char* stream) { |
| 113 if ((FLAG_timeline_dir != NULL) || FLAG_timing || FLAG_complete_timeline) { | 113 if ((FLAG_timeline_dir != NULL) || FLAG_timing || FLAG_complete_timeline) { |
| 114 return true; | 114 return true; |
| 115 } | 115 } |
| 116 for (intptr_t i = 0; i < streams->length(); i++) { | 116 for (intptr_t i = 0; i < streams->length(); i++) { |
| 117 const char* checked_stream = (*streams)[i]; | 117 const char* checked_stream = (*streams)[i]; |
| 118 if ((strcasestr(checked_stream, "all") != NULL) || | 118 if ((strstr(checked_stream, "all") != NULL) || |
| 119 (strcasestr(checked_stream, stream) != NULL)) { | 119 (strstr(checked_stream, stream) != NULL)) { |
| 120 return true; | 120 return true; |
| 121 } | 121 } |
| 122 } | 122 } |
| 123 return false; | 123 return false; |
| 124 } | 124 } |
| 125 | 125 |
| 126 | 126 |
| 127 void Timeline::InitOnce() { | 127 void Timeline::InitOnce() { |
| 128 ASSERT(recorder_ == NULL); | 128 ASSERT(recorder_ == NULL); |
| 129 // Default to ring recorder being enabled. | 129 // Default to ring recorder being enabled. |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 174 } | 174 } |
| 175 } | 175 } |
| 176 | 176 |
| 177 | 177 |
| 178 TimelineEventRecorder* Timeline::recorder() { | 178 TimelineEventRecorder* Timeline::recorder() { |
| 179 return recorder_; | 179 return recorder_; |
| 180 } | 180 } |
| 181 | 181 |
| 182 | 182 |
| 183 void Timeline::SetupIsolateStreams(Isolate* isolate) { | 183 void Timeline::SetupIsolateStreams(Isolate* isolate) { |
| 184 if (!FLAG_support_timeline) { |
| 185 return; |
| 186 } |
| 184 #define ISOLATE_TIMELINE_STREAM_INIT(name, enabled_by_default) \ | 187 #define ISOLATE_TIMELINE_STREAM_INIT(name, enabled_by_default) \ |
| 185 isolate->Get##name##Stream()->Init( \ | 188 isolate->Get##name##Stream()->Init( \ |
| 186 #name, \ | 189 #name, \ |
| 187 (enabled_by_default || HasStream(enabled_streams_, #name)), \ | 190 (enabled_by_default || HasStream(enabled_streams_, #name)), \ |
| 188 Timeline::Stream##name##EnabledFlag()); | 191 Timeline::Stream##name##EnabledFlag()); |
| 189 ISOLATE_TIMELINE_STREAM_LIST(ISOLATE_TIMELINE_STREAM_INIT); | 192 ISOLATE_TIMELINE_STREAM_LIST(ISOLATE_TIMELINE_STREAM_INIT); |
| 190 #undef ISOLATE_TIMELINE_STREAM_INIT | 193 #undef ISOLATE_TIMELINE_STREAM_INIT |
| 191 } | 194 } |
| 192 | 195 |
| 193 | 196 |
| (...skipping 1310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1504 TimelineEventBlock* TimelineEventBlockIterator::Next() { | 1507 TimelineEventBlock* TimelineEventBlockIterator::Next() { |
| 1505 ASSERT(current_ != NULL); | 1508 ASSERT(current_ != NULL); |
| 1506 TimelineEventBlock* r = current_; | 1509 TimelineEventBlock* r = current_; |
| 1507 current_ = current_->next(); | 1510 current_ = current_->next(); |
| 1508 return r; | 1511 return r; |
| 1509 } | 1512 } |
| 1510 | 1513 |
| 1511 #endif // !PRODUCT | 1514 #endif // !PRODUCT |
| 1512 | 1515 |
| 1513 } // namespace dart | 1516 } // namespace dart |
| OLD | NEW |