From 4a79b17f374df876803e34edb60476fe33ab1671 Mon Sep 17 00:00:00 2001 From: Vladimir Marko Date: Thu, 18 Apr 2024 13:21:15 +0000 Subject: 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 --- compiler/optimizing/instruction_builder.cc | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) (limited to 'compiler/optimizing/instruction_builder.cc') 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 cls, const CompilerOptions& compiler_options) +static bool IsInImage(ObjPtr 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 cls, // Check the superclass chain. for (ObjPtr 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 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 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 { -- cgit v1.2.3-59-g8ed1b