From a09025460631dc60477bbcd9f59e04673d8cce4c Mon Sep 17 00:00:00 2001 From: Vladimir Marko Date: Tue, 13 Feb 2024 08:11:47 +0000 Subject: Unresolved field access HIR are not schedulable. Add a comment and remove dead code. Test: m test-art-host-gtest Test: testrunner.py --host --optimizing Change-Id: Ie14a1bd9633f322be7cb4bb312a1232df6697cbd --- compiler/optimizing/scheduler.cc | 43 ++++++++++++---------------------------- 1 file changed, 13 insertions(+), 30 deletions(-) (limited to 'compiler/optimizing/scheduler.cc') diff --git a/compiler/optimizing/scheduler.cc b/compiler/optimizing/scheduler.cc index 9b5091a81a..4236a545bc 100644 --- a/compiler/optimizing/scheduler.cc +++ b/compiler/optimizing/scheduler.cc @@ -106,35 +106,15 @@ static bool IsArrayAccess(const HInstruction* instruction) { } static bool IsInstanceFieldAccess(const HInstruction* instruction) { - return instruction->IsInstanceFieldGet() || - instruction->IsInstanceFieldSet() || - instruction->IsUnresolvedInstanceFieldGet() || - instruction->IsUnresolvedInstanceFieldSet(); + return instruction->IsInstanceFieldGet() || instruction->IsInstanceFieldSet(); } static bool IsStaticFieldAccess(const HInstruction* instruction) { - return instruction->IsStaticFieldGet() || - instruction->IsStaticFieldSet() || - instruction->IsUnresolvedStaticFieldGet() || - instruction->IsUnresolvedStaticFieldSet(); -} - -static bool IsResolvedFieldAccess(const HInstruction* instruction) { - return instruction->IsInstanceFieldGet() || - instruction->IsInstanceFieldSet() || - instruction->IsStaticFieldGet() || - instruction->IsStaticFieldSet(); -} - -static bool IsUnresolvedFieldAccess(const HInstruction* instruction) { - return instruction->IsUnresolvedInstanceFieldGet() || - instruction->IsUnresolvedInstanceFieldSet() || - instruction->IsUnresolvedStaticFieldGet() || - instruction->IsUnresolvedStaticFieldSet(); + return instruction->IsStaticFieldGet() || instruction->IsStaticFieldSet(); } static bool IsFieldAccess(const HInstruction* instruction) { - return IsResolvedFieldAccess(instruction) || IsUnresolvedFieldAccess(instruction); + return IsInstanceFieldAccess(instruction) || IsStaticFieldAccess(instruction); } static const FieldInfo* GetFieldInfo(const HInstruction* instruction) { @@ -165,12 +145,6 @@ bool SideEffectDependencyAnalysis::MemoryDependencyAnalysis::FieldAccessMayAlias return false; } - // If either of the field accesses is unresolved. - if (IsUnresolvedFieldAccess(instr1) || IsUnresolvedFieldAccess(instr2)) { - // Conservatively treat these two accesses may alias. - return true; - } - // If both fields accesses are resolved. size_t instr1_field_access_heap_loc = FieldAccessHeapLocation(instr1); size_t instr2_field_access_heap_loc = FieldAccessHeapLocation(instr2); @@ -201,6 +175,14 @@ bool SideEffectDependencyAnalysis::MemoryDependencyAnalysis::HasMemoryDependency return true; } + // Note: Unresolved field access instructions are currently marked as not schedulable. + // If we change that, we should still keep in mind that these instructions can throw and + // read or write volatile fields and, if static, cause class initialization and write to + // arbitrary heap locations, and therefore cannot be reordered with any other field or + // array access to preserve the observable behavior. The only exception is access to + // singleton members that could actually be reodered across these instructions but we + // currently do not analyze singletons here anyway. + if (IsArrayAccess(instr1) && IsArrayAccess(instr2)) { return ArrayAccessMayAlias(instr1, instr2); } @@ -717,7 +699,8 @@ bool HScheduler::IsSchedulable(const HInstruction* instruction) const { // HNop // HThrow // HTryBoundary - // All volatile field access e.g. HInstanceFieldGet + // All unresolved field access instructions + // All volatile field access instructions, e.g. HInstanceFieldGet // TODO: Some of the instructions above may be safe to schedule (maybe as // scheduling barriers). return instruction->IsArrayGet() || -- cgit v1.2.3-59-g8ed1b