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

Side by Side 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: 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | tests/language/try_catch_optimized4_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "vm/flow_graph.h" 5 #include "vm/flow_graph.h"
6 6
7 #include "vm/bit_vector.h" 7 #include "vm/bit_vector.h"
8 #include "vm/flow_graph_builder.h" 8 #include "vm/flow_graph_builder.h"
9 #include "vm/intermediate_language.h" 9 #include "vm/intermediate_language.h"
10 #include "vm/longjump.h" 10 #include "vm/longjump.h"
(...skipping 982 matching lines...) Expand 10 before | Expand all | Expand 10 after
993 Value* use = new(isolate()) Value((*env)[i]); 993 Value* use = new(isolate()) Value((*env)[i]);
994 phi->SetInputAt(pred_index, use); 994 phi->SetInputAt(pred_index, use);
995 } 995 }
996 } 996 }
997 } 997 }
998 } 998 }
999 } 999 }
1000 1000
1001 1001
1002 void FlowGraph::RemoveDeadPhis(GrowableArray<PhiInstr*>* live_phis) { 1002 void FlowGraph::RemoveDeadPhis(GrowableArray<PhiInstr*>* live_phis) {
1003 // Augment live_phis with those that have implicit real used at
1004 // potentially throwing instructions if there is a try-catch in this graph.
1005 if (graph_entry()->SuccessorCount() > 1) {
1006 for (BlockIterator it(postorder_iterator()); !it.Done(); it.Advance()) {
1007 JoinEntryInstr* join = it.Current()->AsJoinEntry();
1008 if (join == NULL) continue;
1009 for (PhiIterator phi_it(join); !phi_it.Done(); phi_it.Advance()) {
1010 PhiInstr* phi = phi_it.Current();
1011 if (phi == NULL || phi->env_use_list() == NULL) continue;
Vyacheslav Egorov (Google) 2014/06/18 14:21:27 You can skip any phis that has non empty input_use
Florian Schneider 2014/06/18 14:25:40 Done.
1012 for (Value::Iterator it(phi->env_use_list());
1013 !it.Done();
1014 it.Advance()) {
1015 Value* use = it.Current();
1016 if (use->instruction()->MayThrow() &&
1017 use->instruction()->GetBlock()->InsideTryBlock()) {
1018 live_phis->Add(phi);
1019 phi->mark_alive();
1020 break;
1021 }
1022 }
1023 }
1024 }
1025 }
1026
1003 while (!live_phis->is_empty()) { 1027 while (!live_phis->is_empty()) {
1004 PhiInstr* phi = live_phis->RemoveLast(); 1028 PhiInstr* phi = live_phis->RemoveLast();
1005 for (intptr_t i = 0; i < phi->InputCount(); i++) { 1029 for (intptr_t i = 0; i < phi->InputCount(); i++) {
1006 Value* val = phi->InputAt(i); 1030 Value* val = phi->InputAt(i);
1007 PhiInstr* used_phi = val->definition()->AsPhi(); 1031 PhiInstr* used_phi = val->definition()->AsPhi();
1008 if ((used_phi != NULL) && !used_phi->is_alive()) { 1032 if ((used_phi != NULL) && !used_phi->is_alive()) {
1009 used_phi->mark_alive(); 1033 used_phi->mark_alive();
1010 live_phis->Add(used_phi); 1034 live_phis->Add(used_phi);
1011 } 1035 }
1012 } 1036 }
1013 } 1037 }
1014 1038
1015 for (BlockIterator it(postorder_iterator()); !it.Done(); it.Advance()) { 1039 for (BlockIterator it(postorder_iterator()); !it.Done(); it.Advance()) {
1016 JoinEntryInstr* join = it.Current()->AsJoinEntry(); 1040 JoinEntryInstr* join = it.Current()->AsJoinEntry();
1017 if (join != NULL) join->RemoveDeadPhis(constant_null()); 1041 if (join != NULL) join->RemoveDeadPhis(constant_dead());
1018 } 1042 }
1019 } 1043 }
1020 1044
1021 1045
1022 void FlowGraph::RemoveRedefinitions() { 1046 void FlowGraph::RemoveRedefinitions() {
1023 // Remove redefinition instructions inserted to inhibit hoisting. 1047 // Remove redefinition instructions inserted to inhibit hoisting.
1024 for (BlockIterator block_it = reverse_postorder_iterator(); 1048 for (BlockIterator block_it = reverse_postorder_iterator();
1025 !block_it.Done(); 1049 !block_it.Done();
1026 block_it.Advance()) { 1050 block_it.Advance()) {
1027 for (ForwardInstructionIterator instr_it(block_it.Current()); 1051 for (ForwardInstructionIterator instr_it(block_it.Current());
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
1250 } 1274 }
1251 1275
1252 1276
1253 bool BlockEffects::IsSideEffectFreePath(BlockEntryInstr* from, 1277 bool BlockEffects::IsSideEffectFreePath(BlockEntryInstr* from,
1254 BlockEntryInstr* to) const { 1278 BlockEntryInstr* to) const {
1255 return available_at_[to->postorder_number()]->Contains( 1279 return available_at_[to->postorder_number()]->Contains(
1256 from->postorder_number()); 1280 from->postorder_number());
1257 } 1281 }
1258 1282
1259 } // namespace dart 1283 } // namespace dart
OLDNEW
« 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