diff options
author | 2014-11-06 16:35:45 -0800 | |
---|---|---|
committer | 2014-11-07 11:45:06 -0800 | |
commit | e7c9a8c2b8481aafbc6af4ce6229bd361ba24742 (patch) | |
tree | f6d8fe8fd7aeae117a6547dc4f012cd4085cb4e8 /runtime/native/java_lang_VMClassLoader.cc | |
parent | 00b2da5c02339c36ffa4006f731f55203b09265d (diff) |
Add hash map, reduce excessive hashing
Changed the class def index to use a HashMap instead of unordered_map
so that we can use FindWithHash to reduce how often we need to compute
hashes.
Fixed a bug in ClassLinker::UpdateClass where we didn't properly
handle classes with the same descriptor but different class loaders.
Introduced by previous CL.
Before (fb launch):
1.74% art::ComputeModifiedUtf8Hash(char const*)
After:
0.95% art::ComputeModifiedUtf8Hash(char const*)
Bug: 18054905
Bug: 16828525
Change-Id: Iba2ee37c9837289e0ea187800ba4af322225a994
(cherry picked from commit 564ff985184737977aa26c485d0c1a413e530705)
Diffstat (limited to 'runtime/native/java_lang_VMClassLoader.cc')
-rw-r--r-- | runtime/native/java_lang_VMClassLoader.cc | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/runtime/native/java_lang_VMClassLoader.cc b/runtime/native/java_lang_VMClassLoader.cc index 45563d299c..35932e0b89 100644 --- a/runtime/native/java_lang_VMClassLoader.cc +++ b/runtime/native/java_lang_VMClassLoader.cc @@ -36,14 +36,16 @@ static jclass VMClassLoader_findLoadedClass(JNIEnv* env, jclass, jobject javaLoa } ClassLinker* cl = Runtime::Current()->GetClassLinker(); std::string descriptor(DotToDescriptor(name.c_str())); - mirror::Class* c = cl->LookupClass(soa.Self(), descriptor.c_str(), loader); + const size_t descriptor_hash = ComputeModifiedUtf8Hash(descriptor.c_str()); + mirror::Class* c = cl->LookupClass(soa.Self(), descriptor.c_str(), descriptor_hash, loader); if (c != nullptr && c->IsResolved()) { return soa.AddLocalReference<jclass>(c); } if (loader != nullptr) { // Try the common case. StackHandleScope<1> hs(soa.Self()); - c = cl->FindClassInPathClassLoader(soa, soa.Self(), descriptor.c_str(), hs.NewHandle(loader)); + c = cl->FindClassInPathClassLoader(soa, soa.Self(), descriptor.c_str(), descriptor_hash, + hs.NewHandle(loader)); if (c != nullptr) { return soa.AddLocalReference<jclass>(c); } |