| 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 /** | 5 /** |
| 6 * A [Value] represents both symbolic values like the value of a | 6 * A [Value] represents both symbolic values like the value of a |
| 7 * parameter, or the length of an array, and concrete values, like | 7 * parameter, or the length of an array, and concrete values, like |
| 8 * constants. | 8 * constants. |
| 9 */ | 9 */ |
| 10 abstract class Value { | 10 abstract class Value { |
| (...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 182 String toString() => 'Length: $instruction'; | 182 String toString() => 'Length: $instruction'; |
| 183 } | 183 } |
| 184 | 184 |
| 185 /** | 185 /** |
| 186 * Represents a binary operation on two [Value], where the operation | 186 * Represents a binary operation on two [Value], where the operation |
| 187 * did not yield a canonical value. | 187 * did not yield a canonical value. |
| 188 */ | 188 */ |
| 189 class OperationValue extends Value { | 189 class OperationValue extends Value { |
| 190 final Value left; | 190 final Value left; |
| 191 final Value right; | 191 final Value right; |
| 192 final Operation operation; | 192 final BinaryOperation operation; |
| 193 OperationValue(this.left, this.right, this.operation); | 193 OperationValue(this.left, this.right, this.operation); |
| 194 | 194 |
| 195 bool operator ==(other) { | 195 bool operator ==(other) { |
| 196 if (other is !OperationValue) return false; | 196 if (other is !OperationValue) return false; |
| 197 return left == other.left | 197 return left == other.left |
| 198 && right == other.right | 198 && right == other.right |
| 199 && operation == other.operation; | 199 && operation == other.operation; |
| 200 } | 200 } |
| 201 | 201 |
| 202 Value operator +(Value other) => const UnknownValue(); | 202 Value operator +(Value other) => const UnknownValue(); |
| (...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 391 return range; | 391 return range; |
| 392 } | 392 } |
| 393 | 393 |
| 394 Range tryInferLoopPhiRange(HPhi phi) { | 394 Range tryInferLoopPhiRange(HPhi phi) { |
| 395 HInstruction update = phi.inputs[1]; | 395 HInstruction update = phi.inputs[1]; |
| 396 return update.accept(new LoopUpdateRecognizer(phi, ranges, types)); | 396 return update.accept(new LoopUpdateRecognizer(phi, ranges, types)); |
| 397 } | 397 } |
| 398 | 398 |
| 399 Range visitConstant(HConstant constant) { | 399 Range visitConstant(HConstant constant) { |
| 400 if (!constant.isInteger(types)) return const Range.unbound(); | 400 if (!constant.isInteger(types)) return const Range.unbound(); |
| 401 Value value = new IntValue(constant.constant.value); | 401 IntConstant constantInt = constant.constant; |
| 402 Value value = new IntValue(constantInt.value); |
| 402 return new Range(value, value); | 403 return new Range(value, value); |
| 403 } | 404 } |
| 404 | 405 |
| 405 Range visitInvokeInterceptor(HInvokeInterceptor interceptor) { | 406 Range visitInvokeInterceptor(HInvokeInterceptor interceptor) { |
| 406 if (!interceptor.isInteger(types)) return const Range.unbound(); | 407 if (!interceptor.isInteger(types)) return const Range.unbound(); |
| 407 if (!interceptor.isLengthGetterOnStringOrArray(types)) { | 408 if (!interceptor.isLengthGetterOnStringOrArray(types)) { |
| 408 return visitInstruction(interceptor); | 409 return visitInstruction(interceptor); |
| 409 } | 410 } |
| 410 LengthValue value = new LengthValue(interceptor); | 411 LengthValue value = new LengthValue(interceptor); |
| 411 // We know this range is above zero. To simplify the analysis, we | 412 // We know this range is above zero. To simplify the analysis, we |
| (...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 679 if (instruction is HPhi && !instruction.block.isLoopHeader()) { | 680 if (instruction is HPhi && !instruction.block.isLoopHeader()) { |
| 680 HInstruction result = unwrap(instruction.inputs[0]); | 681 HInstruction result = unwrap(instruction.inputs[0]); |
| 681 for (int i = 1; i < instruction.inputs.length; i++) { | 682 for (int i = 1; i < instruction.inputs.length; i++) { |
| 682 if (result != unwrap(instruction.inputs[i])) return instruction; | 683 if (result != unwrap(instruction.inputs[i])) return instruction; |
| 683 } | 684 } |
| 684 return result; | 685 return result; |
| 685 } | 686 } |
| 686 return instruction; | 687 return instruction; |
| 687 } | 688 } |
| 688 } | 689 } |
| OLD | NEW |