summaryrefslogtreecommitdiffstats
path: root/runtime/native/java_lang_DexCache.cc
diff options
context:
space:
mode:
authorVladimir Marko <vmarko@google.com>2015-04-09 14:13:13 +0100
committerVladimir Marko <vmarko@google.com>2015-04-10 18:46:03 +0100
commitc136312832d4be25db2ecc5673967d71d0ad4b9c (patch)
treeb9cdcccdd947632b2031ae2b4c3a9c3658ef3366 /runtime/native/java_lang_DexCache.cc
parent1576be32be4a99a1cffdaaf209a3cd67e8b2f88a (diff)
downloadandroid_art-c136312832d4be25db2ecc5673967d71d0ad4b9c.tar.gz
android_art-c136312832d4be25db2ecc5673967d71d0ad4b9c.tar.bz2
android_art-c136312832d4be25db2ecc5673967d71d0ad4b9c.zip
Avoid using dex cache array pointers in libart.
In preparation for making dex cache arrays native, avoid using them in Java code. This causes a performance regression for our reflection benchmarks. Class_getDeclaredMethod and Class_getMethod take an up to 30% hit, measured using the Quick compiler. We accept this hit at this stage and we will tune the performance after we're done with the larger effort. Companion libcore/ change: https://android-review.googlesource.com/146069 Bug: 20134538 Change-Id: Ibbef3b50043a1311cd40723ed42e1f1c609b8fc1
Diffstat (limited to 'runtime/native/java_lang_DexCache.cc')
-rw-r--r--runtime/native/java_lang_DexCache.cc30
1 files changed, 30 insertions, 0 deletions
diff --git a/runtime/native/java_lang_DexCache.cc b/runtime/native/java_lang_DexCache.cc
index 27eae46236..89442703b6 100644
--- a/runtime/native/java_lang_DexCache.cc
+++ b/runtime/native/java_lang_DexCache.cc
@@ -48,8 +48,38 @@ static jobject DexCache_getDexNative(JNIEnv* env, jobject javaDexCache) {
args);
}
+static jobject DexCache_getResolvedType(JNIEnv* env, jobject javaDexCache, jint type_index) {
+ ScopedFastNativeObjectAccess soa(env);
+ mirror::DexCache* dex_cache = soa.Decode<mirror::DexCache*>(javaDexCache);
+ return soa.AddLocalReference<jobject>(dex_cache->GetResolvedType(type_index));
+}
+
+static jobject DexCache_getResolvedString(JNIEnv* env, jobject javaDexCache, jint string_index) {
+ ScopedFastNativeObjectAccess soa(env);
+ mirror::DexCache* dex_cache = soa.Decode<mirror::DexCache*>(javaDexCache);
+ return soa.AddLocalReference<jobject>(dex_cache->GetResolvedString(string_index));
+}
+
+static void DexCache_setResolvedType(JNIEnv* env, jobject javaDexCache, jint type_index,
+ jobject type) {
+ ScopedFastNativeObjectAccess soa(env);
+ mirror::DexCache* dex_cache = soa.Decode<mirror::DexCache*>(javaDexCache);
+ dex_cache->SetResolvedType(type_index, soa.Decode<mirror::Class*>(type));
+}
+
+static void DexCache_setResolvedString(JNIEnv* env, jobject javaDexCache, jint string_index,
+ jobject string) {
+ ScopedFastNativeObjectAccess soa(env);
+ mirror::DexCache* dex_cache = soa.Decode<mirror::DexCache*>(javaDexCache);
+ dex_cache->SetResolvedString(string_index, soa.Decode<mirror::String*>(string));
+}
+
static JNINativeMethod gMethods[] = {
NATIVE_METHOD(DexCache, getDexNative, "!()Lcom/android/dex/Dex;"),
+ NATIVE_METHOD(DexCache, getResolvedType, "!(I)Ljava/lang/Class;"),
+ NATIVE_METHOD(DexCache, getResolvedString, "!(I)Ljava/lang/String;"),
+ NATIVE_METHOD(DexCache, setResolvedType, "!(ILjava/lang/Class;)V"),
+ NATIVE_METHOD(DexCache, setResolvedString, "!(ILjava/lang/String;)V"),
};
void register_java_lang_DexCache(JNIEnv* env) {