Check whether method is zygote-compiled less frequently.

Move the check to MaybeCompileMethod which means
it will do the look-up only once per 32 invokes.

More importantly, it means the interpreter can
use the invoke fast-path for pre-compiled methods.

Bug: 119800099
Change-Id: Id10cdb7d3717807f60e3d3c71ca943ede8104f36
diff --git a/runtime/jit/jit-inl.h b/runtime/jit/jit-inl.h
index ee70cdf..80324ad 100644
--- a/runtime/jit/jit-inl.h
+++ b/runtime/jit/jit-inl.h
@@ -35,9 +35,6 @@
                             ArtMethod* method,
                             uint16_t samples,
                             bool with_backedges) {
-  if (method->IsPreCompiled()) {
-    return;
-  }
   if (Jit::ShouldUsePriorityThreadWeight(self)) {
     samples *= PriorityThreadWeight();
   }
diff --git a/runtime/jit/jit.cc b/runtime/jit/jit.cc
index 737acda..0b1cd77 100644
--- a/runtime/jit/jit.cc
+++ b/runtime/jit/jit.cc
@@ -870,6 +870,13 @@
   if (thread_pool_ == nullptr) {
     return false;
   }
+  if (UNLIKELY(method->IsPreCompiled()) && !with_backedges /* don't check for OSR */) {
+    const void* code_ptr = code_cache_->GetZygoteMap()->GetCodeFor(method);
+    if (code_ptr != nullptr) {
+      Runtime::Current()->GetInstrumentation()->UpdateMethodsCode(method, code_ptr);
+      return true;
+    }
+  }
   if (IgnoreSamplesForMethod(method)) {
     return false;
   }
@@ -971,14 +978,6 @@
     return;
   }
 
-  if (UNLIKELY(method->IsPreCompiled())) {
-    const void* code_ptr = code_cache_->GetZygoteMap()->GetCodeFor(method);
-    if (code_ptr != nullptr) {
-      Runtime::Current()->GetInstrumentation()->UpdateMethodsCode(method, code_ptr);
-      return;
-    }
-  }
-
   ProfilingInfo* profiling_info = method->GetProfilingInfo(kRuntimePointerSize);
   // Update the entrypoint if the ProfilingInfo has one. The interpreter will call it
   // instead of interpreting the method. We don't update it for instrumentation as the entrypoint