| 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 import '../compiler.dart' show Compiler; | 5 import '../compiler.dart' show Compiler; |
| 6 import '../constant_system_dart.dart'; | 6 import '../constant_system_dart.dart'; |
| 7 import '../constants/constant_system.dart'; | 7 import '../constants/constant_system.dart'; |
| 8 import '../constants/values.dart'; | 8 import '../constants/values.dart'; |
| 9 import '../js_backend/js_backend.dart'; | 9 import '../js_backend/js_backend.dart'; |
| 10 import 'nodes.dart'; | 10 import 'nodes.dart'; |
| (...skipping 669 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 680 if (!hConstant.isInteger(compiler)) return info.newUnboundRange(); | 680 if (!hConstant.isInteger(compiler)) return info.newUnboundRange(); |
| 681 ConstantValue constant = hConstant.constant; | 681 ConstantValue constant = hConstant.constant; |
| 682 NumConstantValue constantNum; | 682 NumConstantValue constantNum; |
| 683 if (constant is DeferredConstantValue) { | 683 if (constant is DeferredConstantValue) { |
| 684 constantNum = constant.referenced; | 684 constantNum = constant.referenced; |
| 685 } else { | 685 } else { |
| 686 constantNum = constant; | 686 constantNum = constant; |
| 687 } | 687 } |
| 688 if (constantNum.isPositiveInfinity || constantNum.isNegativeInfinity) { | 688 if (constantNum.isPositiveInfinity || constantNum.isNegativeInfinity) { |
| 689 return info.newUnboundRange(); | 689 return info.newUnboundRange(); |
| 690 } | 690 } |
| 691 if (constantNum.isMinusZero) constantNum = new IntConstantValue(0); | 691 if (constantNum.isMinusZero) constantNum = new IntConstantValue(0); |
| 692 Value value = info.newIntValue(constantNum.primitiveValue); | 692 Value value = info.newIntValue(constantNum.primitiveValue); |
| 693 return info.newNormalizedRange(value, value); | 693 return info.newNormalizedRange(value, value); |
| 694 } | 694 } |
| 695 | 695 |
| 696 Range visitFieldGet(HFieldGet fieldGet) { | 696 Range visitFieldGet(HFieldGet fieldGet) { |
| 697 if (!fieldGet.isInteger(compiler)) return info.newUnboundRange(); | 697 if (!fieldGet.isInteger(compiler)) return info.newUnboundRange(); |
| 698 if (!fieldGet.receiver.isIndexablePrimitive(compiler)) { | 698 if (!fieldGet.receiver.isIndexablePrimitive(compiler)) { |
| 699 return visitInstruction(fieldGet); | 699 return visitInstruction(fieldGet); |
| 700 } | 700 } |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 825 return info.newNormalizedRange(info.intZero, divisor.upper); | 825 return info.newNormalizedRange(info.intZero, divisor.upper); |
| 826 } else if (divisor.isNegative) { | 826 } else if (divisor.isNegative) { |
| 827 return info.newNormalizedRange( | 827 return info.newNormalizedRange( |
| 828 info.intZero, info.newNegateValue(divisor.lower)); | 828 info.intZero, info.newNegateValue(divisor.lower)); |
| 829 } | 829 } |
| 830 } | 830 } |
| 831 } | 831 } |
| 832 return info.newUnboundRange(); | 832 return info.newUnboundRange(); |
| 833 } | 833 } |
| 834 | 834 |
| 835 Range visitRemainder(HRemainder instruction) { |
| 836 HInstruction left = instruction.inputs[0]; |
| 837 HInstruction right = instruction.inputs[1]; |
| 838 if (left.isPositiveInteger(compiler) && right.isPositiveInteger(compiler)) { |
| 839 Range divisor = ranges[right]; |
| 840 if (divisor != null) { |
| 841 if (divisor.isPositive) { |
| 842 return info.newNormalizedRange( |
| 843 info.intZero, divisor.upper - info.intOne); |
| 844 } |
| 845 } |
| 846 } |
| 847 return info.newUnboundRange(); |
| 848 } |
| 849 |
| 835 Range visitInvokeDynamicMethod(HInvokeDynamicMethod invoke) { | 850 Range visitInvokeDynamicMethod(HInvokeDynamicMethod invoke) { |
| 836 if ((invoke.inputs.length == 3) && (invoke.selector.name == "%")) | 851 if ((invoke.inputs.length == 3) && (invoke.selector.name == "%")) |
| 837 return handleInvokeModulo(invoke); | 852 return handleInvokeModulo(invoke); |
| 838 return super.visitInvokeDynamicMethod(invoke); | 853 return super.visitInvokeDynamicMethod(invoke); |
| 839 } | 854 } |
| 840 | 855 |
| 841 Range handleBinaryOperation(HBinaryArithmetic instruction) { | 856 Range handleBinaryOperation(HBinaryArithmetic instruction) { |
| 842 if (!instruction.isInteger(compiler)) return info.newUnboundRange(); | 857 if (!instruction.isInteger(compiler)) return info.newUnboundRange(); |
| 843 return instruction | 858 return instruction |
| 844 .operation(constantSystem) | 859 .operation(constantSystem) |
| (...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1079 } | 1094 } |
| 1080 | 1095 |
| 1081 Range handleBinaryOperation(HBinaryArithmetic instruction) { | 1096 Range handleBinaryOperation(HBinaryArithmetic instruction) { |
| 1082 Range leftRange = visit(instruction.left); | 1097 Range leftRange = visit(instruction.left); |
| 1083 Range rightRange = visit(instruction.right); | 1098 Range rightRange = visit(instruction.right); |
| 1084 if (leftRange == null || rightRange == null) return null; | 1099 if (leftRange == null || rightRange == null) return null; |
| 1085 BinaryOperation operation = instruction.operation(info.constantSystem); | 1100 BinaryOperation operation = instruction.operation(info.constantSystem); |
| 1086 return operation.apply(leftRange, rightRange); | 1101 return operation.apply(leftRange, rightRange); |
| 1087 } | 1102 } |
| 1088 } | 1103 } |
| OLD | NEW |