Special case JIT update for native methods.
The update might apply to ArtMethods that are going to be
unloaded, so ensure we don't do read barriers there.
Test: while ./art/test/run-test --host --no-dex2oat --jit --host --no-prebuild \
--compact-dex-level none --dex2oat-jobs 4 --no-relocate --runtime-option -Xcheck:jni \
--build-with-javac-dx 674-hiddenapi ; do true; done
Change-Id: I95ec6107c65da25f4b98f7fb77647b3ab382a93f
diff --git a/runtime/jit/jit_code_cache.cc b/runtime/jit/jit_code_cache.cc
index 3d3e61b..7f04477 100644
--- a/runtime/jit/jit_code_cache.cc
+++ b/runtime/jit/jit_code_cache.cc
@@ -1699,7 +1699,9 @@
// can avoid a few expensive GenericJNI calls.
instrumentation::Instrumentation* instrumentation = Runtime::Current()->GetInstrumentation();
for (ArtMethod* m : data->GetMethods()) {
- instrumentation->UpdateMethodsCode(m, entrypoint);
+ // Call the dedicated method instead of the more generic UpdateMethodsCode, because
+ // `m` might be in the process of being deleted.
+ instrumentation->UpdateNativeMethodsCodeToJitCode(m, entrypoint);
}
if (collection_in_progress_) {
GetLiveBitmap()->AtomicTestAndSet(FromCodeToAllocation(data->GetCode()));