Chromium Code Reviews| Index: runtime/vm/timeline.cc |
| diff --git a/runtime/vm/timeline.cc b/runtime/vm/timeline.cc |
| index 5b7ca104dfad2c82dece1a54d58540a3936b36e3..1e8c3a474d1a83d7cab77111a9ffed37a0595f10 100644 |
| --- a/runtime/vm/timeline.cc |
| +++ b/runtime/vm/timeline.cc |
| @@ -33,6 +33,9 @@ DEFINE_FLAG(charp, timeline_streams, NULL, |
| "Comma separated list of timeline streams to record. " |
| "Valid values: all, API, Compiler, Dart, Debugger, Embedder, " |
| "GC, Isolate, and VM."); |
| +DEFINE_FLAG(charp, timeline_recorder, "ring", |
| + "Select the timeline recorder used. " |
| + "Valid values: ring, endless, and startup.") |
| // Implementation notes: |
| // |
| @@ -77,6 +80,38 @@ DEFINE_FLAG(charp, timeline_streams, NULL, |
| // |
| +static TimelineEventRecorder* CreateTimelineRecorder() { |
| + // Some flags require that we use the endless recorder. |
| + const bool use_endless_recorder = |
| + (FLAG_timeline_dir != NULL) || FLAG_timing || FLAG_complete_timeline; |
| + |
| + const char* flag = FLAG_timeline_recorder; |
| + |
| + if (use_endless_recorder || (flag != NULL)) { |
| + if (use_endless_recorder || strcmp("endless", flag) == 0) { |
| + if (FLAG_trace_timeline) { |
| + THR_Print("Using the endless timeline recorder.\n"); |
| + } |
| + return new TimelineEventEndlessRecorder(); |
| + } |
| + |
| + if (strcmp("startup", flag) == 0) { |
| + if (FLAG_trace_timeline) { |
| + THR_Print("Using the startup recorder.\n"); |
| + } |
| + return new TimelineEventStartupRecorder(); |
| + } |
| + } |
| + |
| + if (FLAG_trace_timeline) { |
| + THR_Print("Using the ring timeline recorder.\n"); |
| + } |
| + |
| + // Always fall back to the ring recorder. |
| + return new TimelineEventRingRecorder(); |
| +} |
| + |
| + |
| // Returns a caller freed array of stream names in FLAG_timeline_streams. |
| static MallocGrowableArray<char*>* GetEnabledByDefaultTimelineStreams() { |
| MallocGrowableArray<char*>* result = new MallocGrowableArray<char*>(); |
| @@ -129,18 +164,8 @@ static bool HasStream(MallocGrowableArray<char*>* streams, const char* stream) { |
| void Timeline::InitOnce() { |
| ASSERT(recorder_ == NULL); |
| - // Default to ring recorder being enabled. |
| - const bool use_ring_recorder = true; |
| - // Some flags require that we use the endless recorder. |
| - const bool use_endless_recorder = |
| - (FLAG_timeline_dir != NULL) || FLAG_timing || FLAG_complete_timeline; |
| - if (use_endless_recorder) { |
| - recorder_ = new TimelineEventEndlessRecorder(); |
| - } else if (FLAG_startup_timeline) { |
|
rmacnak
2016/04/19 17:30:56
FLAG_startup_timeline is now ignored but not remov
|
| - recorder_ = new TimelineEventStartupRecorder(); |
| - } else if (use_ring_recorder) { |
| - recorder_ = new TimelineEventRingRecorder(); |
| - } |
| + recorder_ = CreateTimelineRecorder(); |
| + ASSERT(recorder_ != NULL); |
| enabled_streams_ = GetEnabledByDefaultTimelineStreams(); |
| // Global overrides. |
| #define TIMELINE_STREAM_FLAG_DEFAULT(name, not_used) \ |
| @@ -1040,8 +1065,6 @@ void TimelineEventRecorder::WriteTo(const char* directory) { |
| if ((file_open == NULL) || (file_write == NULL) || (file_close == NULL)) { |
| return; |
| } |
| - Thread* T = Thread::Current(); |
| - StackZone zone(T); |
| Timeline::ReclaimCachedBlocksFromThreads(); |