diff options
author | 2024-05-02 15:40:47 +0100 | |
---|---|---|
committer | 2024-05-03 15:40:42 +0000 | |
commit | a4ac01044c50f4da02c40b8da5520d2eb65b41d9 (patch) | |
tree | cd19c2cf8a0422876df3d70327687229748bd77a /runtime/entrypoints/entrypoint_utils-inl.h | |
parent | 721bbf2bfd6ffe689067df5657059925e038bb0d (diff) |
Workaround for b/336842546
Resolve the type if it hasn't been resolved before. Also, change to
use Handles instead of ObjPtr since ResolveType can potentially
suspend.
Bug: 336842546
Bug: 73760543
Test: art/test/testrunner/testrunner.py --host --64 --optimizing -b
Change-Id: I8ad77e63d6d9cc76fee8aac88742d4a4b678abf5
Diffstat (limited to 'runtime/entrypoints/entrypoint_utils-inl.h')
-rw-r--r-- | runtime/entrypoints/entrypoint_utils-inl.h | 34 |
1 files changed, 22 insertions, 12 deletions
diff --git a/runtime/entrypoints/entrypoint_utils-inl.h b/runtime/entrypoints/entrypoint_utils-inl.h index b0d0ab4b07..e1efa4a0ac 100644 --- a/runtime/entrypoints/entrypoint_utils-inl.h +++ b/runtime/entrypoints/entrypoint_utils-inl.h @@ -131,50 +131,60 @@ inline ArtMethod* GetResolvedMethod(ArtMethod* outer_method, ClassLinker* class_linker = Runtime::Current()->GetClassLinker(); ArtMethod* method = outer_method; for (InlineInfo inline_info : inline_infos) { + StackHandleScope<2> hs(Thread::Current()); + Handle<mirror::DexCache> h_dex_cache; + Handle<mirror::ClassLoader> h_class_loader; DCHECK(!inline_info.EncodesArtMethod()); DCHECK_NE(inline_info.GetDexPc(), static_cast<uint32_t>(-1)); MethodInfo method_info = code_info.GetMethodInfoOf(inline_info); uint32_t method_index = method_info.GetMethodIndex(); const uint32_t dex_file_index = method_info.GetDexFileIndex(); ArtMethod* inlined_method = nullptr; - ObjPtr<mirror::DexCache> dex_cache = nullptr; if (method_info.HasDexFileIndex()) { if (method_info.GetDexFileIndexKind() == MethodInfo::kKindBCP) { ArrayRef<const DexFile* const> bcp_dex_files(class_linker->GetBootClassPath()); DCHECK_LT(dex_file_index, bcp_dex_files.size()) << "OOB access to bcp_dex_files. Dumping info: " - << GetResolvedMethodErrorString( - class_linker, inlined_method, method, outer_method, dex_cache, method_info); + << GetResolvedMethodErrorString(class_linker, + inlined_method, + method, + outer_method, + /*dex_cache=*/ nullptr, + method_info); const DexFile* dex_file = bcp_dex_files[dex_file_index]; DCHECK_NE(dex_file, nullptr); - dex_cache = class_linker->FindDexCache(Thread::Current(), *dex_file); + h_dex_cache = hs.NewHandle(class_linker->FindDexCache(Thread::Current(), *dex_file)); } else { ArrayRef<const OatDexFile* const> oat_dex_files( outer_method->GetDexFile()->GetOatDexFile()->GetOatFile()->GetOatDexFiles()); DCHECK_LT(dex_file_index, oat_dex_files.size()) << "OOB access to oat_dex_files. Dumping info: " - << GetResolvedMethodErrorString( - class_linker, inlined_method, method, outer_method, dex_cache, method_info); + << GetResolvedMethodErrorString(class_linker, + inlined_method, + method, + outer_method, + /*dex_cache=*/ nullptr, + method_info); const OatDexFile* odf = oat_dex_files[dex_file_index]; DCHECK_NE(odf, nullptr); - dex_cache = class_linker->FindDexCache(Thread::Current(), *odf); + h_dex_cache = hs.NewHandle(class_linker->FindDexCache(Thread::Current(), *odf)); } } else { - dex_cache = outer_method->GetDexCache(); + h_dex_cache = hs.NewHandle(outer_method->GetDexCache()); } - inlined_method = - class_linker->LookupResolvedMethod(method_index, dex_cache, dex_cache->GetClassLoader()); + h_class_loader = hs.NewHandle(h_dex_cache->GetClassLoader()); + inlined_method = class_linker->LookupResolvedMethod(method_index, h_dex_cache, h_class_loader); if (UNLIKELY(inlined_method == nullptr)) { LOG(FATAL) << GetResolvedMethodErrorString( - class_linker, inlined_method, method, outer_method, dex_cache, method_info); + class_linker, inlined_method, method, outer_method, h_dex_cache.Get(), method_info); UNREACHABLE(); } DCHECK(!inlined_method->IsRuntimeMethod()); DCHECK_EQ(inlined_method->GetDexFile() == outer_method->GetDexFile(), dex_file_index == MethodInfo::kSameDexFile) << GetResolvedMethodErrorString( - class_linker, inlined_method, method, outer_method, dex_cache, method_info); + class_linker, inlined_method, method, outer_method, h_dex_cache.Get(), method_info); method = inlined_method; } |