jni: Fast path for @FastNative annotated java methods
Adds a faster path for java methods annotated with
dalvik.annotation.optimization.FastNative .
Intended to replace usage of fast JNI (registering with "!(FOO)BAR" descriptors).
Performance Microbenchmark Results (Angler):
* Regular JNI cost in nanoseconds: 115
* Fast JNI cost in nanoseconds: 60
* @FastNative cost in nanoseconds: 36
Summary: Up to 67% faster (vs fast jni) JNI transition cost
Change-Id: Ic23823ae0f232270c068ec999fd89aa993894b0e
diff --git a/runtime/dex_file.cc b/runtime/dex_file.cc
index a6eb5f6..90c678c 100644
--- a/runtime/dex_file.cc
+++ b/runtime/dex_file.cc
@@ -1403,7 +1403,9 @@
return GetSignatureValue(method_class, annotation_set);
}
-bool DexFile::IsMethodAnnotationPresent(ArtMethod* method, Handle<mirror::Class> annotation_class)
+bool DexFile::IsMethodAnnotationPresent(ArtMethod* method,
+ Handle<mirror::Class> annotation_class,
+ uint32_t visibility /* = kDexVisibilityRuntime */)
const {
const AnnotationSetItem* annotation_set = FindAnnotationSetForMethod(method);
if (annotation_set == nullptr) {
@@ -1411,8 +1413,10 @@
}
StackHandleScope<1> hs(Thread::Current());
Handle<mirror::Class> method_class(hs.NewHandle(method->GetDeclaringClass()));
- const AnnotationItem* annotation_item = GetAnnotationItemFromAnnotationSet(
- method_class, annotation_set, kDexVisibilityRuntime, annotation_class);
+ const AnnotationItem* annotation_item = GetAnnotationItemFromAnnotationSet(method_class,
+ annotation_set,
+ visibility,
+ annotation_class);
return annotation_item != nullptr;
}