From 06a1e6e9e31ce96915cda3a7c83505507febaf77 Mon Sep 17 00:00:00 2001 From: Ryan Macnak Date: Fri, 18 Jan 2019 00:06:10 +0000 Subject: [PATCH] [vm] Enable timeline on Fuchsia even in product mode. On Fuchsia, the timeline is accessed without involving the service isolate or vm-service. Change-Id: Ia0d4e1ca252604e8fcef466a31e3d2a8b0912251 Reviewed-on: https://dart-review.googlesource.com/c/90100 Reviewed-by: Zach Anderson Commit-Queue: Ryan Macnak --- runtime/lib/timeline.cc | 42 +++++---------- runtime/vm/class_finalizer.cc | 8 +-- runtime/vm/clustered_snapshot.cc | 24 +++------ runtime/vm/compiler/aot/precompiler.cc | 20 ++----- .../vm/compiler/backend/type_propagator.cc | 7 +-- runtime/vm/compiler/compiler_pass.cc | 3 +- .../vm/compiler/frontend/bytecode_reader.cc | 20 +++---- runtime/vm/compiler/intrinsifier_arm.cc | 9 ++-- runtime/vm/compiler/intrinsifier_arm64.cc | 9 ++-- runtime/vm/compiler/intrinsifier_ia32.cc | 9 ++-- runtime/vm/compiler/intrinsifier_x64.cc | 10 ++-- runtime/vm/compiler/jit/compiler.cc | 18 +++---- runtime/vm/dart.cc | 54 ++++++++++--------- runtime/vm/dart_api_impl.cc | 45 ++++++++-------- runtime/vm/dart_api_impl.h | 2 +- runtime/vm/debugger.cc | 3 +- runtime/vm/deopt_instructions.cc | 5 +- runtime/vm/flag_list.h | 1 - runtime/vm/globals.h | 4 ++ runtime/vm/heap/compactor.cc | 4 +- runtime/vm/heap/scavenger.cc | 4 +- runtime/vm/image_snapshot.cc | 3 +- runtime/vm/isolate.cc | 34 ++++++------ runtime/vm/kernel_isolate.cc | 4 +- runtime/vm/object.cc | 3 +- runtime/vm/os_thread.cc | 10 ++-- runtime/vm/os_thread.h | 6 +-- runtime/vm/os_thread_android.cc | 2 +- runtime/vm/os_thread_fuchsia.cc | 2 +- runtime/vm/os_thread_linux.cc | 2 +- runtime/vm/os_thread_macos.cc | 2 +- runtime/vm/os_thread_win.cc | 2 +- runtime/vm/regexp_assembler_bytecode.cc | 2 +- runtime/vm/service.cc | 22 ++++---- runtime/vm/service_isolate.cc | 4 +- runtime/vm/symbols.h | 1 + runtime/vm/thread.cc | 2 +- runtime/vm/timeline.cc | 52 ++++++++++-------- runtime/vm/timeline.h | 29 +++++++++- runtime/vm/timeline_android.cc | 4 +- runtime/vm/timeline_fuchsia.cc | 4 +- runtime/vm/timeline_linux.cc | 4 +- sdk/lib/developer/timeline.dart | 15 +++--- 43 files changed, 255 insertions(+), 255 deletions(-) diff --git a/runtime/lib/timeline.cc b/runtime/lib/timeline.cc index 3e68d996fc8..8255b23bdc1 100644 --- a/runtime/lib/timeline.cc +++ b/runtime/lib/timeline.cc @@ -16,26 +16,24 @@ namespace dart { // Native implementations for the dart:developer library. DEFINE_NATIVE_ENTRY(Timeline_isDartStreamEnabled, 0, 0) { -#ifndef PRODUCT - if (!FLAG_support_timeline) { - return Bool::False().raw(); - } +#if defined(SUPPORT_TIMELINE) if (Timeline::GetDartStream()->enabled()) { return Bool::True().raw(); } -#endif // !PRODUCT +#endif return Bool::False().raw(); } DEFINE_NATIVE_ENTRY(Timeline_getNextAsyncId, 0, 0) { - if (!FLAG_support_timeline) { - return Integer::New(0); - } +#if !defined(SUPPORT_TIMELINE) + return Integer::New(0); +#else TimelineEventRecorder* recorder = Timeline::recorder(); if (recorder == NULL) { return Integer::New(0); } return Integer::New(recorder->GetNextAsyncId()); +#endif } DEFINE_NATIVE_ENTRY(Timeline_getTraceClock, 0, 0) { @@ -47,10 +45,7 @@ DEFINE_NATIVE_ENTRY(Timeline_getThreadCpuClock, 0, 0) { } DEFINE_NATIVE_ENTRY(Timeline_reportTaskEvent, 0, 6) { -#ifndef PRODUCT - if (!FLAG_support_timeline) { - return Object::null(); - } +#if defined(SUPPORT_TIMELINE) GET_NON_NULL_NATIVE_ARGUMENT(Integer, start, arguments->NativeArgAt(0)); GET_NON_NULL_NATIVE_ARGUMENT(Integer, id, arguments->NativeArgAt(1)); GET_NON_NULL_NATIVE_ARGUMENT(String, phase, arguments->NativeArgAt(2)); @@ -72,15 +67,12 @@ DEFINE_NATIVE_ENTRY(Timeline_reportTaskEvent, 0, 6) { DartTimelineEventHelpers::ReportTaskEvent( thread, event, start.AsInt64Value(), id.AsInt64Value(), phase.ToCString(), category.ToCString(), name.ToMallocCString(), args.ToMallocCString()); -#endif +#endif // SUPPORT_TIMELINE return Object::null(); } DEFINE_NATIVE_ENTRY(Timeline_reportCompleteEvent, 0, 5) { -#ifndef PRODUCT - if (!FLAG_support_timeline) { - return Object::null(); - } +#if defined(SUPPORT_TIMELINE) GET_NON_NULL_NATIVE_ARGUMENT(Integer, start, arguments->NativeArgAt(0)); GET_NON_NULL_NATIVE_ARGUMENT(Integer, start_cpu, arguments->NativeArgAt(1)); GET_NON_NULL_NATIVE_ARGUMENT(String, category, arguments->NativeArgAt(2)); @@ -101,15 +93,12 @@ DEFINE_NATIVE_ENTRY(Timeline_reportCompleteEvent, 0, 5) { DartTimelineEventHelpers::ReportCompleteEvent( thread, event, start.AsInt64Value(), start_cpu.AsInt64Value(), category.ToCString(), name.ToMallocCString(), args.ToMallocCString()); -#endif // !defined(PRODUCT) +#endif // SUPPORT_TIMELINE return Object::null(); } DEFINE_NATIVE_ENTRY(Timeline_reportFlowEvent, 0, 7) { -#ifndef PRODUCT - if (!FLAG_support_timeline) { - return Object::null(); - } +#if defined(SUPPORT_TIMELINE) GET_NON_NULL_NATIVE_ARGUMENT(Integer, start, arguments->NativeArgAt(0)); GET_NON_NULL_NATIVE_ARGUMENT(Integer, start_cpu, arguments->NativeArgAt(1)); GET_NON_NULL_NATIVE_ARGUMENT(String, category, arguments->NativeArgAt(2)); @@ -133,15 +122,12 @@ DEFINE_NATIVE_ENTRY(Timeline_reportFlowEvent, 0, 7) { thread, event, start.AsInt64Value(), start_cpu.AsInt64Value(), category.ToCString(), name.ToMallocCString(), type.AsInt64Value(), flow_id.AsInt64Value(), args.ToMallocCString()); -#endif // !defined(PRODUCT) +#endif // SUPPORT_TIMELINE return Object::null(); } DEFINE_NATIVE_ENTRY(Timeline_reportInstantEvent, 0, 4) { -#ifndef PRODUCT - if (!FLAG_support_timeline) { - return Object::null(); - } +#if defined(SUPPORT_TIMELINE) GET_NON_NULL_NATIVE_ARGUMENT(Integer, start, arguments->NativeArgAt(0)); GET_NON_NULL_NATIVE_ARGUMENT(String, category, arguments->NativeArgAt(1)); GET_NON_NULL_NATIVE_ARGUMENT(String, name, arguments->NativeArgAt(2)); @@ -161,7 +147,7 @@ DEFINE_NATIVE_ENTRY(Timeline_reportInstantEvent, 0, 4) { DartTimelineEventHelpers::ReportInstantEvent( thread, event, start.AsInt64Value(), category.ToCString(), name.ToMallocCString(), args.ToMallocCString()); -#endif +#endif // SUPPORT_TIMELINE return Object::null(); } diff --git a/runtime/vm/class_finalizer.cc b/runtime/vm/class_finalizer.cc index 572175da950..09fa482f46c 100644 --- a/runtime/vm/class_finalizer.cc +++ b/runtime/vm/class_finalizer.cc @@ -172,8 +172,7 @@ static void CollectImmediateSuperInterfaces(const Class& cls, // b) after the user classes are loaded (dart_api). bool ClassFinalizer::ProcessPendingClasses() { Thread* thread = Thread::Current(); - NOT_IN_PRODUCT(TimelineDurationScope tds(thread, Timeline::GetIsolateStream(), - "ProcessPendingClasses")); + TIMELINE_DURATION(thread, Isolate, "ProcessPendingClasses"); Isolate* isolate = thread->isolate(); ASSERT(isolate != NULL); HANDLESCOPE(thread); @@ -1127,10 +1126,7 @@ void ClassFinalizer::FinalizeClass(const Class& cls) { THR_Print("Finalize %s\n", cls.ToCString()); } -#if !defined(PRODUCT) - TimelineDurationScope tds(thread, Timeline::GetCompilerStream(), - "ClassFinalizer::FinalizeClass"); -#endif // !defined(PRODUCT) + TIMELINE_DURATION(thread, Compiler, "ClassFinalizer::FinalizeClass"); #if !defined(DART_PRECOMPILED_RUNTIME) // If loading from a kernel, make sure that the class is fully loaded. diff --git a/runtime/vm/clustered_snapshot.cc b/runtime/vm/clustered_snapshot.cc index db68c89edb5..c25b1f94645 100644 --- a/runtime/vm/clustered_snapshot.cc +++ b/runtime/vm/clustered_snapshot.cc @@ -597,8 +597,7 @@ class FunctionDeserializationCluster : public DeserializationCluster { } void PostLoad(const Array& refs, Snapshot::Kind kind, Zone* zone) { - NOT_IN_PRODUCT(TimelineDurationScope tds( - Thread::Current(), Timeline::GetIsolateStream(), "PostLoadFunction")); + TIMELINE_DURATION(Thread::Current(), Isolate, "PostLoadFunction"); if (kind == Snapshot::kFullAOT) { Function& func = Function::Handle(zone); @@ -1011,8 +1010,7 @@ class FieldDeserializationCluster : public DeserializationCluster { } void PostLoad(const Array& refs, Snapshot::Kind kind, Zone* zone) { - NOT_IN_PRODUCT(TimelineDurationScope tds( - Thread::Current(), Timeline::GetIsolateStream(), "PostLoadField")); + TIMELINE_DURATION(Thread::Current(), Isolate, "PostLoadField"); Field& field = Field::Handle(zone); if (!Isolate::Current()->use_field_guards()) { @@ -3285,8 +3283,7 @@ class MintDeserializationCluster : public DeserializationCluster { void ReadFill(Deserializer* d) {} void PostLoad(const Array& refs, Snapshot::Kind kind, Zone* zone) { - NOT_IN_PRODUCT(TimelineDurationScope tds( - Thread::Current(), Timeline::GetIsolateStream(), "PostLoadMint")); + TIMELINE_DURATION(Thread::Current(), Isolate, "PostLoadMint"); const Class& mint_cls = Class::Handle(zone, Isolate::Current()->object_store()->mint_class()); @@ -5107,8 +5104,7 @@ void Deserializer::Deserialize() { } { - NOT_IN_PRODUCT(TimelineDurationScope tds( - thread(), Timeline::GetIsolateStream(), "ReadAlloc")); + TIMELINE_DURATION(thread(), Isolate, "ReadAlloc"); for (intptr_t i = 0; i < num_clusters_; i++) { clusters_[i] = ReadCluster(); clusters_[i]->ReadAlloc(this); @@ -5123,8 +5119,7 @@ void Deserializer::Deserialize() { ASSERT((next_ref_index_ - 1) == num_objects_); { - NOT_IN_PRODUCT(TimelineDurationScope tds( - thread(), Timeline::GetIsolateStream(), "ReadFill")); + TIMELINE_DURATION(thread(), Isolate, "ReadFill"); for (intptr_t i = 0; i < num_clusters_; i++) { clusters_[i]->ReadFill(this); #if defined(DEBUG) @@ -5422,8 +5417,7 @@ FullSnapshotWriter::FullSnapshotWriter(Snapshot::Kind kind, // generated from a VM that has loaded this snapshots, much like app-jit // snapshots. if ((vm_snapshot_data_buffer != NULL) && (kind != Snapshot::kFullAOT)) { - NOT_IN_PRODUCT(TimelineDurationScope tds( - thread(), Timeline::GetIsolateStream(), "PrepareNewVMIsolate")); + TIMELINE_DURATION(thread(), Isolate, "PrepareNewVMIsolate"); SeedVMIsolateVisitor visitor(thread()->zone(), Snapshot::IncludesCode(kind)); @@ -5464,8 +5458,7 @@ FullSnapshotWriter::~FullSnapshotWriter() { } intptr_t FullSnapshotWriter::WriteVMSnapshot() { - NOT_IN_PRODUCT(TimelineDurationScope tds( - thread(), Timeline::GetIsolateStream(), "WriteVMSnapshot")); + TIMELINE_DURATION(thread(), Isolate, "WriteVMSnapshot"); ASSERT(vm_snapshot_data_buffer_ != NULL); Serializer serializer(thread(), kind_, vm_snapshot_data_buffer_, alloc_, @@ -5498,8 +5491,7 @@ intptr_t FullSnapshotWriter::WriteVMSnapshot() { } void FullSnapshotWriter::WriteIsolateSnapshot(intptr_t num_base_objects) { - NOT_IN_PRODUCT(TimelineDurationScope tds( - thread(), Timeline::GetIsolateStream(), "WriteIsolateSnapshot")); + TIMELINE_DURATION(thread(), Isolate, "WriteIsolateSnapshot"); Serializer serializer(thread(), kind_, isolate_snapshot_data_buffer_, alloc_, kInitialSize, isolate_image_writer_, /*vm=*/false, diff --git a/runtime/vm/compiler/aot/precompiler.cc b/runtime/vm/compiler/aot/precompiler.cc index d559f8b9f05..4af9d996099 100644 --- a/runtime/vm/compiler/aot/precompiler.cc +++ b/runtime/vm/compiler/aot/precompiler.cc @@ -2311,10 +2311,8 @@ bool PrecompileParsedFunctionHelper::Compile(CompilationPipeline* pipeline) { { ic_data_array = new (zone) ZoneGrowableArray(); -#ifndef PRODUCT - TimelineDurationScope tds(thread(), compiler_timeline, - "BuildFlowGraph"); -#endif // !PRODUCT + + TIMELINE_DURATION(thread(), Compiler, "BuildFlowGraph"); flow_graph = pipeline->BuildFlowGraph(zone, parsed_function(), ic_data_array, Compiler::kNoOSRDeoptId, optimized()); @@ -2342,10 +2340,7 @@ bool PrecompileParsedFunctionHelper::Compile(CompilationPipeline* pipeline) { NOT_IN_PRODUCT(pass_state.compiler_timeline = compiler_timeline); if (optimized()) { -#ifndef PRODUCT - TimelineDurationScope tds(thread(), compiler_timeline, - "OptimizationPasses"); -#endif // !PRODUCT + TIMELINE_DURATION(thread(), Compiler, "OptimizationPasses"); pass_state.inline_id_to_function.Add(&function); // We do not add the token position now because we don't know the @@ -2389,17 +2384,12 @@ bool PrecompileParsedFunctionHelper::Compile(CompilationPipeline* pipeline) { pass_state.inline_id_to_token_pos, pass_state.caller_inline_id, ic_data_array, function_stats); { -#ifndef PRODUCT - TimelineDurationScope tds(thread(), compiler_timeline, "CompileGraph"); -#endif // !PRODUCT + TIMELINE_DURATION(thread(), Compiler, "CompileGraph"); graph_compiler.CompileGraph(); pipeline->FinalizeCompilation(flow_graph); } { -#ifndef PRODUCT - TimelineDurationScope tds(thread(), compiler_timeline, - "FinalizeCompilation"); -#endif // !PRODUCT + TIMELINE_DURATION(thread(), Compiler, "FinalizeCompilation"); ASSERT(thread()->IsMutatorThread()); FinalizeCompilation(&assembler, &graph_compiler, flow_graph, function_stats); diff --git a/runtime/vm/compiler/backend/type_propagator.cc b/runtime/vm/compiler/backend/type_propagator.cc index 6e70d926ecb..8653b9fd0dd 100644 --- a/runtime/vm/compiler/backend/type_propagator.cc +++ b/runtime/vm/compiler/backend/type_propagator.cc @@ -40,12 +40,7 @@ static void TraceStrongModeType(const Instruction* instr, } void FlowGraphTypePropagator::Propagate(FlowGraph* flow_graph) { -#ifndef PRODUCT - Thread* thread = flow_graph->thread(); - TimelineStream* compiler_timeline = Timeline::GetCompilerStream(); - TimelineDurationScope tds2(thread, compiler_timeline, - "FlowGraphTypePropagator"); -#endif // !PRODUCT + TIMELINE_DURATION(flow_graph->thread(), Compiler, "FlowGraphTypePropagator"); FlowGraphTypePropagator propagator(flow_graph); propagator.Propagate(); } diff --git a/runtime/vm/compiler/compiler_pass.cc b/runtime/vm/compiler/compiler_pass.cc index e72f1a37c78..d0f3d322362 100644 --- a/runtime/vm/compiler/compiler_pass.cc +++ b/runtime/vm/compiler/compiler_pass.cc @@ -173,8 +173,7 @@ void CompilerPass::Run(CompilerPassState* state) const { PrintGraph(state, kTraceBefore, round); { - NOT_IN_PRODUCT( - TimelineDurationScope tds2(thread, state->compiler_timeline, name())); + TIMELINE_DURATION(thread, Compiler, name()); repeat = DoBody(state); DEBUG_ASSERT(state->flow_graph->VerifyUseLists()); thread->CheckForSafepoint(); diff --git a/runtime/vm/compiler/frontend/bytecode_reader.cc b/runtime/vm/compiler/frontend/bytecode_reader.cc index 077b1b1b01a..9f705c5e580 100644 --- a/runtime/vm/compiler/frontend/bytecode_reader.cc +++ b/runtime/vm/compiler/frontend/bytecode_reader.cc @@ -44,7 +44,7 @@ bool BytecodeMetadataHelper::HasBytecode(intptr_t node_offset) { } void BytecodeMetadataHelper::ReadMetadata(const Function& function) { -#if !defined(PRODUCT) +#if defined(SUPPORT_TIMELINE) TimelineDurationScope tds(Thread::Current(), Timeline::GetCompilerStream(), "BytecodeMetadataHelper::ReadMetadata"); // This increases bytecode reading time by ~7%, so only keep it around for @@ -310,10 +310,8 @@ void BytecodeMetadataHelper::ReadTypeParametersDeclaration( void BytecodeMetadataHelper::ReadConstantPool(const Function& function, const ObjectPool& pool) { -#if !defined(PRODUCT) - TimelineDurationScope tds(Thread::Current(), Timeline::GetCompilerStream(), - "BytecodeMetadataHelper::ReadConstantPool"); -#endif // !defined(PRODUCT) + TIMELINE_DURATION(Thread::Current(), Compiler, + "BytecodeMetadataHelper::ReadConstantPool"); // These enums and the code below reading the constant pool from kernel must // be kept in sync with pkg/vm/lib/bytecode/constant_pool.dart. @@ -638,10 +636,8 @@ void BytecodeMetadataHelper::ReadConstantPool(const Function& function, } RawBytecode* BytecodeMetadataHelper::ReadBytecode(const ObjectPool& pool) { -#if !defined(PRODUCT) - TimelineDurationScope tds(Thread::Current(), Timeline::GetCompilerStream(), - "BytecodeMetadataHelper::ReadBytecode"); -#endif // !defined(PRODUCT) + TIMELINE_DURATION(Thread::Current(), Compiler, + "BytecodeMetadataHelper::ReadBytecode"); intptr_t size = helper_->ReadUInt(); intptr_t offset = Utils::RoundUp(helper_->reader_.offset(), sizeof(KBCInstr)); const uint8_t* data = helper_->reader_.BufferAt(offset); @@ -659,10 +655,8 @@ RawBytecode* BytecodeMetadataHelper::ReadBytecode(const ObjectPool& pool) { void BytecodeMetadataHelper::ReadExceptionsTable(const Bytecode& bytecode, bool has_exceptions_table) { -#if !defined(PRODUCT) - TimelineDurationScope tds(Thread::Current(), Timeline::GetCompilerStream(), - "BytecodeMetadataHelper::ReadExceptionsTable"); -#endif // !defined(PRODUCT) + TIMELINE_DURATION(Thread::Current(), Compiler, + "BytecodeMetadataHelper::ReadExceptionsTable"); const intptr_t try_block_count = has_exceptions_table ? helper_->reader_.ReadListLength() : 0; diff --git a/runtime/vm/compiler/intrinsifier_arm.cc b/runtime/vm/compiler/intrinsifier_arm.cc index 9e516f0a68a..8b514888528 100644 --- a/runtime/vm/compiler/intrinsifier_arm.cc +++ b/runtime/vm/compiler/intrinsifier_arm.cc @@ -2227,10 +2227,10 @@ void Intrinsifier::Profiler_getCurrentTag(Assembler* assembler, void Intrinsifier::Timeline_isDartStreamEnabled(Assembler* assembler, Label* normal_ir_body) { - if (!FLAG_support_timeline) { - __ LoadObject(R0, Bool::False()); - __ Ret(); - } +#if !defined(SUPPORT_TIMELINE) + __ LoadObject(R0, Bool::False()); + __ Ret(); +#else // Load TimelineStream*. __ ldr(R0, Address(THR, Thread::dart_stream_offset())); // Load uintptr_t from TimelineStream*. @@ -2239,6 +2239,7 @@ void Intrinsifier::Timeline_isDartStreamEnabled(Assembler* assembler, __ LoadObject(R0, Bool::True(), NE); __ LoadObject(R0, Bool::False(), EQ); __ Ret(); +#endif } void Intrinsifier::ClearAsyncThreadStackTrace(Assembler* assembler, diff --git a/runtime/vm/compiler/intrinsifier_arm64.cc b/runtime/vm/compiler/intrinsifier_arm64.cc index 2abf1ed20ed..16f8f0bad53 100644 --- a/runtime/vm/compiler/intrinsifier_arm64.cc +++ b/runtime/vm/compiler/intrinsifier_arm64.cc @@ -2288,10 +2288,10 @@ void Intrinsifier::Profiler_getCurrentTag(Assembler* assembler, void Intrinsifier::Timeline_isDartStreamEnabled(Assembler* assembler, Label* normal_ir_body) { - if (!FLAG_support_timeline) { - __ LoadObject(R0, Bool::False()); - __ ret(); - } +#if !defined(SUPPORT_TIMELINE) + __ LoadObject(R0, Bool::False()); + __ ret(); +#else // Load TimelineStream*. __ ldr(R0, Address(THR, Thread::dart_stream_offset())); // Load uintptr_t from TimelineStream*. @@ -2301,6 +2301,7 @@ void Intrinsifier::Timeline_isDartStreamEnabled(Assembler* assembler, __ LoadObject(TMP, Bool::True()); __ csel(R0, TMP, R0, NE); __ ret(); +#endif } void Intrinsifier::ClearAsyncThreadStackTrace(Assembler* assembler, diff --git a/runtime/vm/compiler/intrinsifier_ia32.cc b/runtime/vm/compiler/intrinsifier_ia32.cc index cfb50f6e39b..ff8de4fc843 100644 --- a/runtime/vm/compiler/intrinsifier_ia32.cc +++ b/runtime/vm/compiler/intrinsifier_ia32.cc @@ -2202,10 +2202,10 @@ void Intrinsifier::Profiler_getCurrentTag(Assembler* assembler, void Intrinsifier::Timeline_isDartStreamEnabled(Assembler* assembler, Label* normal_ir_body) { - if (!FLAG_support_timeline) { - __ LoadObject(EAX, Bool::False()); - __ ret(); - } +#if !defined(SUPPORT_TIMELINE) + __ LoadObject(EAX, Bool::False()); + __ ret(); +#else Label true_label; // Load TimelineStream*. __ movl(EAX, Address(THR, Thread::dart_stream_offset())); @@ -2220,6 +2220,7 @@ void Intrinsifier::Timeline_isDartStreamEnabled(Assembler* assembler, __ Bind(&true_label); __ LoadObject(EAX, Bool::True()); __ ret(); +#endif } void Intrinsifier::ClearAsyncThreadStackTrace(Assembler* assembler, diff --git a/runtime/vm/compiler/intrinsifier_x64.cc b/runtime/vm/compiler/intrinsifier_x64.cc index a51b665aafa..ac56407c2a9 100644 --- a/runtime/vm/compiler/intrinsifier_x64.cc +++ b/runtime/vm/compiler/intrinsifier_x64.cc @@ -2229,11 +2229,10 @@ void Intrinsifier::Profiler_getCurrentTag(Assembler* assembler, void Intrinsifier::Timeline_isDartStreamEnabled(Assembler* assembler, Label* normal_ir_body) { - if (!FLAG_support_timeline) { - __ LoadObject(RAX, Bool::False()); - __ ret(); - return; - } +#if !defined(SUPPORT_TIMELINE) + __ LoadObject(RAX, Bool::False()); + __ ret(); +#else Label true_label; // Load TimelineStream*. __ movq(RAX, Address(THR, Thread::dart_stream_offset())); @@ -2248,6 +2247,7 @@ void Intrinsifier::Timeline_isDartStreamEnabled(Assembler* assembler, __ Bind(&true_label); __ LoadObject(RAX, Bool::True()); __ ret(); +#endif } void Intrinsifier::ClearAsyncThreadStackTrace(Assembler* assembler, diff --git a/runtime/vm/compiler/jit/compiler.cc b/runtime/vm/compiler/jit/compiler.cc index c63af582111..22acf860f85 100644 --- a/runtime/vm/compiler/jit/compiler.cc +++ b/runtime/vm/compiler/jit/compiler.cc @@ -619,8 +619,7 @@ RawCode* CompileParsedFunctionHelper::Compile(CompilationPipeline* pipeline) { } } - NOT_IN_PRODUCT(TimelineDurationScope tds(thread(), compiler_timeline, - "BuildFlowGraph")); + TIMELINE_DURATION(thread(), Compiler, "BuildFlowGraph"); flow_graph = pipeline->BuildFlowGraph( zone, parsed_function(), ic_data_array, osr_id(), optimized()); } @@ -638,8 +637,8 @@ RawCode* CompileParsedFunctionHelper::Compile(CompilationPipeline* pipeline) { const bool reorder_blocks = FlowGraph::ShouldReorderBlocks(function, optimized()); if (reorder_blocks) { - NOT_IN_PRODUCT(TimelineDurationScope tds( - thread(), compiler_timeline, "BlockScheduler::AssignEdgeWeights")); + TIMELINE_DURATION(thread(), Compiler, + "BlockScheduler::AssignEdgeWeights"); block_scheduler.AssignEdgeWeights(); } @@ -649,8 +648,7 @@ RawCode* CompileParsedFunctionHelper::Compile(CompilationPipeline* pipeline) { pass_state.reorder_blocks = reorder_blocks; if (optimized()) { - NOT_IN_PRODUCT(TimelineDurationScope tds(thread(), compiler_timeline, - "OptimizationPasses")); + TIMELINE_DURATION(thread(), Compiler, "OptimizationPasses"); pass_state.inline_id_to_function.Add(&function); // We do not add the token position now because we don't know the @@ -677,14 +675,12 @@ RawCode* CompileParsedFunctionHelper::Compile(CompilationPipeline* pipeline) { pass_state.inline_id_to_token_pos, pass_state.caller_inline_id, ic_data_array); { - NOT_IN_PRODUCT(TimelineDurationScope tds(thread(), compiler_timeline, - "CompileGraph")); + TIMELINE_DURATION(thread(), Compiler, "CompileGraph"); graph_compiler.CompileGraph(); pipeline->FinalizeCompilation(flow_graph); } { - NOT_IN_PRODUCT(TimelineDurationScope tds(thread(), compiler_timeline, - "FinalizeCompilation")); + TIMELINE_DURATION(thread(), Compiler, "FinalizeCompilation"); if (thread()->IsMutatorThread()) { *result = FinalizeCompilation(&assembler, &graph_compiler, flow_graph); @@ -1205,7 +1201,7 @@ RawObject* Compiler::EvaluateStaticInitializer(const Field& field) { // it now, but don't bother remembering it because it won't be used again. ASSERT(!field.HasPrecompiledInitializer()); { -#if !defined(PRODUCT) +#if defined(SUPPORT_TIMELINE) VMTagScope tagScope(thread, VMTag::kCompileUnoptimizedTagId); TimelineDurationScope tds(thread, Timeline::GetCompilerStream(), "CompileStaticInitializer"); diff --git a/runtime/vm/dart.cc b/runtime/vm/dart.cc index a9519916e30..8dbd0e11c04 100644 --- a/runtime/vm/dart.cc +++ b/runtime/vm/dart.cc @@ -164,11 +164,10 @@ char* Dart::Init(const uint8_t* vm_isolate_snapshot, start_time_micros_ = OS::GetCurrentMonotonicMicros(); VirtualMemory::Init(); OSThread::Init(); - if (FLAG_support_timeline) { - Timeline::Init(); - } - NOT_IN_PRODUCT( - TimelineDurationScope tds(Timeline::GetVMStream(), "Dart::Init")); +#if defined(SUPPORT_TIMELINE) + Timeline::Init(); + TimelineDurationScope tds(Timeline::GetVMStream(), "Dart::Init"); +#endif Isolate::InitVM(); PortMap::Init(); FreeListElement::Init(); @@ -214,8 +213,9 @@ char* Dart::Init(const uint8_t* vm_isolate_snapshot, ArgumentsDescriptor::Init(); ICData::Init(); if (vm_isolate_snapshot != NULL) { - NOT_IN_PRODUCT(TimelineDurationScope tds(Timeline::GetVMStream(), - "VMIsolateSnapshot")); +#if defined(SUPPORT_TIMELINE) + TimelineDurationScope tds(Timeline::GetVMStream(), "VMIsolateSnapshot"); +#endif const Snapshot* snapshot = Snapshot::SetupFromBuffer(vm_isolate_snapshot); if (snapshot == NULL) { return strdup("Invalid vm isolate snapshot seen"); @@ -260,7 +260,7 @@ char* Dart::Init(const uint8_t* vm_isolate_snapshot, ReversePcLookupCache::BuildAndAttachToIsolate(vm_isolate_); Object::FinishInit(vm_isolate_); -#if !defined(PRODUCT) +#if defined(SUPPORT_TIMELINE) if (tds.enabled()) { tds.SetNumArguments(2); tds.FormatArgument(0, "snapshotSize", "%" Pd, snapshot->length()); @@ -309,8 +309,9 @@ char* Dart::Init(const uint8_t* vm_isolate_snapshot, } #endif { - NOT_IN_PRODUCT(TimelineDurationScope tds(Timeline::GetVMStream(), - "FinalizeVMIsolate")); +#if defined(SUPPORT_TIMELINE) + TimelineDurationScope tds(Timeline::GetVMStream(), "FinalizeVMIsolate"); +#endif Object::FinalizeVMIsolate(vm_isolate_); } #if defined(DEBUG) @@ -526,13 +527,13 @@ char* Dart::Cleanup() { UptimeMillis()); } NOT_IN_PRODUCT(CodeObservers::Cleanup()); - if (FLAG_support_timeline) { - if (FLAG_trace_shutdown) { - OS::PrintErr("[+%" Pd64 "ms] SHUTDOWN: Shutting down timeline\n", - UptimeMillis()); - } - Timeline::Cleanup(); +#if defined(SUPPORT_TIMELINE) + if (FLAG_trace_shutdown) { + OS::PrintErr("[+%" Pd64 "ms] SHUTDOWN: Shutting down timeline\n", + UptimeMillis()); } + Timeline::Cleanup(); +#endif OS::Cleanup(); if (FLAG_trace_shutdown) { OS::PrintErr("[+%" Pd64 "ms] SHUTDOWN: Done\n", UptimeMillis()); @@ -571,16 +572,17 @@ RawError* Dart::InitializeIsolate(const uint8_t* snapshot_data, // Initialize the new isolate. Thread* T = Thread::Current(); Isolate* I = T->isolate(); - NOT_IN_PRODUCT(TimelineDurationScope tds(T, Timeline::GetIsolateStream(), - "InitializeIsolate"); - tds.SetNumArguments(1); - tds.CopyArgument(0, "isolateName", I->name());) +#if defined(SUPPORT_TIMLINE) + TimelineDurationScope tds(T, Timeline::GetIsolateStream(), + "InitializeIsolate"); + tds.SetNumArguments(1); + tds.CopyArgument(0, "isolateName", I->name()); +#endif ASSERT(I != NULL); StackZone zone(T); HandleScope handle_scope(T); { - NOT_IN_PRODUCT(TimelineDurationScope tds(T, Timeline::GetIsolateStream(), - "ObjectStore::Init")); + TIMELINE_DURATION(T, Isolate, "ObjectStore::Init"); ObjectStore::Init(I); } @@ -591,8 +593,10 @@ RawError* Dart::InitializeIsolate(const uint8_t* snapshot_data, } if ((snapshot_data != NULL) && kernel_buffer == NULL) { // Read the snapshot and setup the initial state. - NOT_IN_PRODUCT(TimelineDurationScope tds(T, Timeline::GetIsolateStream(), - "IsolateSnapshotReader")); +#if defined(SUPPORT_TIMELINE) + TimelineDurationScope tds(T, Timeline::GetIsolateStream(), + "IsolateSnapshotReader"); +#endif // TODO(turnidge): Remove once length is not part of the snapshot. const Snapshot* snapshot = Snapshot::SetupFromBuffer(snapshot_data); if (snapshot == NULL) { @@ -618,7 +622,7 @@ RawError* Dart::InitializeIsolate(const uint8_t* snapshot_data, ReversePcLookupCache::BuildAndAttachToIsolate(I); -#if !defined(PRODUCT) +#if defined(SUPPORT_TIMELINE) if (tds.enabled()) { tds.SetNumArguments(2); tds.FormatArgument(0, "snapshotSize", "%" Pd, snapshot->length()); diff --git a/runtime/vm/dart_api_impl.cc b/runtime/vm/dart_api_impl.cc index dbdcc891eca..f6e7d305cae 100644 --- a/runtime/vm/dart_api_impl.cc +++ b/runtime/vm/dart_api_impl.cc @@ -4729,6 +4729,14 @@ RawString* Api::GetEnvironmentValue(Thread* thread, const String& name) { #endif } + if (name.Equals(Symbols::DartDeveloperTimeline())) { +#ifdef SUPPORT_TIMELINE + return Symbols::True().raw(); +#else + return Symbols::False().raw(); +#endif + } + const String& prefix = Symbols::DartLibrary(); if (name.StartsWith(prefix)) { const String& library_name = @@ -5655,9 +5663,7 @@ DART_EXPORT bool Dart_IsReloading() { } DART_EXPORT void Dart_GlobalTimelineSetRecordedStreams(int64_t stream_mask) { - if (!FLAG_support_timeline) { - return; - } +#if defined(SUPPORT_TIMELINE) const bool api_enabled = (stream_mask & DART_TIMELINE_STREAM_API) != 0; const bool compiler_enabled = (stream_mask & DART_TIMELINE_STREAM_COMPILER) != 0; @@ -5678,6 +5684,7 @@ DART_EXPORT void Dart_GlobalTimelineSetRecordedStreams(int64_t stream_mask) { Timeline::SetStreamGCEnabled(gc_enabled); Timeline::SetStreamIsolateEnabled(isolate_enabled); Timeline::SetStreamVMEnabled(vm_enabled); +#endif } static void StartStreamToConsumer(Dart_StreamConsumer consumer, @@ -5758,18 +5765,17 @@ static bool StreamTraceEvents(Dart_StreamConsumer consumer, DART_EXPORT void Dart_SetEmbedderTimelineCallbacks( Dart_EmbedderTimelineStartRecording start_recording, Dart_EmbedderTimelineStopRecording stop_recording) { - if (!FLAG_support_timeline) { - return; - } +#if defined(SUPPORT_TIMELINE) Timeline::set_start_recording_cb(start_recording); Timeline::set_stop_recording_cb(stop_recording); +#endif } DART_EXPORT bool Dart_GlobalTimelineGetTrace(Dart_StreamConsumer consumer, void* user_data) { - if (!FLAG_support_timeline) { - return false; - } +#if defined(PRODUCT) + return false; +#else // To support various embedders, it must be possible to call this function // from a thread for which we have not entered an Isolate and set up a Thread // TLS object. Therefore, a Zone may not be available, a StackZone cannot be @@ -5793,6 +5799,7 @@ DART_EXPORT bool Dart_GlobalTimelineGetTrace(Dart_StreamConsumer consumer, } FinishStreamToConsumer(consumer, user_data, "timeline"); return success; +#endif } DART_EXPORT void Dart_TimelineEvent(const char* label, @@ -5802,9 +5809,7 @@ DART_EXPORT void Dart_TimelineEvent(const char* label, intptr_t argument_count, const char** argument_names, const char** argument_values) { - if (!FLAG_support_timeline) { - return; - } +#if defined(SUPPORT_TIMELINE) if (type < Dart_Timeline_Event_Begin) { return; } @@ -5861,6 +5866,7 @@ DART_EXPORT void Dart_TimelineEvent(const char* label, event->CopyArgument(i, argument_names[i], argument_values[i]); } event->Complete(); +#endif } #endif // defined(PRODUCT) @@ -6019,8 +6025,7 @@ Dart_CreateAppAOTSnapshotAsAssembly(Dart_StreamingWriteCallback callback, ASSERT(FLAG_load_deferred_eagerly); CHECK_NULL(callback); - NOT_IN_PRODUCT(TimelineDurationScope tds2(T, Timeline::GetIsolateStream(), - "WriteAppAOTSnapshot")); + TIMELINE_DURATION(T, Isolate, "WriteAppAOTSnapshot"); AssemblyImageWriter image_writer(T, callback, callback_data, NULL, NULL); uint8_t* vm_snapshot_data_buffer = NULL; uint8_t* isolate_snapshot_data_buffer = NULL; @@ -6052,8 +6057,7 @@ Dart_CreateVMAOTSnapshotAsAssembly(Dart_StreamingWriteCallback callback, API_TIMELINE_DURATION(T); CHECK_NULL(callback); - NOT_IN_PRODUCT(TimelineDurationScope tds2(T, Timeline::GetIsolateStream(), - "WriteVMAOTSnapshot")); + TIMELINE_DURATION(T, Isolate, "WriteVMAOTSnapshot"); AssemblyImageWriter image_writer(T, callback, callback_data, NULL, NULL); uint8_t* vm_snapshot_data_buffer = NULL; FullSnapshotWriter writer(Snapshot::kFullAOT, &vm_snapshot_data_buffer, NULL, @@ -6108,8 +6112,7 @@ Dart_CreateAppAOTSnapshotAsBlobs(uint8_t** vm_snapshot_data_buffer, } const void* shared_instructions_image = shared_instructions; - NOT_IN_PRODUCT(TimelineDurationScope tds2(T, Timeline::GetIsolateStream(), - "WriteAppAOTSnapshot")); + TIMELINE_DURATION(T, Isolate, "WriteAppAOTSnapshot"); BlobImageWriter vm_image_writer(T, vm_snapshot_instructions_buffer, ApiReallocate, 2 * MB /* initial_size */, /*shared_objects=*/nullptr, @@ -6220,8 +6223,7 @@ DART_EXPORT Dart_Handle Dart_CreateCoreJITSnapshotAsBlobs( ProgramVisitor::Dedup(); Symbols::Compact(I); - NOT_IN_PRODUCT(TimelineDurationScope tds2(T, Timeline::GetIsolateStream(), - "WriteCoreJITSnapshot")); + TIMELINE_DURATION(T, Isolate, "WriteCoreJITSnapshot"); BlobImageWriter vm_image_writer(T, vm_snapshot_instructions_buffer, ApiReallocate, 2 * MB /* initial_size */, /*shared_objects=*/nullptr, @@ -6289,8 +6291,7 @@ Dart_CreateAppJITSnapshotAsBlobs(uint8_t** isolate_snapshot_data_buffer, DumpTypeArgumentsTable(I); } - NOT_IN_PRODUCT(TimelineDurationScope tds2(T, Timeline::GetIsolateStream(), - "WriteAppJITSnapshot")); + TIMELINE_DURATION(T, Isolate, "WriteAppJITSnapshot"); BlobImageWriter isolate_image_writer(T, isolate_snapshot_instructions_buffer, ApiReallocate, 2 * MB /* initial_size */, /*shared_objects=*/nullptr, diff --git a/runtime/vm/dart_api_impl.h b/runtime/vm/dart_api_impl.h index 8d91094d2eb..261fd731320 100644 --- a/runtime/vm/dart_api_impl.h +++ b/runtime/vm/dart_api_impl.h @@ -102,7 +102,7 @@ const char* CanonicalFunction(const char* func); } \ } while (0) -#ifndef PRODUCT +#ifdef SUPPORT_TIMELINE #define API_TIMELINE_DURATION(thread) \ TimelineDurationScope tds(thread, Timeline::GetAPIStream(), CURRENT_FUNC) #define API_TIMELINE_DURATION_BASIC(thread) \ diff --git a/runtime/vm/debugger.cc b/runtime/vm/debugger.cc index f78316d9faa..0a1a227c5b9 100644 --- a/runtime/vm/debugger.cc +++ b/runtime/vm/debugger.cc @@ -3111,8 +3111,7 @@ void Debugger::Pause(ServiceEvent* event) { { Thread* thread = Thread::Current(); DisableThreadInterruptsScope dtis(thread); - TimelineDurationScope tds(thread, Timeline::GetDebuggerStream(), - "Debugger Pause"); + TIMELINE_DURATION(thread, Debugger, "Debugger Pause"); // Send the pause event. Service::HandleEvent(event); diff --git a/runtime/vm/deopt_instructions.cc b/runtime/vm/deopt_instructions.cc index 0f499e1c0be..02d29913cce 100644 --- a/runtime/vm/deopt_instructions.cc +++ b/runtime/vm/deopt_instructions.cc @@ -155,8 +155,9 @@ DeoptContext::~DeoptContext() { delete[] deferred_objects_; deferred_objects_ = NULL; deferred_objects_count_ = 0; -#ifndef PRODUCT - if (FLAG_support_timeline && (deopt_start_micros_ != 0)) { + +#if defined(SUPPORT_TIMELINE) + if (deopt_start_micros_ != 0) { TimelineStream* compiler_stream = Timeline::GetCompilerStream(); ASSERT(compiler_stream != NULL); if (compiler_stream->enabled()) { diff --git a/runtime/vm/flag_list.h b/runtime/vm/flag_list.h index d11e2036ab7..1f6cb3bd819 100644 --- a/runtime/vm/flag_list.h +++ b/runtime/vm/flag_list.h @@ -161,7 +161,6 @@ constexpr bool kDartPrecompiledRuntime = false; R(support_il_printer, false, bool, true, "Support the IL printer.") \ C(support_reload, false, false, bool, true, "Support isolate reload.") \ R(support_service, false, bool, true, "Support the service protocol.") \ - R(support_timeline, false, bool, true, "Support timeline.") \ D(trace_cha, bool, false, "Trace CHA operations") \ R(trace_field_guards, false, bool, false, "Trace changes in field's cids.") \ D(trace_ic, bool, false, "Trace IC handling") \ diff --git a/runtime/vm/globals.h b/runtime/vm/globals.h index 0e7e1cdbf12..ad33a4262a6 100644 --- a/runtime/vm/globals.h +++ b/runtime/vm/globals.h @@ -73,6 +73,10 @@ const intptr_t kDefaultMaxOldGenHeapSize = (kWordSize <= 4) ? 1536 : 0; #define NOT_IN_PRECOMPILED(code) code #endif // defined(DART_PRECOMPILED_RUNTIME) +#if !defined(PRODUCT) || defined(HOST_OS_FUCHSIA) || defined(TARGET_OS_FUCHSIA) +#define SUPPORT_TIMELINE 1 +#endif + #if defined(ARCH_IS_64_BIT) #define HASH_IN_OBJECT_HEADER 1 #endif diff --git a/runtime/vm/heap/compactor.cc b/runtime/vm/heap/compactor.cc index 859174ef62d..6855871368c 100644 --- a/runtime/vm/heap/compactor.cc +++ b/runtime/vm/heap/compactor.cc @@ -293,7 +293,9 @@ void CompactorTask::Run() { bool result = Thread::EnterIsolateAsHelper(isolate_, Thread::kCompactorTask, true); ASSERT(result); - NOT_IN_PRODUCT(Thread* thread = Thread::Current()); +#ifdef SUPPORT_TIMELINE + Thread* thread = Thread::Current(); +#endif { { TIMELINE_FUNCTION_GC_DURATION(thread, "Plan"); diff --git a/runtime/vm/heap/scavenger.cc b/runtime/vm/heap/scavenger.cc index b07afe956fe..a3dca1f3b63 100644 --- a/runtime/vm/heap/scavenger.cc +++ b/runtime/vm/heap/scavenger.cc @@ -603,7 +603,9 @@ void Scavenger::IterateObjectIdTable(Isolate* isolate, } void Scavenger::IterateRoots(Isolate* isolate, ScavengerVisitor* visitor) { - NOT_IN_PRODUCT(Thread* thread = Thread::Current()); +#ifdef SUPPORT_TIMELINE + Thread* thread = Thread::Current(); +#endif int64_t start = OS::GetCurrentMonotonicMicros(); { TIMELINE_FUNCTION_GC_DURATION(thread, "ProcessRoots"); diff --git a/runtime/vm/image_snapshot.cc b/runtime/vm/image_snapshot.cc index 303ca6e6c74..419cf009b6a 100644 --- a/runtime/vm/image_snapshot.cc +++ b/runtime/vm/image_snapshot.cc @@ -281,8 +281,7 @@ void ImageWriter::Write(WriteStream* clustered_stream, bool vm) { Thread* thread = Thread::Current(); Zone* zone = thread->zone(); Heap* heap = thread->isolate()->heap(); - NOT_IN_PRODUCT(TimelineDurationScope tds(thread, Timeline::GetIsolateStream(), - "WriteInstructions")); + TIMELINE_DURATION(thread, Isolate, "WriteInstructions"); // Handlify collected raw pointers as building the names below // will allocate on the Dart heap. diff --git a/runtime/vm/isolate.cc b/runtime/vm/isolate.cc index 5a6a1a6e925..d793eb23f2d 100644 --- a/runtime/vm/isolate.cc +++ b/runtime/vm/isolate.cc @@ -496,7 +496,7 @@ MessageHandler::MessageStatus IsolateMessageHandler::HandleMessage( StackZone stack_zone(thread); Zone* zone = stack_zone.GetZone(); HandleScope handle_scope(thread); -#ifndef PRODUCT +#if defined(SUPPORT_TIMELINE) TimelineDurationScope tds( thread, Timeline::GetIsolateStream(), message->IsOOB() ? "HandleOOBMessage" : "HandleMessage"); @@ -1359,16 +1359,16 @@ const char* Isolate::MakeRunnable() { ASSERT(this == state->isolate()); Run(); } -#ifndef PRODUCT - if (FLAG_support_timeline) { - TimelineStream* stream = Timeline::GetIsolateStream(); - ASSERT(stream != NULL); - TimelineEvent* event = stream->StartEvent(); - if (event != NULL) { - event->Instant("Runnable"); - event->Complete(); - } +#if defined(SUPPORT_TIMELINE) + TimelineStream* stream = Timeline::GetIsolateStream(); + ASSERT(stream != NULL); + TimelineEvent* event = stream->StartEvent(); + if (event != NULL) { + event->Instant("Runnable"); + event->Complete(); } +#endif +#ifndef PRODUCT if (FLAG_support_service && !Isolate::IsVMInternalIsolate(this) && Service::isolate_stream.enabled()) { ServiceEvent runnableEvent(this, ServiceEvent::kIsolateRunnable); @@ -1812,15 +1812,15 @@ void Isolate::LowLevelShutdown() { // Fail fast if anybody tries to post any more messages to this isolate. delete message_handler(); set_message_handler(NULL); - if (FLAG_support_timeline) { - // Before analyzing the isolate's timeline blocks- reclaim all cached - // blocks. - Timeline::ReclaimCachedBlocksFromThreads(); - } +#if defined(SUPPORT_TIMELINE) + // Before analyzing the isolate's timeline blocks- reclaim all cached + // blocks. + Timeline::ReclaimCachedBlocksFromThreads(); +#endif // Dump all timing data for the isolate. -#ifndef PRODUCT - if (FLAG_support_timeline && FLAG_timing) { +#if defined(SUPPORT_TIMELINE) && !defined(PRODUCT) + if (FLAG_timing) { TimelinePauseTrace tpt; tpt.Print(); } diff --git a/runtime/vm/kernel_isolate.cc b/runtime/vm/kernel_isolate.cc index 693078cb429..ab9049196ee 100644 --- a/runtime/vm/kernel_isolate.cc +++ b/runtime/vm/kernel_isolate.cc @@ -71,9 +71,9 @@ class RunKernelTask : public ThreadPool::Task { public: virtual void Run() { ASSERT(Isolate::Current() == NULL); -#ifndef PRODUCT +#ifdef SUPPORT_TIMELINE TimelineDurationScope tds(Timeline::GetVMStream(), "KernelIsolateStartup"); -#endif // !PRODUCT +#endif // SUPPORT_TIMELINE char* error = NULL; Isolate* isolate = NULL; diff --git a/runtime/vm/object.cc b/runtime/vm/object.cc index da8c7537bff..dd6d8307897 100644 --- a/runtime/vm/object.cc +++ b/runtime/vm/object.cc @@ -1300,8 +1300,7 @@ RawError* Object::Init(Isolate* isolate, #if !defined(DART_PRECOMPILED_RUNTIME) const bool is_kernel = (kernel_buffer != NULL); #endif - NOT_IN_PRODUCT(TimelineDurationScope tds(thread, Timeline::GetIsolateStream(), - "Object::Init");) + TIMELINE_DURATION(thread, Isolate, "Object::Init"); #if defined(DART_NO_SNAPSHOT) bool bootstrapping = diff --git a/runtime/vm/os_thread.cc b/runtime/vm/os_thread.cc index 22abcbbd7c5..fa5e8ea2892 100644 --- a/runtime/vm/os_thread.cc +++ b/runtime/vm/os_thread.cc @@ -29,7 +29,7 @@ OSThread::OSThread() #if defined(DEBUG) join_id_(kInvalidThreadJoinId), #endif -#ifndef PRODUCT +#ifdef SUPPORT_TIMELINE trace_id_(OSThread::GetCurrentThreadTraceId()), #endif name_(NULL), @@ -75,11 +75,11 @@ OSThread::~OSThread() { RemoveThreadFromList(this); delete log_; log_ = NULL; - if (FLAG_support_timeline) { - if (Timeline::recorder() != NULL) { - Timeline::recorder()->FinishBlock(timeline_block_); - } +#if defined(SUPPORT_TIMELINE) + if (Timeline::recorder() != NULL) { + Timeline::recorder()->FinishBlock(timeline_block_); } +#endif timeline_block_ = NULL; delete timeline_block_lock_; free(name_); diff --git a/runtime/vm/os_thread.h b/runtime/vm/os_thread.h index 1fcf0dada12..811bb072e18 100644 --- a/runtime/vm/os_thread.h +++ b/runtime/vm/os_thread.h @@ -69,7 +69,7 @@ class OSThread : public BaseThread { return id_; } -#ifndef PRODUCT +#ifdef SUPPORT_TIMELINE ThreadId trace_id() const { ASSERT(trace_id_ != OSThread::kInvalidThreadId); return trace_id_; @@ -230,7 +230,7 @@ class OSThread : public BaseThread { void set_thread(ThreadState* value) { thread_ = value; } static void Cleanup(); -#ifndef PRODUCT +#ifdef SUPPORT_TIMELINE static ThreadId GetCurrentThreadTraceId(); #endif // PRODUCT static OSThread* GetOSThreadFromThread(ThreadState* thread); @@ -246,7 +246,7 @@ class OSThread : public BaseThread { // only called once per OSThread. ThreadJoinId join_id_; #endif -#ifndef PRODUCT +#ifdef SUPPORT_TIMELINE const ThreadId trace_id_; // Used to interface with tracing tools. #endif char* name_; // A name for this thread. diff --git a/runtime/vm/os_thread_android.cc b/runtime/vm/os_thread_android.cc index 5eab0b8b557..e03d9b75c12 100644 --- a/runtime/vm/os_thread_android.cc +++ b/runtime/vm/os_thread_android.cc @@ -187,7 +187,7 @@ ThreadId OSThread::GetCurrentThreadId() { return gettid(); } -#ifndef PRODUCT +#ifdef SUPPORT_TIMELINE ThreadId OSThread::GetCurrentThreadTraceId() { return GetCurrentThreadId(); } diff --git a/runtime/vm/os_thread_fuchsia.cc b/runtime/vm/os_thread_fuchsia.cc index cae2552dac3..b465e077e6b 100644 --- a/runtime/vm/os_thread_fuchsia.cc +++ b/runtime/vm/os_thread_fuchsia.cc @@ -175,7 +175,7 @@ ThreadId OSThread::GetCurrentThreadId() { return info.koid; } -#ifndef PRODUCT +#ifdef SUPPORT_TIMELINE ThreadId OSThread::GetCurrentThreadTraceId() { return pthread_self(); } diff --git a/runtime/vm/os_thread_linux.cc b/runtime/vm/os_thread_linux.cc index 4b8da4d0d27..8c9fa0fbf1b 100644 --- a/runtime/vm/os_thread_linux.cc +++ b/runtime/vm/os_thread_linux.cc @@ -189,7 +189,7 @@ ThreadId OSThread::GetCurrentThreadId() { return pthread_self(); } -#ifndef PRODUCT +#ifdef SUPPORT_TIMELINE ThreadId OSThread::GetCurrentThreadTraceId() { return syscall(__NR_gettid); } diff --git a/runtime/vm/os_thread_macos.cc b/runtime/vm/os_thread_macos.cc index 39f0047b020..0fff6fd34ec 100644 --- a/runtime/vm/os_thread_macos.cc +++ b/runtime/vm/os_thread_macos.cc @@ -165,7 +165,7 @@ ThreadId OSThread::GetCurrentThreadId() { return pthread_self(); } -#ifndef PRODUCT +#ifdef SUPPORT_TIMELINE ThreadId OSThread::GetCurrentThreadTraceId() { return ThreadIdFromIntPtr(pthread_mach_thread_np(pthread_self())); } diff --git a/runtime/vm/os_thread_win.cc b/runtime/vm/os_thread_win.cc index 56b5e2f3cb5..b1aed904a4c 100644 --- a/runtime/vm/os_thread_win.cc +++ b/runtime/vm/os_thread_win.cc @@ -114,7 +114,7 @@ ThreadId OSThread::GetCurrentThreadId() { return ::GetCurrentThreadId(); } -#ifndef PRODUCT +#ifdef SUPPORT_TIMELINE ThreadId OSThread::GetCurrentThreadTraceId() { return ::GetCurrentThreadId(); } diff --git a/runtime/vm/regexp_assembler_bytecode.cc b/runtime/vm/regexp_assembler_bytecode.cc index 3847c62465b..f63bfecdeb9 100644 --- a/runtime/vm/regexp_assembler_bytecode.cc +++ b/runtime/vm/regexp_assembler_bytecode.cc @@ -419,7 +419,7 @@ static intptr_t Prepare(const RegExp& regexp, if (regexp.bytecode(is_one_byte, sticky) == TypedData::null()) { const String& pattern = String::Handle(zone, regexp.pattern()); -#if !defined(PRODUCT) +#if defined(SUPPORT_TIMELINE) TimelineDurationScope tds(Thread::Current(), Timeline::GetCompilerStream(), "CompileIrregexpBytecode"); if (tds.enabled()) { diff --git a/runtime/vm/service.cc b/runtime/vm/service.cc index 2860a7e173e..3c2eca26897 100644 --- a/runtime/vm/service.cc +++ b/runtime/vm/service.cc @@ -3527,6 +3527,7 @@ static const MethodParameter* set_vm_timeline_flags_params[] = { NULL, }; +#if defined(SUPPORT_TIMELINE) static bool HasStream(const char** recorded_streams, const char* stream) { while (*recorded_streams != NULL) { if ((strstr(*recorded_streams, "all") != NULL) || @@ -3537,12 +3538,13 @@ static bool HasStream(const char** recorded_streams, const char* stream) { } return false; } +#endif static bool SetVMTimelineFlags(Thread* thread, JSONStream* js) { - if (!FLAG_support_timeline) { - PrintSuccess(js); - return true; - } +#if !defined(SUPPORT_TIMELINE) + PrintSuccess(js); + return true; +#else Isolate* isolate = thread->isolate(); ASSERT(isolate != NULL); StackZone zone(thread); @@ -3562,6 +3564,7 @@ static bool SetVMTimelineFlags(Thread* thread, JSONStream* js) { PrintSuccess(js); return true; +#endif } static const MethodParameter* get_vm_timeline_flags_params[] = { @@ -3569,16 +3572,17 @@ static const MethodParameter* get_vm_timeline_flags_params[] = { }; static bool GetVMTimelineFlags(Thread* thread, JSONStream* js) { - if (!FLAG_support_timeline) { - JSONObject obj(js); - obj.AddProperty("type", "TimelineFlags"); - return true; - } +#if !defined(SUPPORT_TIMELINE) + JSONObject obj(js); + obj.AddProperty("type", "TimelineFlags"); + return true; +#else Isolate* isolate = thread->isolate(); ASSERT(isolate != NULL); StackZone zone(thread); Timeline::PrintFlagsToJSON(js); return true; +#endif } static const MethodParameter* clear_vm_timeline_params[] = { diff --git a/runtime/vm/service_isolate.cc b/runtime/vm/service_isolate.cc index e645e35d814..c02c9fd2069 100644 --- a/runtime/vm/service_isolate.cc +++ b/runtime/vm/service_isolate.cc @@ -313,9 +313,9 @@ class RunServiceTask : public ThreadPool::Task { public: virtual void Run() { ASSERT(Isolate::Current() == NULL); -#ifndef PRODUCT +#if defined(SUPPORT_TIMELINE) TimelineDurationScope tds(Timeline::GetVMStream(), "ServiceIsolateStartup"); -#endif // !PRODUCT +#endif // SUPPORT_TIMELINE char* error = NULL; Isolate* isolate = NULL; diff --git a/runtime/vm/symbols.h b/runtime/vm/symbols.h index 536ad2b12e0..f0577034170 100644 --- a/runtime/vm/symbols.h +++ b/runtime/vm/symbols.h @@ -380,6 +380,7 @@ class ObjectPointerVisitor; V(DartVMService, "dart:_vmservice") \ V(DartIOLibName, "dart.io") \ V(DartVMProduct, "dart.vm.product") \ + V(DartDeveloperTimeline, "dart.developer.timeline") \ V(EvalSourceUri, "evaluate:source") \ V(ExternalName, "ExternalName") \ V(_Random, "_Random") \ diff --git a/runtime/vm/thread.cc b/runtime/vm/thread.cc index 87561130bdf..d4b98ccbb65 100644 --- a/runtime/vm/thread.cc +++ b/runtime/vm/thread.cc @@ -106,7 +106,7 @@ Thread::Thread(Isolate* isolate) interpreter_(nullptr), #endif next_(NULL) { -#if !defined(PRODUCT) +#if defined(SUPPORT_TIMELINE) dart_stream_ = Timeline::GetDartStream(); ASSERT(dart_stream_ != NULL); #endif diff --git a/runtime/vm/timeline.cc b/runtime/vm/timeline.cc index e343cddb4ea..e26ff0452d6 100644 --- a/runtime/vm/timeline.cc +++ b/runtime/vm/timeline.cc @@ -2,8 +2,8 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. -#include "platform/globals.h" -#ifndef PRODUCT +#include "vm/globals.h" +#if defined(SUPPORT_TIMELINE) #include "vm/timeline.h" @@ -239,9 +239,11 @@ void Timeline::Cleanup() { Timeline::get_stop_recording_cb()(); } +#ifndef PRODUCT if (FLAG_timeline_dir != NULL) { recorder_->WriteTo(FLAG_timeline_dir); } +#endif // Disable global streams. #define TIMELINE_STREAM_DISABLE(name, not_used) \ @@ -281,6 +283,7 @@ void Timeline::ReclaimCachedBlocksFromThreads() { } } +#ifndef PRODUCT void Timeline::PrintFlagsToJSON(JSONStream* js) { JSONObject obj(js); obj.AddProperty("type", "TimelineFlags"); @@ -306,6 +309,7 @@ void Timeline::PrintFlagsToJSON(JSONStream* js) { #undef ADD_RECORDED_STREAM_NAME } } +#endif void Timeline::Clear() { TimelineEventRecorder* recorder = Timeline::recorder(); @@ -621,6 +625,7 @@ bool TimelineEvent::Within(int64_t time_origin_micros, return (delta >= 0) && (delta <= time_extent_micros); } +#ifndef PRODUCT void TimelineEvent::PrintJSON(JSONStream* stream) const { if (!FLAG_support_service) { return; @@ -712,6 +717,7 @@ void TimelineEvent::PrintJSON(JSONStream* stream) const { } } } +#endif int64_t TimelineEvent::TimeOrigin() const { return timestamp0_; @@ -860,7 +866,7 @@ void TimelineEventScope::StealArguments(TimelineEvent* event) { TimelineDurationScope::TimelineDurationScope(TimelineStream* stream, const char* label) : TimelineEventScope(stream, label) { - if (!FLAG_support_timeline || !enabled()) { + if (!enabled()) { return; } timestamp_ = OS::GetCurrentMonotonicMicros(); @@ -871,7 +877,7 @@ TimelineDurationScope::TimelineDurationScope(Thread* thread, TimelineStream* stream, const char* label) : TimelineEventScope(thread, stream, label) { - if (!FLAG_support_timeline || !enabled()) { + if (!enabled()) { return; } timestamp_ = OS::GetCurrentMonotonicMicros(); @@ -879,9 +885,6 @@ TimelineDurationScope::TimelineDurationScope(Thread* thread, } TimelineDurationScope::~TimelineDurationScope() { - if (!FLAG_support_timeline) { - return; - } if (!ShouldEmitEvent()) { return; } @@ -901,9 +904,6 @@ TimelineDurationScope::~TimelineDurationScope() { TimelineBeginEndScope::TimelineBeginEndScope(TimelineStream* stream, const char* label) : TimelineEventScope(stream, label) { - if (!FLAG_support_timeline) { - return; - } EmitBegin(); } @@ -911,23 +911,14 @@ TimelineBeginEndScope::TimelineBeginEndScope(Thread* thread, TimelineStream* stream, const char* label) : TimelineEventScope(thread, stream, label) { - if (!FLAG_support_timeline) { - return; - } EmitBegin(); } TimelineBeginEndScope::~TimelineBeginEndScope() { - if (!FLAG_support_timeline) { - return; - } EmitEnd(); } void TimelineBeginEndScope::EmitBegin() { - if (!FLAG_support_timeline) { - return; - } if (!ShouldEmitEvent()) { return; } @@ -944,9 +935,6 @@ void TimelineBeginEndScope::EmitBegin() { } void TimelineBeginEndScope::EmitEnd() { - if (!FLAG_support_timeline) { - return; - } if (!ShouldEmitEvent()) { return; } @@ -983,6 +971,7 @@ IsolateTimelineEventFilter::IsolateTimelineEventFilter( TimelineEventRecorder::TimelineEventRecorder() : async_id_(0), time_low_micros_(0), time_high_micros_(0) {} +#ifndef PRODUCT void TimelineEventRecorder::PrintJSONMeta(JSONArray* events) const { if (!FLAG_support_service) { return; @@ -1009,6 +998,7 @@ void TimelineEventRecorder::PrintJSONMeta(JSONArray* events) const { } } } +#endif TimelineEvent* TimelineEventRecorder::ThreadBlockStartEvent() { // Grab the current thread. @@ -1105,6 +1095,7 @@ void TimelineEventRecorder::ThreadBlockCompleteEvent(TimelineEvent* event) { thread_block_lock->Unlock(); } +#ifndef PRODUCT void TimelineEventRecorder::WriteTo(const char* directory) { if (!FLAG_support_service) { return; @@ -1143,6 +1134,7 @@ void TimelineEventRecorder::WriteTo(const char* directory) { return; } +#endif int64_t TimelineEventRecorder::GetNextAsyncId() { // TODO(johnmccutchan): Gracefully handle wrap around. @@ -1195,6 +1187,7 @@ TimelineEventFixedBufferRecorder::~TimelineEventFixedBufferRecorder() { delete memory_; } +#ifndef PRODUCT void TimelineEventFixedBufferRecorder::PrintJSONEvents( JSONArray* events, TimelineEventFilter* filter) { @@ -1253,6 +1246,7 @@ void TimelineEventFixedBufferRecorder::PrintTraceEvent( PrintJSONMeta(&events); PrintJSONEvents(&events, filter); } +#endif TimelineEventBlock* TimelineEventFixedBufferRecorder::GetHeadBlockLocked() { return &blocks_[0]; @@ -1320,6 +1314,7 @@ TimelineEventCallbackRecorder::TimelineEventCallbackRecorder() {} TimelineEventCallbackRecorder::~TimelineEventCallbackRecorder() {} +#ifndef PRODUCT void TimelineEventCallbackRecorder::PrintJSON(JSONStream* js, TimelineEventFilter* filter) { if (!FLAG_support_service) { @@ -1341,6 +1336,7 @@ void TimelineEventCallbackRecorder::PrintTraceEvent( } JSONArray events(js); } +#endif TimelineEvent* TimelineEventCallbackRecorder::StartEvent() { TimelineEvent* event = new TimelineEvent(); @@ -1356,6 +1352,7 @@ TimelineEventPlatformRecorder::TimelineEventPlatformRecorder() {} TimelineEventPlatformRecorder::~TimelineEventPlatformRecorder() {} +#ifndef PRODUCT void TimelineEventPlatformRecorder::PrintJSON(JSONStream* js, TimelineEventFilter* filter) { if (!FLAG_support_service) { @@ -1377,6 +1374,7 @@ void TimelineEventPlatformRecorder::PrintTraceEvent( } JSONArray events(js); } +#endif TimelineEvent* TimelineEventPlatformRecorder::StartEvent() { TimelineEvent* event = new TimelineEvent(); @@ -1402,6 +1400,7 @@ TimelineEventEndlessRecorder::~TimelineEventEndlessRecorder() { } } +#ifndef PRODUCT void TimelineEventEndlessRecorder::PrintJSON(JSONStream* js, TimelineEventFilter* filter) { if (!FLAG_support_service) { @@ -1428,6 +1427,7 @@ void TimelineEventEndlessRecorder::PrintTraceEvent( PrintJSONMeta(&events); PrintJSONEvents(&events, filter); } +#endif TimelineEventBlock* TimelineEventEndlessRecorder::GetHeadBlockLocked() { return head_; @@ -1455,6 +1455,7 @@ TimelineEventBlock* TimelineEventEndlessRecorder::GetNewBlockLocked() { return head_; } +#ifndef PRODUCT static int TimelineEventBlockCompare(TimelineEventBlock* const* a, TimelineEventBlock* const* b) { return (*a)->LowerTimeBound() - (*b)->LowerTimeBound(); @@ -1500,6 +1501,7 @@ void TimelineEventEndlessRecorder::PrintJSONEvents( } } } +#endif void TimelineEventEndlessRecorder::Clear() { TimelineEventBlock* current = head_; @@ -1525,6 +1527,7 @@ TimelineEventBlock::~TimelineEventBlock() { Reset(); } +#ifndef PRODUCT void TimelineEventBlock::PrintJSON(JSONStream* js) const { ASSERT(!in_use()); JSONArray events(js); @@ -1533,6 +1536,7 @@ void TimelineEventBlock::PrintJSON(JSONStream* js) const { events.AddValue(event); } } +#endif TimelineEvent* TimelineEventBlock::StartEvent() { ASSERT(!IsFull()); @@ -1598,11 +1602,13 @@ void TimelineEventBlock::Finish() { OS::PrintErr("Finish block %p\n", this); } in_use_ = false; +#ifndef PRODUCT if (Service::timeline_stream.enabled()) { ServiceEvent service_event(NULL, ServiceEvent::kTimelineEvents); service_event.set_timeline_event_block(this); Service::HandleEvent(&service_event); } +#endif } TimelineEventBlockIterator::TimelineEventBlockIterator( @@ -1727,4 +1733,4 @@ void DartTimelineEventHelpers::ReportInstantEvent(Thread* thread, } // namespace dart -#endif // !PRODUCT +#endif // defined(SUPPORT_TIMELINE) diff --git a/runtime/vm/timeline.h b/runtime/vm/timeline.h index 92f33a33430..55a5db07e92 100644 --- a/runtime/vm/timeline.h +++ b/runtime/vm/timeline.h @@ -89,8 +89,10 @@ class Timeline : public AllStatic { static void Clear(); +#ifndef PRODUCT // Print information about streams to JSON. static void PrintFlagsToJSON(JSONStream* json); +#endif #define TIMELINE_STREAM_ACCESSOR(name, not_used) \ static TimelineStream* Get##name##Stream() { return &stream_##name##_; } @@ -311,7 +313,9 @@ class TimelineEvent { // The highest time value stored in this event. int64_t HighTime() const; +#ifndef PRODUCT void PrintJSON(JSONStream* stream) const; +#endif ThreadId thread() const { return thread_; } @@ -447,7 +451,9 @@ class TimelineEvent { DISALLOW_COPY_AND_ASSIGN(TimelineEvent); }; -#ifndef PRODUCT +#ifdef SUPPORT_TIMELINE +#define TIMELINE_DURATION(thread, stream, name) \ + TimelineDurationScope(thread, Timeline::Get##stream##Stream(), name); #define TIMELINE_FUNCTION_COMPILATION_DURATION(thread, name, function) \ TimelineDurationScope tds(thread, Timeline::GetCompilerStream(), name); \ if (tds.enabled()) { \ @@ -463,6 +469,7 @@ class TimelineEvent { tds.SetNumArguments(1); \ tds.CopyArgument(0, "mode", "basic"); #else +#define TIMELINE_DURATION(thread, stream, name) #define TIMELINE_FUNCTION_COMPILATION_DURATION(thread, name, function) #define TIMELINE_FUNCTION_GC_DURATION(thread, name) #define TIMELINE_FUNCTION_GC_DURATION_BASIC(thread, name) @@ -598,7 +605,9 @@ class TimelineEventBlock { ThreadId thread_id() const { return thread_id_; } protected: +#ifndef PRODUCT void PrintJSON(JSONStream* stream) const; +#endif TimelineEvent* StartEvent(); @@ -689,15 +698,19 @@ class TimelineEventRecorder { TimelineEventBlock* GetNewBlock(); // Interface method(s) which must be implemented. +#ifndef PRODUCT virtual void PrintJSON(JSONStream* js, TimelineEventFilter* filter) = 0; virtual void PrintTraceEvent(JSONStream* js, TimelineEventFilter* filter) = 0; +#endif virtual const char* name() const = 0; int64_t GetNextAsyncId(); void FinishBlock(TimelineEventBlock* block); protected: +#ifndef PRODUCT void WriteTo(const char* directory); +#endif // Interface method(s) which must be implemented. virtual TimelineEvent* StartEvent() = 0; @@ -707,7 +720,9 @@ class TimelineEventRecorder { virtual void Clear() = 0; // Utility method(s). +#ifndef PRODUCT void PrintJSONMeta(JSONArray* array) const; +#endif TimelineEvent* ThreadBlockStartEvent(); void ThreadBlockCompleteEvent(TimelineEvent* event); @@ -739,8 +754,10 @@ class TimelineEventFixedBufferRecorder : public TimelineEventRecorder { explicit TimelineEventFixedBufferRecorder(intptr_t capacity); virtual ~TimelineEventFixedBufferRecorder(); +#ifndef PRODUCT void PrintJSON(JSONStream* js, TimelineEventFilter* filter); void PrintTraceEvent(JSONStream* js, TimelineEventFilter* filter); +#endif protected: TimelineEvent* StartEvent(); @@ -749,7 +766,9 @@ class TimelineEventFixedBufferRecorder : public TimelineEventRecorder { intptr_t FindOldestBlockIndex() const; void Clear(); +#ifndef PRODUCT void PrintJSONEvents(JSONArray* array, TimelineEventFilter* filter); +#endif VirtualMemory* memory_; TimelineEventBlock* blocks_; @@ -793,8 +812,10 @@ class TimelineEventCallbackRecorder : public TimelineEventRecorder { TimelineEventCallbackRecorder(); virtual ~TimelineEventCallbackRecorder(); +#ifndef PRODUCT void PrintJSON(JSONStream* js, TimelineEventFilter* filter); void PrintTraceEvent(JSONStream* js, TimelineEventFilter* filter); +#endif // Called when |event| is completed. It is unsafe to keep a reference to // |event| as it may be freed as soon as this function returns. @@ -818,8 +839,10 @@ class TimelineEventEndlessRecorder : public TimelineEventRecorder { TimelineEventEndlessRecorder(); virtual ~TimelineEventEndlessRecorder(); +#ifndef PRODUCT void PrintJSON(JSONStream* js, TimelineEventFilter* filter); void PrintTraceEvent(JSONStream* js, TimelineEventFilter* filter); +#endif const char* name() const { return "Endless"; } @@ -830,7 +853,9 @@ class TimelineEventEndlessRecorder : public TimelineEventRecorder { TimelineEventBlock* GetHeadBlockLocked(); void Clear(); +#ifndef PRODUCT void PrintJSONEvents(JSONArray* array, TimelineEventFilter* filter); +#endif TimelineEventBlock* head_; intptr_t block_index_; @@ -865,8 +890,10 @@ class TimelineEventPlatformRecorder : public TimelineEventRecorder { TimelineEventPlatformRecorder(); virtual ~TimelineEventPlatformRecorder(); +#ifndef PRODUCT void PrintJSON(JSONStream* js, TimelineEventFilter* filter); void PrintTraceEvent(JSONStream* js, TimelineEventFilter* filter); +#endif // Called when |event| is completed. It is unsafe to keep a reference to // |event| as it may be freed as soon as this function returns. diff --git a/runtime/vm/timeline_android.cc b/runtime/vm/timeline_android.cc index cd316ebd961..5ca038bd6c0 100644 --- a/runtime/vm/timeline_android.cc +++ b/runtime/vm/timeline_android.cc @@ -2,8 +2,8 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. -#include "platform/globals.h" -#if defined(HOST_OS_ANDROID) && !defined(PRODUCT) +#include "vm/globals.h" +#if defined(HOST_OS_ANDROID) && defined(SUPPORT_TIMELINE) #include #include diff --git a/runtime/vm/timeline_fuchsia.cc b/runtime/vm/timeline_fuchsia.cc index f39cc20c8f1..9c0dab495b7 100644 --- a/runtime/vm/timeline_fuchsia.cc +++ b/runtime/vm/timeline_fuchsia.cc @@ -2,8 +2,8 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. -#include "platform/globals.h" -#if defined(HOST_OS_FUCHSIA) && !defined(PRODUCT) +#include "vm/globals.h" +#if defined(HOST_OS_FUCHSIA) && defined(SUPPORT_TIMELINE) #include #include diff --git a/runtime/vm/timeline_linux.cc b/runtime/vm/timeline_linux.cc index c1c5d531912..ed9ff7f2568 100644 --- a/runtime/vm/timeline_linux.cc +++ b/runtime/vm/timeline_linux.cc @@ -2,8 +2,8 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. -#include "platform/globals.h" -#if defined(HOST_OS_LINUX) && !defined(PRODUCT) +#include "vm/globals.h" +#if defined(HOST_OS_LINUX) && defined(SUPPORT_TIMELINE) #include #include diff --git a/sdk/lib/developer/timeline.dart b/sdk/lib/developer/timeline.dart index 37ae997806c..4853f4a7221 100644 --- a/sdk/lib/developer/timeline.dart +++ b/sdk/lib/developer/timeline.dart @@ -4,7 +4,8 @@ part of dart.developer; -const bool _isProduct = const bool.fromEnvironment("dart.vm.product"); +const bool _hasTimeline = + const bool.fromEnvironment("dart.developer.timeline", defaultValue: true); /// A typedef for the function argument to [Timeline.timeSync]. typedef dynamic TimelineSyncFunction(); @@ -100,7 +101,7 @@ class Timeline { /// a [Flow] event. This operation must be finished before /// returning to the event queue. static void startSync(String name, {Map arguments, Flow flow}) { - if (_isProduct) return; + if (!_hasTimeline) return; ArgumentError.checkNotNull(name, 'name'); if (!_isDartStreamEnabled()) { // Push a null onto the stack and return. @@ -119,7 +120,7 @@ class Timeline { /// Finish the last synchronous operation that was started. static void finishSync() { - if (_isProduct) { + if (!_hasTimeline) { return; } if (_stack.length == 0) { @@ -137,7 +138,7 @@ class Timeline { /// Emit an instant event. static void instantSync(String name, {Map arguments}) { - if (_isProduct) return; + if (!_hasTimeline) return; ArgumentError.checkNotNull(name, 'name'); if (!_isDartStreamEnabled()) { // Stream is disabled. @@ -187,7 +188,7 @@ class TimelineTask { /// Start a synchronous operation within this task named [name]. /// Optionally takes a [Map] of [arguments]. void start(String name, {Map arguments}) { - if (_isProduct) return; + if (!_hasTimeline) return; ArgumentError.checkNotNull(name, 'name'); var block = new _AsyncBlock._(name, _taskId); if (arguments != null) { @@ -199,7 +200,7 @@ class TimelineTask { /// Emit an instant event for this task. void instant(String name, {Map arguments}) { - if (_isProduct) return; + if (!_hasTimeline) return; ArgumentError.checkNotNull(name, 'name'); Map instantArguments; if (arguments != null) { @@ -211,7 +212,7 @@ class TimelineTask { /// Finish the last synchronous operation that was started. void finish() { - if (_isProduct) { + if (!_hasTimeline) { return; } if (_stack.length == 0) {