summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author David Srbecky <dsrbecky@google.com> 2019-04-24 10:32:04 +0100
committer David Srbecky <dsrbecky@google.com> 2019-04-26 15:01:21 +0000
commitc45b5897e65d8713f008732277db2544b9af1e67 (patch)
tree1d193616a402f6d21f730bff8ac9377b4ae1896e
parent2cd21b20345c2733bda1366830ffd767f0682b9f (diff)
jitzygote: JIT native methods on first use.
Compile JNI stub on first use to avoid the expensive generic stub. Test: profile calendar Bug: 119800099 Change-Id: Iaef9d0d528ff34c1636237cdcce6e8639c47c8ed
-rw-r--r--runtime/jit/jit.cc7
-rw-r--r--runtime/jit/jit_code_cache.cc5
2 files changed, 10 insertions, 2 deletions
diff --git a/runtime/jit/jit.cc b/runtime/jit/jit.cc
index 25c747eed0..f8d51c6d8a 100644
--- a/runtime/jit/jit.cc
+++ b/runtime/jit/jit.cc
@@ -815,6 +815,13 @@ bool Jit::MaybeCompileMethod(Thread* self,
}
}
if (UseJitCompilation()) {
+ if (old_count == 0 &&
+ method->IsNative() &&
+ Runtime::Current()->IsUsingApexBootImageLocation()) {
+ // jitzygote: Compile JNI stub on first use to avoid the expensive generic stub.
+ CompileMethod(method, self, /* baseline= */ false, /* osr= */ false);
+ return true;
+ }
if (old_count < HotMethodThreshold() && new_count >= HotMethodThreshold()) {
if (!code_cache_->ContainsPc(method->GetEntryPointFromQuickCompiledCode())) {
DCHECK(thread_pool_ != nullptr);
diff --git a/runtime/jit/jit_code_cache.cc b/runtime/jit/jit_code_cache.cc
index c22f4e3d67..fee5becd75 100644
--- a/runtime/jit/jit_code_cache.cc
+++ b/runtime/jit/jit_code_cache.cc
@@ -2062,8 +2062,9 @@ bool JitCodeCache::NotifyCompilationOf(ArtMethod* method, Thread* self, bool osr
}
}
if (collection_in_progress_) {
- CHECK(!IsInZygoteExecSpace(data->GetCode()));
- GetLiveBitmap()->AtomicTestAndSet(FromCodeToAllocation(data->GetCode()));
+ if (!IsInZygoteExecSpace(data->GetCode())) {
+ GetLiveBitmap()->AtomicTestAndSet(FromCodeToAllocation(data->GetCode()));
+ }
}
}
return new_compilation;