diff options
author | 2024-03-07 14:46:40 +0000 | |
---|---|---|
committer | 2024-03-19 13:48:04 +0000 | |
commit | 799ea81c066e910da7efb1ad06bc7d2dbc966726 (patch) | |
tree | 20d0bcd36da21962eac0bd5522014605d9bfeb58 | |
parent | c655cdc973087e8357e6aa388cbb1b0e737b69e6 (diff) |
Remove the environment from ArraySets which can't throw
When clearing the NeedsTypeCheck flag in ArraySet instructions,
we can remove the environment as it is no longer needed.
Also add a check in GraphChecker that instructions have an
environment iff they need one.
Test: art/test/testrunner/testrunner.py --host --64 --optimizing -b
Change-Id: I698d9d88bc7c6c8569caf6397cbebf29b34585d5
-rw-r--r-- | compiler/optimizing/graph_checker.cc | 12 | ||||
-rw-r--r-- | compiler/optimizing/nodes.h | 2 |
2 files changed, 11 insertions, 3 deletions
diff --git a/compiler/optimizing/graph_checker.cc b/compiler/optimizing/graph_checker.cc index b061b401ff..f2662700c7 100644 --- a/compiler/optimizing/graph_checker.cc +++ b/compiler/optimizing/graph_checker.cc @@ -673,9 +673,15 @@ void GraphChecker::VisitInstruction(HInstruction* instruction) { } } - if (instruction->NeedsEnvironment() && !instruction->HasEnvironment()) { - AddError(StringPrintf("Instruction %s:%d in block %d requires an environment " - "but does not have one.", + if (instruction->NeedsEnvironment() != instruction->HasEnvironment()) { + const char* str; + if (instruction->NeedsEnvironment()) { + str = "Instruction %s:%d in block %d requires an environment but does not have one."; + } else { + str = "Instruction %s:%d in block %d doesn't require an environment but it has one."; + } + + AddError(StringPrintf(str, instruction->DebugName(), instruction->GetId(), current_block_->GetBlockId())); diff --git a/compiler/optimizing/nodes.h b/compiler/optimizing/nodes.h index 4d6b909629..8a47895625 100644 --- a/compiler/optimizing/nodes.h +++ b/compiler/optimizing/nodes.h @@ -6607,6 +6607,8 @@ class HArraySet final : public HExpression<3> { SetPackedFlag<kFlagNeedsTypeCheck>(false); // Clear the `CanTriggerGC` flag too as we can only trigger a GC when doing a type check. SetSideEffects(GetSideEffects().Exclusion(SideEffects::CanTriggerGC())); + // Clear the environment too as we can only throw if we need a type check. + RemoveEnvironment(); } void ClearValueCanBeNull() { |