Remove MethodHelper::HasSameNameAndSignature.

Move sole use to a static method with art_method.cc.

Change-Id: I2e7994cc1c31b5ca74df5d7be5538003d4ed0150
diff --git a/runtime/class_linker.cc b/runtime/class_linker.cc
index 52e6662..04e2992 100644
--- a/runtime/class_linker.cc
+++ b/runtime/class_linker.cc
@@ -43,7 +43,7 @@
 #include "intern_table.h"
 #include "interpreter/interpreter.h"
 #include "leb128.h"
-#include "method_helper-inl.h"
+#include "method_helper.h"
 #include "oat.h"
 #include "oat_file.h"
 #include "object_lock.h"
diff --git a/runtime/method_helper-inl.h b/runtime/method_helper-inl.h
deleted file mode 100644
index 2c18205..0000000
--- a/runtime/method_helper-inl.h
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef ART_RUNTIME_METHOD_HELPER_INL_H_
-#define ART_RUNTIME_METHOD_HELPER_INL_H_
-
-#include "method_helper.h"
-
-#include "class_linker.h"
-#include "dex_file-inl.h"
-
-namespace art {
-
-template <template <class T> class HandleKind>
-template <template <class T2> class HandleKind2>
-inline bool MethodHelperT<HandleKind>::HasSameNameAndSignature(MethodHelperT<HandleKind2>* other) {
-  const DexFile* dex_file = method_->GetDexFile();
-  const DexFile::MethodId& mid = dex_file->GetMethodId(GetMethod()->GetDexMethodIndex());
-  if (method_->GetDexCache() == other->method_->GetDexCache()) {
-    const DexFile::MethodId& other_mid =
-        dex_file->GetMethodId(other->GetMethod()->GetDexMethodIndex());
-    return mid.name_idx_ == other_mid.name_idx_ && mid.proto_idx_ == other_mid.proto_idx_;
-  }
-  const DexFile* other_dex_file = other->method_->GetDexFile();
-  const DexFile::MethodId& other_mid =
-      other_dex_file->GetMethodId(other->GetMethod()->GetDexMethodIndex());
-  if (!DexFileStringEquals(dex_file, mid.name_idx_, other_dex_file, other_mid.name_idx_)) {
-    return false;  // Name mismatch.
-  }
-  return dex_file->GetMethodSignature(mid) == other_dex_file->GetMethodSignature(other_mid);
-}
-
-}  // namespace art
-
-#endif  // ART_RUNTIME_METHOD_HELPER_INL_H_
diff --git a/runtime/method_helper.cc b/runtime/method_helper.cc
index 9ca29ce..4e634c8 100644
--- a/runtime/method_helper.cc
+++ b/runtime/method_helper.cc
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-#include "method_helper-inl.h"
+#include "method_helper.h"
 
 #include "class_linker.h"
 #include "dex_file-inl.h"
diff --git a/runtime/method_helper.h b/runtime/method_helper.h
index babcc83..44c6913 100644
--- a/runtime/method_helper.h
+++ b/runtime/method_helper.h
@@ -99,10 +99,6 @@
   }
 
   template <template <class T> class HandleKind2>
-  ALWAYS_INLINE bool HasSameNameAndSignature(MethodHelperT<HandleKind2>* other)
-      SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
-
-  template <template <class T> class HandleKind2>
   bool HasSameSignatureWithDifferentClassLoaders(Thread* self, MethodHelperT<HandleKind2>* other)
       SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
 
diff --git a/runtime/mirror/art_method.cc b/runtime/mirror/art_method.cc
index 0f13344..6350bd9 100644
--- a/runtime/mirror/art_method.cc
+++ b/runtime/mirror/art_method.cc
@@ -29,7 +29,7 @@
 #include "interpreter/interpreter.h"
 #include "jni_internal.h"
 #include "mapping_table.h"
-#include "method_helper-inl.h"
+#include "method_helper.h"
 #include "object_array-inl.h"
 #include "object_array.h"
 #include "object-inl.h"
@@ -93,7 +93,7 @@
 
 void ArtMethod::SetClass(Class* java_lang_reflect_ArtMethod) {
   CHECK(java_lang_reflect_ArtMethod_.IsNull());
-  CHECK(java_lang_reflect_ArtMethod != NULL);
+  CHECK(java_lang_reflect_ArtMethod != nullptr);
   java_lang_reflect_ArtMethod_ = GcRoot<Class>(java_lang_reflect_ArtMethod);
 }
 
@@ -116,14 +116,31 @@
   return num_registers;
 }
 
+static bool HasSameNameAndSignature(ArtMethod* method1, ArtMethod* method2)
+    SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
+  ScopedAssertNoThreadSuspension ants(Thread::Current(), "HasSameNameAndSignature");
+  const DexFile* dex_file = method1->GetDexFile();
+  const DexFile::MethodId& mid = dex_file->GetMethodId(method1->GetDexMethodIndex());
+  if (method1->GetDexCache() == method2->GetDexCache()) {
+    const DexFile::MethodId& mid2 = dex_file->GetMethodId(method2->GetDexMethodIndex());
+    return mid.name_idx_ == mid2.name_idx_ && mid.proto_idx_ == mid2.proto_idx_;
+  }
+  const DexFile* dex_file2 = method2->GetDexFile();
+  const DexFile::MethodId& mid2 = dex_file2->GetMethodId(method2->GetDexMethodIndex());
+  if (!DexFileStringEquals(dex_file, mid.name_idx_, dex_file2, mid2.name_idx_)) {
+    return false;  // Name mismatch.
+  }
+  return dex_file->GetMethodSignature(mid) == dex_file2->GetMethodSignature(mid2);
+}
+
 ArtMethod* ArtMethod::FindOverriddenMethod() {
   if (IsStatic()) {
-    return NULL;
+    return nullptr;
   }
   Class* declaring_class = GetDeclaringClass();
   Class* super_class = declaring_class->GetSuperClass();
   uint16_t method_index = GetMethodIndex();
-  ArtMethod* result = NULL;
+  ArtMethod* result = nullptr;
   // Did this method override a super class method? If so load the result from the super class'
   // vtable
   if (super_class->HasVTable() && method_index < super_class->GetVTableLength()) {
@@ -135,16 +152,13 @@
       CHECK_EQ(result,
                Runtime::Current()->GetClassLinker()->FindMethodForProxy(GetDeclaringClass(), this));
     } else {
-      StackHandleScope<2> hs(Thread::Current());
-      MethodHelper mh(hs.NewHandle(this));
-      MutableMethodHelper interface_mh(hs.NewHandle<mirror::ArtMethod>(nullptr));
       IfTable* iftable = GetDeclaringClass()->GetIfTable();
-      for (size_t i = 0; i < iftable->Count() && result == NULL; i++) {
+      for (size_t i = 0; i < iftable->Count() && result == nullptr; i++) {
         Class* interface = iftable->GetInterface(i);
         for (size_t j = 0; j < interface->NumVirtualMethods(); ++j) {
-          interface_mh.ChangeMethod(interface->GetVirtualMethod(j));
-          if (mh.HasSameNameAndSignature(&interface_mh)) {
-            result = interface_mh.GetMethod();
+          mirror::ArtMethod* interface_method = interface->GetVirtualMethod(j);
+          if (HasSameNameAndSignature(this, interface_method)) {
+            result = interface_method;
             break;
           }
         }
@@ -152,10 +166,7 @@
     }
   }
   if (kIsDebugBuild) {
-    StackHandleScope<2> hs(Thread::Current());
-    MethodHelper result_mh(hs.NewHandle(result));
-    MethodHelper this_mh(hs.NewHandle(this));
-    DCHECK(result == nullptr || this_mh.HasSameNameAndSignature(&result_mh));
+    DCHECK(result == nullptr || HasSameNameAndSignature(this, result));
   }
   return result;
 }
@@ -448,7 +459,7 @@
       }
     } else {
       LOG(INFO) << "Not invoking '" << PrettyMethod(this) << "' code=null";
-      if (result != NULL) {
+      if (result != nullptr) {
         result->SetJ(0);
       }
     }
@@ -521,7 +532,7 @@
 void ArtMethod::RegisterNative(const void* native_method, bool is_fast) {
   CHECK(IsNative()) << PrettyMethod(this);
   CHECK(!IsFastNative()) << PrettyMethod(this);
-  CHECK(native_method != NULL) << PrettyMethod(this);
+  CHECK(native_method != nullptr) << PrettyMethod(this);
   if (is_fast) {
     SetAccessFlags(GetAccessFlags() | kAccFastNative);
   }
diff --git a/runtime/mirror/object_test.cc b/runtime/mirror/object_test.cc
index 4402031..25b3144 100644
--- a/runtime/mirror/object_test.cc
+++ b/runtime/mirror/object_test.cc
@@ -34,7 +34,7 @@
 #include "gc/heap.h"
 #include "handle_scope-inl.h"
 #include "iftable-inl.h"
-#include "method_helper-inl.h"
+#include "method_helper.h"
 #include "object-inl.h"
 #include "object_array-inl.h"
 #include "scoped_thread_state_change.h"
@@ -528,26 +528,6 @@
   EXPECT_STREQ(m3_2->GetName(), "m3");
   ArtMethod* m4_2 = klass2->GetVirtualMethod(3);
   EXPECT_STREQ(m4_2->GetName(), "m4");
-
-  MutableMethodHelper mh(hs.NewHandle(m1_1));
-  MutableMethodHelper mh2(hs.NewHandle(m1_2));
-  EXPECT_TRUE(mh.HasSameNameAndSignature(&mh2));
-  EXPECT_TRUE(mh2.HasSameNameAndSignature(&mh));
-
-  mh.ChangeMethod(m2_1);
-  mh2.ChangeMethod(m2_2);
-  EXPECT_TRUE(mh.HasSameNameAndSignature(&mh2));
-  EXPECT_TRUE(mh2.HasSameNameAndSignature(&mh));
-
-  mh.ChangeMethod(m3_1);
-  mh2.ChangeMethod(m3_2);
-  EXPECT_TRUE(mh.HasSameNameAndSignature(&mh2));
-  EXPECT_TRUE(mh2.HasSameNameAndSignature(&mh));
-
-  mh.ChangeMethod(m4_1);
-  mh2.ChangeMethod(m4_2);
-  EXPECT_TRUE(mh.HasSameNameAndSignature(&mh2));
-  EXPECT_TRUE(mh2.HasSameNameAndSignature(&mh));
 }
 
 TEST_F(ObjectTest, StringHashCode) {
diff --git a/runtime/thread.h b/runtime/thread.h
index b69d2f4..5b3e746 100644
--- a/runtime/thread.h
+++ b/runtime/thread.h
@@ -1189,7 +1189,7 @@
 
  private:
   Thread* const self_;
-  const char* old_cause_;
+  const char* const old_cause_;
 };
 
 std::ostream& operator<<(std::ostream& os, const Thread& thread);