Remove ArtMethod's declaring class state checks.

This check was not very useful because the Class is already
in a state to pass the check when we're constructing the
ArtMethod and it can never revert to an earlier state, so
the check is essentially a weak protection against GC bugs.
Besides not being very useful, the check had the ability to
invalidate ObjPtr<> cookies (when called in non-runnable
state), making it difficult to fully ObjPtr<>-ify the code.

Also remove a lot of kReadBarrierOption template parameters
which were needed specifically for this check. This removes
unnecessary maintence burden as shown by past bugs dealing
with carefully adding those parameters where necessary.

Test: m test-art-host-gtest
Test: testrunner.py --host --optimizing
Bug: 74373650
Bug: 31113334
Change-Id: I87f2999fc4e7c27b5c2307139269b4b5f6649d16
diff --git a/runtime/art_method.cc b/runtime/art_method.cc
index 80b6921..68ccfee 100644
--- a/runtime/art_method.cc
+++ b/runtime/art_method.cc
@@ -59,8 +59,6 @@
 extern "C" void art_quick_invoke_static_stub(ArtMethod*, uint32_t*, uint32_t, Thread*, JValue*,
                                              const char*);
 
-DEFINE_RUNTIME_DEBUG_FLAG(ArtMethod, kCheckDeclaringClassState);
-
 // Enforce that we he have the right index for runtime methods.
 static_assert(ArtMethod::kRuntimeMethodDexMethodIndex == dex::kDexNoIndex,
               "Wrong runtime-method dex method index");
@@ -90,18 +88,13 @@
   }
 }
 
-template <ReadBarrierOption kReadBarrierOption>
 ArtMethod* ArtMethod::GetSingleImplementation(PointerSize pointer_size) {
-  if (!IsAbstract<kReadBarrierOption>()) {
+  if (!IsAbstract()) {
     // A non-abstract's single implementation is itself.
     return this;
   }
   return reinterpret_cast<ArtMethod*>(GetDataPtrSize(pointer_size));
 }
-template ArtMethod* ArtMethod::GetSingleImplementation<ReadBarrierOption::kWithReadBarrier>(
-    PointerSize pointer_size);
-template ArtMethod* ArtMethod::GetSingleImplementation<ReadBarrierOption::kWithoutReadBarrier>(
-    PointerSize pointer_size);
 
 ArtMethod* ArtMethod::FromReflectedMethod(const ScopedObjectAccessAlreadyRunnable& soa,
                                           jobject jlr_method) {
@@ -801,25 +794,4 @@
         method->GetDeclaringClass<kReadBarrierOption>()->IsErroneous());
 }
 
-template <ReadBarrierOption kReadBarrierOption> void ArtMethod::GetAccessFlagsDCheck() {
-  if (kCheckDeclaringClassState) {
-    Thread* self = Thread::Current();
-    if (!Locks::mutator_lock_->IsSharedHeld(self)) {
-      if (self->IsThreadSuspensionAllowable()) {
-        ScopedObjectAccess soa(self);
-        CHECK(IsRuntimeMethod() ||
-              GetDeclaringClass<kReadBarrierOption>()->IsIdxLoaded() ||
-              GetDeclaringClass<kReadBarrierOption>()->IsErroneous());
-      }
-    } else {
-      // We cannot use SOA in this case. We might be holding the lock, but may not be in the
-      // runnable state (e.g., during GC).
-      Locks::mutator_lock_->AssertSharedHeld(self);
-      DoGetAccessFlagsHelper<kReadBarrierOption>(this);
-    }
-  }
-}
-template void ArtMethod::GetAccessFlagsDCheck<ReadBarrierOption::kWithReadBarrier>();
-template void ArtMethod::GetAccessFlagsDCheck<ReadBarrierOption::kWithoutReadBarrier>();
-
 }  // namespace art