If a collection is in progress, we need to mark new code.
Otherwise, the GC will collect it.
This got accidentally removed here:
https://android-review.googlesource.com/c/platform/art/+/719573
Bug: 136108889
Test: test.py
Change-Id: I00a803b7fe8220bd84f55c039d6d0e52b1469459
diff --git a/runtime/jit/jit_code_cache.cc b/runtime/jit/jit_code_cache.cc
index 82ca44c..c02a699 100644
--- a/runtime/jit/jit_code_cache.cc
+++ b/runtime/jit/jit_code_cache.cc
@@ -767,6 +767,11 @@
method, method_header->GetEntryPoint());
}
}
+ if (collection_in_progress_) {
+ // We need to update the live bitmap if there is a GC to ensure it sees this new
+ // code.
+ GetLiveBitmap()->AtomicTestAndSet(FromCodeToAllocation(code_ptr));
+ }
VLOG(jit)
<< "JIT added (osr=" << std::boolalpha << osr << std::noboolalpha << ") "
<< ArtMethod::PrettyMethod(method) << "@" << method