Fix JIT crash due to unverified dead code

The JIT compiler assumes that it only gets completely verified code. To
work around potential unverified dead code it uses kAccDontBotherCompile
flag set during runtime verification. However, if a class is verified
during a prior dex2oat the flag is not persisted and JIT happily things
that everything is ok.

The simplest fix is to mark classes with potential unverified dex code
as verify at runtime. We only do this for apps and assume that
everything in the boot image is well formed.

Test: m test-art-host
Bug: 31000839
Change-Id: I092d2e9553cd1c577036d78e8563a7a39d6cb7b9
diff --git a/test/common/runtime_state.cc b/test/common/runtime_state.cc
index 285f3aa..f26e122 100644
--- a/test/common/runtime_state.cc
+++ b/test/common/runtime_state.cc
@@ -188,4 +188,28 @@
   return method->HasSingleImplementation();
 }
 
+extern "C" JNIEXPORT int JNICALL Java_Main_getHotnessCounter(JNIEnv* env,
+                                                             jclass,
+                                                             jclass cls,
+                                                             jstring method_name) {
+  jit::Jit* jit = Runtime::Current()->GetJit();
+  if (jit == nullptr) {
+    // The hotness counter is valid only under JIT.
+    // If we don't JIT return 0 to match test expectations.
+    return 0;
+  }
+
+  ArtMethod* method = nullptr;
+  {
+    ScopedObjectAccess soa(Thread::Current());
+
+    ScopedUtfChars chars(env, method_name);
+    CHECK(chars.c_str() != nullptr);
+    method = soa.Decode<mirror::Class>(cls)->FindDeclaredDirectMethodByName(
+        chars.c_str(), kRuntimePointerSize);
+  }
+
+  return method->GetCounter();
+}
+
 }  // namespace art