| 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 24 matching lines...) Expand all Loading... |
| 35 for (HInstruction input in instruction.inputs) { | 35 for (HInstruction input in instruction.inputs) { |
| 36 if (!generateAtUseSite.contains(input) | 36 if (!generateAtUseSite.contains(input) |
| 37 && !input.isCodeMotionInvariant() | 37 && !input.isCodeMotionInvariant() |
| 38 && input.usedBy.length == 1 | 38 && input.usedBy.length == 1 |
| 39 && input is! HPhi) { | 39 && input is! HPhi) { |
| 40 expectedInputs.add(input); | 40 expectedInputs.add(input); |
| 41 } | 41 } |
| 42 } | 42 } |
| 43 } | 43 } |
| 44 | 44 |
| 45 void visitTypeConversion(HTypeConversion instruction) { | |
| 46 generateAtUseSite.add(instruction); | |
| 47 } | |
| 48 | |
| 49 // The codegen might use the input multiple times, so it must not be | 45 // The codegen might use the input multiple times, so it must not be |
| 50 // set generate at use site. | 46 // set generate at use site. |
| 51 void visitIs(HIs instruction) {} | 47 void visitIs(HIs instruction) {} |
| 52 | 48 |
| 53 // A check method must not have its input generate at use site, | 49 // A check method must not have its input generate at use site, |
| 54 // because it's using it multiple times. | 50 // because it's using it multiple times. |
| 55 void visitCheck(HCheck instruction) {} | 51 void visitCheck(HCheck instruction) {} |
| 56 | 52 |
| 57 // A type guard should not generate its input at use site, otherwise | 53 // A type guard should not generate its input at use site, otherwise |
| 58 // they would not be alive. | 54 // they would not be alive. |
| 59 void visitTypeGuard(HTypeGuard instruction) {} | 55 void visitTypeGuard(HTypeGuard instruction) {} |
| 60 | 56 |
| 57 // TODO(ngeoffray): This should not be needed. The codegen should |
| 58 // cope better with this instruction. |
| 59 void visitTypeConversion(HTypeConversion instruction) {} |
| 60 |
| 61 void tryGenerateAtUseSite(HInstruction instruction) { | 61 void tryGenerateAtUseSite(HInstruction instruction) { |
| 62 // A type guard should never be generate at use site, otherwise we | 62 // A type guard should never be generate at use site, otherwise we |
| 63 // cannot bailout. | 63 // cannot bailout. |
| 64 if (instruction is HTypeGuard) return; | 64 if (instruction is HTypeGuard) return; |
| 65 | 65 |
| 66 // A check should never be generate at use site, otherwise we | 66 // A check should never be generate at use site, otherwise we |
| 67 // cannot throw. | 67 // cannot throw. |
| 68 if (instruction is HCheck) return; | 68 if (instruction is HCheck) return; |
| 69 | 69 |
| 70 // TODO(ngeoffray): This should not be needed. The codegen should |
| 71 // cope better with this instruction. |
| 72 if (instruction is HTypeConversion) return; |
| 73 |
| 70 generateAtUseSite.add(instruction); | 74 generateAtUseSite.add(instruction); |
| 71 } | 75 } |
| 72 | 76 |
| 73 bool isBlockSinglePredecessor(HBasicBlock block) { | 77 bool isBlockSinglePredecessor(HBasicBlock block) { |
| 74 return block.successors.length === 1 | 78 return block.successors.length === 1 |
| 75 && block.successors[0].predecessors.length === 1; | 79 && block.successors[0].predecessors.length === 1; |
| 76 } | 80 } |
| 77 | 81 |
| 78 void visitBasicBlock(HBasicBlock block) { | 82 void visitBasicBlock(HBasicBlock block) { |
| 79 // Compensate from not merging blocks: if the block is the | 83 // Compensate from not merging blocks: if the block is the |
| (...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 492 // improving the performance of future lookups. | 496 // improving the performance of future lookups. |
| 493 T root = getRepresentative(parent); | 497 T root = getRepresentative(parent); |
| 494 if (root !== parent) representative[element] = root; | 498 if (root !== parent) representative[element] = root; |
| 495 return root; | 499 return root; |
| 496 } | 500 } |
| 497 | 501 |
| 498 bool areEquivalent(T a, T b) { | 502 bool areEquivalent(T a, T b) { |
| 499 return getRepresentative(a) === getRepresentative(b); | 503 return getRepresentative(a) === getRepresentative(b); |
| 500 } | 504 } |
| 501 } | 505 } |
| OLD | NEW |