diff options
author | 2022-03-23 08:25:33 +0000 | |
---|---|---|
committer | 2022-04-06 15:09:46 +0000 | |
commit | f4bd5debf74ee5473756b4cbd71fadb3506e653b (patch) | |
tree | 115bb605fbd66a90d0c3ff12cc196fd4ebdca528 | |
parent | 6a1d9b9106183d829fd17e81cce345d1ef81f034 (diff) |
Touch up changes related to cross-dex compiling
* Added exaplanatory comments
* Used IsBootStrapClassLoaded to avoid a read barrier
* Use the new multi-image from CompilerOptions
Bug: 154012332
Test: art/test/testrunner/testrunner.py --host --64 --optimizing -b
Change-Id: I10a4ed0f9d5b2e796102846564a54dc90f297068
-rw-r--r-- | compiler/driver/compiler_options.h | 5 | ||||
-rw-r--r-- | compiler/optimizing/inliner.cc | 21 | ||||
-rw-r--r-- | compiler/optimizing/stack_map_stream.cc | 4 | ||||
-rw-r--r-- | runtime/hidden_api.cc | 2 | ||||
-rw-r--r-- | runtime/jit/jit_code_cache.cc | 2 |
5 files changed, 17 insertions, 17 deletions
diff --git a/compiler/driver/compiler_options.h b/compiler/driver/compiler_options.h index 0034306fdf..1bffdb11ed 100644 --- a/compiler/driver/compiler_options.h +++ b/compiler/driver/compiler_options.h @@ -26,6 +26,7 @@ #include "base/globals.h" #include "base/hash_set.h" #include "base/macros.h" +#include "base/stl_util.h" #include "base/utils.h" #include "optimizing/register_allocator.h" @@ -377,9 +378,9 @@ class CompilerOptions final { return initialize_app_image_classes_; } + // Returns true if `dex_file` is within an oat file we're producing right now. bool WithinOatFile(const DexFile* dex_file) const { - return std::find(GetDexFilesForOatFile().begin(), GetDexFilesForOatFile().end(), dex_file) != - GetDexFilesForOatFile().end(); + return ContainsElement(GetDexFilesForOatFile(), dex_file); } private: diff --git a/compiler/optimizing/inliner.cc b/compiler/optimizing/inliner.cc index 741e6dffc1..8b41205c53 100644 --- a/compiler/optimizing/inliner.cc +++ b/compiler/optimizing/inliner.cc @@ -1744,13 +1744,11 @@ static bool CanEncodeInlinedMethodInStackMap(const DexFile& outer_dex_file, // Inline across dexfiles if the callee's DexFile is: // 1) in the bootclasspath, or - if (callee->GetDeclaringClass()->GetClassLoader() == nullptr) { + if (callee->GetDeclaringClass()->IsBootStrapClassLoaded()) { // In multi-image, each BCP DexFile has their own OatWriter. Since they don't cooperate with // each other, we request the BSS check for them. - // TODO(solanes): Add .bss support for BCP multi-image. - const bool is_multi_image = codegen->GetCompilerOptions().IsBootImage() || - codegen->GetCompilerOptions().IsBootImageExtension(); - *out_needs_bss_check = is_multi_image; + // TODO(solanes, 154012332): Add .bss support for BCP multi-image. + *out_needs_bss_check = codegen->GetCompilerOptions().IsMultiImage(); return true; } @@ -1939,13 +1937,14 @@ bool HInliner::CanInlineBody(const HGraph* callee_graph, return false; } - // We currently don't have support for inlining across dex files if the inlined method needs a - // .bss entry. This only happens when we are: + // We currently don't have support for inlining across dex files if we are: // 1) In AoT, - // 2) cross-dex inlining, and - // 3) have an instruction that needs a bss entry, which will always be - // 3)b) an instruction that needs an environment. - // TODO(solanes, 154012332): Add this support. + // 2) cross-dex inlining, + // 3) the callee is a BCP DexFile, + // 4) we are compiling multi image, and + // 5) have an instruction that needs a bss entry, which will always be + // 5)b) an instruction that needs an environment. + // 1) - 4) are encoded in `needs_bss_check` (see CanEncodeInlinedMethodInStackMap). if (needs_bss_check && current->NeedsBss()) { DCHECK(current->NeedsEnvironment()); LOG_FAIL(stats_, MethodCompilationStat::kNotInlinedBss) diff --git a/compiler/optimizing/stack_map_stream.cc b/compiler/optimizing/stack_map_stream.cc index 7317bdfc8f..f55bbee1c8 100644 --- a/compiler/optimizing/stack_map_stream.cc +++ b/compiler/optimizing/stack_map_stream.cc @@ -224,7 +224,7 @@ void StackMapStream::BeginInlineInfoEntry(ArtMethod* method, ScopedObjectAccess soa(Thread::Current()); const DexFile* dex_file = method->GetDexFile(); if (!IsSameDexFile(*outer_dex_file, *dex_file)) { - if (method->GetDeclaringClass()->GetClassLoader() == nullptr) { + if (method->GetDeclaringClass()->IsBootStrapClassLoaded()) { ClassLinker* class_linker = Runtime::Current()->GetClassLinker(); const std::vector<const DexFile*>& boot_class_path = class_linker->GetBootClassPath(); auto it = std::find_if( @@ -269,7 +269,7 @@ void StackMapStream::BeginInlineInfoEntry(ArtMethod* method, ScopedObjectAccess soa(Thread::Current()); if (inline_info.GetDexPc() != static_cast<uint32_t>(-1) && !IsSameDexFile(*outer_dex_file, *method->GetDexFile())) { - if (method->GetDeclaringClass()->GetClassLoader() == nullptr) { + if (method->GetDeclaringClass()->IsBootStrapClassLoaded()) { CHECK_EQ(method_info.GetDexFileIndexKind(), MethodInfo::kKindBCP); ClassLinker* class_linker = Runtime::Current()->GetClassLinker(); const std::vector<const DexFile*>& boot_class_path = class_linker->GetBootClassPath(); diff --git a/runtime/hidden_api.cc b/runtime/hidden_api.cc index e1d0f70e79..54acbb449c 100644 --- a/runtime/hidden_api.cc +++ b/runtime/hidden_api.cc @@ -684,7 +684,7 @@ bool ShouldDenyAccessToMember(T* member, // The check only applies to boot classpaths dex files. Runtime* runtime = Runtime::Current(); if (UNLIKELY(runtime->IsAotCompiler())) { - if (member->GetDeclaringClass()->GetClassLoader() == nullptr && + if (member->GetDeclaringClass()->IsBootStrapClassLoaded() && runtime->GetClassLinker()->DenyAccessBasedOnPublicSdk(member)) { return true; } diff --git a/runtime/jit/jit_code_cache.cc b/runtime/jit/jit_code_cache.cc index e6be531d36..0b34688ff3 100644 --- a/runtime/jit/jit_code_cache.cc +++ b/runtime/jit/jit_code_cache.cc @@ -326,7 +326,7 @@ const void* JitCodeCache::GetJniStubCode(ArtMethod* method) { const void* JitCodeCache::GetSavedEntryPointOfPreCompiledMethod(ArtMethod* method) { if (method->IsPreCompiled()) { const void* code_ptr = nullptr; - if (method->GetDeclaringClass()->GetClassLoader() == nullptr) { + if (method->GetDeclaringClass()->IsBootStrapClassLoaded()) { code_ptr = zygote_map_.GetCodeFor(method); } else { MutexLock mu(Thread::Current(), *Locks::jit_lock_); |