summaryrefslogtreecommitdiff
path: root/runtime/native/java_lang_VMClassLoader.cc
diff options
context:
space:
mode:
author Mathieu Chartier <mathieuc@google.com> 2014-09-11 14:21:41 -0700
committer Mathieu Chartier <mathieuc@google.com> 2014-09-11 18:04:33 -0700
commitab0ed82ff64ba5a751dcc0a38d0e0c41c53dc923 (patch)
treec67cceb67994868c42cc16ab8416fa93b56ce682 /runtime/native/java_lang_VMClassLoader.cc
parent3fec7718041302f769995eedda9beef362131842 (diff)
Add fast path to VMClassLoader.findLoadedClass
VMClassLoader.findLoadedClass now calls FindClassInPathClassLoader as a fast path. Exclusive time results (trace view maps launch): Before: nativeFillInStackTrace 1.4% defineClassNative 1.2% findLoadedClass 0.2% After: nativeFillInStackTrace 0.5% defineClassNative 0.0% findLoadedClass 0.9% (cherry picked from commit 194116c836080de14245a3a7c4617d07b8abf8cf) Change-Id: I63fd7b4bccb71789e92bd39d1d3f9d0de22535de
Diffstat (limited to 'runtime/native/java_lang_VMClassLoader.cc')
-rw-r--r--runtime/native/java_lang_VMClassLoader.cc19
1 files changed, 13 insertions, 6 deletions
diff --git a/runtime/native/java_lang_VMClassLoader.cc b/runtime/native/java_lang_VMClassLoader.cc
index fefddae761..761e8009e3 100644
--- a/runtime/native/java_lang_VMClassLoader.cc
+++ b/runtime/native/java_lang_VMClassLoader.cc
@@ -31,16 +31,23 @@ static jclass VMClassLoader_findLoadedClass(JNIEnv* env, jclass, jobject javaLoa
if (name.c_str() == NULL) {
return NULL;
}
-
+ ClassLinker* cl = Runtime::Current()->GetClassLinker();
std::string descriptor(DotToDescriptor(name.c_str()));
- mirror::Class* c = Runtime::Current()->GetClassLinker()->LookupClass(descriptor.c_str(), loader);
+ mirror::Class* c = cl->LookupClass(descriptor.c_str(), loader);
if (c != NULL && c->IsResolved()) {
return soa.AddLocalReference<jclass>(c);
- } else {
- // Class wasn't resolved so it may be erroneous or not yet ready, force the caller to go into
- // the regular loadClass code.
- return NULL;
}
+ if (loader != nullptr) {
+ // Try the common case.
+ StackHandleScope<1> hs(soa.Self());
+ c = cl->FindClassInPathClassLoader(soa, soa.Self(), descriptor.c_str(), hs.NewHandle(loader));
+ if (c != nullptr) {
+ return soa.AddLocalReference<jclass>(c);
+ }
+ }
+ // Class wasn't resolved so it may be erroneous or not yet ready, force the caller to go into
+ // the regular loadClass code.
+ return NULL;
}
static jint VMClassLoader_getBootClassPathSize(JNIEnv*, jclass) {