Invoke static/direct dispatch change.

There was a subtle race in static/direct dispatch via the code and methods
table. This patch removes the table in preparation of architectures like
x86 which will more aggressively sink loads.

Removes unused fields, code.. Brings back resolved methods table
short-cut and associated fast paths to use this (such as in Proxy). Adds
a resolution method that is used as the trampoline for static and direct
methods.

Add source file and line number to Throwable::Dump.

MethodHelper knowledge of runtime methods.

Change-Id: Ieae1b74c24072e6327a5bb2cad466f04e3c46c4d
diff --git a/src/object_utils.h b/src/object_utils.h
index 0e0d7de..b9d8a24 100644
--- a/src/object_utils.h
+++ b/src/object_utils.h
@@ -399,11 +399,28 @@
   }
   const char* GetName() {
     const DexFile& dex_file = GetDexFile();
-    return dex_file.GetMethodName(dex_file.GetMethodId(method_->GetDexMethodIndex()));
+    uint32_t dex_method_idx = method_->GetDexMethodIndex();
+    if (dex_method_idx != DexFile::kDexNoIndex16) {
+      return dex_file.GetMethodName(dex_file.GetMethodId(dex_method_idx));
+    } else {
+      Runtime* runtime = Runtime::Current();
+      if (method_ == runtime->GetResolutionMethod()) {
+        return "<VM internal resolution method>";
+      } else if (method_ == runtime->GetCalleeSaveMethod(Runtime::kSaveAll)) {
+        return "<VM internal callee-save all registers method>";
+      } else if (method_ == runtime->GetCalleeSaveMethod(Runtime::kRefsOnly)) {
+        return "<VM internal callee-save reference registers method>";
+      } else if (method_ == runtime->GetCalleeSaveMethod(Runtime::kRefsAndArgs)) {
+        return "<VM internal callee-save reference and argument registers method>";
+      } else {
+        return "<unknown VM internal method>";
+      }
+    }
   }
   String* GetNameAsString() {
     const DexFile& dex_file = GetDexFile();
-    const DexFile::MethodId& method_id = dex_file.GetMethodId(method_->GetDexMethodIndex());
+    uint32_t dex_method_idx = method_->GetDexMethodIndex();
+    const DexFile::MethodId& method_id = dex_file.GetMethodId(dex_method_idx);
     return GetClassLinker()->ResolveString(dex_file, method_id.name_idx_, GetDexCache());
   }
   const char* GetShorty() {
@@ -424,7 +441,12 @@
   }
   const std::string GetSignature() {
     const DexFile& dex_file = GetDexFile();
-    return dex_file.GetMethodSignature(dex_file.GetMethodId(method_->GetDexMethodIndex()));
+    uint32_t dex_method_idx = method_->GetDexMethodIndex();
+    if (dex_method_idx != DexFile::kDexNoIndex16) {
+      return dex_file.GetMethodSignature(dex_file.GetMethodId(dex_method_idx));
+    } else {
+      return "<no signature>";
+    }
   }
   const DexFile::ProtoId& GetPrototype() {
     const DexFile& dex_file = GetDexFile();
@@ -558,8 +580,11 @@
     if (method != NULL) {
       Class* klass = method->GetDeclaringClass();
       if (klass->IsProxyClass()) {
-        method = GetClassLinker()->FindMethodForProxy(klass, method);
-        CHECK(method != NULL);
+        Method* interface_method =
+            method->GetDexCacheResolvedMethods()->Get(method->GetDexMethodIndex());
+        CHECK(interface_method != NULL);
+        CHECK(interface_method == GetClassLinker()->FindMethodForProxy(klass, method));
+        method = interface_method;
       }
     }
     method_ = method;