diff options
author | 2024-02-13 08:11:47 +0000 | |
---|---|---|
committer | 2024-02-13 10:50:40 +0000 | |
commit | a09025460631dc60477bbcd9f59e04673d8cce4c (patch) | |
tree | c885b005304ff7d155cb57464712380746bd7899 /compiler/optimizing | |
parent | 5cda0cc8f1f44df121080e26eefbae4c3116e2fb (diff) |
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
Diffstat (limited to 'compiler/optimizing')
-rw-r--r-- | compiler/optimizing/scheduler.cc | 43 |
1 files changed, 13 insertions, 30 deletions
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() || |