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 --- compiler/driver/compiler_driver.cc | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) (limited to 'compiler/driver/compiler_driver.cc') diff --git a/compiler/driver/compiler_driver.cc b/compiler/driver/compiler_driver.cc index 5adb792497..54397f5e31 100644 --- a/compiler/driver/compiler_driver.cc +++ b/compiler/driver/compiler_driver.cc @@ -447,13 +447,12 @@ void CompilerDriver::CompileAll(jobject class_loader, } static DexToDexCompilationLevel GetDexToDexCompilationlevel( - SirtRef& class_loader, const DexFile& dex_file, + Thread* self, SirtRef& class_loader, const DexFile& dex_file, const DexFile::ClassDef& class_def) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { const char* descriptor = dex_file.GetClassDescriptor(class_def); ClassLinker* class_linker = Runtime::Current()->GetClassLinker(); - mirror::Class* klass = class_linker->FindClass(descriptor, class_loader); + mirror::Class* klass = class_linker->FindClass(self, descriptor, class_loader); if (klass == NULL) { - Thread* self = Thread::Current(); CHECK(self->IsExceptionPending()); self->ClearException(); return kDontDexToDexCompile; @@ -515,7 +514,8 @@ void CompilerDriver::CompileOne(mirror::ArtMethod* method, TimingLogger& timings const DexFile::ClassDef& class_def = dex_file->GetClassDef(class_def_idx); SirtRef class_loader(soa.Self(), soa.Decode(jclass_loader)); - dex_to_dex_compilation_level = GetDexToDexCompilationlevel(class_loader, *dex_file, class_def); + dex_to_dex_compilation_level = GetDexToDexCompilationlevel(self, class_loader, *dex_file, + class_def); } CompileMethod(code_item, access_flags, invoke_type, class_def_idx, method_idx, jclass_loader, *dex_file, dex_to_dex_compilation_level); @@ -633,7 +633,7 @@ void CompilerDriver::LoadImageClasses(TimingLogger& timings) ClassLinker* class_linker = Runtime::Current()->GetClassLinker(); for (auto it = image_classes_->begin(), end = image_classes_->end(); it != end;) { const std::string& descriptor(*it); - SirtRef klass(self, class_linker->FindSystemClass(descriptor.c_str())); + SirtRef klass(self, class_linker->FindSystemClass(self, descriptor.c_str())); if (klass.get() == NULL) { VLOG(compiler) << "Failed to find class " << descriptor; image_classes_->erase(it++); @@ -648,7 +648,7 @@ void CompilerDriver::LoadImageClasses(TimingLogger& timings) // Do this here so that exception classes appear to have been specified image classes. std::set > unresolved_exception_types; SirtRef java_lang_Throwable(self, - class_linker->FindSystemClass("Ljava/lang/Throwable;")); + class_linker->FindSystemClass(self, "Ljava/lang/Throwable;")); do { unresolved_exception_types.clear(); class_linker->VisitClasses(ResolveCatchBlockExceptionsClassVisitor, @@ -1661,7 +1661,8 @@ static void VerifyClass(const ParallelCompilationManager* manager, size_t class_ jobject jclass_loader = manager->GetClassLoader(); SirtRef class_loader( soa.Self(), soa.Decode(jclass_loader)); - SirtRef klass(soa.Self(), class_linker->FindClass(descriptor, class_loader)); + SirtRef klass(soa.Self(), class_linker->FindClass(soa.Self(), descriptor, + class_loader)); if (klass.get() == nullptr) { CHECK(soa.Self()->IsExceptionPending()); soa.Self()->ClearException(); @@ -1716,7 +1717,8 @@ static void InitializeClass(const ParallelCompilationManager* manager, size_t cl SirtRef class_loader(soa.Self(), soa.Decode(jclass_loader)); SirtRef klass(soa.Self(), - manager->GetClassLinker()->FindClass(descriptor, class_loader)); + manager->GetClassLinker()->FindClass(soa.Self(), descriptor, + class_loader)); if (klass.get() != nullptr && !SkipClass(jclass_loader, dex_file, klass.get())) { // Only try to initialize classes that were successfully verified. @@ -1861,7 +1863,8 @@ void CompilerDriver::CompileClass(const ParallelCompilationManager* manager, siz ScopedObjectAccess soa(Thread::Current()); SirtRef class_loader(soa.Self(), soa.Decode(jclass_loader)); - dex_to_dex_compilation_level = GetDexToDexCompilationlevel(class_loader, dex_file, class_def); + dex_to_dex_compilation_level = GetDexToDexCompilationlevel(soa.Self(), class_loader, dex_file, + class_def); } ClassDataItemIterator it(dex_file, class_data); // Skip fields -- cgit v1.2.3-59-g8ed1b