| 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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 } | 59 } |
| 60 | 60 |
| 61 // An integer check method must not have its input generated at use site, | 61 // An integer check method must not have its input generated at use site, |
| 62 // because it's using it twice. | 62 // because it's using it twice. |
| 63 void visitIntegerCheck(HIntegerCheck instruction) {} | 63 void visitIntegerCheck(HIntegerCheck instruction) {} |
| 64 | 64 |
| 65 // A type guard should not generate its input at use site, otherwise | 65 // A type guard should not generate its input at use site, otherwise |
| 66 // they would not be alive. | 66 // they would not be alive. |
| 67 void visitTypeGuard(HTypeGuard instruction) {} | 67 void visitTypeGuard(HTypeGuard instruction) {} |
| 68 | 68 |
| 69 // If an equality operation is builtin it must only have its inputs generated | |
| 70 // at use site if it does not require an expression with repeated uses | |
| 71 // (because of null / undefined). | |
| 72 void visitEquals(HEquals instruction) { | |
| 73 HInstruction left = instruction.left; | |
| 74 HInstruction right = instruction.right; | |
| 75 if (!instruction.isBuiltin(types) || | |
| 76 singleIdentityComparison(left, right, types) != null) { | |
| 77 super.visitEquals(instruction); | |
| 78 } | |
| 79 // Do nothing. | |
| 80 } | |
| 81 | |
| 82 // An identity operation must only have its inputs generated at use site if | 69 // An identity operation must only have its inputs generated at use site if |
| 83 // does not require an expression with multiple uses (because of null / | 70 // does not require an expression with multiple uses (because of null / |
| 84 // undefined). | 71 // undefined). |
| 85 void visitIdentity(HIdentity instruction) { | 72 void visitIdentity(HIdentity instruction) { |
| 86 HInstruction left = instruction.left; | 73 HInstruction left = instruction.left; |
| 87 HInstruction right = instruction.right; | 74 HInstruction right = instruction.right; |
| 88 if (singleIdentityComparison(left, right, types) != null) { | 75 if (singleIdentityComparison(left, right, types) != null) { |
| 89 super.visitIdentity(instruction); | 76 super.visitIdentity(instruction); |
| 90 } | 77 } |
| 91 // Do nothing. | 78 // Do nothing. |
| (...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 343 } | 330 } |
| 344 | 331 |
| 345 // If [thenInput] is defined in the first predecessor, then it is only used | 332 // If [thenInput] is defined in the first predecessor, then it is only used |
| 346 // by [phi] and can be generated at use site. | 333 // by [phi] and can be generated at use site. |
| 347 if (identical(thenInput.block, end.predecessors[0])) { | 334 if (identical(thenInput.block, end.predecessors[0])) { |
| 348 assert(thenInput.usedBy.length == 1); | 335 assert(thenInput.usedBy.length == 1); |
| 349 markAsGenerateAtUseSite(thenInput); | 336 markAsGenerateAtUseSite(thenInput); |
| 350 } | 337 } |
| 351 } | 338 } |
| 352 } | 339 } |
| OLD | NEW |