From 10e244f9e7f6d96a95c910a2bedef5bd3810c637 Mon Sep 17 00:00:00 2001 From: Calin Juravle Date: Mon, 26 Jan 2015 18:54:32 +0000 Subject: optimizing: NullCheck elimination How it works: - run a type analysis to propagate null information on instructions - during the last instruction simplifier remove null checks for which the input is known to be not null The current type analysis is actually a nullability analysis but it will be reused in follow up CLs to propagate type information: so it keeps the more convenient name. Change-Id: I54bb1d32ab24604b4d677d1ecdaf8d60a5ff5ce9 --- compiler/optimizing/optimizing_compiler.cc | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) (limited to 'compiler/optimizing/optimizing_compiler.cc') diff --git a/compiler/optimizing/optimizing_compiler.cc b/compiler/optimizing/optimizing_compiler.cc index 4f05afa1a6..705345b279 100644 --- a/compiler/optimizing/optimizing_compiler.cc +++ b/compiler/optimizing/optimizing_compiler.cc @@ -43,6 +43,7 @@ #include "ssa_builder.h" #include "ssa_phi_elimination.h" #include "ssa_liveness_analysis.h" +#include "reference_type_propagation.h" #include "utils/arena_allocator.h" namespace art { @@ -196,6 +197,18 @@ static bool CanOptimize(const DexFile::CodeItem& code_item) { return code_item.tries_size_ == 0; } +static void RunOptimizations(HOptimization* optimizations[], + size_t length, + const HGraphVisualizer& visualizer) { + for (size_t i = 0; i < length; ++i) { + HOptimization* optimization = optimizations[i]; + visualizer.DumpGraph(optimization->GetPassName(), /*is_after=*/false); + optimization->Run(); + visualizer.DumpGraph(optimization->GetPassName(), /*is_after=*/true); + optimization->Check(); + } +} + static void RunOptimizations(HGraph* graph, CompilerDriver* driver, OptimizingCompilerStats* stats, @@ -213,7 +226,8 @@ static void RunOptimizations(HGraph* graph, SideEffectsAnalysis side_effects(graph); GVNOptimization gvn(graph, side_effects); BoundsCheckElimination bce(graph); - InstructionSimplifier simplify2(graph); + ReferenceTypePropagation type_propagation(graph); + InstructionSimplifier simplify2(graph, "instruction_simplifier_after_types"); IntrinsicsRecognizer intrinsics(graph, dex_compilation_unit.GetDexFile(), driver); @@ -229,16 +243,11 @@ static void RunOptimizations(HGraph* graph, &side_effects, &gvn, &bce, + &type_propagation, &simplify2 }; - for (size_t i = 0; i < arraysize(optimizations); ++i) { - HOptimization* optimization = optimizations[i]; - visualizer.DumpGraph(optimization->GetPassName(), /*is_after=*/false); - optimization->Run(); - visualizer.DumpGraph(optimization->GetPassName(), /*is_after=*/true); - optimization->Check(); - } + RunOptimizations(optimizations, arraysize(optimizations), visualizer); } // The stack map we generate must be 4-byte aligned on ARM. Since existing -- cgit v1.2.3-59-g8ed1b