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 662 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
673 IntConstant constantInt = constant.constant; | 673 IntConstant constantInt = constant.constant; |
674 Value value = info.newIntValue(constantInt.value); | 674 Value value = info.newIntValue(constantInt.value); |
675 return info.newNormalizedRange(value, value); | 675 return info.newNormalizedRange(value, value); |
676 } | 676 } |
677 | 677 |
678 Range visitFieldGet(HFieldGet fieldGet) { | 678 Range visitFieldGet(HFieldGet fieldGet) { |
679 if (!fieldGet.isInteger(compiler)) return info.newUnboundRange(); | 679 if (!fieldGet.isInteger(compiler)) return info.newUnboundRange(); |
680 if (!fieldGet.receiver.isIndexable(compiler)) { | 680 if (!fieldGet.receiver.isIndexable(compiler)) { |
681 return visitInstruction(fieldGet); | 681 return visitInstruction(fieldGet); |
682 } | 682 } |
| 683 JavaScriptBackend backend = compiler.backend; |
| 684 assert(fieldGet.element == backend.jsIndexableLength); |
683 LengthValue value = info.newLengthValue(fieldGet); | 685 LengthValue value = info.newLengthValue(fieldGet); |
684 // We know this range is above zero. To simplify the analysis, we | 686 // We know this range is above zero. To simplify the analysis, we |
685 // put the zero value as the lower bound of this range. This | 687 // put the zero value as the lower bound of this range. This |
686 // allows to easily remove the second bound check in the following | 688 // allows to easily remove the second bound check in the following |
687 // expression: a[1] + a[0]. | 689 // expression: a[1] + a[0]. |
688 return info.newNormalizedRange(info.intZero, value); | 690 return info.newNormalizedRange(info.intZero, value); |
689 } | 691 } |
690 | 692 |
691 Range visitBoundsCheck(HBoundsCheck check) { | 693 Range visitBoundsCheck(HBoundsCheck check) { |
692 // Save the next instruction, in case the check gets removed. | 694 // Save the next instruction, in case the check gets removed. |
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1006 } | 1008 } |
1007 | 1009 |
1008 Range handleBinaryOperation(HBinaryArithmetic instruction) { | 1010 Range handleBinaryOperation(HBinaryArithmetic instruction) { |
1009 Range leftRange = visit(instruction.left); | 1011 Range leftRange = visit(instruction.left); |
1010 Range rightRange = visit(instruction.right); | 1012 Range rightRange = visit(instruction.right); |
1011 if (leftRange == null || rightRange == null) return null; | 1013 if (leftRange == null || rightRange == null) return null; |
1012 BinaryOperation operation = instruction.operation(info.constantSystem); | 1014 BinaryOperation operation = instruction.operation(info.constantSystem); |
1013 return operation.apply(leftRange, rightRange); | 1015 return operation.apply(leftRange, rightRange); |
1014 } | 1016 } |
1015 } | 1017 } |
OLD | NEW |