OLD | NEW |
---|---|
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 829 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
840 } | 840 } |
841 } | 841 } |
842 | 842 |
843 for (BlockIterator it(postorder_iterator()); !it.Done(); it.Advance()) { | 843 for (BlockIterator it(postorder_iterator()); !it.Done(); it.Advance()) { |
844 JoinEntryInstr* join = it.Current()->AsJoinEntry(); | 844 JoinEntryInstr* join = it.Current()->AsJoinEntry(); |
845 if (join != NULL) join->RemoveDeadPhis(constant_null()); | 845 if (join != NULL) join->RemoveDeadPhis(constant_null()); |
846 } | 846 } |
847 } | 847 } |
848 | 848 |
849 | 849 |
850 void FlowGraph::RemoveRedefinitions() { | |
Florian Schneider
2013/05/03 10:41:36
This is very similar to what we do with Constraint
Kevin Millikin (Google)
2013/05/03 11:47:38
That one uses a maintained list of constraints, th
| |
851 // Remove redefinition instructions inserted to inhibit hoisting. | |
852 for (BlockIterator block_it = reverse_postorder_iterator(); | |
853 !block_it.Done(); | |
854 block_it.Advance()) { | |
855 for (ForwardInstructionIterator instr_it(block_it.Current()); | |
856 !instr_it.Done(); | |
857 instr_it.Advance()) { | |
858 RedefinitionInstr* redefinition = instr_it.Current()->AsRedefinition(); | |
859 if (redefinition != NULL) { | |
860 redefinition->ReplaceUsesWith(redefinition->value()->definition()); | |
861 instr_it.RemoveCurrentFromGraph(); | |
862 } | |
863 } | |
864 } | |
865 } | |
866 | |
867 | |
850 // Find the natural loop for the back edge m->n and attach loop information | 868 // Find the natural loop for the back edge m->n and attach loop information |
851 // to block n (loop header). The algorithm is described in "Advanced Compiler | 869 // to block n (loop header). The algorithm is described in "Advanced Compiler |
852 // Design & Implementation" (Muchnick) p192. | 870 // Design & Implementation" (Muchnick) p192. |
853 static void FindLoop(BlockEntryInstr* m, | 871 static void FindLoop(BlockEntryInstr* m, |
854 BlockEntryInstr* n, | 872 BlockEntryInstr* n, |
855 intptr_t num_blocks) { | 873 intptr_t num_blocks) { |
856 GrowableArray<BlockEntryInstr*> stack; | 874 GrowableArray<BlockEntryInstr*> stack; |
857 BitVector* loop = new BitVector(num_blocks); | 875 BitVector* loop = new BitVector(num_blocks); |
858 | 876 |
859 loop->Add(n->preorder_number()); | 877 loop->Add(n->preorder_number()); |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1031 } | 1049 } |
1032 | 1050 |
1033 | 1051 |
1034 bool BlockEffects::IsSideEffectFreePath(BlockEntryInstr* from, | 1052 bool BlockEffects::IsSideEffectFreePath(BlockEntryInstr* from, |
1035 BlockEntryInstr* to) const { | 1053 BlockEntryInstr* to) const { |
1036 return available_at_[to->postorder_number()]->Contains( | 1054 return available_at_[to->postorder_number()]->Contains( |
1037 from->postorder_number()); | 1055 from->postorder_number()); |
1038 } | 1056 } |
1039 | 1057 |
1040 } // namespace dart | 1058 } // namespace dart |
OLD | NEW |