Fix relation between debuggable / JIT zygote.

- Move the logic to clear precompiled in ClassLinker.
- Add a null check on entries in ZygoteMap
- Avoid doing JIT zygote actions (precompile, remapping boot images)
when debuggable.

Test: android.jdwptunnel.cts.JdwpTunnelTest#testAttachDebuggerToProfileableApp
Change-Id: I9b5e391bb35aa04bbeba01b9b563b33f96395d2e
diff --git a/runtime/runtime.cc b/runtime/runtime.cc
index 1a83372..b62cd11 100644
--- a/runtime/runtime.cc
+++ b/runtime/runtime.cc
@@ -2829,6 +2829,20 @@
           !m.IsProxyMethod()) {
         instrumentation_->UpdateMethodsCodeForJavaDebuggable(&m, GetQuickToInterpreterBridge());
       }
+
+      if (Runtime::Current()->GetJit() != nullptr &&
+          Runtime::Current()->GetJit()->GetCodeCache()->IsInZygoteExecSpace(code) &&
+          !m.IsNative()) {
+        DCHECK(!m.IsProxyMethod());
+        instrumentation_->UpdateMethodsCodeForJavaDebuggable(&m, GetQuickToInterpreterBridge());
+      }
+
+      if (m.IsPreCompiled()) {
+        // Precompilation is incompatible with debuggable, so clear the flag
+        // and update the entrypoint in case it has been compiled.
+        m.ClearPreCompiled();
+        instrumentation_->UpdateMethodsCodeForJavaDebuggable(&m, GetQuickToInterpreterBridge());
+      }
     }
     return true;
   }