Chromium Code Reviews| 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 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 279 else up = upper; | 279 else up = upper; |
| 280 } | 280 } |
| 281 return new Range(low, up); | 281 return new Range(low, up); |
| 282 } | 282 } |
| 283 | 283 |
| 284 Range operator +(Range other) { | 284 Range operator +(Range other) { |
| 285 return new Range.normalize(lower + other.lower, upper + other.upper); | 285 return new Range.normalize(lower + other.lower, upper + other.upper); |
| 286 } | 286 } |
| 287 | 287 |
| 288 Range operator -(Range other) { | 288 Range operator -(Range other) { |
| 289 return new Range.normalize(lower - other.lower, upper - other.upper); | 289 return new Range.normalize(lower - other.upper, upper - other.lower); |
| 290 } | 290 } |
| 291 | 291 |
| 292 Range operator &(Range other) { | 292 Range operator &(Range other) { |
| 293 return new Range.normalize(lower & other.lower, upper & other.upper); | 293 // Only operate on simple operations, ie when one of the range is |
|
floitsch
2012/10/02 09:32:28
There is no need to make this restriction.
if this
| |
| 294 // constant. | |
| 295 if (lower == upper) { | |
| 296 if (isPositive()) return new Range(const IntValue(0), upper); | |
| 297 else if (isNegative()) return new Range(lower, const IntValue(0)); | |
|
floitsch
2012/10/02 09:32:28
This is wrong: -1 & 5 -> 5
| |
| 298 else return const Range.unbound(); | |
| 299 } else if (other.lower == other.upper) { | |
| 300 return other & this; | |
| 301 } | |
| 302 return const Range.unbound(); | |
| 294 } | 303 } |
| 295 | 304 |
| 296 bool operator ==(other) { | 305 bool operator ==(other) { |
| 297 if (other is! Range) return false; | 306 if (other is! Range) return false; |
| 298 return other.lower == lower && other.upper == upper; | 307 return other.lower == lower && other.upper == upper; |
| 299 } | 308 } |
| 300 | 309 |
| 301 bool isLessThan(Range other) { | 310 bool isLessThan(Range other) { |
| 302 return upper != other.lower && upper.min(other.lower) == upper; | 311 return upper != other.lower && upper.min(other.lower) == upper; |
| 303 } | 312 } |
| (...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 679 if (instruction is HPhi && !instruction.block.isLoopHeader()) { | 688 if (instruction is HPhi && !instruction.block.isLoopHeader()) { |
| 680 HInstruction result = unwrap(instruction.inputs[0]); | 689 HInstruction result = unwrap(instruction.inputs[0]); |
| 681 for (int i = 1; i < instruction.inputs.length; i++) { | 690 for (int i = 1; i < instruction.inputs.length; i++) { |
| 682 if (result != unwrap(instruction.inputs[i])) return instruction; | 691 if (result != unwrap(instruction.inputs[i])) return instruction; |
| 683 } | 692 } |
| 684 return result; | 693 return result; |
| 685 } | 694 } |
| 686 return instruction; | 695 return instruction; |
| 687 } | 696 } |
| 688 } | 697 } |
| OLD | NEW |