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