summaryrefslogtreecommitdiff
path: root/compiler/optimizing/builder.cc
diff options
context:
space:
mode:
author David Brazdil <dbrazdil@google.com> 2015-07-01 15:16:14 +0000
committer Gerrit Code Review <noreply-gerritcodereview@google.com> 2015-07-01 15:16:15 +0000
commit8941d5e0755e8cd3f1e35e3efcbe8eeaf3b616fa (patch)
tree5a318a6fc2009bfe49d7073af6d660ed1d4fed67 /compiler/optimizing/builder.cc
parent8922e0b575742aaabbb4168b8703f7c1a4cb346c (diff)
parent49bace1ccbec6f12b5b475ccc2ce76e0b666b500 (diff)
Merge "Address additional comments on try-catch CL"
Diffstat (limited to 'compiler/optimizing/builder.cc')
-rw-r--r--compiler/optimizing/builder.cc18
1 files changed, 13 insertions, 5 deletions
diff --git a/compiler/optimizing/builder.cc b/compiler/optimizing/builder.cc
index 883c983fed..54155dbef4 100644
--- a/compiler/optimizing/builder.cc
+++ b/compiler/optimizing/builder.cc
@@ -346,11 +346,19 @@ void HGraphBuilder::InsertTryBoundaryBlocks(const DexFile::CodeItem& code_item)
// Catch blocks are always considered an entry point into the TryItem in
// order to avoid splitting exceptional edges (they might not have been
// created yet). We separate the move-exception (if present) from the
- // rest of the block and insert a TryBoundary after it.
- HInstruction* split_position = try_block->GetFirstInstruction();
- if (split_position->IsLoadException()) {
- DCHECK(split_position->GetNext()->IsStoreLocal());
- split_position = split_position->GetNext()->GetNext();
+ // rest of the block and insert a TryBoundary after it, creating a
+ // landing pad for the exceptional edges.
+ HInstruction* first_insn = try_block->GetFirstInstruction();
+ HInstruction* split_position = nullptr;
+ if (first_insn->IsLoadException()) {
+ // Catch block starts with a LoadException. Split the block after the
+ // StoreLocal that must come after the load.
+ DCHECK(first_insn->GetNext()->IsStoreLocal());
+ split_position = first_insn->GetNext()->GetNext();
+ } else {
+ // Catch block does not obtain the exception. Split at the beginning
+ // to create an empty catch block.
+ split_position = first_insn;
}
DCHECK(split_position != nullptr);
HBasicBlock* catch_block = try_block;