summaryrefslogtreecommitdiff
path: root/compiler/driver/compiler_driver.cc
diff options
context:
space:
mode:
author Igor Murashkin <iam@google.com> 2016-09-01 17:00:24 -0700
committer Igor Murashkin <iam@google.com> 2016-09-09 10:48:56 -0700
commit367f3dd32454858b8b25d87feb8f6599d3b4c9dd (patch)
tree9fe45c9f6785c31918f70ed2d12683f9c8d702af /compiler/driver/compiler_driver.cc
parentfa7b5c97db681e3d64d145807927cfafae78729b (diff)
jni: Add @CriticalNative optimization to speed up JNI transitions
Change-Id: I963059ac3a72dd8e6a867596c356d7062deb6da7
Diffstat (limited to 'compiler/driver/compiler_driver.cc')
-rw-r--r--compiler/driver/compiler_driver.cc17
1 files changed, 11 insertions, 6 deletions
diff --git a/compiler/driver/compiler_driver.cc b/compiler/driver/compiler_driver.cc
index b5bc2fb116..daac7fbb96 100644
--- a/compiler/driver/compiler_driver.cc
+++ b/compiler/driver/compiler_driver.cc
@@ -616,17 +616,22 @@ static void CompileMethod(Thread* self,
/* referrer */ nullptr,
invoke_type);
- bool fast_native = false;
- if (LIKELY(method != nullptr)) {
- fast_native = method->IsAnnotatedWithFastNative();
- } else {
+ // Query any JNI optimization annotations such as @FastNative or @CriticalNative.
+ Compiler::JniOptimizationFlags optimization_flags = Compiler::kNone;
+ if (UNLIKELY(method == nullptr)) {
// Failed method resolutions happen very rarely, e.g. ancestor class cannot be resolved.
DCHECK(self->IsExceptionPending());
self->ClearException();
+ } else if (method->IsAnnotatedWithFastNative()) {
+ // TODO: Will no longer need this CHECK once we have verifier checking this.
+ CHECK(!method->IsAnnotatedWithCriticalNative());
+ optimization_flags = Compiler::kFastNative;
+ } else if (method->IsAnnotatedWithCriticalNative()) {
+ // TODO: Will no longer need this CHECK once we have verifier checking this.
+ CHECK(!method->IsAnnotatedWithFastNative());
+ optimization_flags = Compiler::kCriticalNative;
}
- Compiler::JniOptimizationFlags optimization_flags =
- fast_native ? Compiler::kFastNative : Compiler::kNone;
compiled_method = driver->GetCompiler()->JniCompile(access_flags,
method_idx,
dex_file,