summaryrefslogtreecommitdiff
path: root/compiler/optimizing/graph_checker.cc
diff options
context:
space:
mode:
author Santiago Aboy Solanes <solanes@google.com> 2022-09-06 16:15:49 +0000
committer Treehugger Robot <treehugger-gerrit@google.com> 2022-09-06 18:05:48 +0000
commit37fe26288aaacae0f26873131dd92704796e09ec (patch)
tree1b48127108019126390310fae57a553807830683 /compiler/optimizing/graph_checker.cc
parent0c8b0c159db65db503ada4d6ae1bc9a70adcefc9 (diff)
Revert "Add an environment to the beginning of catch blocks"
This reverts commit f976aa822dd35496e4e936b5802af0d53d39ac95. Reason for revert: breaking some tests https://ci.chromium.org/ui/p/art/builders/ci/angler-armv8-ndebug/3244/blamelist Change-Id: I5c2732e81bef8a7e83b661b1b947d7c079994c1b
Diffstat (limited to 'compiler/optimizing/graph_checker.cc')
-rw-r--r--compiler/optimizing/graph_checker.cc36
1 files changed, 12 insertions, 24 deletions
diff --git a/compiler/optimizing/graph_checker.cc b/compiler/optimizing/graph_checker.cc
index 10711510f2..eda6363dda 100644
--- a/compiler/optimizing/graph_checker.cc
+++ b/compiler/optimizing/graph_checker.cc
@@ -159,24 +159,6 @@ void GraphChecker::VisitBasicBlock(HBasicBlock* block) {
}
}
- // Make sure the first instruction of a catch block is always a Nop that emits an environment.
- if (block->IsCatchBlock()) {
- if (!block->GetFirstInstruction()->IsNop()) {
- AddError(StringPrintf("Block %d doesn't have a Nop as its first instruction.",
- current_block_->GetBlockId()));
- } else {
- HNop* nop = block->GetFirstInstruction()->AsNop();
- if (!nop->NeedsEnvironment()) {
- AddError(
- StringPrintf("%s:%d is a Nop and the first instruction of block %d, but it doesn't "
- "need an environment.",
- nop->DebugName(),
- nop->GetId(),
- current_block_->GetBlockId()));
- }
- }
- }
-
// Visit this block's list of phis.
for (HInstructionIterator it(block->GetPhis()); !it.Done(); it.Advance()) {
HInstruction* current = it.Current();
@@ -360,15 +342,14 @@ void GraphChecker::VisitTryBoundary(HTryBoundary* try_boundary) {
}
void GraphChecker::VisitLoadException(HLoadException* load) {
- // Ensure that LoadException is the second instruction in a catch block. The first one should be a
- // Nop (checked separately).
+ // Ensure that LoadException is the first instruction in a catch block.
if (!load->GetBlock()->IsCatchBlock()) {
AddError(StringPrintf("%s:%d is in a non-catch block %d.",
load->DebugName(),
load->GetId(),
load->GetBlock()->GetBlockId()));
- } else if (load->GetBlock()->GetFirstInstruction()->GetNext() != load) {
- AddError(StringPrintf("%s:%d is not the second instruction in catch block %d.",
+ } else if (load->GetBlock()->GetFirstInstruction() != load) {
+ AddError(StringPrintf("%s:%d is not the first instruction in catch block %d.",
load->DebugName(),
load->GetId(),
load->GetBlock()->GetBlockId()));
@@ -532,10 +513,17 @@ void GraphChecker::VisitInstruction(HInstruction* instruction) {
instruction->GetId(),
current_block_->GetBlockId()));
} else if (instruction->CanThrowIntoCatchBlock()) {
- // Find all catch blocks and test that `instruction` has an environment value for each one.
+ // Find the top-level environment. This corresponds to the environment of
+ // the catch block since we do not inline methods with try/catch.
+ HEnvironment* environment = instruction->GetEnvironment();
+ while (environment->GetParent() != nullptr) {
+ environment = environment->GetParent();
+ }
+
+ // Find all catch blocks and test that `instruction` has an environment
+ // value for each one.
const HTryBoundary& entry = instruction->GetBlock()->GetTryCatchInformation()->GetTryEntry();
for (HBasicBlock* catch_block : entry.GetExceptionHandlers()) {
- const HEnvironment* environment = catch_block->GetFirstInstruction()->GetEnvironment();
for (HInstructionIterator phi_it(catch_block->GetPhis()); !phi_it.Done(); phi_it.Advance()) {
HPhi* catch_phi = phi_it.Current()->AsPhi();
if (environment->GetInstructionAt(catch_phi->GetRegNumber()) == nullptr) {