| 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 part of ssa; | 5 part of ssa; |
| 6 | 6 |
| 7 /** | 7 /** |
| 8 * Instead of emitting each SSA instruction with a temporary variable | 8 * Instead of emitting each SSA instruction with a temporary variable |
| 9 * mark instructions that can be emitted at their use-site. | 9 * mark instructions that can be emitted at their use-site. |
| 10 * For example, in: | 10 * For example, in: |
| (...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 257 return false; | 257 return false; |
| 258 } | 258 } |
| 259 | 259 |
| 260 bool isSafeToGenerateAtUseSite(HInstruction user, HInstruction input) { | 260 bool isSafeToGenerateAtUseSite(HInstruction user, HInstruction input) { |
| 261 // A [HForeign] instruction uses operators and if we generate | 261 // A [HForeign] instruction uses operators and if we generate |
| 262 // [input] at use site, the precedence might be wrong. | 262 // [input] at use site, the precedence might be wrong. |
| 263 if (user is HForeign) return false; | 263 if (user is HForeign) return false; |
| 264 // A [HCheck] instruction with control flow uses its input | 264 // A [HCheck] instruction with control flow uses its input |
| 265 // multiple times, so we avoid generating it at use site. | 265 // multiple times, so we avoid generating it at use site. |
| 266 if (user is HCheck && user.isControlFlow()) return false; | 266 if (user is HCheck && user.isControlFlow()) return false; |
| 267 // A [HIs] instruction uses its input multiple times, so we | |
| 268 // avoid generating it at use site. | |
| 269 if (user is HIs) return false; | |
| 270 return true; | 267 return true; |
| 271 } | 268 } |
| 272 | 269 |
| 273 void visitBasicBlock(HBasicBlock block) { | 270 void visitBasicBlock(HBasicBlock block) { |
| 274 if (block.last is !HIf) return; | 271 if (block.last is !HIf) return; |
| 275 HIf startIf = block.last; | 272 HIf startIf = block.last; |
| 276 HBasicBlock end = startIf.joinBlock; | 273 HBasicBlock end = startIf.joinBlock; |
| 277 | 274 |
| 278 // We check that the structure is the following: | 275 // We check that the structure is the following: |
| 279 // If | 276 // If |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 367 } | 364 } |
| 368 | 365 |
| 369 // If [thenInput] is defined in the first predecessor, then it is only used | 366 // If [thenInput] is defined in the first predecessor, then it is only used |
| 370 // by [phi] and can be generated at use site. | 367 // by [phi] and can be generated at use site. |
| 371 if (identical(thenInput.block, end.predecessors[0])) { | 368 if (identical(thenInput.block, end.predecessors[0])) { |
| 372 assert(thenInput.usedBy.length == 1); | 369 assert(thenInput.usedBy.length == 1); |
| 373 markAsGenerateAtUseSite(thenInput); | 370 markAsGenerateAtUseSite(thenInput); |
| 374 } | 371 } |
| 375 } | 372 } |
| 376 } | 373 } |
| OLD | NEW |