Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(987)

Unified Diff: runtime/vm/flow_graph.cc

Issue 340113002: Fix our initial dead phi elimination in the presence of try-catch. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: addressed feedback Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | tests/language/try_catch_optimized4_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/flow_graph.cc
===================================================================
--- runtime/vm/flow_graph.cc (revision 37442)
+++ runtime/vm/flow_graph.cc (working copy)
@@ -1000,6 +1000,35 @@
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) {
+ for (BlockIterator it(postorder_iterator()); !it.Done(); it.Advance()) {
+ JoinEntryInstr* join = it.Current()->AsJoinEntry();
+ if (join == NULL) continue;
+ for (PhiIterator phi_it(join); !phi_it.Done(); phi_it.Advance()) {
+ PhiInstr* phi = phi_it.Current();
+ if (phi == NULL ||
+ phi->is_alive() ||
+ (phi->input_use_list() != NULL) ||
+ (phi->env_use_list() == NULL)) {
+ continue;
+ }
+ for (Value::Iterator it(phi->env_use_list());
+ !it.Done();
+ it.Advance()) {
+ Value* use = it.Current();
+ if (use->instruction()->MayThrow() &&
+ use->instruction()->GetBlock()->InsideTryBlock()) {
+ live_phis->Add(phi);
+ phi->mark_alive();
+ break;
+ }
+ }
+ }
+ }
+ }
+
while (!live_phis->is_empty()) {
PhiInstr* phi = live_phis->RemoveLast();
for (intptr_t i = 0; i < phi->InputCount(); i++) {
@@ -1014,7 +1043,7 @@
for (BlockIterator it(postorder_iterator()); !it.Done(); it.Advance()) {
JoinEntryInstr* join = it.Current()->AsJoinEntry();
- if (join != NULL) join->RemoveDeadPhis(constant_null());
+ if (join != NULL) join->RemoveDeadPhis(constant_dead());
}
}
« no previous file with comments | « no previous file | tests/language/try_catch_optimized4_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698