diff options
Diffstat (limited to 'compiler')
| -rw-r--r-- | compiler/dex/mir_method_info.cc | 3 | ||||
| -rw-r--r-- | compiler/driver/compiler_driver-inl.h | 9 | ||||
| -rw-r--r-- | compiler/driver/compiler_driver.cc | 38 | ||||
| -rw-r--r-- | compiler/driver/compiler_driver_test.cc | 2 | ||||
| -rw-r--r-- | compiler/image_writer.cc | 77 | ||||
| -rw-r--r-- | compiler/image_writer.h | 5 | ||||
| -rw-r--r-- | compiler/oat_writer.cc | 12 | ||||
| -rw-r--r-- | compiler/optimizing/builder.cc | 14 | ||||
| -rw-r--r-- | compiler/optimizing/inliner.cc | 4 | ||||
| -rw-r--r-- | compiler/optimizing/optimizing_compiler.cc | 3 | ||||
| -rw-r--r-- | compiler/optimizing/reference_type_propagation.cc | 12 |
11 files changed, 81 insertions, 98 deletions
diff --git a/compiler/dex/mir_method_info.cc b/compiler/dex/mir_method_info.cc index be913fe634..31c3808197 100644 --- a/compiler/dex/mir_method_info.cc +++ b/compiler/dex/mir_method_info.cc @@ -105,7 +105,8 @@ void MirMethodLoweringInfo::Resolve(CompilerDriver* compiler_driver, // Don't devirt if we are in a different dex file since we can't have direct invokes in // another dex file unless we always put a direct / patch pointer. devirt_target = nullptr; - current_dex_cache.Assign(runtime->GetClassLinker()->FindDexCache(*it->target_dex_file_)); + current_dex_cache.Assign(runtime->GetClassLinker()->FindDexCache( + soa.Self(), *it->target_dex_file_)); CHECK(current_dex_cache.Get() != nullptr); DexCompilationUnit cu( mUnit->GetCompilationUnit(), mUnit->GetClassLoader(), mUnit->GetClassLinker(), diff --git a/compiler/driver/compiler_driver-inl.h b/compiler/driver/compiler_driver-inl.h index 80387f2842..8f1987a7db 100644 --- a/compiler/driver/compiler_driver-inl.h +++ b/compiler/driver/compiler_driver-inl.h @@ -31,7 +31,7 @@ namespace art { inline mirror::DexCache* CompilerDriver::GetDexCache(const DexCompilationUnit* mUnit) { - return mUnit->GetClassLinker()->FindDexCache(*mUnit->GetDexFile()); + return mUnit->GetClassLinker()->FindDexCache(Thread::Current(), *mUnit->GetDexFile(), false); } inline mirror::ClassLoader* CompilerDriver::GetClassLoader(ScopedObjectAccess& soa, @@ -87,7 +87,7 @@ inline ArtField* CompilerDriver::ResolveFieldWithDexFile( } inline mirror::DexCache* CompilerDriver::FindDexCache(const DexFile* dex_file) { - return Runtime::Current()->GetClassLinker()->FindDexCache(*dex_file); + return Runtime::Current()->GetClassLinker()->FindDexCache(Thread::Current(), *dex_file, false); } inline ArtField* CompilerDriver::ResolveField( @@ -339,7 +339,8 @@ inline int CompilerDriver::IsFastInvoke( // Sharpen a virtual call into a direct call. The method_idx is into referrer's // dex cache, check that this resolved method is where we expect it. CHECK_EQ(target_method->dex_file, mUnit->GetDexFile()); - DCHECK_EQ(dex_cache.Get(), mUnit->GetClassLinker()->FindDexCache(*mUnit->GetDexFile())); + DCHECK_EQ(dex_cache.Get(), mUnit->GetClassLinker()->FindDexCache( + soa.Self(), *mUnit->GetDexFile(), false)); CHECK_EQ(referrer_class->GetDexCache()->GetResolvedMethod( target_method->dex_method_index, pointer_size), resolved_method) << PrettyMethod(resolved_method); @@ -369,7 +370,7 @@ inline int CompilerDriver::IsFastInvoke( nullptr, kVirtual); } else { StackHandleScope<1> hs(soa.Self()); - auto target_dex_cache(hs.NewHandle(class_linker->FindDexCache(*devirt_target->dex_file))); + auto target_dex_cache(hs.NewHandle(class_linker->RegisterDexFile(*devirt_target->dex_file))); called_method = class_linker->ResolveMethod( *devirt_target->dex_file, devirt_target->dex_method_index, target_dex_cache, class_loader, nullptr, kVirtual); diff --git a/compiler/driver/compiler_driver.cc b/compiler/driver/compiler_driver.cc index fb3af2d2b7..6d3a960048 100644 --- a/compiler/driver/compiler_driver.cc +++ b/compiler/driver/compiler_driver.cc @@ -940,7 +940,7 @@ void CompilerDriver::LoadImageClasses(TimingLogger* timings) { uint16_t exception_type_idx = exception_type.first; const DexFile* dex_file = exception_type.second; StackHandleScope<2> hs2(self); - Handle<mirror::DexCache> dex_cache(hs2.NewHandle(class_linker->FindDexCache(*dex_file))); + Handle<mirror::DexCache> dex_cache(hs2.NewHandle(class_linker->RegisterDexFile(*dex_file))); Handle<mirror::Class> klass(hs2.NewHandle( class_linker->ResolveType(*dex_file, exception_type_idx, dex_cache, NullHandle<mirror::ClassLoader>()))); @@ -1174,7 +1174,8 @@ bool CompilerDriver::CanAssumeTypeIsPresentInDexCache(const DexFile& dex_file, u IsImageClass(dex_file.StringDataByIdx(dex_file.GetTypeId(type_idx).descriptor_idx_))) { { ScopedObjectAccess soa(Thread::Current()); - mirror::DexCache* dex_cache = Runtime::Current()->GetClassLinker()->FindDexCache(dex_file); + mirror::DexCache* dex_cache = Runtime::Current()->GetClassLinker()->FindDexCache( + soa.Self(), dex_file, false); mirror::Class* resolved_class = dex_cache->GetResolvedType(type_idx); if (resolved_class == nullptr) { // Erroneous class. @@ -1199,9 +1200,10 @@ bool CompilerDriver::CanAssumeStringIsPresentInDexCache(const DexFile& dex_file, // We resolve all const-string strings when building for the image. ScopedObjectAccess soa(Thread::Current()); StackHandleScope<1> hs(soa.Self()); - Handle<mirror::DexCache> dex_cache( - hs.NewHandle(Runtime::Current()->GetClassLinker()->FindDexCache(dex_file))); - Runtime::Current()->GetClassLinker()->ResolveString(dex_file, string_idx, dex_cache); + ClassLinker* const class_linker = Runtime::Current()->GetClassLinker(); + Handle<mirror::DexCache> dex_cache(hs.NewHandle(class_linker->FindDexCache( + soa.Self(), dex_file, false))); + class_linker->ResolveString(dex_file, string_idx, dex_cache); result = true; } if (result) { @@ -1226,7 +1228,8 @@ bool CompilerDriver::CanAccessTypeWithoutChecks(uint32_t referrer_idx, const Dex *equals_referrers_class = false; } ScopedObjectAccess soa(Thread::Current()); - mirror::DexCache* dex_cache = Runtime::Current()->GetClassLinker()->FindDexCache(dex_file); + mirror::DexCache* dex_cache = Runtime::Current()->GetClassLinker()->FindDexCache( + soa.Self(), dex_file, false); // Get type from dex cache assuming it was populated by the verifier mirror::Class* resolved_class = dex_cache->GetResolvedType(type_idx); if (resolved_class == nullptr) { @@ -1263,7 +1266,8 @@ bool CompilerDriver::CanAccessInstantiableTypeWithoutChecks(uint32_t referrer_id const DexFile& dex_file, uint32_t type_idx) { ScopedObjectAccess soa(Thread::Current()); - mirror::DexCache* dex_cache = Runtime::Current()->GetClassLinker()->FindDexCache(dex_file); + mirror::DexCache* dex_cache = Runtime::Current()->GetClassLinker()->FindDexCache( + soa.Self(), dex_file, false); // Get type from dex cache assuming it was populated by the verifier. mirror::Class* resolved_class = dex_cache->GetResolvedType(type_idx); if (resolved_class == nullptr) { @@ -1292,7 +1296,8 @@ bool CompilerDriver::CanEmbedTypeInCode(const DexFile& dex_file, uint32_t type_i uintptr_t* direct_type_ptr, bool* out_is_finalizable) { ScopedObjectAccess soa(Thread::Current()); Runtime* runtime = Runtime::Current(); - mirror::DexCache* dex_cache = runtime->GetClassLinker()->FindDexCache(dex_file); + mirror::DexCache* dex_cache = runtime->GetClassLinker()->FindDexCache( + soa.Self(), dex_file, false); mirror::Class* resolved_class = dex_cache->GetResolvedType(type_idx); if (resolved_class == nullptr) { return false; @@ -1421,7 +1426,8 @@ ArtField* CompilerDriver::ComputeInstanceFieldInfo(uint32_t field_idx, { StackHandleScope<2> hs(soa.Self()); Handle<mirror::DexCache> dex_cache_handle( - hs.NewHandle(mUnit->GetClassLinker()->FindDexCache(*mUnit->GetDexFile()))); + hs.NewHandle(mUnit->GetClassLinker()->FindDexCache( + soa.Self(), *mUnit->GetDexFile(), false))); Handle<mirror::ClassLoader> class_loader_handle( hs.NewHandle(soa.Decode<mirror::ClassLoader*>(mUnit->GetClassLoader()))); resolved_field = @@ -1471,7 +1477,8 @@ bool CompilerDriver::ComputeStaticFieldInfo(uint32_t field_idx, const DexCompila { StackHandleScope<2> hs(soa.Self()); Handle<mirror::DexCache> dex_cache_handle( - hs.NewHandle(mUnit->GetClassLinker()->FindDexCache(*mUnit->GetDexFile()))); + hs.NewHandle(mUnit->GetClassLinker()->FindDexCache( + soa.Self(), *mUnit->GetDexFile(), false))); Handle<mirror::ClassLoader> class_loader_handle( hs.NewHandle(soa.Decode<mirror::ClassLoader*>(mUnit->GetClassLoader()))); resolved_field = @@ -1657,7 +1664,8 @@ bool CompilerDriver::ComputeInvokeInfo(const DexCompilationUnit* mUnit, const ui // Try to resolve the method and compiling method's class. StackHandleScope<3> hs(soa.Self()); Handle<mirror::DexCache> dex_cache( - hs.NewHandle(mUnit->GetClassLinker()->FindDexCache(*mUnit->GetDexFile()))); + hs.NewHandle(mUnit->GetClassLinker()->FindDexCache( + soa.Self(), *mUnit->GetDexFile(), false))); Handle<mirror::ClassLoader> class_loader(hs.NewHandle( soa.Decode<mirror::ClassLoader*>(mUnit->GetClassLoader()))); uint32_t method_idx = target_method->dex_method_index; @@ -1909,7 +1917,8 @@ class ResolveClassFieldsAndMethodsVisitor : public CompilationVisitor { StackHandleScope<2> hs(soa.Self()); Handle<mirror::ClassLoader> class_loader( hs.NewHandle(soa.Decode<mirror::ClassLoader*>(jclass_loader))); - Handle<mirror::DexCache> dex_cache(hs.NewHandle(class_linker->FindDexCache(dex_file))); + Handle<mirror::DexCache> dex_cache(hs.NewHandle(class_linker->FindDexCache( + soa.Self(), dex_file, false))); // Resolve the class. mirror::Class* klass = class_linker->ResolveType(dex_file, class_def.class_idx_, dex_cache, class_loader); @@ -2002,7 +2011,7 @@ class ResolveTypeVisitor : public CompilationVisitor { ClassLinker* class_linker = manager_->GetClassLinker(); const DexFile& dex_file = *manager_->GetDexFile(); StackHandleScope<2> hs(soa.Self()); - Handle<mirror::DexCache> dex_cache(hs.NewHandle(class_linker->FindDexCache(dex_file))); + Handle<mirror::DexCache> dex_cache(hs.NewHandle(class_linker->RegisterDexFile(dex_file))); Handle<mirror::ClassLoader> class_loader( hs.NewHandle(soa.Decode<mirror::ClassLoader*>(manager_->GetClassLoader()))); mirror::Class* klass = class_linker->ResolveType(dex_file, type_idx, dex_cache, class_loader); @@ -2088,7 +2097,8 @@ class VerifyClassVisitor : public CompilationVisitor { * This is to ensure the class is structurally sound for compilation. An unsound class * will be rejected by the verifier and later skipped during compilation in the compiler. */ - Handle<mirror::DexCache> dex_cache(hs.NewHandle(class_linker->FindDexCache(dex_file))); + Handle<mirror::DexCache> dex_cache(hs.NewHandle(class_linker->FindDexCache( + soa.Self(), dex_file, false))); std::string error_msg; if (verifier::MethodVerifier::VerifyClass(soa.Self(), &dex_file, dex_cache, class_loader, &class_def, true, &error_msg) == diff --git a/compiler/driver/compiler_driver_test.cc b/compiler/driver/compiler_driver_test.cc index a5ace0bf42..1107599779 100644 --- a/compiler/driver/compiler_driver_test.cc +++ b/compiler/driver/compiler_driver_test.cc @@ -108,7 +108,7 @@ TEST_F(CompilerDriverTest, DISABLED_LARGE_CompileDexLibCore) { ScopedObjectAccess soa(Thread::Current()); ASSERT_TRUE(java_lang_dex_file_ != nullptr); const DexFile& dex = *java_lang_dex_file_; - mirror::DexCache* dex_cache = class_linker_->FindDexCache(dex); + mirror::DexCache* dex_cache = class_linker_->FindDexCache(soa.Self(), dex); EXPECT_EQ(dex.NumStringIds(), dex_cache->NumStrings()); for (size_t i = 0; i < dex_cache->NumStrings(); i++) { const mirror::String* string = dex_cache->GetResolvedString(i); diff --git a/compiler/image_writer.cc b/compiler/image_writer.cc index 93897aa228..dbd3366c1b 100644 --- a/compiler/image_writer.cc +++ b/compiler/image_writer.cc @@ -70,7 +70,6 @@ namespace art { // Separate objects into multiple bins to optimize dirty memory use. static constexpr bool kBinObjects = true; -static constexpr bool kComputeEagerResolvedStrings = false; static void CheckNoDexObjectsCallback(Object* obj, void* arg ATTRIBUTE_UNUSED) SHARED_REQUIRES(Locks::mutator_lock_) { @@ -90,11 +89,6 @@ bool ImageWriter::PrepareImageAddressSpace() { PruneNonImageClasses(); // Remove junk ComputeLazyFieldsForImageClasses(); // Add useful information - // Calling this can in theory fill in some resolved strings. However, in practice it seems to - // never resolve any. - if (kComputeEagerResolvedStrings) { - ComputeEagerResolvedStrings(); - } Thread::Current()->TransitionFromRunnableToSuspended(kNative); } gc::Heap* heap = Runtime::Current()->GetHeap(); @@ -302,11 +296,15 @@ void ImageWriter::SetImageBinSlot(mirror::Object* object, BinSlot bin_slot) { void ImageWriter::PrepareDexCacheArraySlots() { ClassLinker* class_linker = Runtime::Current()->GetClassLinker(); - ReaderMutexLock mu(Thread::Current(), *class_linker->DexLock()); - size_t dex_cache_count = class_linker->GetDexCacheCount(); + Thread* const self = Thread::Current(); + ReaderMutexLock mu(self, *class_linker->DexLock()); uint32_t size = 0u; - for (size_t idx = 0; idx < dex_cache_count; ++idx) { - DexCache* dex_cache = class_linker->GetDexCache(idx); + for (jobject weak_root : class_linker->GetDexCaches()) { + mirror::DexCache* dex_cache = + down_cast<mirror::DexCache*>(self->DecodeJObject(weak_root)); + if (dex_cache == nullptr) { + continue; + } const DexFile* dex_file = dex_cache->GetDexFile(); dex_cache_array_starts_.Put(dex_file, size); DexCacheArraysLayout layout(target_ptr_size_, dex_file); @@ -554,39 +552,6 @@ void ImageWriter::ComputeLazyFieldsForImageClasses() { class_linker->VisitClassesWithoutClassesLock(&visitor); } -void ImageWriter::ComputeEagerResolvedStringsCallback(Object* obj, void* arg ATTRIBUTE_UNUSED) { - if (!obj->GetClass()->IsStringClass()) { - return; - } - mirror::String* string = obj->AsString(); - const uint16_t* utf16_string = string->GetValue(); - size_t utf16_length = static_cast<size_t>(string->GetLength()); - ClassLinker* class_linker = Runtime::Current()->GetClassLinker(); - ReaderMutexLock mu(Thread::Current(), *class_linker->DexLock()); - size_t dex_cache_count = class_linker->GetDexCacheCount(); - for (size_t i = 0; i < dex_cache_count; ++i) { - DexCache* dex_cache = class_linker->GetDexCache(i); - const DexFile& dex_file = *dex_cache->GetDexFile(); - const DexFile::StringId* string_id; - if (UNLIKELY(utf16_length == 0)) { - string_id = dex_file.FindStringId(""); - } else { - string_id = dex_file.FindStringId(utf16_string, utf16_length); - } - if (string_id != nullptr) { - // This string occurs in this dex file, assign the dex cache entry. - uint32_t string_idx = dex_file.GetIndexForStringId(*string_id); - if (dex_cache->GetResolvedString(string_idx) == nullptr) { - dex_cache->SetResolvedString(string_idx, string); - } - } - } -} - -void ImageWriter::ComputeEagerResolvedStrings() { - Runtime::Current()->GetHeap()->VisitObjects(ComputeEagerResolvedStringsCallback, this); -} - bool ImageWriter::IsImageClass(Class* klass) { if (klass == nullptr) { return false; @@ -631,16 +596,14 @@ void ImageWriter::PruneNonImageClasses() { // Clear references to removed classes from the DexCaches. const ArtMethod* resolution_method = runtime->GetResolutionMethod(); - size_t dex_cache_count; - { - ReaderMutexLock mu(self, *class_linker->DexLock()); - dex_cache_count = class_linker->GetDexCacheCount(); - } - for (size_t idx = 0; idx < dex_cache_count; ++idx) { - DexCache* dex_cache; - { - ReaderMutexLock mu(self, *class_linker->DexLock()); - dex_cache = class_linker->GetDexCache(idx); + + ScopedAssertNoThreadSuspension sa(self, __FUNCTION__); + ReaderMutexLock mu(self, *Locks::classlinker_classes_lock_); // For ClassInClassTable + ReaderMutexLock mu2(self, *class_linker->DexLock()); + for (jobject weak_root : class_linker->GetDexCaches()) { + mirror::DexCache* dex_cache = down_cast<mirror::DexCache*>(self->DecodeJObject(weak_root)); + if (dex_cache == nullptr) { + continue; } for (size_t i = 0; i < dex_cache->NumResolvedTypes(); i++) { Class* klass = dex_cache->GetResolvedType(i); @@ -762,8 +725,12 @@ ObjectArray<Object>* ImageWriter::CreateImageRoots() const { ReaderMutexLock mu(self, *class_linker->DexLock()); CHECK_EQ(dex_cache_count, class_linker->GetDexCacheCount()) << "The number of dex caches changed."; - for (size_t i = 0; i < dex_cache_count; ++i) { - dex_caches->Set<false>(i, class_linker->GetDexCache(i)); + size_t i = 0; + for (jobject weak_root : class_linker->GetDexCaches()) { + mirror::DexCache* dex_cache = + down_cast<mirror::DexCache*>(self->DecodeJObject(weak_root)); + dex_caches->Set<false>(i, dex_cache); + ++i; } } diff --git a/compiler/image_writer.h b/compiler/image_writer.h index c8aa82dc32..778521c606 100644 --- a/compiler/image_writer.h +++ b/compiler/image_writer.h @@ -225,11 +225,6 @@ class ImageWriter FINAL { void ComputeLazyFieldsForImageClasses() SHARED_REQUIRES(Locks::mutator_lock_); - // Wire dex cache resolved strings to strings in the image to avoid runtime resolution. - void ComputeEagerResolvedStrings() SHARED_REQUIRES(Locks::mutator_lock_); - static void ComputeEagerResolvedStringsCallback(mirror::Object* obj, void* arg) - SHARED_REQUIRES(Locks::mutator_lock_); - // Remove unwanted classes from various roots. void PruneNonImageClasses() SHARED_REQUIRES(Locks::mutator_lock_); diff --git a/compiler/oat_writer.cc b/compiler/oat_writer.cc index 64e748776d..fdf904d1f0 100644 --- a/compiler/oat_writer.cc +++ b/compiler/oat_writer.cc @@ -617,7 +617,8 @@ class OatWriter::InitImageMethodVisitor : public OatDexMethodVisitor { // Unchecked as we hold mutator_lock_ on entry. ScopedObjectAccessUnchecked soa(Thread::Current()); StackHandleScope<1> hs(soa.Self()); - Handle<mirror::DexCache> dex_cache(hs.NewHandle(linker->FindDexCache(*dex_file_))); + Handle<mirror::DexCache> dex_cache(hs.NewHandle(linker->FindDexCache( + Thread::Current(), *dex_file_))); ArtMethod* method = linker->ResolveMethod( *dex_file_, it.GetMemberIndex(), dex_cache, NullHandle<mirror::ClassLoader>(), nullptr, invoke_type); @@ -668,7 +669,7 @@ class OatWriter::WriteCodeMethodVisitor : public OatDexMethodVisitor { SHARED_REQUIRES(Locks::mutator_lock_) { OatDexMethodVisitor::StartClass(dex_file, class_def_index); if (dex_cache_ == nullptr || dex_cache_->GetDexFile() != dex_file) { - dex_cache_ = class_linker_->FindDexCache(*dex_file); + dex_cache_ = class_linker_->FindDexCache(Thread::Current(), *dex_file); } return true; } @@ -691,6 +692,8 @@ class OatWriter::WriteCodeMethodVisitor : public OatDexMethodVisitor { OatClass* oat_class = writer_->oat_classes_[oat_class_index_]; const CompiledMethod* compiled_method = oat_class->GetCompiledMethod(class_def_method_index); + // No thread suspension since dex_cache_ that may get invalidated if that occurs. + ScopedAssertNoThreadSuspension tsc(Thread::Current(), __FUNCTION__); if (compiled_method != nullptr) { // ie. not an abstract method size_t file_offset = file_offset_; OutputStream* out = out_; @@ -796,7 +799,8 @@ class OatWriter::WriteCodeMethodVisitor : public OatDexMethodVisitor { SHARED_REQUIRES(Locks::mutator_lock_) { MethodReference ref = patch.TargetMethod(); mirror::DexCache* dex_cache = - (dex_file_ == ref.dex_file) ? dex_cache_ : class_linker_->FindDexCache(*ref.dex_file); + (dex_file_ == ref.dex_file) ? dex_cache_ : class_linker_->FindDexCache( + Thread::Current(), *ref.dex_file); ArtMethod* method = dex_cache->GetResolvedMethod( ref.dex_method_index, class_linker_->GetImagePointerSize()); CHECK(method != nullptr); @@ -830,7 +834,7 @@ class OatWriter::WriteCodeMethodVisitor : public OatDexMethodVisitor { mirror::Class* GetTargetType(const LinkerPatch& patch) SHARED_REQUIRES(Locks::mutator_lock_) { mirror::DexCache* dex_cache = (dex_file_ == patch.TargetTypeDexFile()) - ? dex_cache_ : class_linker_->FindDexCache(*patch.TargetTypeDexFile()); + ? dex_cache_ : class_linker_->FindDexCache(Thread::Current(), *patch.TargetTypeDexFile()); mirror::Class* type = dex_cache->GetResolvedType(patch.TargetTypeIndex()); CHECK(type != nullptr); return type; diff --git a/compiler/optimizing/builder.cc b/compiler/optimizing/builder.cc index 7b42db8a7f..23ab94e5fe 100644 --- a/compiler/optimizing/builder.cc +++ b/compiler/optimizing/builder.cc @@ -902,7 +902,7 @@ HClinitCheck* HGraphBuilder::ProcessClinitCheckForInvoke( StackHandleScope<4> hs(soa.Self()); Handle<mirror::DexCache> dex_cache(hs.NewHandle( dex_compilation_unit_->GetClassLinker()->FindDexCache( - *dex_compilation_unit_->GetDexFile()))); + soa.Self(), *dex_compilation_unit_->GetDexFile()))); Handle<mirror::ClassLoader> class_loader(hs.NewHandle( soa.Decode<mirror::ClassLoader*>(dex_compilation_unit_->GetClassLoader()))); ArtMethod* resolved_method = compiler_driver_->ResolveMethod( @@ -912,7 +912,7 @@ HClinitCheck* HGraphBuilder::ProcessClinitCheckForInvoke( const DexFile& outer_dex_file = *outer_compilation_unit_->GetDexFile(); Handle<mirror::DexCache> outer_dex_cache(hs.NewHandle( - outer_compilation_unit_->GetClassLinker()->FindDexCache(outer_dex_file))); + outer_compilation_unit_->GetClassLinker()->FindDexCache(soa.Self(), outer_dex_file))); Handle<mirror::Class> outer_class(hs.NewHandle(GetOutermostCompilingClass())); // The index at which the method's class is stored in the DexCache's type array. @@ -1228,7 +1228,7 @@ static mirror::Class* GetClassFrom(CompilerDriver* driver, Handle<mirror::ClassLoader> class_loader(hs.NewHandle( soa.Decode<mirror::ClassLoader*>(compilation_unit.GetClassLoader()))); Handle<mirror::DexCache> dex_cache(hs.NewHandle( - compilation_unit.GetClassLinker()->FindDexCache(dex_file))); + compilation_unit.GetClassLinker()->FindDexCache(soa.Self(), dex_file))); return driver->ResolveCompilingMethodsClass(soa, dex_cache, class_loader, &compilation_unit); } @@ -1245,7 +1245,8 @@ bool HGraphBuilder::IsOutermostCompilingClass(uint16_t type_index) const { ScopedObjectAccess soa(Thread::Current()); StackHandleScope<4> hs(soa.Self()); Handle<mirror::DexCache> dex_cache(hs.NewHandle( - dex_compilation_unit_->GetClassLinker()->FindDexCache(*dex_compilation_unit_->GetDexFile()))); + dex_compilation_unit_->GetClassLinker()->FindDexCache( + soa.Self(), *dex_compilation_unit_->GetDexFile()))); Handle<mirror::ClassLoader> class_loader(hs.NewHandle( soa.Decode<mirror::ClassLoader*>(dex_compilation_unit_->GetClassLoader()))); Handle<mirror::Class> cls(hs.NewHandle(compiler_driver_->ResolveClass( @@ -1264,7 +1265,8 @@ bool HGraphBuilder::BuildStaticFieldAccess(const Instruction& instruction, ScopedObjectAccess soa(Thread::Current()); StackHandleScope<4> hs(soa.Self()); Handle<mirror::DexCache> dex_cache(hs.NewHandle( - dex_compilation_unit_->GetClassLinker()->FindDexCache(*dex_compilation_unit_->GetDexFile()))); + dex_compilation_unit_->GetClassLinker()->FindDexCache( + soa.Self(), *dex_compilation_unit_->GetDexFile()))); Handle<mirror::ClassLoader> class_loader(hs.NewHandle( soa.Decode<mirror::ClassLoader*>(dex_compilation_unit_->GetClassLoader()))); ArtField* resolved_field = compiler_driver_->ResolveField( @@ -1277,7 +1279,7 @@ bool HGraphBuilder::BuildStaticFieldAccess(const Instruction& instruction, const DexFile& outer_dex_file = *outer_compilation_unit_->GetDexFile(); Handle<mirror::DexCache> outer_dex_cache(hs.NewHandle( - outer_compilation_unit_->GetClassLinker()->FindDexCache(outer_dex_file))); + outer_compilation_unit_->GetClassLinker()->FindDexCache(soa.Self(), outer_dex_file))); Handle<mirror::Class> outer_class(hs.NewHandle(GetOutermostCompilingClass())); // The index at which the field's class is stored in the DexCache's type array. diff --git a/compiler/optimizing/inliner.cc b/compiler/optimizing/inliner.cc index ff90f32754..112d42e904 100644 --- a/compiler/optimizing/inliner.cc +++ b/compiler/optimizing/inliner.cc @@ -182,10 +182,10 @@ bool HInliner::TryInline(HInvoke* invoke_instruction) { ArtMethod* resolved_method; if (invoke_instruction->IsInvokeStaticOrDirect()) { MethodReference ref = invoke_instruction->AsInvokeStaticOrDirect()->GetTargetMethod(); - resolved_method = class_linker->FindDexCache(*ref.dex_file)->GetResolvedMethod( + resolved_method = class_linker->FindDexCache(soa.Self(), *ref.dex_file)->GetResolvedMethod( ref.dex_method_index, class_linker->GetImagePointerSize()); } else { - resolved_method = class_linker->FindDexCache(caller_dex_file)->GetResolvedMethod( + resolved_method = class_linker->FindDexCache(soa.Self(), caller_dex_file)->GetResolvedMethod( method_index, class_linker->GetImagePointerSize()); } diff --git a/compiler/optimizing/optimizing_compiler.cc b/compiler/optimizing/optimizing_compiler.cc index 1db3063aec..6f251e8e6c 100644 --- a/compiler/optimizing/optimizing_compiler.cc +++ b/compiler/optimizing/optimizing_compiler.cc @@ -714,7 +714,8 @@ CompiledMethod* OptimizingCompiler::TryCompile(const DexFile::CodeItem* code_ite ScopedObjectAccess soa(Thread::Current()); StackHandleScope<4> hs(soa.Self()); ClassLinker* class_linker = dex_compilation_unit.GetClassLinker(); - Handle<mirror::DexCache> dex_cache(hs.NewHandle(class_linker->FindDexCache(dex_file))); + Handle<mirror::DexCache> dex_cache(hs.NewHandle(class_linker->FindDexCache( + soa.Self(), dex_file))); Handle<mirror::ClassLoader> loader(hs.NewHandle( soa.Decode<mirror::ClassLoader*>(class_loader))); ArtMethod* art_method = compiler_driver->ResolveMethod( diff --git a/compiler/optimizing/reference_type_propagation.cc b/compiler/optimizing/reference_type_propagation.cc index d3eec1a9e6..516638b33c 100644 --- a/compiler/optimizing/reference_type_propagation.cc +++ b/compiler/optimizing/reference_type_propagation.cc @@ -363,7 +363,8 @@ void RTPVisitor::SetClassAsTypeInfo(HInstruction* instr, if (kIsDebugBuild) { ScopedObjectAccess soa(Thread::Current()); ClassLinker* cl = Runtime::Current()->GetClassLinker(); - mirror::DexCache* dex_cache = cl->FindDexCache(instr->AsInvoke()->GetDexFile()); + mirror::DexCache* dex_cache = cl->FindDexCache( + soa.Self(), instr->AsInvoke()->GetDexFile(), false); ArtMethod* method = dex_cache->GetResolvedMethod( instr->AsInvoke()->GetDexMethodIndex(), cl->GetImagePointerSize()); DCHECK(method != nullptr); @@ -394,7 +395,8 @@ void RTPVisitor::UpdateReferenceTypeInfo(HInstruction* instr, DCHECK_EQ(instr->GetType(), Primitive::kPrimNot); ScopedObjectAccess soa(Thread::Current()); - mirror::DexCache* dex_cache = Runtime::Current()->GetClassLinker()->FindDexCache(dex_file); + mirror::DexCache* dex_cache = Runtime::Current()->GetClassLinker()->FindDexCache( + soa.Self(), dex_file, false); // Get type from dex cache assuming it was populated by the verifier. SetClassAsTypeInfo(instr, dex_cache->GetResolvedType(type_idx), is_exact); } @@ -432,7 +434,7 @@ void RTPVisitor::UpdateFieldAccessTypeInfo(HInstruction* instr, ScopedObjectAccess soa(Thread::Current()); ClassLinker* cl = Runtime::Current()->GetClassLinker(); - mirror::DexCache* dex_cache = cl->FindDexCache(info.GetDexFile()); + mirror::DexCache* dex_cache = cl->FindDexCache(soa.Self(), info.GetDexFile(), false); ArtField* field = cl->GetResolvedField(info.GetFieldIndex(), dex_cache); // TODO: There are certain cases where we can't resolve the field. // b/21914925 is open to keep track of a repro case for this issue. @@ -451,7 +453,7 @@ void RTPVisitor::VisitStaticFieldGet(HStaticFieldGet* instr) { void RTPVisitor::VisitLoadClass(HLoadClass* instr) { ScopedObjectAccess soa(Thread::Current()); mirror::DexCache* dex_cache = - Runtime::Current()->GetClassLinker()->FindDexCache(instr->GetDexFile()); + Runtime::Current()->GetClassLinker()->FindDexCache(soa.Self(), instr->GetDexFile(), false); // Get type from dex cache assuming it was populated by the verifier. mirror::Class* resolved_class = dex_cache->GetResolvedType(instr->GetTypeIndex()); // TODO: investigating why we are still getting unresolved classes: b/22821472. @@ -634,7 +636,7 @@ void RTPVisitor::VisitInvoke(HInvoke* instr) { ScopedObjectAccess soa(Thread::Current()); ClassLinker* cl = Runtime::Current()->GetClassLinker(); - mirror::DexCache* dex_cache = cl->FindDexCache(instr->GetDexFile()); + mirror::DexCache* dex_cache = cl->FindDexCache(soa.Self(), instr->GetDexFile()); ArtMethod* method = dex_cache->GetResolvedMethod( instr->GetDexMethodIndex(), cl->GetImagePointerSize()); mirror::Class* klass = (method == nullptr) ? nullptr : method->GetReturnType(false); |