Remove dexCacheResolvedMethods from Method/Constructor

This short-cut is no longer directly accessed via compiled code.

Also fix compiler_test which requires isFinalizable to be explicitly
compiled when Object.<init> is handled in managed code.

Change-Id: I028cf0fc8fa25a44df4adacc7c686ade413a5a42
diff --git a/src/class_linker.cc b/src/class_linker.cc
index 62d3df7..bfdc3b1 100644
--- a/src/class_linker.cc
+++ b/src/class_linker.cc
@@ -1517,7 +1517,6 @@
 
   dst->SetDexCacheStrings(klass->GetDexCache()->GetStrings());
   dst->SetDexCacheResolvedTypes(klass->GetDexCache()->GetResolvedTypes());
-  dst->SetDexCacheResolvedMethods(klass->GetDexCache()->GetResolvedMethods());
   dst->SetDexCacheCodeAndDirectMethods(klass->GetDexCache()->GetCodeAndDirectMethods());
   dst->SetDexCacheInitializedStaticStorage(klass->GetDexCache()->GetInitializedStaticStorage());
 }
@@ -2168,7 +2167,8 @@
 Method* ClassLinker::CreateProxyMethod(SirtRef<Class>& klass, SirtRef<Method>& prototype) {
   // Ensure prototype is in dex cache so that we can use the dex cache to look up the overridden
   // prototype method
-  prototype->GetDexCacheResolvedMethods()->Set(prototype->GetDexMethodIndex(), prototype.get());
+  klass->GetDexCache()->SetResolvedMethod(prototype->GetDexMethodIndex(),
+                                          prototype.get());
   // We steal everything from the prototype (such as DexCache, invoke stub, etc.) then specialize
   // as necessary
   Method* method = down_cast<Method*>(prototype->Clone());
diff --git a/src/class_linker.h b/src/class_linker.h
index 0b16533..297cee7 100644
--- a/src/class_linker.h
+++ b/src/class_linker.h
@@ -158,10 +158,10 @@
                         bool is_direct);
 
   Method* ResolveMethod(uint32_t method_idx, const Method* referrer, bool is_direct) {
-    Method* resolved_method = referrer->GetDexCacheResolvedMethods()->Get(method_idx);
+    Class* declaring_class = referrer->GetDeclaringClass();
+    DexCache* dex_cache = declaring_class->GetDexCache();
+    Method* resolved_method = dex_cache->GetResolvedMethod(method_idx);
     if (UNLIKELY(resolved_method == NULL)) {
-      Class* declaring_class = referrer->GetDeclaringClass();
-      DexCache* dex_cache = declaring_class->GetDexCache();
       const ClassLoader* class_loader = declaring_class->GetClassLoader();
       const DexFile& dex_file = FindDexFile(dex_cache);
       resolved_method = ResolveMethod(dex_file, method_idx, dex_cache, class_loader, is_direct);
@@ -170,11 +170,10 @@
   }
 
   Field* ResolveField(uint32_t field_idx, const Method* referrer, bool is_static) {
-    Field* resolved_field =
-        referrer->GetDeclaringClass()->GetDexCache()->GetResolvedField(field_idx);
+    Class* declaring_class = referrer->GetDeclaringClass();
+    DexCache* dex_cache = declaring_class->GetDexCache();
+    Field* resolved_field = dex_cache->GetResolvedField(field_idx);
     if (UNLIKELY(resolved_field == NULL)) {
-      Class* declaring_class = referrer->GetDeclaringClass();
-      DexCache* dex_cache = declaring_class->GetDexCache();
       const ClassLoader* class_loader = declaring_class->GetClassLoader();
       const DexFile& dex_file = FindDexFile(dex_cache);
       resolved_field = ResolveField(dex_file, field_idx, dex_cache, class_loader, is_static);
@@ -194,11 +193,10 @@
                       bool is_static);
 
   Field* ResolveFieldJLS(uint32_t field_idx, const Method* referrer) {
-    Field* resolved_field =
-        referrer->GetDeclaringClass()->GetDexCache()->GetResolvedField(field_idx);
+    Class* declaring_class = referrer->GetDeclaringClass();
+    DexCache* dex_cache = declaring_class->GetDexCache();
+    Field* resolved_field = dex_cache->GetResolvedField(field_idx);
     if (UNLIKELY(resolved_field == NULL)) {
-      Class* declaring_class = referrer->GetDeclaringClass();
-      DexCache* dex_cache = declaring_class->GetDexCache();
       const ClassLoader* class_loader = declaring_class->GetClassLoader();
       const DexFile& dex_file = FindDexFile(dex_cache);
       resolved_field = ResolveFieldJLS(dex_file, field_idx, dex_cache, class_loader);
diff --git a/src/class_linker_test.cc b/src/class_linker_test.cc
index e9a94a9..9f63c5e 100644
--- a/src/class_linker_test.cc
+++ b/src/class_linker_test.cc
@@ -139,15 +139,12 @@
 
     EXPECT_TRUE(method->GetDexCacheStrings() != NULL);
     EXPECT_TRUE(method->GetDexCacheResolvedTypes() != NULL);
-    EXPECT_TRUE(method->GetDexCacheResolvedMethods() != NULL);
     EXPECT_TRUE(method->GetDexCacheCodeAndDirectMethods() != NULL);
     EXPECT_TRUE(method->GetDexCacheInitializedStaticStorage() != NULL);
     EXPECT_EQ(method->GetDeclaringClass()->GetDexCache()->GetStrings(),
               method->GetDexCacheStrings());
     EXPECT_EQ(method->GetDeclaringClass()->GetDexCache()->GetResolvedTypes(),
               method->GetDexCacheResolvedTypes());
-    EXPECT_EQ(method->GetDeclaringClass()->GetDexCache()->GetResolvedMethods(),
-              method->GetDexCacheResolvedMethods());
     EXPECT_EQ(method->GetDeclaringClass()->GetDexCache()->GetCodeAndDirectMethods(),
               method->GetDexCacheCodeAndDirectMethods());
     EXPECT_EQ(method->GetDeclaringClass()->GetDexCache()->GetInitializedStaticStorage(),
@@ -446,7 +443,6 @@
     offsets.push_back(CheckOffset(OFFSETOF_MEMBER(Method, declaring_class_),                      "declaringClass"));
     offsets.push_back(CheckOffset(OFFSETOF_MEMBER(Method, dex_cache_code_and_direct_methods_),    "dexCacheCodeAndDirectMethods"));
     offsets.push_back(CheckOffset(OFFSETOF_MEMBER(Method, dex_cache_initialized_static_storage_), "dexCacheInitializedStaticStorage"));
-    offsets.push_back(CheckOffset(OFFSETOF_MEMBER(Method, dex_cache_resolved_methods_),           "dexCacheResolvedMethods"));
     offsets.push_back(CheckOffset(OFFSETOF_MEMBER(Method, dex_cache_resolved_types_),             "dexCacheResolvedTypes"));
     offsets.push_back(CheckOffset(OFFSETOF_MEMBER(Method, dex_cache_strings_),                    "dexCacheStrings"));
 
diff --git a/src/compiler_test.cc b/src/compiler_test.cc
index 76a39a4..2257f87 100644
--- a/src/compiler_test.cc
+++ b/src/compiler_test.cc
@@ -139,6 +139,7 @@
 }
 
 TEST_F(CompilerTest, AbstractMethodErrorStub) {
+  CompileVirtualMethod(NULL, "java.lang.Class", "isFinalizable", "()Z");
   CompileDirectMethod(NULL, "java.lang.Object", "<init>", "()V");
 
   SirtRef<ClassLoader> class_loader(LoadDex("AbstractMethod"));
diff --git a/src/object.cc b/src/object.cc
index bb87698..a8493ef 100644
--- a/src/object.cc
+++ b/src/object.cc
@@ -355,16 +355,6 @@
                  new_dex_cache_classes, false);
 }
 
-ObjectArray<Method>* Method::GetDexCacheResolvedMethods() const {
-  return GetFieldObject<ObjectArray<Method>*>(
-      OFFSET_OF_OBJECT_MEMBER(Method, dex_cache_resolved_methods_), false);
-}
-
-void Method::SetDexCacheResolvedMethods(ObjectArray<Method>* new_dex_cache_methods) {
-  SetFieldObject(OFFSET_OF_OBJECT_MEMBER(Method, dex_cache_resolved_methods_),
-                 new_dex_cache_methods, false);
-}
-
 CodeAndDirectMethods* Method::GetDexCacheCodeAndDirectMethods() const {
   return GetFieldPtr<CodeAndDirectMethods*>(
       OFFSET_OF_OBJECT_MEMBER(Method, dex_cache_code_and_direct_methods_),
diff --git a/src/object.h b/src/object.h
index 738d2b0..6092ce4 100644
--- a/src/object.h
+++ b/src/object.h
@@ -604,9 +604,6 @@
   ObjectArray<Class>* GetDexCacheResolvedTypes() const;
   void SetDexCacheResolvedTypes(ObjectArray<Class>* new_dex_cache_types);
 
-  ObjectArray<Method>* GetDexCacheResolvedMethods() const;
-  void SetDexCacheResolvedMethods(ObjectArray<Method>* new_dex_cache_methods);
-
   CodeAndDirectMethods* GetDexCacheCodeAndDirectMethods() const;
   void SetDexCacheCodeAndDirectMethods(CodeAndDirectMethods* new_value);
 
@@ -792,10 +789,6 @@
     return OFFSET_OF_OBJECT_MEMBER(Method, dex_cache_code_and_direct_methods_);
   }
 
-  static MemberOffset GetDexCacheResolvedMethodsOffset() {
-    return OFFSET_OF_OBJECT_MEMBER(Method, dex_cache_resolved_methods_);
-  }
-
   static MemberOffset GetMethodIndexOffset() {
     return OFFSET_OF_OBJECT_MEMBER(Method, method_index_);
   }
@@ -868,9 +861,6 @@
   ObjectArray<StaticStorageBase>* dex_cache_initialized_static_storage_;
 
   // short cuts to declaring_class_->dex_cache_ member for fast compiled code access
-  ObjectArray<Method>* dex_cache_resolved_methods_;
-
-  // short cuts to declaring_class_->dex_cache_ member for fast compiled code access
   ObjectArray<Class>* dex_cache_resolved_types_;
 
   // short cuts to declaring_class_->dex_cache_ member for fast compiled code access
diff --git a/src/object_utils.h b/src/object_utils.h
index e2d9b88..2286f7f 100644
--- a/src/object_utils.h
+++ b/src/object_utils.h
@@ -561,7 +561,7 @@
     if (method != NULL) {
       Class* klass = method->GetDeclaringClass();
       if (klass->IsProxyClass()) {
-        method = method->GetDexCacheResolvedMethods()->Get(method->GetDexMethodIndex());
+        method = klass->GetDexCache()->GetResolvedMethod(method->GetDexMethodIndex());
         CHECK(method != NULL);
       }
     }
diff --git a/src/runtime_support.cc b/src/runtime_support.cc
index 14b14e0..889414f 100644
--- a/src/runtime_support.cc
+++ b/src/runtime_support.cc
@@ -1037,7 +1037,7 @@
     FinishCalleeSaveFrameSetup(self, sp, Runtime::kRefsOnly);
     ClassLinker* class_linker = Runtime::Current()->GetClassLinker();
     Method* method = class_linker->ResolveMethod(method_idx, referrer, is_direct);
-    referrer->GetDexCacheResolvedMethods()->Set(method_idx, method);
+    referrer->GetDeclaringClass()->GetDexCache()->SetResolvedMethod(method_idx, method);
     return method;
 }