diff options
author | 2024-04-18 13:21:15 +0000 | |
---|---|---|
committer | 2024-04-22 07:28:48 +0000 | |
commit | 4a79b17f374df876803e34edb60476fe33ab1671 (patch) | |
tree | 12c07faf384d12d7ae535300f8218527628144b1 /compiler/optimizing/instruction_builder.cc | |
parent | 55e99bd1c5a403c4bddc023403593c9199af56f2 (diff) |
Optimizing: Treat app image objects as non-movable.
Treat app image objects similar to boot image objects and
avoid unnecessary read barriers for app image `HLoadClass`
and `HInstanceOf` checks with app image `HLoadClass` input.
Extend other optimizations to treat app image classes the
same way as boot image classes even though this remains
mostly dormant because we currently do not initialize app
image classes with class initializers; the experimental
flag `--initialize-app-image-classes` is false by default.
Test: m test-art-host-gtest
Test: testrunner.py --host --optimizing --speed-profile
Bug: 38313278
Change-Id: I359dd8897f6d128213602f5731d40edace298ab8
Diffstat (limited to 'compiler/optimizing/instruction_builder.cc')
-rw-r--r-- | compiler/optimizing/instruction_builder.cc | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/compiler/optimizing/instruction_builder.cc b/compiler/optimizing/instruction_builder.cc index 81970d2108..344a93707d 100644 --- a/compiler/optimizing/instruction_builder.cc +++ b/compiler/optimizing/instruction_builder.cc @@ -1513,12 +1513,12 @@ void HInstructionBuilder::BuildConstructorFenceForAllocation(HInstruction* alloc MethodCompilationStat::kConstructorFenceGeneratedNew); } -static bool IsInBootImage(ObjPtr<mirror::Class> cls, const CompilerOptions& compiler_options) +static bool IsInImage(ObjPtr<mirror::Class> cls, const CompilerOptions& compiler_options) REQUIRES_SHARED(Locks::mutator_lock_) { if (Runtime::Current()->GetHeap()->ObjectIsInBootImageSpace(cls)) { return true; } - if (compiler_options.IsBootImage() || compiler_options.IsBootImageExtension()) { + if (compiler_options.IsGeneratingImage()) { std::string temp; const char* descriptor = cls->GetDescriptor(&temp); return compiler_options.IsImageClass(descriptor); @@ -1634,8 +1634,8 @@ static bool HasTrivialInitialization(ObjPtr<mirror::Class> cls, // Check the superclass chain. for (ObjPtr<mirror::Class> klass = cls; klass != nullptr; klass = klass->GetSuperClass()) { - if (klass->IsInitialized() && IsInBootImage(klass, compiler_options)) { - break; // `klass` and its superclasses are already initialized in the boot image. + if (klass->IsInitialized() && IsInImage(klass, compiler_options)) { + break; // `klass` and its superclasses are already initialized in the boot or app image. } if (!HasTrivialClinit(klass, pointer_size)) { return false; @@ -1650,8 +1650,8 @@ static bool HasTrivialInitialization(ObjPtr<mirror::Class> cls, if (!iface->HasDefaultMethods()) { continue; // Initializing `cls` does not initialize this interface. } - if (iface->IsInitialized() && IsInBootImage(iface, compiler_options)) { - continue; // This interface is already initialized in the boot image. + if (iface->IsInitialized() && IsInImage(iface, compiler_options)) { + continue; // This interface is already initialized in the boot or app image. } if (!HasTrivialClinit(iface, pointer_size)) { return false; @@ -1669,9 +1669,8 @@ bool HInstructionBuilder::IsInitialized(ObjPtr<mirror::Class> cls) const { if (cls->IsInitialized()) { const CompilerOptions& compiler_options = code_generator_->GetCompilerOptions(); if (compiler_options.IsAotCompiler()) { - // Assume loaded only if klass is in the boot image. App classes cannot be assumed - // loaded because we don't even know what class loader will be used to load them. - if (IsInBootImage(cls, compiler_options)) { + // Assume loaded only if klass is in the boot or app image. + if (IsInImage(cls, compiler_options)) { return true; } } else { |