| 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 class ValueRangeInfo { | 8 class ValueRangeInfo { |
| 9 final ConstantSystem constantSystem; | 9 final ConstantSystem constantSystem; |
| 10 | 10 |
| (...skipping 688 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 699 | 699 |
| 700 Range visitRelational(HRelational relational) { | 700 Range visitRelational(HRelational relational) { |
| 701 HInstruction right = relational.right; | 701 HInstruction right = relational.right; |
| 702 HInstruction left = relational.left; | 702 HInstruction left = relational.left; |
| 703 if (!left.isInteger(types)) return info.newUnboundRange(); | 703 if (!left.isInteger(types)) return info.newUnboundRange(); |
| 704 if (!right.isInteger(types)) return info.newUnboundRange(); | 704 if (!right.isInteger(types)) return info.newUnboundRange(); |
| 705 BinaryOperation operation = relational.operation(constantSystem); | 705 BinaryOperation operation = relational.operation(constantSystem); |
| 706 Range rightRange = ranges[relational.right]; | 706 Range rightRange = ranges[relational.right]; |
| 707 Range leftRange = ranges[relational.left]; | 707 Range leftRange = ranges[relational.left]; |
| 708 | 708 |
| 709 if (relational is HEquals || relational is HIdentity) { | 709 if (relational is HIdentity) { |
| 710 handleEqualityCheck(relational); | 710 handleEqualityCheck(relational); |
| 711 } else if (operation.apply(leftRange, rightRange)) { | 711 } else if (operation.apply(leftRange, rightRange)) { |
| 712 relational.block.rewrite( | 712 relational.block.rewrite( |
| 713 relational, graph.addConstantBool(true, constantSystem)); | 713 relational, graph.addConstantBool(true, constantSystem)); |
| 714 relational.block.remove(relational); | 714 relational.block.remove(relational); |
| 715 } else if (reverseOperation(operation).apply(leftRange, rightRange)) { | 715 } else if (reverseOperation(operation).apply(leftRange, rightRange)) { |
| 716 relational.block.rewrite( | 716 relational.block.rewrite( |
| 717 relational, graph.addConstantBool(false, constantSystem)); | 717 relational, graph.addConstantBool(false, constantSystem)); |
| 718 relational.block.remove(relational); | 718 relational.block.remove(relational); |
| 719 } | 719 } |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 822 } else { | 822 } else { |
| 823 range = info.newUnboundRange(); | 823 range = info.newUnboundRange(); |
| 824 } | 824 } |
| 825 return range.intersection(leftRange); | 825 return range.intersection(leftRange); |
| 826 } | 826 } |
| 827 | 827 |
| 828 Range visitConditionalBranch(HConditionalBranch branch) { | 828 Range visitConditionalBranch(HConditionalBranch branch) { |
| 829 var condition = branch.condition; | 829 var condition = branch.condition; |
| 830 // TODO(ngeoffray): Handle complex conditions. | 830 // TODO(ngeoffray): Handle complex conditions. |
| 831 if (condition is !HRelational) return info.newUnboundRange(); | 831 if (condition is !HRelational) return info.newUnboundRange(); |
| 832 if (condition is HEquals) return info.newUnboundRange(); | |
| 833 if (condition is HIdentity) return info.newUnboundRange(); | 832 if (condition is HIdentity) return info.newUnboundRange(); |
| 834 HInstruction right = condition.right; | 833 HInstruction right = condition.right; |
| 835 HInstruction left = condition.left; | 834 HInstruction left = condition.left; |
| 836 if (!left.isInteger(types)) return info.newUnboundRange(); | 835 if (!left.isInteger(types)) return info.newUnboundRange(); |
| 837 if (!right.isInteger(types)) return info.newUnboundRange(); | 836 if (!right.isInteger(types)) return info.newUnboundRange(); |
| 838 | 837 |
| 839 Range rightRange = ranges[right]; | 838 Range rightRange = ranges[right]; |
| 840 Range leftRange = ranges[left]; | 839 Range leftRange = ranges[left]; |
| 841 Operation operation = condition.operation(constantSystem); | 840 Operation operation = condition.operation(constantSystem); |
| 842 Operation reverse = reverseOperation(operation); | 841 Operation reverse = reverseOperation(operation); |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 987 if (instruction is HPhi && !instruction.block.isLoopHeader()) { | 986 if (instruction is HPhi && !instruction.block.isLoopHeader()) { |
| 988 HInstruction result = unwrap(instruction.inputs[0]); | 987 HInstruction result = unwrap(instruction.inputs[0]); |
| 989 for (int i = 1; i < instruction.inputs.length; i++) { | 988 for (int i = 1; i < instruction.inputs.length; i++) { |
| 990 if (result != unwrap(instruction.inputs[i])) return instruction; | 989 if (result != unwrap(instruction.inputs[i])) return instruction; |
| 991 } | 990 } |
| 992 return result; | 991 return result; |
| 993 } | 992 } |
| 994 return instruction; | 993 return instruction; |
| 995 } | 994 } |
| 996 } | 995 } |
| OLD | NEW |