Clear PreCompiled when we transition to debuggable after zygote fork

We were leaving the PreCompiled bits set on method objects. This meant
that in some circumstances non-debuggable compiled code could be
reattached to methods after the switch to debuggable with the zygote
fork.

Bug: 144947842
Test: atest CtsJvmtiRunTest1982HostTestCases
Change-Id: I1f642f6da441c4f023ec1cbd873c05914c73dd7e
diff --git a/runtime/jit/jit_code_cache.cc b/runtime/jit/jit_code_cache.cc
index fb11a05..2415a9f 100644
--- a/runtime/jit/jit_code_cache.cc
+++ b/runtime/jit/jit_code_cache.cc
@@ -879,13 +879,26 @@
   }
 }
 
-void JitCodeCache::ClearEntryPointsInZygoteExecSpace() {
-  MutexLock mu(Thread::Current(), *Locks::jit_lock_);
-  for (const auto& it : method_code_map_) {
-    ArtMethod* method = it.second;
-    if (IsInZygoteExecSpace(method->GetEntryPointFromQuickCompiledCode())) {
+void JitCodeCache::TransitionToDebuggable() {
+  {
+    MutexLock mu(Thread::Current(), *Locks::jit_lock_);
+    for (const auto& it : method_code_map_) {
+      ArtMethod* method = it.second;
+      if (IsInZygoteExecSpace(method->GetEntryPointFromQuickCompiledCode())) {
+        method->SetEntryPointFromQuickCompiledCode(GetQuickToInterpreterBridge());
+      }
+      // We don't want any pre-compiled data being selected.
+      method->ClearPreCompiled();
+    }
+  }
+  for (const auto& entry : zygote_map_) {
+    ArtMethod* method = entry.method;
+    if (ContainsPc(method->GetEntryPointFromQuickCompiledCode())) {
+      DCHECK(IsInZygoteExecSpace(method->GetEntryPointFromQuickCompiledCode()));
+      DCHECK(method->IsPreCompiled());
       method->SetEntryPointFromQuickCompiledCode(GetQuickToInterpreterBridge());
     }
+    method->ClearPreCompiled();
   }
 }