Revert "Revert "Support for inlining virtual and interface calls.""

It now works thanks to:
- https://android-review.googlesource.com/#/c/154016/ where
  the invoke type is changed.
- The new FindMethodIndexIn method in this change, that
  locates the right method index relative to the caller's
  dex file.

This reverts commit 6e4758615308bb525b6350c30468e33a2e1f2274.

Change-Id: Iddba11664a9241e210fec211cd2aed9f4b90d118
diff --git a/compiler/optimizing/optimizing_compiler.cc b/compiler/optimizing/optimizing_compiler.cc
index f6ef2f7..bf0b9fa 100644
--- a/compiler/optimizing/optimizing_compiler.cc
+++ b/compiler/optimizing/optimizing_compiler.cc
@@ -326,7 +326,7 @@
   InstructionSimplifier simplify1(graph, stats);
   HBooleanSimplifier boolean_simplify(graph);
 
-  HInliner inliner(graph, dex_compilation_unit, dex_compilation_unit, driver, stats);
+  HInliner inliner(graph, dex_compilation_unit, dex_compilation_unit, driver, handles, stats);
 
   HConstantFolding fold2(graph, "constant_folding_after_inlining");
   SideEffectsAnalysis side_effects(graph);
@@ -335,6 +335,8 @@
   BoundsCheckElimination bce(graph);
   ReferenceTypePropagation type_propagation(graph, handles);
   InstructionSimplifier simplify2(graph, stats, "instruction_simplifier_after_types");
+  InstructionSimplifier simplify3(graph, stats, "last_instruction_simplifier");
+  ReferenceTypePropagation type_propagation2(graph, handles);
 
   IntrinsicsRecognizer intrinsics(graph, driver);
 
@@ -343,7 +345,12 @@
     &dce1,
     &fold1,
     &simplify1,
+    &type_propagation,
+    &simplify2,
     &inliner,
+    // Run another type propagation phase: inlining will open up more opprotunities
+    // to remove checkast/instanceof and null checks.
+    &type_propagation2,
     // BooleanSimplifier depends on the InstructionSimplifier removing redundant
     // suspend checks to recognize empty blocks.
     &boolean_simplify,
@@ -352,8 +359,7 @@
     &gvn,
     &licm,
     &bce,
-    &type_propagation,
-    &simplify2,
+    &simplify3,
     &dce2,
   };