| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 interface OptimizationPhase { | 5 interface OptimizationPhase { |
| 6 String get name(); | 6 String get name(); |
| 7 void visitGraph(HGraph graph); | 7 void visitGraph(HGraph graph); |
| 8 } | 8 } |
| 9 | 9 |
| 10 class SsaOptimizerTask extends CompilerTask { | 10 class SsaOptimizerTask extends CompilerTask { |
| (...skipping 969 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 980 values = new List<ValueSet>(graph.blocks.length); | 980 values = new List<ValueSet>(graph.blocks.length); |
| 981 for (int i = 0; i < graph.blocks.length; i++) { | 981 for (int i = 0; i < graph.blocks.length; i++) { |
| 982 values[graph.blocks[i].id] = new ValueSet(); | 982 values[graph.blocks[i].id] = new ValueSet(); |
| 983 } | 983 } |
| 984 visitPostDominatorTree(graph); | 984 visitPostDominatorTree(graph); |
| 985 } | 985 } |
| 986 | 986 |
| 987 void visitBasicBlock(HBasicBlock block) { | 987 void visitBasicBlock(HBasicBlock block) { |
| 988 List<HBasicBlock> successors = block.successors; | 988 List<HBasicBlock> successors = block.successors; |
| 989 | 989 |
| 990 // Phase 1: get the ValueSet of all successors, compute the | 990 // Phase 1: get the ValueSet of all successors (if there are more than one), |
| 991 // intersection and move the instructions of the intersection into | 991 // compute the intersection and move the instructions of the intersection |
| 992 // this block. | 992 // into this block. |
| 993 if (successors.length != 0) { | 993 if (successors.length > 1) { |
| 994 ValueSet instructions = values[successors[0].id]; | 994 ValueSet instructions = values[successors[0].id]; |
| 995 for (int i = 1; i < successors.length; i++) { | 995 for (int i = 1; i < successors.length; i++) { |
| 996 ValueSet other = values[successors[i].id]; | 996 ValueSet other = values[successors[i].id]; |
| 997 instructions = instructions.intersection(other); | 997 instructions = instructions.intersection(other); |
| 998 } | 998 } |
| 999 | 999 |
| 1000 if (!instructions.isEmpty()) { | 1000 if (!instructions.isEmpty()) { |
| 1001 List<HInstruction> list = instructions.toList(); | 1001 List<HInstruction> list = instructions.toList(); |
| 1002 for (HInstruction instruction in list) { | 1002 for (HInstruction instruction in list) { |
| 1003 // Move the instruction to the current block. | 1003 // Move the instruction to the current block. |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1117 // the if block terminates. So any use of the instruction | 1117 // the if block terminates. So any use of the instruction |
| 1118 // after the join block should be changed to the new | 1118 // after the join block should be changed to the new |
| 1119 // instruction. | 1119 // instruction. |
| 1120 changeUsesDominatedBy(ifUser.joinBlock, input, convertedType); | 1120 changeUsesDominatedBy(ifUser.joinBlock, input, convertedType); |
| 1121 } | 1121 } |
| 1122 // TODO(ngeoffray): Also change uses for the then block on a HType | 1122 // TODO(ngeoffray): Also change uses for the then block on a HType |
| 1123 // that knows it is not of a specific Type. | 1123 // that knows it is not of a specific Type. |
| 1124 } | 1124 } |
| 1125 } | 1125 } |
| 1126 } | 1126 } |
| OLD | NEW |