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_simplifier.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_simplifier.cc')
-rw-r--r-- | compiler/optimizing/instruction_simplifier.cc | 27 |
1 files changed, 13 insertions, 14 deletions
diff --git a/compiler/optimizing/instruction_simplifier.cc b/compiler/optimizing/instruction_simplifier.cc index 2710f49ef2..56bbd8017f 100644 --- a/compiler/optimizing/instruction_simplifier.cc +++ b/compiler/optimizing/instruction_simplifier.cc @@ -127,7 +127,7 @@ class InstructionSimplifierVisitor final : public HGraphDelegateVisitor { void SimplifyAllocationIntrinsic(HInvoke* invoke); void SimplifyVarHandleIntrinsic(HInvoke* invoke); - bool CanUseKnownBootImageVarHandle(HInvoke* invoke); + bool CanUseKnownImageVarHandle(HInvoke* invoke); static bool CanEnsureNotNullAt(HInstruction* input, HInstruction* at); CodeGenerator* codegen_; @@ -3025,15 +3025,15 @@ void InstructionSimplifierVisitor::SimplifyVarHandleIntrinsic(HInvoke* invoke) { } } - if (CanUseKnownBootImageVarHandle(invoke)) { - optimizations.SetUseKnownBootImageVarHandle(); + if (CanUseKnownImageVarHandle(invoke)) { + optimizations.SetUseKnownImageVarHandle(); } } -bool InstructionSimplifierVisitor::CanUseKnownBootImageVarHandle(HInvoke* invoke) { - // If the `VarHandle` comes from a static final field of an initialized class in - // the boot image, we can do the checks at compile time. We do this optimization only - // for AOT and only for field handles when we can avoid all checks. This avoids the +bool InstructionSimplifierVisitor::CanUseKnownImageVarHandle(HInvoke* invoke) { + // If the `VarHandle` comes from a static final field of an initialized class in an image + // (boot image or app image), we can do the checks at compile time. We do this optimization + // only for AOT and only for field handles when we can avoid all checks. This avoids the // possibility of the code concurrently messing with the `VarHandle` using reflection, // we simply perform the operation with the `VarHandle` as seen at compile time. // TODO: Extend this to arrays to support the `AtomicIntegerArray` class. @@ -3066,18 +3066,17 @@ bool InstructionSimplifierVisitor::CanUseKnownBootImageVarHandle(HInvoke* invoke } HInstruction* load_class = var_handle_instruction->InputAt(0); if (kIsDebugBuild) { - bool is_in_boot_image = false; + bool is_in_image = false; if (Runtime::Current()->GetHeap()->ObjectIsInBootImageSpace(declaring_class)) { - is_in_boot_image = true; - } else if (compiler_options.IsBootImage() || compiler_options.IsBootImageExtension()) { + is_in_image = true; + } else if (compiler_options.IsGeneratingImage()) { std::string storage; const char* descriptor = declaring_class->GetDescriptor(&storage); - is_in_boot_image = compiler_options.IsImageClass(descriptor); + is_in_image = compiler_options.IsImageClass(descriptor); } - CHECK_EQ(is_in_boot_image, - load_class->IsLoadClass() && load_class->AsLoadClass()->IsInBootImage()); + CHECK_EQ(is_in_image, load_class->IsLoadClass() && load_class->AsLoadClass()->IsInImage()); } - if (!load_class->IsLoadClass() || !load_class->AsLoadClass()->IsInBootImage()) { + if (!load_class->IsLoadClass() || !load_class->AsLoadClass()->IsInImage()) { return false; } |