[vm/compiler] Check for catch presence explicitly in optimizer.
Some optimizations were checking for a number of successors of graph
entry - but that count includes unchecked entry and indirect entries.
Change-Id: Ib163a7710aaba3e68023a9cd04ca194c03262c33
Reviewed-on: https://dart-review.googlesource.com/71302
Reviewed-by: Samir Jindel <sjindel@google.com>
Commit-Queue: Vyacheslav Egorov <vegorov@google.com>
diff --git a/runtime/vm/compiler/backend/flow_graph.cc b/runtime/vm/compiler/backend/flow_graph.cc
index dc2d982..a6f8c52 100644
--- a/runtime/vm/compiler/backend/flow_graph.cc
+++ b/runtime/vm/compiler/backend/flow_graph.cc
@@ -1407,7 +1407,7 @@
void FlowGraph::RemoveDeadPhis(GrowableArray<PhiInstr*>* live_phis) {
// Augment live_phis with those that have implicit real used at
// potentially throwing instructions if there is a try-catch in this graph.
- if (graph_entry()->SuccessorCount() > 1) {
+ if (!graph_entry()->catch_entries().is_empty()) {
for (BlockIterator it(postorder_iterator()); !it.Done(); it.Advance()) {
JoinEntryInstr* join = it.Current()->AsJoinEntry();
if (join == NULL) continue;
@@ -1693,7 +1693,7 @@
ConvertUse(it.Current(), from_rep);
}
- if (graph_entry()->SuccessorCount() > 1) {
+ if (!graph_entry()->catch_entries().is_empty()) {
for (Value::Iterator it(def->env_use_list()); !it.Done(); it.Advance()) {
Value* use = it.Current();
if (use->instruction()->MayThrow() &&
diff --git a/runtime/vm/compiler/backend/redundancy_elimination.cc b/runtime/vm/compiler/backend/redundancy_elimination.cc
index 0e4eea8..e74aaff 100644
--- a/runtime/vm/compiler/backend/redundancy_elimination.cc
+++ b/runtime/vm/compiler/backend/redundancy_elimination.cc
@@ -2613,7 +2613,6 @@
// Right now we are attempting to sink allocation only into
// deoptimization exit. So candidate should only be used in StoreInstanceField
// instructions that write into fields of the allocated object.
-// We do not support materialization of the object that has type arguments.
static bool IsAllocationSinkingCandidate(Definition* alloc,
SafeUseCheck check_type) {
for (Value* use = alloc->input_use_list(); use != NULL;
diff --git a/runtime/vm/compiler/compiler_pass.cc b/runtime/vm/compiler/compiler_pass.cc
index b81e5c6..b33a4cb 100644
--- a/runtime/vm/compiler/compiler_pass.cc
+++ b/runtime/vm/compiler/compiler_pass.cc
@@ -374,7 +374,7 @@
COMPILER_PASS(AllocationSinking_Sink, {
// TODO(vegorov): Support allocation sinking with try-catch.
- if (flow_graph->graph_entry()->SuccessorCount() == 1) {
+ if (flow_graph->graph_entry()->catch_entries().is_empty()) {
state->sinking = new AllocationSinking(flow_graph);
state->sinking->Optimize();
}