Index: runtime/vm/compiler.cc |
diff --git a/runtime/vm/compiler.cc b/runtime/vm/compiler.cc |
index fcab75e3fefb12fe47cbdf506932f92cfbc41682..39c88460c22a3de60ed4eb5bdcf5f9cb367a938c 100644 |
--- a/runtime/vm/compiler.cc |
+++ b/runtime/vm/compiler.cc |
@@ -275,7 +275,7 @@ RawError* Compiler::CompileClass(const Class& cls) { |
Thread* const thread = Thread::Current(); |
StackZone zone(thread); |
-#ifndef PRODUCT |
+NOT_IN_PRODUCT( |
VMTagScope tagScope(thread, VMTag::kCompileClassTagId); |
TimelineDurationScope tds(thread, |
thread->isolate()->GetCompilerStream(), |
@@ -284,7 +284,7 @@ RawError* Compiler::CompileClass(const Class& cls) { |
tds.SetNumArguments(1); |
tds.CopyArgument(0, "class", cls.ToCString()); |
} |
-#endif // !PRODUCT |
+) // !PRODUCT |
// We remember all the classes that are being compiled in these lists. This |
// also allows us to reset the marked_for_parsing state in case we see an |
@@ -563,9 +563,8 @@ bool CompileParsedFunctionHelper::Compile(CompilationPipeline* pipeline) { |
} |
bool is_compiled = false; |
Zone* const zone = thread()->zone(); |
-#ifndef PRODUCT |
- TimelineStream* compiler_timeline = isolate()->GetCompilerStream(); |
-#endif |
+ NOT_IN_PRODUCT( |
+ TimelineStream* compiler_timeline = isolate()->GetCompilerStream()); |
CSTAT_TIMER_SCOPE(thread(), codegen_timer); |
HANDLESCOPE(thread()); |
@@ -627,11 +626,9 @@ bool CompileParsedFunctionHelper::Compile(CompilationPipeline* pipeline) { |
} |
} |
-#ifndef PRODUCT |
- TimelineDurationScope tds(thread(), |
- compiler_timeline, |
- "BuildFlowGraph"); |
-#endif // !PRODUCT |
+ NOT_IN_PRODUCT(TimelineDurationScope tds(thread(), |
+ compiler_timeline, |
+ "BuildFlowGraph");) |
flow_graph = pipeline->BuildFlowGraph(zone, |
parsed_function(), |
*ic_data_array, |
@@ -655,20 +652,15 @@ bool CompileParsedFunctionHelper::Compile(CompilationPipeline* pipeline) { |
const bool reorder_blocks = |
FlowGraph::ShouldReorderBlocks(function, optimized()); |
if (reorder_blocks) { |
-#ifndef PRODUCT |
- TimelineDurationScope tds(thread(), |
- compiler_timeline, |
- "BlockScheduler::AssignEdgeWeights"); |
-#endif // !PRODUCT |
+ NOT_IN_PRODUCT(TimelineDurationScope tds( |
+ thread(), compiler_timeline, "BlockScheduler::AssignEdgeWeights")); |
block_scheduler.AssignEdgeWeights(); |
} |
if (optimized()) { |
-#ifndef PRODUCT |
- TimelineDurationScope tds(thread(), |
- compiler_timeline, |
- "ComputeSSA"); |
-#endif // !PRODUCT |
+ NOT_IN_PRODUCT(TimelineDurationScope tds(thread(), |
+ compiler_timeline, |
+ "ComputeSSA")); |
CSTAT_TIMER_SCOPE(thread(), ssa_timer); |
// Transform to SSA (virtual register 0 and no inlining arguments). |
flow_graph->ComputeSSA(0, NULL); |
@@ -687,11 +679,9 @@ bool CompileParsedFunctionHelper::Compile(CompilationPipeline* pipeline) { |
// have non-generic type feedback attached to them that can |
// potentially affect optimizations. |
if (optimized()) { |
-#ifndef PRODUCT |
- TimelineDurationScope tds(thread(), |
- compiler_timeline, |
- "OptimizationPasses"); |
-#endif // !PRODUCT |
+ NOT_IN_PRODUCT(TimelineDurationScope tds(thread(), |
+ compiler_timeline, |
+ "OptimizationPasses")); |
inline_id_to_function.Add(&function); |
// Top scope function has no caller (-1). |
caller_inline_id.Add(-1); |
@@ -712,11 +702,9 @@ bool CompileParsedFunctionHelper::Compile(CompilationPipeline* pipeline) { |
// Inlining (mutates the flow graph) |
if (FLAG_use_inlining) { |
-#ifndef PRODUCT |
- TimelineDurationScope tds2(thread(), |
- compiler_timeline, |
- "Inlining"); |
-#endif // !PRODUCT |
+ NOT_IN_PRODUCT(TimelineDurationScope tds2(thread(), |
+ compiler_timeline, |
+ "Inlining")); |
CSTAT_TIMER_SCOPE(thread(), graphinliner_timer); |
// Propagate types to create more inlining opportunities. |
FlowGraphTypePropagator::Propagate(flow_graph); |
@@ -741,11 +729,9 @@ bool CompileParsedFunctionHelper::Compile(CompilationPipeline* pipeline) { |
DEBUG_ASSERT(flow_graph->VerifyUseLists()); |
{ |
-#ifndef PRODUCT |
- TimelineDurationScope tds2(thread(), |
- compiler_timeline, |
- "ApplyClassIds"); |
-#endif // !PRODUCT |
+ NOT_IN_PRODUCT(TimelineDurationScope tds2(thread(), |
+ compiler_timeline, |
+ "ApplyClassIds")); |
// Use propagated class-ids to optimize further. |
optimizer.ApplyClassIds(); |
DEBUG_ASSERT(flow_graph->VerifyUseLists()); |
@@ -765,11 +751,9 @@ bool CompileParsedFunctionHelper::Compile(CompilationPipeline* pipeline) { |
DEBUG_ASSERT(flow_graph->VerifyUseLists()); |
{ |
-#ifndef PRODUCT |
- TimelineDurationScope tds2(thread(), |
- compiler_timeline, |
- "BranchSimplifier"); |
-#endif // !PRODUCT |
+ NOT_IN_PRODUCT(TimelineDurationScope tds2(thread(), |
+ compiler_timeline, |
+ "BranchSimplifier")); |
BranchSimplifier::Simplify(flow_graph); |
DEBUG_ASSERT(flow_graph->VerifyUseLists()); |
@@ -778,12 +762,10 @@ bool CompileParsedFunctionHelper::Compile(CompilationPipeline* pipeline) { |
} |
if (FLAG_constant_propagation) { |
-#ifndef PRODUCT |
- TimelineDurationScope tds2(thread(), |
- compiler_timeline, |
- "ConstantPropagation"); |
-#endif // !PRODUCT |
- ConstantPropagator::Optimize(flow_graph); |
+ NOT_IN_PRODUCT(TimelineDurationScope tds2(thread(), |
+ compiler_timeline, |
+ "ConstantPropagation"); |
+ ConstantPropagator::Optimize(flow_graph)); |
DEBUG_ASSERT(flow_graph->VerifyUseLists()); |
// A canonicalization pass to remove e.g. smi checks on smi constants. |
flow_graph->Canonicalize(); |
@@ -809,11 +791,9 @@ bool CompileParsedFunctionHelper::Compile(CompilationPipeline* pipeline) { |
DEBUG_ASSERT(flow_graph->VerifyUseLists()); |
{ |
-#ifndef PRODUCT |
- TimelineDurationScope tds2(thread(), |
- compiler_timeline, |
- "SelectRepresentations"); |
-#endif // !PRODUCT |
+ NOT_IN_PRODUCT(TimelineDurationScope tds2(thread(), |
+ compiler_timeline, |
+ "SelectRepresentations")); |
// Where beneficial convert Smi operations into Int32 operations. |
// Only meanigful for 32bit platforms right now. |
flow_graph->WidenSmiToInt32(); |
@@ -826,11 +806,8 @@ bool CompileParsedFunctionHelper::Compile(CompilationPipeline* pipeline) { |
} |
{ |
-#ifndef PRODUCT |
- TimelineDurationScope tds2(thread(), |
- compiler_timeline, |
- "CommonSubexpressionElinination"); |
-#endif // !PRODUCT |
+ NOT_IN_PRODUCT(TimelineDurationScope tds2( |
+ thread(), compiler_timeline, "CommonSubexpressionElinination")); |
if (FLAG_common_subexpression_elimination || |
FLAG_loop_invariant_code_motion) { |
flow_graph->ComputeBlockEffects(); |
@@ -868,20 +845,16 @@ bool CompileParsedFunctionHelper::Compile(CompilationPipeline* pipeline) { |
DEBUG_ASSERT(flow_graph->VerifyUseLists()); |
{ |
-#ifndef PRODUCT |
- TimelineDurationScope tds2(thread(), |
- compiler_timeline, |
- "DeadStoreElimination"); |
-#endif // !PRODUCT |
+ NOT_IN_PRODUCT(TimelineDurationScope tds2(thread(), |
+ compiler_timeline, |
+ "DeadStoreElimination")); |
DeadStoreElimination::Optimize(flow_graph); |
} |
if (FLAG_range_analysis) { |
-#ifndef PRODUCT |
- TimelineDurationScope tds2(thread(), |
- compiler_timeline, |
- "RangeAnalysis"); |
-#endif // !PRODUCT |
+ NOT_IN_PRODUCT(TimelineDurationScope tds2(thread(), |
+ compiler_timeline, |
+ "RangeAnalysis")); |
// Propagate types after store-load-forwarding. Some phis may have |
// become smi phis that can be processed by range analysis. |
FlowGraphTypePropagator::Propagate(flow_graph); |
@@ -896,11 +869,9 @@ bool CompileParsedFunctionHelper::Compile(CompilationPipeline* pipeline) { |
} |
if (FLAG_constant_propagation) { |
-#ifndef PRODUCT |
- TimelineDurationScope tds2(thread(), |
- compiler_timeline, |
- "ConstantPropagator::OptimizeBranches"); |
-#endif // !PRODUCT |
+ NOT_IN_PRODUCT(TimelineDurationScope tds2( |
+ thread(), compiler_timeline, |
+ "ConstantPropagator::OptimizeBranches")); |
// Constant propagation can use information from range analysis to |
// find unreachable branch targets and eliminate branches that have |
// the same true- and false-target. |
@@ -914,11 +885,8 @@ bool CompileParsedFunctionHelper::Compile(CompilationPipeline* pipeline) { |
DEBUG_ASSERT(flow_graph->VerifyUseLists()); |
{ |
-#ifndef PRODUCT |
- TimelineDurationScope tds2(thread(), |
- compiler_timeline, |
- "TryCatchAnalyzer::Optimize"); |
-#endif // !PRODUCT |
+ NOT_IN_PRODUCT(TimelineDurationScope tds2( |
+ thread(), compiler_timeline, "TryCatchAnalyzer::Optimize")); |
// Optimize try-blocks. |
TryCatchAnalyzer::Optimize(flow_graph); |
} |
@@ -929,11 +897,9 @@ bool CompileParsedFunctionHelper::Compile(CompilationPipeline* pipeline) { |
flow_graph->EliminateEnvironments(); |
{ |
-#ifndef PRODUCT |
- TimelineDurationScope tds2(thread(), |
- compiler_timeline, |
- "EliminateDeadPhis"); |
-#endif // !PRODUCT |
+ NOT_IN_PRODUCT(TimelineDurationScope tds2(thread(), |
+ compiler_timeline, |
+ "EliminateDeadPhis")); |
DeadCodeElimination::EliminateDeadPhis(flow_graph); |
DEBUG_ASSERT(flow_graph->VerifyUseLists()); |
} |
@@ -947,11 +913,8 @@ bool CompileParsedFunctionHelper::Compile(CompilationPipeline* pipeline) { |
AllocationSinking* sinking = NULL; |
if (FLAG_allocation_sinking && |
(flow_graph->graph_entry()->SuccessorCount() == 1)) { |
-#ifndef PRODUCT |
- TimelineDurationScope tds2(thread(), |
- compiler_timeline, |
- "AllocationSinking::Optimize"); |
-#endif // !PRODUCT |
+ NOT_IN_PRODUCT(TimelineDurationScope tds2( |
+ thread(), compiler_timeline, "AllocationSinking::Optimize")); |
// TODO(fschneider): Support allocation sinking with try-catch. |
sinking = new AllocationSinking(flow_graph); |
sinking->Optimize(); |
@@ -965,11 +928,9 @@ bool CompileParsedFunctionHelper::Compile(CompilationPipeline* pipeline) { |
DEBUG_ASSERT(flow_graph->VerifyUseLists()); |
{ |
-#ifndef PRODUCT |
- TimelineDurationScope tds2(thread(), |
- compiler_timeline, |
- "SelectRepresentations"); |
-#endif // !PRODUCT |
+ NOT_IN_PRODUCT(TimelineDurationScope tds2(thread(), |
+ compiler_timeline, |
+ "SelectRepresentations")); |
// Ensure that all phis inserted by optimization passes have |
// consistent representations. |
flow_graph->SelectRepresentations(); |
@@ -986,12 +947,9 @@ bool CompileParsedFunctionHelper::Compile(CompilationPipeline* pipeline) { |
DEBUG_ASSERT(flow_graph->VerifyUseLists()); |
if (sinking != NULL) { |
-#ifndef PRODUCT |
- TimelineDurationScope tds2( |
- thread(), |
- compiler_timeline, |
- "AllocationSinking::DetachMaterializations"); |
-#endif // !PRODUCT |
+ NOT_IN_PRODUCT(TimelineDurationScope tds2( |
+ thread(), compiler_timeline, |
+ "AllocationSinking::DetachMaterializations")); |
// Remove all MaterializeObject instructions inserted by allocation |
// sinking from the flow graph and let them float on the side |
// referenced only from environments. Register allocator will consider |
@@ -1004,22 +962,17 @@ bool CompileParsedFunctionHelper::Compile(CompilationPipeline* pipeline) { |
FlowGraphInliner::CollectGraphInfo(flow_graph, true); |
{ |
-#ifndef PRODUCT |
- TimelineDurationScope tds2(thread(), |
- compiler_timeline, |
- "AllocateRegisters"); |
-#endif // !PRODUCT |
+ NOT_IN_PRODUCT(TimelineDurationScope tds2(thread(), |
+ compiler_timeline, |
+ "AllocateRegisters")); |
// Perform register allocation on the SSA graph. |
FlowGraphAllocator allocator(*flow_graph); |
allocator.AllocateRegisters(); |
} |
if (reorder_blocks) { |
-#ifndef PRODUCT |
- TimelineDurationScope tds(thread(), |
- compiler_timeline, |
- "BlockScheduler::ReorderBlocks"); |
-#endif // !PRODUCT |
+ NOT_IN_PRODUCT(TimelineDurationScope tds( |
+ thread(), compiler_timeline, "BlockScheduler::ReorderBlocks")); |
block_scheduler.ReorderBlocks(); |
} |
@@ -1036,20 +989,16 @@ bool CompileParsedFunctionHelper::Compile(CompilationPipeline* pipeline) { |
caller_inline_id); |
{ |
CSTAT_TIMER_SCOPE(thread(), graphcompiler_timer); |
-#ifndef PRODUCT |
- TimelineDurationScope tds(thread(), |
- compiler_timeline, |
- "CompileGraph"); |
-#endif // !PRODUCT |
+ NOT_IN_PRODUCT(TimelineDurationScope tds(thread(), |
+ compiler_timeline, |
+ "CompileGraph")); |
graph_compiler.CompileGraph(); |
pipeline->FinalizeCompilation(); |
} |
{ |
-#ifndef PRODUCT |
- TimelineDurationScope tds(thread(), |
- compiler_timeline, |
- "FinalizeCompilation"); |
-#endif // !PRODUCT |
+ NOT_IN_PRODUCT(TimelineDurationScope tds(thread(), |
+ compiler_timeline, |
+ "FinalizeCompilation")); |
if (thread()->IsMutatorThread()) { |
FinalizeCompilation(&assembler, &graph_compiler, flow_graph); |
} else { |
@@ -1114,7 +1063,7 @@ bool CompileParsedFunctionHelper::Compile(CompilationPipeline* pipeline) { |
} |
-#if defined(DEBUG) |
+DEBUG_ONLY( |
// Verifies that the inliner is always in the list of inlined functions. |
// If this fails run with --trace-inlining-intervals to get more information. |
static void CheckInliningIntervals(const Function& function) { |
@@ -1132,8 +1081,7 @@ static void CheckInliningIntervals(const Function& function) { |
function.raw()); |
} |
} |
-#endif |
- |
+) |
static RawError* CompileFunctionHelper(CompilationPipeline* pipeline, |
const Function& function, |
@@ -1229,9 +1177,7 @@ static RawError* CompileFunctionHelper(CompilationPipeline* pipeline, |
Disassembler::DisassembleCode(function, true); |
THR_Print("*** END CODE\n"); |
} |
-#if defined(DEBUG) |
- CheckInliningIntervals(function); |
-#endif |
+ DEBUG_ONLY(CheckInliningIntervals(function)); |
return Error::null(); |
} else { |
Thread* const thread = Thread::Current(); |