Add more compilation stats to optimizing

Optimizing is getting closer to have full coverage and this provides a
nice overview on why certain methods are not compiled/optimized.

Also, clean up some of the builder methods.

Change-Id: Id2f31441a788b797b0efea7ec78bee27bb654186
diff --git a/compiler/optimizing/builder.h b/compiler/optimizing/builder.h
index 73c2f50..75c8634 100644
--- a/compiler/optimizing/builder.h
+++ b/compiler/optimizing/builder.h
@@ -21,6 +21,7 @@
 #include "dex_file-inl.h"
 #include "driver/compiler_driver.h"
 #include "driver/dex_compilation_unit.h"
+#include "optimizing_compiler_stats.h"
 #include "primitive.h"
 #include "utils/arena_object.h"
 #include "utils/growable_array.h"
@@ -36,7 +37,8 @@
   HGraphBuilder(ArenaAllocator* arena,
                 DexCompilationUnit* dex_compilation_unit,
                 const DexFile* dex_file,
-                CompilerDriver* driver)
+                CompilerDriver* driver,
+                OptimizingCompilerStats* compiler_stats)
       : arena_(arena),
         branch_targets_(arena, 0),
         locals_(arena, 0),
@@ -51,7 +53,8 @@
         compiler_driver_(driver),
         return_type_(Primitive::GetType(dex_compilation_unit_->GetShorty()[0])),
         code_start_(nullptr),
-        latest_result_(nullptr) {}
+        latest_result_(nullptr),
+        compilation_stats_(compiler_stats) {}
 
   // Only for unit testing.
   HGraphBuilder(ArenaAllocator* arena, Primitive::Type return_type = Primitive::kPrimInt)
@@ -69,7 +72,8 @@
         compiler_driver_(nullptr),
         return_type_(return_type),
         code_start_(nullptr),
-        latest_result_(nullptr) {}
+        latest_result_(nullptr),
+        compilation_stats_(nullptr) {}
 
   HGraph* BuildGraph(const DexFile::CodeItem& code);
 
@@ -205,16 +209,22 @@
                       uint32_t dex_pc);
 
   // Builds an instruction sequence for a packed switch statement.
-  bool BuildPackedSwitch(const Instruction& instruction, uint32_t dex_pc);
+  void BuildPackedSwitch(const Instruction& instruction, uint32_t dex_pc);
 
   // Builds an instruction sequence for a sparse switch statement.
-  bool BuildSparseSwitch(const Instruction& instruction, uint32_t dex_pc);
+  void BuildSparseSwitch(const Instruction& instruction, uint32_t dex_pc);
 
   void BuildSwitchCaseHelper(const Instruction& instruction, size_t index,
                              bool is_last_case, const SwitchTable& table,
                              HInstruction* value, int32_t case_value_int,
                              int32_t target_offset, uint32_t dex_pc);
 
+  bool SkipCompilation(size_t number_of_dex_instructions,
+                       size_t number_of_blocks,
+                       size_t number_of_branches);
+
+  void MaybeRecordStat(MethodCompilationStat compilation_stat);
+
   ArenaAllocator* const arena_;
 
   // A list of the size of the dex code holding block information for
@@ -245,6 +255,8 @@
   // used by move-result instructions.
   HInstruction* latest_result_;
 
+  OptimizingCompilerStats* compilation_stats_;
+
   DISALLOW_COPY_AND_ASSIGN(HGraphBuilder);
 };