| 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 /** | 5 /** |
| 6 * Instead of emitting each SSA instruction with a temporary variable | 6 * Instead of emitting each SSA instruction with a temporary variable |
| 7 * mark instructions that can be emitted at their use-site. | 7 * mark instructions that can be emitted at their use-site. |
| 8 * For example, in: | 8 * For example, in: |
| 9 * t0 = 4; | 9 * t0 = 4; |
| 10 * t1 = 3; | 10 * t1 = 3; |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 void visitIs(HIs instruction) {} | 45 void visitIs(HIs instruction) {} |
| 46 | 46 |
| 47 // A check method must not have its input generated at use site, | 47 // A check method must not have its input generated at use site, |
| 48 // because it's using it multiple times. | 48 // because it's using it multiple times. |
| 49 void visitCheck(HCheck instruction) {} | 49 void visitCheck(HCheck instruction) {} |
| 50 | 50 |
| 51 // A type guard should not generate its input at use site, otherwise | 51 // A type guard should not generate its input at use site, otherwise |
| 52 // they would not be alive. | 52 // they would not be alive. |
| 53 void visitTypeGuard(HTypeGuard instruction) {} | 53 void visitTypeGuard(HTypeGuard instruction) {} |
| 54 | 54 |
| 55 // If an equality operation is builtin it must only have its inputs generated | 55 // If an equality operation is builtin it must not have its input generated at |
| 56 // at use site if it does not require an expression with repeated uses | 56 // use site, because it's using it multiple times (because of null/undefined). |
| 57 // (because of null / undefined). | |
| 58 void visitEquals(HEquals instruction) { | 57 void visitEquals(HEquals instruction) { |
| 59 if (!instruction.builtin) super.visitEquals(instruction); | 58 if (!instruction.builtin) super.visitEquals(instruction); |
| 60 if (singleIdentityComparison(instruction.left, instruction.right) != null) { | 59 // Otherwise do nothing. |
| 61 super.visitEquals(instruction); | |
| 62 } | |
| 63 // Do nothing. | |
| 64 } | 60 } |
| 65 | 61 |
| 66 // An identity operation must only have its inputs generated at use site if | 62 // Identity operations must not have its input generated at use site, because |
| 67 // does not require an expression with multiple uses (because of null / | 63 // it's using it multiple times (because of null/undefined). |
| 68 // undefined). | 64 void visitIdentity(HIdentity instruction) {} |
| 69 void visitIdentity(HIdentity instruction) { | |
| 70 if (singleIdentityComparison(instruction.left, instruction.right) != null) { | |
| 71 super.visitIdentity(instruction); | |
| 72 } | |
| 73 // Do nothing. | |
| 74 } | |
| 75 | 65 |
| 76 void visitTypeConversion(HTypeConversion instruction) { | 66 void visitTypeConversion(HTypeConversion instruction) { |
| 77 if (!instruction.isChecked) { | 67 if (!instruction.isChecked) { |
| 78 markAsGenerateAtUseSite(instruction); | 68 markAsGenerateAtUseSite(instruction); |
| 79 } else if (instruction.isCheckedModeCheck) { | 69 } else if (instruction.isCheckedModeCheck) { |
| 80 // Checked mode checks compile to code that only use their input | 70 // Checked mode checks compile to code that only use their input |
| 81 // once, so we can safely visit them and try to merge the input. | 71 // once, so we can safely visit them and try to merge the input. |
| 82 visitInstruction(instruction); | 72 visitInstruction(instruction); |
| 83 } | 73 } |
| 84 } | 74 } |
| (...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 370 }; | 360 }; |
| 371 } | 361 } |
| 372 | 362 |
| 373 class JSBinaryOperatorPrecedence { | 363 class JSBinaryOperatorPrecedence { |
| 374 final int left; | 364 final int left; |
| 375 final int right; | 365 final int right; |
| 376 const JSBinaryOperatorPrecedence(this.left, this.right); | 366 const JSBinaryOperatorPrecedence(this.left, this.right); |
| 377 // All binary operators (excluding assignment) are left associative. | 367 // All binary operators (excluding assignment) are left associative. |
| 378 int get precedence() => left; | 368 int get precedence() => left; |
| 379 } | 369 } |
| OLD | NEW |