From 69a87e30730d0c6e6e5974fd2bd001f77fffed5e Mon Sep 17 00:00:00 2001 From: Santiago Aboy Solanes Date: Tue, 8 Mar 2022 16:43:54 +0000 Subject: Revert^4 "Add bss support for inlining BCP DexFiles for single image" This reverts commit 1849c3a875aab44d9bff45623ec076b0331302f8. Reason for revert: Relading after fix. It can be seen in PS 1..2 Bug: 154012332 Test: art/test/testrunner/testrunner.py --target --32 --optimizing Test: art/test/testrunner/testrunner.py --host --64 --optimizing Change-Id: I168572957363dd5ae1598279f2ecc8fb947a1fd5 --- runtime/entrypoints/entrypoint_utils.cc | 51 ++++++++++++++++++++++++--------- 1 file changed, 38 insertions(+), 13 deletions(-) (limited to 'runtime/entrypoints/entrypoint_utils.cc') diff --git a/runtime/entrypoints/entrypoint_utils.cc b/runtime/entrypoints/entrypoint_utils.cc index 1c0127a519..63d2aa4351 100644 --- a/runtime/entrypoints/entrypoint_utils.cc +++ b/runtime/entrypoints/entrypoint_utils.cc @@ -36,6 +36,7 @@ #include "mirror/object_array-inl.h" #include "nth_caller_visitor.h" #include "oat_file.h" +#include "oat_file-inl.h" #include "oat_quick_method_header.h" #include "reflection.h" #include "scoped_thread_state_change-inl.h" @@ -284,22 +285,46 @@ ObjPtr ResolveMethodTypeFromCode(ArtMethod* referrer, return method_type; } -void MaybeUpdateBssMethodEntry(ArtMethod* callee, MethodReference callee_reference) { - DCHECK(callee != nullptr); - if (callee_reference.dex_file->GetOatDexFile() != nullptr) { - size_t bss_offset = IndexBssMappingLookup::GetBssOffset( - callee_reference.dex_file->GetOatDexFile()->GetMethodBssMapping(), - callee_reference.index, - callee_reference.dex_file->NumMethodIds(), - static_cast(kRuntimePointerSize)); +void MaybeUpdateBssMethodEntry(ArtMethod* callee, + MethodReference callee_reference, + ArtMethod* outer_method) { + DCHECK_NE(callee, nullptr); + if (outer_method->GetDexFile()->GetOatDexFile() == nullptr || + outer_method->GetDexFile()->GetOatDexFile()->GetOatFile() == nullptr) { + // No OatFile to update. + return; + } + const OatFile* outer_oat_file = outer_method->GetDexFile()->GetOatDexFile()->GetOatFile(); + + const DexFile* dex_file = callee_reference.dex_file; + const OatDexFile* oat_dex_file = dex_file->GetOatDexFile(); + const IndexBssMapping* mapping = nullptr; + if (oat_dex_file != nullptr && oat_dex_file->GetOatFile() == outer_oat_file) { + // DexFiles compiled together to an oat file case. + mapping = oat_dex_file->GetMethodBssMapping(); + } else { + // Try to find the DexFile in the BCP of the outer_method. + const OatFile::BssMappingInfo* mapping_info = outer_oat_file->FindBcpMappingInfo(dex_file); + if (mapping_info != nullptr) { + mapping = mapping_info->method_bss_mapping; + } + } + + // Perform the update if we found a mapping. + if (mapping != nullptr) { + size_t bss_offset = + IndexBssMappingLookup::GetBssOffset(mapping, + callee_reference.index, + dex_file->NumMethodIds(), + static_cast(kRuntimePointerSize)); if (bss_offset != IndexBssMappingLookup::npos) { DCHECK_ALIGNED(bss_offset, static_cast(kRuntimePointerSize)); - const OatFile* oat_file = callee_reference.dex_file->GetOatDexFile()->GetOatFile(); - ArtMethod** method_entry = reinterpret_cast(const_cast( - oat_file->BssBegin() + bss_offset)); - DCHECK_GE(method_entry, oat_file->GetBssMethods().data()); + DCHECK_NE(outer_oat_file, nullptr); + ArtMethod** method_entry = reinterpret_cast( + const_cast(outer_oat_file->BssBegin() + bss_offset)); + DCHECK_GE(method_entry, outer_oat_file->GetBssMethods().data()); DCHECK_LT(method_entry, - oat_file->GetBssMethods().data() + oat_file->GetBssMethods().size()); + outer_oat_file->GetBssMethods().data() + outer_oat_file->GetBssMethods().size()); std::atomic* atomic_entry = reinterpret_cast*>(method_entry); if (kIsDebugBuild) { -- cgit v1.2.3-59-g8ed1b