Index: runtime/vm/kernel_to_il.cc |
diff --git a/runtime/vm/kernel_to_il.cc b/runtime/vm/kernel_to_il.cc |
index 0aff92bde22c049fe019ecf25664c11b8a31faf7..bc8fbf0554fa8658546a958330f4427640c28ad0 100644 |
--- a/runtime/vm/kernel_to_il.cc |
+++ b/runtime/vm/kernel_to_il.cc |
@@ -2647,6 +2647,19 @@ void FlowGraphBuilder::InlineBailout(const char* reason) { |
} |
+void FlowGraphBuilder::PruneUnreachableIfOSR() { |
+ // 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); |
+ } |
+} |
+ |
+ |
FlowGraph* FlowGraphBuilder::BuildGraph() { |
const dart::Function& function = parsed_function_->function(); |
@@ -2750,7 +2763,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 +2930,7 @@ FlowGraph* FlowGraphBuilder::BuildGraphOfFunction(FunctionNode* function, |
} |
normal_entry->LinkTo(body.entry); |
+ PruneUnreachableIfOSR(); |
Vyacheslav Egorov (Google)
2016/10/31 17:46:37
I think only this one can OSR - inline the functi
kustermann
2016/10/31 18:18:13
Done.
|
return new (Z) FlowGraph(*parsed_function_, graph_entry_, next_block_id_ - 1); |
} |
@@ -3088,7 +3102,7 @@ FlowGraph* FlowGraphBuilder::BuildGraphOfFieldAccessor( |
TargetEntryInstr* normal_entry = BuildTargetEntry(); |
graph_entry_ = new (Z) |
- GraphEntryInstr(*parsed_function_, normal_entry, Compiler::kNoOSRDeoptId); |
+ GraphEntryInstr(*parsed_function_, normal_entry, osr_id_); |
// TODO(27590): Add support for FLAG_use_field_guards. |
Fragment body(normal_entry); |
@@ -3126,6 +3140,7 @@ FlowGraph* FlowGraphBuilder::BuildGraphOfFieldAccessor( |
} |
body += Return(); |
+ PruneUnreachableIfOSR(); |
Vyacheslav Egorov (Google)
2016/10/31 17:46:37
I don't think this and below can be OSRed.
kustermann
2016/10/31 18:18:13
Done.
|
return new (Z) FlowGraph(*parsed_function_, graph_entry_, next_block_id_ - 1); |
} |
@@ -3138,7 +3153,7 @@ FlowGraph* FlowGraphBuilder::BuildGraphOfStaticFieldInitializer( |
TargetEntryInstr* normal_entry = BuildTargetEntry(); |
graph_entry_ = new (Z) |
- GraphEntryInstr(*parsed_function_, normal_entry, Compiler::kNoOSRDeoptId); |
+ GraphEntryInstr(*parsed_function_, normal_entry, osr_id_); |
Fragment body(normal_entry); |
body += CheckStackOverflowInPrologue(); |
@@ -3149,6 +3164,7 @@ FlowGraph* FlowGraphBuilder::BuildGraphOfStaticFieldInitializer( |
} |
body += Return(); |
+ PruneUnreachableIfOSR(); |
return new (Z) FlowGraph(*parsed_function_, graph_entry_, next_block_id_ - 1); |
} |
@@ -3192,12 +3208,13 @@ FlowGraph* FlowGraphBuilder::BuildGraphOfMethodExtractor( |
TargetEntryInstr* normal_entry = BuildTargetEntry(); |
graph_entry_ = new (Z) |
- GraphEntryInstr(*parsed_function_, normal_entry, Compiler::kNoOSRDeoptId); |
+ GraphEntryInstr(*parsed_function_, normal_entry, osr_id_); |
Fragment body(normal_entry); |
body += CheckStackOverflowInPrologue(); |
body += BuildImplicitClosureCreation(function); |
body += Return(); |
+ PruneUnreachableIfOSR(); |
return new (Z) FlowGraph(*parsed_function_, graph_entry_, next_block_id_ - 1); |
} |
@@ -3208,7 +3225,7 @@ FlowGraph* FlowGraphBuilder::BuildGraphOfImplicitClosureFunction( |
TargetEntryInstr* normal_entry = BuildTargetEntry(); |
graph_entry_ = new (Z) |
- GraphEntryInstr(*parsed_function_, normal_entry, Compiler::kNoOSRDeoptId); |
+ GraphEntryInstr(*parsed_function_, normal_entry, osr_id_); |
SetupDefaultParameterValues(kernel_function); |
Fragment body(normal_entry); |
@@ -3248,6 +3265,7 @@ FlowGraph* FlowGraphBuilder::BuildGraphOfImplicitClosureFunction( |
// Return the result. |
body += Return(); |
+ PruneUnreachableIfOSR(); |
return new (Z) FlowGraph(*parsed_function_, graph_entry_, next_block_id_ - 1); |
} |
@@ -3259,7 +3277,7 @@ FlowGraph* FlowGraphBuilder::BuildGraphOfNoSuchMethodDispatcher( |
TargetEntryInstr* normal_entry = BuildTargetEntry(); |
graph_entry_ = new (Z) |
- GraphEntryInstr(*parsed_function_, normal_entry, Compiler::kNoOSRDeoptId); |
+ GraphEntryInstr(*parsed_function_, normal_entry, osr_id_); |
// The backend will expect an array of default values for all the named |
// parameters, even if they are all known to be passed at the call site |
@@ -3349,6 +3367,7 @@ FlowGraph* FlowGraphBuilder::BuildGraphOfNoSuchMethodDispatcher( |
body += StaticCall(no_such_method, 2); |
body += Return(); |
+ PruneUnreachableIfOSR(); |
return new (Z) FlowGraph(*parsed_function_, graph_entry_, next_block_id_ - 1); |
} |
@@ -3393,7 +3412,7 @@ FlowGraph* FlowGraphBuilder::BuildGraphOfInvokeFieldDispatcher( |
TargetEntryInstr* normal_entry = BuildTargetEntry(); |
graph_entry_ = new (Z) |
- GraphEntryInstr(*parsed_function_, normal_entry, Compiler::kNoOSRDeoptId); |
+ GraphEntryInstr(*parsed_function_, normal_entry, osr_id_); |
Fragment body(normal_entry); |
body += CheckStackOverflowInPrologue(); |
@@ -3435,6 +3454,7 @@ FlowGraph* FlowGraphBuilder::BuildGraphOfInvokeFieldDispatcher( |
body += Return(); |
+ PruneUnreachableIfOSR(); |
return new (Z) FlowGraph(*parsed_function_, graph_entry_, next_block_id_ - 1); |
} |