Enable devirtualization for abstract and sub-class methods.

If we know the type of a receiver in the verifier we record devirtualization
data. Currently we only use this data to avoid virtual method dispatch when
we know the receiver of a method isn't a sub-class. This change allows
devirtualization of virtual and interface methods when we know the receiver's
type and the method the we'd find via dispatch is either known within boot or
has a reference from the current dex file.

Pass the receiver through to the method resolution trampoline as
devirtualization may mean the dex method index needs to be made more accurate
for the receiver.

Tidy up method devirtualization and related statistics.

Push the devirtualization map lookup into a less common case to avoid
taking its lock.

Make MethodReference a struct rather than a typedef of a pair, so the members
can have more meaningful names than first and second.

Rough statistics show that we devirtualize using this change around 2.5% of
the time, whilst some apps like GMS core devirtualize over 3.4% of the time.

Change-Id: Ieed3471dbedfc4cc881d652631b67176bb37d394
diff --git a/src/compiler/llvm/gbc_expander.cc b/src/compiler/llvm/gbc_expander.cc
index 99c8fd5..bdf9aca 100644
--- a/src/compiler/llvm/gbc_expander.cc
+++ b/src/compiler/llvm/gbc_expander.cc
@@ -776,7 +776,8 @@
   art::InvokeType invoke_type =
       static_cast<art::InvokeType>(LV2UInt(call_inst.getArgOperand(0)));
   bool is_static = (invoke_type == art::kStatic);
-  uint32_t callee_method_idx = LV2UInt(call_inst.getArgOperand(1));
+  art::CompilerDriver::MethodReference target_method(dex_compilation_unit_->GetDexFile(),
+                                                     LV2UInt(call_inst.getArgOperand(1)));
 
   // Load *this* actual parameter
   llvm::Value* this_addr = (!is_static) ? call_inst.getArgOperand(3) : NULL;
@@ -785,18 +786,17 @@
   int vtable_idx = -1;
   uintptr_t direct_code = 0;
   uintptr_t direct_method = 0;
-  // TODO: pass actual value of dex PC (instead of kDexPCNotready) needed by verifier based
-  // sharpening after LLVM re-factoring is finished.
-  bool is_fast_path = driver_->
-      ComputeInvokeInfo(callee_method_idx, art::kDexPCNotReady, dex_compilation_unit_,
-                        invoke_type, vtable_idx, direct_code, direct_method);
-
+  bool is_fast_path = driver_->ComputeInvokeInfo(dex_compilation_unit_, dex_pc,
+                                                 invoke_type, target_method,
+                                                 vtable_idx,
+                                                 direct_code, direct_method,
+                                                 true);
   // Load the method object
   llvm::Value* callee_method_object_addr = NULL;
 
   if (!is_fast_path) {
     callee_method_object_addr =
-        EmitCallRuntimeForCalleeMethodObjectAddr(callee_method_idx, invoke_type,
+        EmitCallRuntimeForCalleeMethodObjectAddr(target_method.dex_method_index, invoke_type,
                                                  this_addr, dex_pc, is_fast_path);
   } else {
     switch (invoke_type) {
@@ -809,7 +809,7 @@
                                   irb_.getJObjectTy());
         } else {
           callee_method_object_addr =
-              EmitLoadSDCalleeMethodObjectAddr(callee_method_idx);
+              EmitLoadSDCalleeMethodObjectAddr(target_method.dex_method_index);
         }
         break;
 
@@ -826,7 +826,7 @@
 
       case art::kInterface:
         callee_method_object_addr =
-            EmitCallRuntimeForCalleeMethodObjectAddr(callee_method_idx,
+            EmitCallRuntimeForCalleeMethodObjectAddr(target_method.dex_method_index,
                                                      invoke_type, this_addr,
                                                      dex_pc, is_fast_path);
         break;
@@ -844,7 +844,7 @@
 
   llvm::Value* code_addr;
   llvm::Type* func_type = GetFunctionType(call_inst.getType(),
-                                          callee_method_idx, is_static);
+                                          target_method.dex_method_index, is_static);
   if (direct_code != 0u && direct_code != static_cast<uintptr_t>(-1)) {
     code_addr =
         irb_.CreateIntToPtr(irb_.getPtrEquivInt(direct_code),