From 3fcfd7303a7a0683e334d0509b17d65d773b3d71 Mon Sep 17 00:00:00 2001 From: Santiago Aboy Solanes Date: Wed, 7 Sep 2022 10:31:59 +0000 Subject: Reland "Add an environment to the beginning of catch blocks" This reverts commit 37fe26288aaacae0f26873131dd92704796e09ec. Reason for revert: Pattern match fix Bug: 227283224 Test: art/test/testrunner/testrunner.py --host --64 --optimizing -b Test: art/test/testrunner/testrunner.py --host --64 --optimizing -b --debuggable 565-checker-condition-liveness (also for --target) Change-Id: Iaf784c12fb6229df6cfbd9a1b43467f5ed43c4d4 --- compiler/optimizing/instruction_builder.cc | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'compiler/optimizing/instruction_builder.cc') diff --git a/compiler/optimizing/instruction_builder.cc b/compiler/optimizing/instruction_builder.cc index 605427ba11..ba58c8d1fe 100644 --- a/compiler/optimizing/instruction_builder.cc +++ b/compiler/optimizing/instruction_builder.cc @@ -343,6 +343,10 @@ static bool IsBlockPopulated(HBasicBlock* block) { // Suspend checks were inserted into loop headers during building of dominator tree. DCHECK(block->GetFirstInstruction()->IsSuspendCheck()); return block->GetFirstInstruction() != block->GetLastInstruction(); + } else if (block->IsCatchBlock()) { + // Nops were inserted into the beginning of catch blocks. + DCHECK(block->GetFirstInstruction()->IsNop()); + return block->GetFirstInstruction() != block->GetLastInstruction(); } else { return !block->GetInstructions().IsEmpty(); } @@ -387,6 +391,11 @@ bool HInstructionBuilder::Build() { // This is slightly odd because the loop header might not be empty (TryBoundary). // But we're still creating the environment with locals from the top of the block. InsertInstructionAtTop(suspend_check); + } else if (current_block_->IsCatchBlock()) { + // We add an environment emitting instruction at the beginning of each catch block, in order + // to support try catch inlining. + // This is slightly odd because the catch block might not be empty (TryBoundary). + InsertInstructionAtTop(new (allocator_) HNop(block_dex_pc, /* needs_environment= */ true)); } if (block_dex_pc == kNoDexPc || current_block_ != block_builder_->GetBlockAt(block_dex_pc)) { -- cgit v1.2.3-59-g8ed1b