Chromium Code Reviews| Index: sdk/lib/_internal/compiler/implementation/ssa/value_range_analyzer.dart |
| =================================================================== |
| --- sdk/lib/_internal/compiler/implementation/ssa/value_range_analyzer.dart (revision 30699) |
| +++ sdk/lib/_internal/compiler/implementation/ssa/value_range_analyzer.dart (working copy) |
| @@ -24,8 +24,8 @@ |
| return new InstructionValue(instruction, this); |
| } |
| - Value newLengthValue(HInstruction instruction) { |
| - return new LengthValue(instruction, this); |
| + Value newPositiveValue(HInstruction instruction) { |
| + return new PositiveValue(instruction, this); |
| } |
| Value newAddValue(Value left, Value right) { |
| @@ -291,14 +291,11 @@ |
| } |
| /** |
| - * Special value for instructions that represent the length of an |
| - * array. The difference with an [InstructionValue] is that we know |
| - * the value is positive. |
| + * Special value for instructions whose type is a positive integer. |
| */ |
| -class LengthValue extends InstructionValue { |
| - LengthValue(HInstruction instruction, info) : super(instruction, info); |
| +class PositiveValue extends InstructionValue { |
|
sra1
2013/11/27 20:29:36
Zero is possible, but is not positive.
Perhaps lea
|
| + PositiveValue(HInstruction instruction, info) : super(instruction, info); |
| bool get isPositive => true; |
| - String toString() => 'Length: $instruction'; |
| } |
| /** |
| @@ -637,15 +634,17 @@ |
| } |
| Range visitInstruction(HInstruction instruction) { |
| - return info.newUnboundRange(); |
| + if (instruction.isUInt32(compiler)) { |
| + return info.newNormalizedRange( |
| + info.intZero, info.newPositiveValue(instruction)); |
| + } else if (instruction.isInteger(compiler)) { |
| + InstructionValue value = info.newInstructionValue(instruction); |
| + return info.newNormalizedRange(value, value); |
| + } else { |
| + return info.newUnboundRange(); |
| + } |
| } |
| - Range visitParameterValue(HParameterValue parameter) { |
| - if (!parameter.isInteger(compiler)) return info.newUnboundRange(); |
| - Value value = info.newInstructionValue(parameter); |
| - return info.newNormalizedRange(value, value); |
| - } |
| - |
| Range visitPhi(HPhi phi) { |
| if (!phi.isInteger(compiler)) return info.newUnboundRange(); |
| // Some phases may replace instructions that change the inputs of |
| @@ -682,7 +681,7 @@ |
| } |
| JavaScriptBackend backend = compiler.backend; |
| assert(fieldGet.element == backend.jsIndexableLength); |
| - LengthValue value = info.newLengthValue(fieldGet); |
| + PositiveValue value = info.newPositiveValue(fieldGet); |
| // We know this range is above zero. To simplify the analysis, we |
| // put the zero value as the lower bound of this range. This |
| // allows to easily remove the second bound check in the following |