Chromium Code Reviews| Index: runtime/vm/intermediate_language.cc |
| diff --git a/runtime/vm/intermediate_language.cc b/runtime/vm/intermediate_language.cc |
| index b84179fdec01c563ce4571ce858c73eefcc7d1a0..eaa28f3405d5d3753db045ad6074ecd51092767c 100644 |
| --- a/runtime/vm/intermediate_language.cc |
| +++ b/runtime/vm/intermediate_language.cc |
| @@ -2464,8 +2464,7 @@ RangeBoundary RangeBoundary::FromDefinition(Definition* defn, intptr_t offs) { |
| RangeBoundary RangeBoundary::LowerBound() const { |
|
Vyacheslav Egorov (Google)
2014/06/11 17:36:37
I don't think having PositiveInfinity.LowerBound()
|
| - if (IsNegativeInfinity()) return *this; |
| - if (IsConstant()) return *this; |
| + if (IsConstantOrInfinity()) return *this; |
| return Add(Range::ConstantMin(symbol()->range()), |
| RangeBoundary::FromConstant(offset_), |
| NegativeInfinity()); |
| @@ -2473,14 +2472,39 @@ RangeBoundary RangeBoundary::LowerBound() const { |
| RangeBoundary RangeBoundary::UpperBound() const { |
| - if (IsPositiveInfinity()) return *this; |
| - if (IsConstant()) return *this; |
| + if (IsConstantOrInfinity()) return *this; |
|
Vyacheslav Egorov (Google)
2014/06/11 17:36:37
Ditto.
|
| return Add(Range::ConstantMax(symbol()->range()), |
| RangeBoundary::FromConstant(offset_), |
| PositiveInfinity()); |
| } |
| +RangeBoundary RangeBoundary::Add(const RangeBoundary& a, |
| + const RangeBoundary& b, |
| + const RangeBoundary& overflow) { |
| + ASSERT(a.IsConstantOrInfinity() && b.IsConstantOrInfinity()); |
| + |
| + intptr_t result = a.Value() + b.Value(); |
| + if (!Smi::IsValid(result)) { |
| + return overflow; |
| + } |
| + return RangeBoundary::FromConstant(result); |
| +} |
| + |
| + |
| +RangeBoundary RangeBoundary::Sub(const RangeBoundary& a, |
| + const RangeBoundary& b, |
| + const RangeBoundary& overflow) { |
| + ASSERT(a.IsConstantOrInfinity() && b.IsConstantOrInfinity()); |
| + |
| + intptr_t result = a.Value() - b.Value(); |
| + if (!Smi::IsValid(result)) { |
| + return overflow; |
| + } |
| + return RangeBoundary::FromConstant(result); |
| +} |
| + |
| + |
| static Definition* UnwrapConstraint(Definition* defn) { |
| while (defn->IsConstraint()) { |
| defn = defn->AsConstraint()->value()->definition(); |
| @@ -2508,37 +2532,21 @@ static bool DependOnSameSymbol(const RangeBoundary& a, const RangeBoundary& b) { |
| } |
| -// Returns true if range has a least specific minimum value. |
| -static bool IsMinSmi(Range* range) { |
| - return (range == NULL) || |
| - (range->min().IsConstant() && |
| - (range->min().value() <= Smi::kMinValue)); |
| -} |
| - |
| - |
| -// Returns true if range has a least specific maximium value. |
| -static bool IsMaxSmi(Range* range) { |
| - return (range == NULL) || |
| - (range->max().IsConstant() && |
| - (range->max().value() >= Smi::kMaxValue)); |
| -} |
| - |
| - |
| -// Returns true if two range boundaries can be proven to be equal. |
| -static bool IsEqual(const RangeBoundary& a, const RangeBoundary& b) { |
| - if (a.IsConstant() && b.IsConstant()) { |
| - return a.value() == b.value(); |
| - } else if (a.IsSymbol() && b.IsSymbol()) { |
| - return (a.offset() == b.offset()) && DependOnSameSymbol(a, b); |
| - } else { |
| - return false; |
| +bool RangeBoundary::Equals(const RangeBoundary& other) const { |
| + if (IsConstant() && other.IsConstant()) { |
| + return Value() == other.Value(); |
| + } else if (IsInfinity() && other.IsInfinity()) { |
| + return Value() == other.Value(); |
| + } else if (IsSymbol() && other.IsSymbol()) { |
| + return (offset() == other.offset()) && DependOnSameSymbol(*this, other); |
| } |
| + return false; |
| } |
| static RangeBoundary CanonicalizeBoundary(const RangeBoundary& a, |
| const RangeBoundary& overflow) { |
| - if (a.IsConstant() || a.IsNegativeInfinity() || a.IsPositiveInfinity()) { |
| + if (a.IsConstant() || a.IsInfinity()) { |
| return a; |
| } |
| @@ -2634,8 +2642,8 @@ RangeBoundary RangeBoundary::Min(RangeBoundary a, RangeBoundary b) { |
| return (a.offset() <= b.offset()) ? a : b; |
| } |
| - const intptr_t min_a = a.LowerBound().Clamp().value(); |
| - const intptr_t min_b = b.LowerBound().Clamp().value(); |
| + const intptr_t min_a = a.LowerBound().Clamp().Value(); |
| + const intptr_t min_b = b.LowerBound().Clamp().Value(); |
| return RangeBoundary::FromConstant(Utils::Minimum(min_a, min_b)); |
| } |
| @@ -2646,13 +2654,25 @@ RangeBoundary RangeBoundary::Max(RangeBoundary a, RangeBoundary b) { |
| return (a.offset() >= b.offset()) ? a : b; |
| } |
| - const intptr_t max_a = a.UpperBound().Clamp().value(); |
| - const intptr_t max_b = b.UpperBound().Clamp().value(); |
| + const intptr_t max_a = a.UpperBound().Clamp().Value(); |
| + const intptr_t max_b = b.UpperBound().Clamp().Value(); |
| return RangeBoundary::FromConstant(Utils::Maximum(max_a, max_b)); |
| } |
| +intptr_t RangeBoundary::Value() const { |
|
Florian Schneider
2014/06/11 10:41:00
maybe add ASSERT(kind_ == kConstant);
Cutch
2014/06/13 04:24:25
Done.
|
| + if (IsNegativeInfinity()) { |
| + return kMin; |
|
Florian Schneider
2014/06/11 10:41:00
I'm not sure this is ideal to return kMin/kMax. A
Vyacheslav Egorov (Google)
2014/06/11 17:36:37
I second Florian here. Let's prohibit asking a val
Cutch
2014/06/13 04:24:26
Done.
|
| + } |
| + if (IsPositiveInfinity()) { |
| + return kMax; |
|
Florian Schneider
2014/06/11 10:41:00
UNREACHABLE()?
Cutch
2014/06/13 04:24:25
Done.
|
| + } |
| + ASSERT(IsConstant()); |
| + return value_; |
| +} |
| + |
| + |
| void Definition::InferRange() { |
| ASSERT(Type()->ToCid() == kSmiCid); // Has meaning only for smis. |
| if (range_ == NULL) { |
| @@ -2677,12 +2697,14 @@ void ConstraintInstr::InferRange() { |
| RangeBoundary min; |
| RangeBoundary max; |
| - if (IsMinSmi(value_range) && !IsMinSmi(constraint())) { |
| + if (Range::IsSmiMinimumOrUnderflow(value_range) && |
|
Vyacheslav Egorov (Google)
2014/06/11 17:36:37
for simplicity I suggest we make this code differe
Vyacheslav Egorov (Google)
2014/06/11 20:06:37
I wonder if this code will become better if we int
Cutch
2014/06/13 04:24:25
I've extended Min and Max to handle infinities but
Cutch
2014/06/13 04:24:25
Done.
|
| + !Range::IsSmiMinimumOrUnderflow(constraint())) { |
| min = constraint()->min(); |
| - } else if (IsMinSmi(constraint()) && !IsMinSmi(value_range)) { |
| + } else if (Range::IsSmiMinimumOrUnderflow(constraint()) && |
| + !Range::IsSmiMinimumOrUnderflow(value_range)) { |
| min = value_range->min(); |
| } else if ((value_range != NULL) && |
| - IsEqual(constraint()->min(), value_range->min())) { |
| + constraint()->min().Equals(value_range->min())) { |
| min = constraint()->min(); |
| } else { |
| if (value_range != NULL) { |
| @@ -2708,12 +2730,14 @@ void ConstraintInstr::InferRange() { |
| } |
| } |
| - if (IsMaxSmi(value_range) && !IsMaxSmi(constraint())) { |
| + if (Range::IsSmiMaximumOrOverflow(value_range) && |
| + !Range::IsSmiMaximumOrOverflow(constraint())) { |
| max = constraint()->max(); |
| - } else if (IsMaxSmi(constraint()) && !IsMaxSmi(value_range)) { |
| + } else if (Range::IsSmiMaximumOrOverflow(constraint()) && |
| + !Range::IsSmiMaximumOrOverflow(value_range)) { |
| max = value_range->max(); |
| } else if ((value_range != NULL) && |
| - IsEqual(constraint()->max(), value_range->max())) { |
| + constraint()->max().Equals(value_range->max())) { |
| max = constraint()->max(); |
| } else { |
| if (value_range != NULL) { |
| @@ -2974,7 +2998,7 @@ static bool SymbolicSub(const RangeBoundary& a, |
| const RangeBoundary& b, |
| RangeBoundary* result) { |
| if (a.IsSymbol() && b.IsConstant() && !b.Overflowed()) { |
| - const intptr_t offset = a.offset() - b.value(); |
| + const intptr_t offset = a.offset() - b.Value(); |
| if (!Smi::IsValid(offset)) return false; |
| *result = RangeBoundary::FromDefinition(a.symbol(), offset); |
| @@ -2988,13 +3012,13 @@ static bool SymbolicAdd(const RangeBoundary& a, |
| const RangeBoundary& b, |
| RangeBoundary* result) { |
| if (a.IsSymbol() && b.IsConstant() && !b.Overflowed()) { |
| - const intptr_t offset = a.offset() + b.value(); |
| + const intptr_t offset = a.offset() + b.Value(); |
| if (!Smi::IsValid(offset)) return false; |
| *result = RangeBoundary::FromDefinition(a.symbol(), offset); |
| return true; |
| } else if (b.IsSymbol() && a.IsConstant() && !a.Overflowed()) { |
| - const intptr_t offset = b.offset() + a.value(); |
| + const intptr_t offset = b.offset() + a.Value(); |
| if (!Smi::IsValid(offset)) return false; |
| *result = RangeBoundary::FromDefinition(b.symbol(), offset); |
| @@ -3010,30 +3034,6 @@ static bool IsArrayLength(Definition* defn) { |
| } |
| -static int64_t ConstantAbsMax(const Range* range) { |
| - if (range == NULL) return Smi::kMaxValue; |
| - const int64_t abs_min = Utils::Abs(Range::ConstantMin(range).value()); |
| - const int64_t abs_max = Utils::Abs(Range::ConstantMax(range).value()); |
| - return abs_min > abs_max ? abs_min : abs_max; |
| -} |
| - |
| - |
| -static bool OnlyPositiveOrZero(const Range* a, const Range* b) { |
| - if ((a == NULL) || (b == NULL)) return false; |
| - if (Range::ConstantMin(a).value() < 0) return false; |
| - if (Range::ConstantMin(b).value() < 0) return false; |
| - return true; |
| -} |
| - |
| - |
| -static bool OnlyNegativeOrZero(const Range* a, const Range* b) { |
| - if ((a == NULL) || (b == NULL)) return false; |
| - if (Range::ConstantMax(a).value() > 0) return false; |
| - if (Range::ConstantMax(b).value() > 0) return false; |
| - return true; |
| -} |
| - |
| - |
| void BinarySmiOpInstr::InferRange() { |
| // TODO(vegorov): canonicalize BinarySmiOp to always have constant on the |
| // right and a non-constant on the left. |
| @@ -3055,93 +3055,28 @@ void BinarySmiOpInstr::InferRange() { |
| IsArrayLength(left_defn) ? |
| RangeBoundary::FromDefinition(left_defn) : left_range->max(); |
| - RangeBoundary min; |
| - RangeBoundary max; |
| - switch (op_kind()) { |
| - case Token::kADD: |
| - if (!SymbolicAdd(left_min, right_range->min(), &min)) { |
| - min = |
| - RangeBoundary::Add(Range::ConstantMin(left_range), |
| - Range::ConstantMin(right_range), |
| - RangeBoundary::NegativeInfinity()); |
| - } |
| + // If we had no range information before, we do not update the overflow state. |
| + bool should_update_overflow = range_ != NULL; |
|
Vyacheslav Egorov (Google)
2014/06/11 20:06:37
I don't understand the reasoning behind this lack
Cutch
2014/06/13 04:24:26
I've updated the predicate to include the + and -
|
| - if (!SymbolicAdd(left_max, right_range->max(), &max)) { |
| - max = |
| - RangeBoundary::Add(Range::ConstantMax(right_range), |
| - Range::ConstantMax(left_range), |
| - RangeBoundary::PositiveInfinity()); |
| - } |
| - break; |
| - |
| - case Token::kSUB: |
| - if (!SymbolicSub(left_min, right_range->max(), &min)) { |
| - min = |
| - RangeBoundary::Sub(Range::ConstantMin(left_range), |
| - Range::ConstantMax(right_range), |
| - RangeBoundary::NegativeInfinity()); |
| - } |
| - |
| - if (!SymbolicSub(left_max, right_range->min(), &max)) { |
| - max = |
| - RangeBoundary::Sub(Range::ConstantMax(left_range), |
| - Range::ConstantMin(right_range), |
| - RangeBoundary::PositiveInfinity()); |
| - } |
| - break; |
| - |
| - case Token::kMUL: { |
| - const int64_t left_max = ConstantAbsMax(left_range); |
| - const int64_t right_max = ConstantAbsMax(right_range); |
| - if ((left_max < 0x7FFFFFFF) && (right_max < 0x7FFFFFFF)) { |
| - // Product of left and right max values stays in 64 bit range. |
| - const int64_t result_max = left_max * right_max; |
| - if (Smi::IsValid64(result_max) && Smi::IsValid64(-result_max)) { |
| - const intptr_t r_min = |
| - OnlyPositiveOrZero(left_range, right_range) ? 0 : -result_max; |
| - min = RangeBoundary::FromConstant(r_min); |
| - const intptr_t r_max = |
| - OnlyNegativeOrZero(left_range, right_range) ? 0 : result_max; |
| - max = RangeBoundary::FromConstant(r_max); |
| - break; |
| - } |
| - } |
| - if (range_ == NULL) { |
| - range_ = Range::Unknown(); |
| - } |
| - return; |
| - } |
| - case Token::kBIT_AND: |
| - if (Range::ConstantMin(right_range).value() >= 0) { |
| - min = RangeBoundary::FromConstant(0); |
| - max = Range::ConstantMax(right_range); |
| - break; |
| - } |
| - if (Range::ConstantMin(left_range).value() >= 0) { |
| - min = RangeBoundary::FromConstant(0); |
| - max = Range::ConstantMax(left_range); |
| - break; |
| - } |
| - |
| - if (range_ == NULL) { |
| - range_ = Range::Unknown(); |
| - } |
| - return; |
| - |
| - default: |
| - if (range_ == NULL) { |
| - range_ = Range::Unknown(); |
| - } |
| - return; |
| + range_ = Range::BinaryOp(op_kind(), |
| + left_min, |
| + left_max, |
| + left_range, |
| + right_range, |
| + range_); |
| + if (range_ == NULL) { |
| + // No range information. |
| + return; |
| } |
| - ASSERT(!min.IsUnknown() && !max.IsUnknown()); |
| - set_overflow(min.LowerBound().Overflowed() || max.UpperBound().Overflowed()); |
| - |
| - if (min.IsConstant()) min.Clamp(); |
| - if (max.IsConstant()) max.Clamp(); |
| + if (!should_update_overflow) { |
| + return; |
| + } |
| - range_ = new Range(min, max); |
| + ASSERT(!range_->min().IsUnknown() && !range_->max().IsUnknown()); |
| + const bool overflowed = range_->min().LowerBound().Overflowed() || |
| + range_->max().UpperBound().Overflowed(); |
| + set_overflow(overflowed); |
| } |
| @@ -3149,13 +3084,13 @@ bool Range::IsPositive() const { |
| if (min().IsNegativeInfinity()) { |
| return false; |
| } |
| - if (min().LowerBound().value() < 0) { |
| + if (min().LowerBound().Value() < 0) { |
| return false; |
| } |
| if (max().IsPositiveInfinity()) { |
| return true; |
| } |
| - return max().UpperBound().value() >= 0; |
| + return max().UpperBound().Value() >= 0; |
| } |
| @@ -3163,13 +3098,13 @@ bool Range::IsNegative() const { |
| if (max().IsPositiveInfinity()) { |
| return false; |
| } |
| - if (max().UpperBound().value() >= 0) { |
| + if (max().UpperBound().Value() >= 0) { |
| return false; |
| } |
| if (min().IsNegativeInfinity()) { |
| return true; |
| } |
| - return min().LowerBound().value() < 0; |
| + return min().LowerBound().Value() < 0; |
| } |
| @@ -3178,12 +3113,12 @@ bool Range::OnlyLessThanOrEqualTo(intptr_t val) const { |
| // Cannot be true. |
| return false; |
| } |
| - if (max().UpperBound().value() > val) { |
| + if (max().UpperBound().Value() > val) { |
| // Not true. |
| return false; |
| } |
| if (!min().IsNegativeInfinity()) { |
| - if (min().LowerBound().value() > val) { |
| + if (min().LowerBound().Value() > val) { |
| // Lower bound is > value. |
| return false; |
| } |
| @@ -3195,11 +3130,11 @@ bool Range::OnlyLessThanOrEqualTo(intptr_t val) const { |
| // Inclusive. |
| bool Range::IsWithin(intptr_t min_int, intptr_t max_int) const { |
| RangeBoundary lower_min = min().LowerBound(); |
| - if (lower_min.IsNegativeInfinity() || (lower_min.value() < min_int)) { |
| + if (lower_min.IsNegativeInfinity() || (lower_min.Value() < min_int)) { |
| return false; |
| } |
| RangeBoundary upper_max = max().UpperBound(); |
| - if (upper_max.IsPositiveInfinity() || (upper_max.value() > max_int)) { |
| + if (upper_max.IsPositiveInfinity() || (upper_max.Value() > max_int)) { |
| return false; |
| } |
| return true; |
| @@ -3207,10 +3142,8 @@ bool Range::IsWithin(intptr_t min_int, intptr_t max_int) const { |
| bool Range::Overlaps(intptr_t min_int, intptr_t max_int) const { |
| - const intptr_t this_min = min().IsNegativeInfinity() ? |
| - kIntptrMin : min().LowerBound().value(); |
| - const intptr_t this_max = max().IsPositiveInfinity() ? |
| - kIntptrMax : max().UpperBound().value(); |
| + const intptr_t this_min = min().LowerBound().Value(); |
| + const intptr_t this_max = max().UpperBound().Value(); |
| if ((this_min <= min_int) && (min_int <= this_max)) return true; |
| if ((this_min <= max_int) && (max_int <= this_max)) return true; |
| if ((min_int < this_min) && (max_int > this_max)) return true; |
| @@ -3224,7 +3157,7 @@ bool Range::IsUnsatisfiable() const { |
| return true; |
| } |
| // Constant case: For example [0, -1]. |
| - if (Range::ConstantMin(this).value() > Range::ConstantMax(this).value()) { |
| + if (Range::ConstantMin(this).Value() > Range::ConstantMax(this).Value()) { |
| return true; |
| } |
| // Symbol case: For example [v+1, v]. |
| @@ -3235,6 +3168,140 @@ bool Range::IsUnsatisfiable() const { |
| } |
| +// Returns true if range is at or below the minimum smi value. |
| +bool Range::IsSmiMinimumOrUnderflow(const Range* range) { |
| + return (range == NULL) || |
| + ((range->min().IsConstant() || range->min().IsInfinity()) && |
|
Florian Schneider
2014/06/11 10:41:00
IsNegativeInfinity()?
|
| + (range->min().Value() <= Smi::kMinValue)); |
|
Florian Schneider
2014/06/11 10:41:00
Same comment as below.
|
| +} |
| + |
| +// Returns true if range is at or above the maximum smi value. |
| +bool Range::IsSmiMaximumOrOverflow(const Range* range) { |
| + return (range == NULL) || |
| + ((range->max().IsConstant() || range->max().IsInfinity()) && |
|
Florian Schneider
2014/06/11 10:41:00
IsPositiveInfinity?
|
| + (range->max().Value() >= Smi::kMaxValue)); |
|
Florian Schneider
2014/06/11 10:41:00
This is a piece of code that gets hard to read bec
|
| +} |
| + |
| + |
| +// Both the a and b ranges are >= 0. |
| +bool Range::OnlyPositiveOrZero(const Range& a, const Range& b) { |
|
Vyacheslav Egorov (Google)
2014/06/11 20:06:36
It feels like we have some kind of duplication her
Cutch
2014/06/13 04:24:25
Done.
|
| + if (Range::ConstantMin(&a).Value() < 0) { |
| + return false; |
| + } |
| + if (Range::ConstantMin(&b).Value() < 0) { |
| + return false; |
| + } |
| + return true; |
| +} |
| + |
| + |
| +// Both the a and b ranges are <= 0. |
| +bool Range::OnlyNegativeOrZero(const Range& a, const Range& b) { |
| + if (Range::ConstantMax(&a).Value() > 0) { |
| + return false; |
| + } |
| + if (Range::ConstantMax(&b).Value() > 0) { |
| + return false; |
| + } |
| + return true; |
| +} |
| + |
| + |
| +// Return the maximum absolute value included in range. |
| +int64_t Range::ConstantAbsMax(const Range* range) { |
| + if (range == NULL) { |
| + return RangeBoundary::kMax; |
| + } |
| + const int64_t abs_min = Utils::Abs(Range::ConstantMin(range).Value()); |
| + const int64_t abs_max = Utils::Abs(Range::ConstantMax(range).Value()); |
| + return Utils::Maximum(abs_min, abs_max); |
| +} |
| + |
| + |
| +Range* Range::BinaryOp(const Token::Kind op, |
| + const RangeBoundary& left_min, |
| + const RangeBoundary& left_max, |
| + const Range* left_range, |
| + const Range* right_range, |
| + const Range* original_range) { |
| + ASSERT(left_range != NULL); |
| + ASSERT(right_range != NULL); |
| + RangeBoundary min; |
| + RangeBoundary max; |
| + switch (op) { |
| + case Token::kADD: |
| + if (!SymbolicAdd(left_min, right_range->min(), &min)) { |
| + min = RangeBoundary::Add(Range::ConstantMin(left_range), |
| + Range::ConstantMin(right_range), |
| + RangeBoundary::NegativeInfinity()); |
| + } |
| + if (!SymbolicAdd(left_max, right_range->max(), &max)) { |
| + max = RangeBoundary::Add(Range::ConstantMax(right_range), |
| + Range::ConstantMax(left_range), |
| + RangeBoundary::PositiveInfinity()); |
| + } |
| + break; |
| + case Token::kSUB: |
| + if (!SymbolicSub(left_min, right_range->max(), &min)) { |
| + min = RangeBoundary::Sub(Range::ConstantMin(left_range), |
| + Range::ConstantMax(right_range), |
| + RangeBoundary::NegativeInfinity()); |
| + } |
| + if (!SymbolicSub(left_max, right_range->min(), &max)) { |
| + max = RangeBoundary::Sub(Range::ConstantMax(left_range), |
| + Range::ConstantMin(right_range), |
| + RangeBoundary::PositiveInfinity()); |
| + } |
| + break; |
| + case Token::kMUL: { |
| + const int64_t left_max = ConstantAbsMax(left_range); |
| + const int64_t right_max = ConstantAbsMax(right_range); |
| + if ((left_max < 0x7FFFFFFF) && (right_max < 0x7FFFFFFF)) { |
| + // Product of left and right max values stays in 64 bit range. |
| + const int64_t result_max = left_max * right_max; |
| + if (Smi::IsValid64(result_max) && Smi::IsValid64(-result_max)) { |
| + const intptr_t r_min = |
| + OnlyPositiveOrZero(*left_range, *right_range) ? 0 : -result_max; |
| + min = RangeBoundary::FromConstant(r_min); |
| + const intptr_t r_max = |
| + OnlyNegativeOrZero(*left_range, *right_range) ? 0 : result_max; |
| + max = RangeBoundary::FromConstant(r_max); |
| + break; |
| + } |
| + } |
| + if (original_range == NULL) { |
| + return Range::Unknown(); |
| + } |
| + break; |
| + } |
| + case Token::kBIT_AND: |
| + if (Range::ConstantMin(right_range).Value() >= 0) { |
| + min = RangeBoundary::FromConstant(0); |
| + max = Range::ConstantMax(right_range); |
| + break; |
| + } |
| + if (Range::ConstantMin(left_range).Value() >= 0) { |
| + min = RangeBoundary::FromConstant(0); |
| + max = Range::ConstantMax(left_range); |
| + break; |
| + } |
| + if (original_range == NULL) { |
| + return Range::Unknown(); |
| + } |
| + break; |
| + default: |
| + if (original_range == NULL) { |
| + return Range::Unknown(); |
| + } |
| + return const_cast<Range*>(original_range); |
| + } |
| + |
| + ASSERT(!min.IsUnknown() && !max.IsUnknown()); |
| + |
| + return new Range(min, max); |
| +} |
| + |
| + |
| bool CheckArrayBoundInstr::IsFixedLengthArrayType(intptr_t cid) { |
| return LoadFieldInstr::IsFixedLengthArrayCid(cid); |
| } |
| @@ -3249,7 +3316,7 @@ bool CheckArrayBoundInstr::IsRedundant(RangeBoundary length) { |
| } |
| // Range of the index is not positive. Check can't be redundant. |
| - if (Range::ConstantMin(index_range).value() < 0) { |
| + if (Range::ConstantMin(index_range).Value() < 0) { |
| return false; |
| } |
| @@ -3269,7 +3336,7 @@ bool CheckArrayBoundInstr::IsRedundant(RangeBoundary length) { |
| } |
| // Try to compare constant boundaries. |
| - if (max_upper.value() < length_lower.value()) { |
| + if (max_upper.Value() < length_lower.Value()) { |
| return true; |
| } |