Reland "Refactor code in inliner."

This reverts commit aa1b711a40bfe92785f52bff9700dc516eba1d09.

Reason for revert: Fix wrong method being recorded as CHA dependency.

Change-Id: Ic8ed84979b4cd67e49b96166792729b3b586cc25
diff --git a/compiler/optimizing/inliner.h b/compiler/optimizing/inliner.h
index 241c63b..e98a66b 100644
--- a/compiler/optimizing/inliner.h
+++ b/compiler/optimizing/inliner.h
@@ -72,24 +72,13 @@
 
   bool TryInline(HInvoke* invoke_instruction);
 
-  // Attempt to resolve the target of the invoke instruction to an acutal call
-  // target.
-  //
-  // Returns the target directly in the case of static or direct invokes.
-  // Otherwise, uses CHA devirtualization or other methods to try to find the
-  // call target.
-  ArtMethod* FindActualCallTarget(HInvoke* invoke_instruction, bool* cha_devirtualize)
-    REQUIRES_SHARED(Locks::mutator_lock_);
-
   // Try to inline `resolved_method` in place of `invoke_instruction`. `do_rtp` is whether
   // reference type propagation can run after the inlining. If the inlining is successful, this
-  // method will replace and remove the `invoke_instruction`. If `cha_devirtualize` is true,
-  // a CHA guard needs to be added for the inlining.
+  // method will replace and remove the `invoke_instruction`.
   bool TryInlineAndReplace(HInvoke* invoke_instruction,
                            ArtMethod* resolved_method,
                            ReferenceTypeInfo receiver_type,
-                           bool do_rtp,
-                           bool cha_devirtualize)
+                           bool do_rtp)
     REQUIRES_SHARED(Locks::mutator_lock_);
 
   bool TryBuildAndInline(HInvoke* invoke_instruction,
@@ -170,6 +159,17 @@
   bool TryInlineFromInlineCache(HInvoke* invoke_instruction)
     REQUIRES_SHARED(Locks::mutator_lock_);
 
+  // Try inlining the invoke instruction using CHA.
+  bool TryInlineFromCHA(HInvoke* invoke_instruction)
+    REQUIRES_SHARED(Locks::mutator_lock_);
+
+  // When we fail inlining `invoke_instruction`, we will try to devirtualize the
+  // call.
+  bool TryDevirtualize(HInvoke* invoke_instruction,
+                       ArtMethod* method,
+                       HInvoke** replacement)
+    REQUIRES_SHARED(Locks::mutator_lock_);
+
   // Try getting the inline cache from JIT code cache.
   // Return true if the inline cache was successfully allocated and the
   // invoke info was found in the profile info.
@@ -215,7 +215,7 @@
   // Try CHA-based devirtualization to change virtual method calls into
   // direct calls.
   // Returns the actual method that resolved_method can be devirtualized to.
-  ArtMethod* TryCHADevirtualization(ArtMethod* resolved_method)
+  ArtMethod* FindMethodFromCHA(ArtMethod* resolved_method)
     REQUIRES_SHARED(Locks::mutator_lock_);
 
   // Add a CHA guard for a CHA-based devirtualized call. A CHA guard checks a
@@ -230,13 +230,17 @@
                                            uint32_t dex_pc) const
     REQUIRES_SHARED(Locks::mutator_lock_);
 
+  void MaybeRunReferenceTypePropagation(HInstruction* replacement,
+                                        HInvoke* invoke_instruction)
+    REQUIRES_SHARED(Locks::mutator_lock_);
+
   void FixUpReturnReferenceType(ArtMethod* resolved_method, HInstruction* return_replacement)
     REQUIRES_SHARED(Locks::mutator_lock_);
 
   bool ArgumentTypesMoreSpecific(HInvoke* invoke_instruction, ArtMethod* resolved_method)
     REQUIRES_SHARED(Locks::mutator_lock_);
 
-  bool ReturnTypeMoreSpecific(HInvoke* invoke_instruction, HInstruction* return_replacement)
+  bool ReturnTypeMoreSpecific(HInstruction* return_replacement, HInvoke* invoke_instruction)
     REQUIRES_SHARED(Locks::mutator_lock_);
 
   // Add a type guard on the given `receiver`. This will add to the graph: