| 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 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 1150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1161 | 1161 |
| 1162 if (ifUsers.isEmpty() && notIfUsers.isEmpty()) return; | 1162 if (ifUsers.isEmpty() && notIfUsers.isEmpty()) return; |
| 1163 | 1163 |
| 1164 for (HIf ifUser in ifUsers) { | 1164 for (HIf ifUser in ifUsers) { |
| 1165 changeUsesDominatedBy(ifUser.thenBlock, input, convertedType); | 1165 changeUsesDominatedBy(ifUser.thenBlock, input, convertedType); |
| 1166 // TODO(ngeoffray): Also change uses for the else block on a HType | 1166 // TODO(ngeoffray): Also change uses for the else block on a HType |
| 1167 // that knows it is not of a specific Type. | 1167 // that knows it is not of a specific Type. |
| 1168 } | 1168 } |
| 1169 | 1169 |
| 1170 for (HIf ifUser in notIfUsers) { | 1170 for (HIf ifUser in notIfUsers) { |
| 1171 if (ifUser.hasElse) { | 1171 changeUsesDominatedBy(ifUser.elseBlock, input, convertedType); |
| 1172 changeUsesDominatedBy(ifUser.elseBlock, input, convertedType); | |
| 1173 } else if (ifUser.joinBlock.predecessors.length == 1) { | |
| 1174 // If the join block has only one predecessor, then we know | |
| 1175 // the if block terminates. So any use of the instruction | |
| 1176 // after the join block should be changed to the new | |
| 1177 // instruction. | |
| 1178 changeUsesDominatedBy(ifUser.joinBlock, input, convertedType); | |
| 1179 } | |
| 1180 // TODO(ngeoffray): Also change uses for the then block on a HType | 1172 // TODO(ngeoffray): Also change uses for the then block on a HType |
| 1181 // that knows it is not of a specific Type. | 1173 // that knows it is not of a specific Type. |
| 1182 } | 1174 } |
| 1183 } | 1175 } |
| 1184 } | 1176 } |
| 1185 | 1177 |
| 1186 class SsaProcessRecompileCandidates | 1178 class SsaProcessRecompileCandidates |
| 1187 extends HBaseVisitor implements OptimizationPhase { | 1179 extends HBaseVisitor implements OptimizationPhase { |
| 1188 final String name = "SsaProcessRecompileCandidates"; | 1180 final String name = "SsaProcessRecompileCandidates"; |
| 1189 final JavaScriptBackend backend; | 1181 final JavaScriptBackend backend; |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1272 break; | 1264 break; |
| 1273 default: | 1265 default: |
| 1274 assert(false); | 1266 assert(false); |
| 1275 break; | 1267 break; |
| 1276 } | 1268 } |
| 1277 } | 1269 } |
| 1278 } | 1270 } |
| 1279 } | 1271 } |
| 1280 | 1272 |
| 1281 } | 1273 } |
| OLD | NEW |