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 675 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
686 Value value = info.newIntValue(constantNum.primitiveValue); | 686 Value value = info.newIntValue(constantNum.primitiveValue); |
687 return info.newNormalizedRange(value, value); | 687 return info.newNormalizedRange(value, value); |
688 } | 688 } |
689 | 689 |
690 Range visitFieldGet(HFieldGet fieldGet) { | 690 Range visitFieldGet(HFieldGet fieldGet) { |
691 if (!fieldGet.isInteger(compiler)) return info.newUnboundRange(); | 691 if (!fieldGet.isInteger(compiler)) return info.newUnboundRange(); |
692 if (!fieldGet.receiver.isIndexablePrimitive(compiler)) { | 692 if (!fieldGet.receiver.isIndexablePrimitive(compiler)) { |
693 return visitInstruction(fieldGet); | 693 return visitInstruction(fieldGet); |
694 } | 694 } |
695 JavaScriptBackend backend = compiler.backend; | 695 JavaScriptBackend backend = compiler.backend; |
696 assert(fieldGet.element == backend.jsIndexableLength); | 696 assert(fieldGet.element == backend.helpers.jsIndexableLength); |
697 PositiveValue value = info.newPositiveValue(fieldGet); | 697 PositiveValue value = info.newPositiveValue(fieldGet); |
698 // We know this range is above zero. To simplify the analysis, we | 698 // We know this range is above zero. To simplify the analysis, we |
699 // put the zero value as the lower bound of this range. This | 699 // put the zero value as the lower bound of this range. This |
700 // allows to easily remove the second bound check in the following | 700 // allows to easily remove the second bound check in the following |
701 // expression: a[1] + a[0]. | 701 // expression: a[1] + a[0]. |
702 return info.newNormalizedRange(info.intZero, value); | 702 return info.newNormalizedRange(info.intZero, value); |
703 } | 703 } |
704 | 704 |
705 Range visitBoundsCheck(HBoundsCheck check) { | 705 Range visitBoundsCheck(HBoundsCheck check) { |
706 // Save the next instruction, in case the check gets removed. | 706 // Save the next instruction, in case the check gets removed. |
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1075 } | 1075 } |
1076 | 1076 |
1077 Range handleBinaryOperation(HBinaryArithmetic instruction) { | 1077 Range handleBinaryOperation(HBinaryArithmetic instruction) { |
1078 Range leftRange = visit(instruction.left); | 1078 Range leftRange = visit(instruction.left); |
1079 Range rightRange = visit(instruction.right); | 1079 Range rightRange = visit(instruction.right); |
1080 if (leftRange == null || rightRange == null) return null; | 1080 if (leftRange == null || rightRange == null) return null; |
1081 BinaryOperation operation = instruction.operation(info.constantSystem); | 1081 BinaryOperation operation = instruction.operation(info.constantSystem); |
1082 return operation.apply(leftRange, rightRange); | 1082 return operation.apply(leftRange, rightRange); |
1083 } | 1083 } |
1084 } | 1084 } |
OLD | NEW |