diff --git a/runtime/vm/flow_graph_builder.cc b/runtime/vm/flow_graph_builder.cc index d6871ae0d02..a506a18001c 100644 --- a/runtime/vm/flow_graph_builder.cc +++ b/runtime/vm/flow_graph_builder.cc @@ -4637,7 +4637,7 @@ FlowGraph* FlowGraphBuilder::BuildGraph() { void FlowGraphBuilder::PruneUnreachable() { ASSERT(osr_id_ != Compiler::kNoOSRDeoptId); BitVector* block_marks = new(Z) BitVector(Z, last_used_block_id_ + 1); - bool found = graph_entry_->PruneUnreachable(this, graph_entry_, NULL, osr_id_, + bool found = graph_entry_->PruneUnreachable(graph_entry_, NULL, osr_id_, block_marks); ASSERT(found); } diff --git a/runtime/vm/intermediate_language.cc b/runtime/vm/intermediate_language.cc index c3359f1f23f..f3af7360173 100644 --- a/runtime/vm/intermediate_language.cc +++ b/runtime/vm/intermediate_language.cc @@ -975,8 +975,7 @@ bool BlockEntryInstr::DiscoverBlock( } -bool BlockEntryInstr::PruneUnreachable(FlowGraphBuilder* builder, - GraphEntryInstr* graph_entry, +bool BlockEntryInstr::PruneUnreachable(GraphEntryInstr* graph_entry, Instruction* parent, intptr_t osr_id, BitVector* block_marks) { @@ -1012,8 +1011,7 @@ bool BlockEntryInstr::PruneUnreachable(FlowGraphBuilder* builder, // Recursively search the successors. for (intptr_t i = instr->SuccessorCount() - 1; i >= 0; --i) { - if (instr->SuccessorAt(i)->PruneUnreachable(builder, - graph_entry, + if (instr->SuccessorAt(i)->PruneUnreachable(graph_entry, instr, osr_id, block_marks)) { diff --git a/runtime/vm/intermediate_language.h b/runtime/vm/intermediate_language.h index 8e7241a16ea..57b98b75071 100644 --- a/runtime/vm/intermediate_language.h +++ b/runtime/vm/intermediate_language.h @@ -1176,8 +1176,7 @@ class BlockEntryInstr : public Instruction { // Perform a depth first search to prune code not reachable from an OSR // entry point. - bool PruneUnreachable(FlowGraphBuilder* builder, - GraphEntryInstr* graph_entry, + bool PruneUnreachable(GraphEntryInstr* graph_entry, Instruction* parent, intptr_t osr_id, BitVector* block_marks); diff --git a/runtime/vm/kernel_to_il.cc b/runtime/vm/kernel_to_il.cc index 0aff92bde22..e5bf5ae5da4 100644 --- a/runtime/vm/kernel_to_il.cc +++ b/runtime/vm/kernel_to_il.cc @@ -2750,7 +2750,7 @@ FlowGraph* FlowGraphBuilder::BuildGraphOfFunction(FunctionNode* function, const Function& dart_function = parsed_function_->function(); TargetEntryInstr* normal_entry = BuildTargetEntry(); graph_entry_ = new (Z) - GraphEntryInstr(*parsed_function_, normal_entry, Compiler::kNoOSRDeoptId); + GraphEntryInstr(*parsed_function_, normal_entry, osr_id_); SetupDefaultParameterValues(function); @@ -2917,6 +2917,15 @@ FlowGraph* FlowGraphBuilder::BuildGraphOfFunction(FunctionNode* function, } normal_entry->LinkTo(body.entry); + // When compiling for OSR, use a depth first search to prune instructions + // unreachable from the OSR entry. Catch entries are always considered + // reachable, even if they become unreachable after OSR. + if (osr_id_ != Compiler::kNoOSRDeoptId) { + BitVector* block_marks = new(Z) BitVector(Z, next_block_id_); + bool found = graph_entry_->PruneUnreachable(graph_entry_, NULL, osr_id_, + block_marks); + ASSERT(found); + } return new (Z) FlowGraph(*parsed_function_, graph_entry_, next_block_id_ - 1); }