Chromium Code Reviews| 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 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 262 return false; | 262 return false; |
| 263 } | 263 } |
| 264 | 264 |
| 265 bool isSafeToGenerateAtUseSite(HInstruction user, HInstruction input) { | 265 bool isSafeToGenerateAtUseSite(HInstruction user, HInstruction input) { |
| 266 // A [HForeign] instruction uses operators and if we generate | 266 // A [HForeign] instruction uses operators and if we generate |
| 267 // [input] at use site, the precedence might be wrong. | 267 // [input] at use site, the precedence might be wrong. |
| 268 if (user is HForeign) return false; | 268 if (user is HForeign) return false; |
| 269 // A [HCheck] instruction with control flow uses its input | 269 // A [HCheck] instruction with control flow uses its input |
| 270 // multiple times, so we avoid generating it at use site. | 270 // multiple times, so we avoid generating it at use site. |
| 271 if (user is HCheck && user.isControlFlow()) return false; | 271 if (user is HCheck && user.isControlFlow()) return false; |
| 272 // A [HIs] instruction uses its input multiple times, so we | |
| 273 // avoid generating it at use site. | |
| 274 if (user is HIs) return false; | |
|
ngeoffray
2013/05/13 09:10:59
I think you still need this.
karlklose
2013/05/14 13:49:41
Done.
| |
| 275 return true; | 272 return true; |
| 276 } | 273 } |
| 277 | 274 |
| 278 void visitBasicBlock(HBasicBlock block) { | 275 void visitBasicBlock(HBasicBlock block) { |
| 279 if (block.last is !HIf) return; | 276 if (block.last is !HIf) return; |
| 280 HIf startIf = block.last; | 277 HIf startIf = block.last; |
| 281 HBasicBlock end = startIf.joinBlock; | 278 HBasicBlock end = startIf.joinBlock; |
| 282 | 279 |
| 283 // We check that the structure is the following: | 280 // We check that the structure is the following: |
| 284 // If | 281 // If |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 372 } | 369 } |
| 373 | 370 |
| 374 // If [thenInput] is defined in the first predecessor, then it is only used | 371 // If [thenInput] is defined in the first predecessor, then it is only used |
| 375 // by [phi] and can be generated at use site. | 372 // by [phi] and can be generated at use site. |
| 376 if (identical(thenInput.block, end.predecessors[0])) { | 373 if (identical(thenInput.block, end.predecessors[0])) { |
| 377 assert(thenInput.usedBy.length == 1); | 374 assert(thenInput.usedBy.length == 1); |
| 378 markAsGenerateAtUseSite(thenInput); | 375 markAsGenerateAtUseSite(thenInput); |
| 379 } | 376 } |
| 380 } | 377 } |
| 381 } | 378 } |
| OLD | NEW |