From 9837939678bb5dcba178e5fb00ed59b5d14c8d9b Mon Sep 17 00:00:00 2001 From: Ian Rogers Date: Mon, 24 Feb 2014 16:53:16 -0800 Subject: Avoid std::string allocations for finding an array class. Introduce ClassLinker::FindArrayClass which performs an array class lookup given the element/component class. This has a 16 element cache of recently looked up arrays. Pass the current thread to ClassLinker Find .. Class routines to avoid calls to Thread::Current(). Avoid some uses of FindClass in the debugger where WellKnownClasses is a faster and more compacting GC friendly alternative. Change-Id: I60e231820b349543a7edb3ceb9cf1ce92db3c843 --- runtime/native/java_lang_Class.cc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'runtime/native/java_lang_Class.cc') diff --git a/runtime/native/java_lang_Class.cc b/runtime/native/java_lang_Class.cc index 3e3f608c89..8bf36e7e37 100644 --- a/runtime/native/java_lang_Class.cc +++ b/runtime/native/java_lang_Class.cc @@ -43,7 +43,8 @@ static mirror::Class* DecodeClass(const ScopedFastNativeObjectAccess& soa, jobje } // "name" is in "binary name" format, e.g. "dalvik.system.Debug$1". -static jclass Class_classForName(JNIEnv* env, jclass, jstring javaName, jboolean initialize, jobject javaLoader) { +static jclass Class_classForName(JNIEnv* env, jclass, jstring javaName, jboolean initialize, + jobject javaLoader) { ScopedObjectAccess soa(env); ScopedUtfChars name(env, javaName); if (name.c_str() == nullptr) { @@ -64,7 +65,8 @@ static jclass Class_classForName(JNIEnv* env, jclass, jstring javaName, jboolean SirtRef class_loader(soa.Self(), soa.Decode(javaLoader)); ClassLinker* class_linker = Runtime::Current()->GetClassLinker(); - SirtRef c(soa.Self(), class_linker->FindClass(descriptor.c_str(), class_loader)); + SirtRef c(soa.Self(), class_linker->FindClass(soa.Self(), descriptor.c_str(), + class_loader)); if (c.get() == nullptr) { ScopedLocalRef cause(env, env->ExceptionOccurred()); env->ExceptionClear(); -- cgit v1.2.3-59-g8ed1b