diff options
author | 2021-10-01 09:26:56 +0100 | |
---|---|---|
committer | 2021-10-26 13:51:31 +0000 | |
commit | d690f8ae8f8e2675bc52089a83ac18c749f8e6d2 (patch) | |
tree | dac10b65d901cad87d6dbb7b48453f6da214a76f /compiler/optimizing/stack_map_stream.cc | |
parent | e91a954ee350cbc0b311f342c90697191e1ae495 (diff) |
Inline across dex files for bootclaspath's methods
We can relax a bit the restriction for not inlining across dexfiles when
we are AoT compiling and we need an environment. There's an added new
restriction related to BSS entries. We could potentially inline across
dex files for those cases too but are left to be solved in follow-up
CLs.
Bug: 154012332
Test: ART tests
Change-Id: I5122b26c79b3e30d2643c0ccc05d595a0047953e
Diffstat (limited to 'compiler/optimizing/stack_map_stream.cc')
-rw-r--r-- | compiler/optimizing/stack_map_stream.cc | 37 |
1 files changed, 33 insertions, 4 deletions
diff --git a/compiler/optimizing/stack_map_stream.cc b/compiler/optimizing/stack_map_stream.cc index e52a3ce272..964b48c6ac 100644 --- a/compiler/optimizing/stack_map_stream.cc +++ b/compiler/optimizing/stack_map_stream.cc @@ -17,10 +17,14 @@ #include "stack_map_stream.h" #include <memory> +#include <vector> #include "art_method-inl.h" #include "base/stl_util.h" +#include "class_linker.h" +#include "dex/dex_file.h" #include "dex/dex_file_types.h" +#include "optimizing/nodes.h" #include "optimizing/optimizing_compiler.h" #include "runtime.h" #include "scoped_thread_state_change-inl.h" @@ -211,12 +215,26 @@ void StackMapStream::BeginInlineInfoEntry(ArtMethod* method, entry[InlineInfo::kArtMethodHi] = High32Bits(reinterpret_cast<uintptr_t>(method)); entry[InlineInfo::kArtMethodLo] = Low32Bits(reinterpret_cast<uintptr_t>(method)); } else { - if (dex_pc != static_cast<uint32_t>(-1) && kIsDebugBuild) { + uint32_t bootclasspath_index = MethodInfo::kSameDexFile; + if (dex_pc != static_cast<uint32_t>(-1)) { ScopedObjectAccess soa(Thread::Current()); - DCHECK(IsSameDexFile(*outer_dex_file, *method->GetDexFile())); + const DexFile* dex_file = method->GetDexFile(); + if (method->GetDeclaringClass()->GetClassLoader() == nullptr) { + ClassLinker* class_linker = Runtime::Current()->GetClassLinker(); + const std::vector<const DexFile*>& boot_class_path = class_linker->GetBootClassPath(); + auto it = std::find_if( + boot_class_path.begin(), boot_class_path.end(), [dex_file](const DexFile* df) { + return IsSameDexFile(*df, *dex_file); + }); + DCHECK(it != boot_class_path.end()); + bootclasspath_index = std::distance(boot_class_path.begin(), it); + } else { + DCHECK(IsSameDexFile(*outer_dex_file, *dex_file)); + } } uint32_t dex_method_index = method->GetDexMethodIndex(); - entry[InlineInfo::kMethodInfoIndex] = method_infos_.Dedup({dex_method_index}); + entry[InlineInfo::kMethodInfoIndex] = + method_infos_.Dedup({dex_method_index, bootclasspath_index}); } current_inline_infos_.push_back(entry); @@ -232,7 +250,18 @@ void StackMapStream::BeginInlineInfoEntry(ArtMethod* method, if (encode_art_method) { CHECK_EQ(inline_info.GetArtMethod(), method); } else { - CHECK_EQ(code_info.GetMethodIndexOf(inline_info), method->GetDexMethodIndex()); + MethodInfo method_info = code_info.GetMethodInfoOf(inline_info); + CHECK_EQ(method_info.GetMethodIndex(), method->GetDexMethodIndex()); + if (inline_info.GetDexPc() != static_cast<uint32_t>(-1)) { + ScopedObjectAccess soa(Thread::Current()); + if (method->GetDeclaringClass()->GetClassLoader() == nullptr) { + ClassLinker* class_linker = Runtime::Current()->GetClassLinker(); + const std::vector<const DexFile*>& boot_class_path = class_linker->GetBootClassPath(); + DCHECK_LT(method_info.GetDexFileIndex(), boot_class_path.size()); + CHECK(IsSameDexFile(*boot_class_path[method_info.GetDexFileIndex()], + *method->GetDexFile())); + } + } } }); } |