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 #include "vm/intermediate_language.h" | 5 #include "vm/intermediate_language.h" |
6 | 6 |
7 #include "vm/bit_vector.h" | 7 #include "vm/bit_vector.h" |
8 #include "vm/dart_entry.h" | 8 #include "vm/dart_entry.h" |
9 #include "vm/flow_graph_allocator.h" | 9 #include "vm/flow_graph_allocator.h" |
10 #include "vm/flow_graph_builder.h" | 10 #include "vm/flow_graph_builder.h" |
(...skipping 2495 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2506 } | 2506 } |
2507 | 2507 |
2508 if (!SymbolicSub(left_max, right_range->min(), &max)) { | 2508 if (!SymbolicSub(left_max, right_range->min(), &max)) { |
2509 max = | 2509 max = |
2510 RangeBoundary::Sub(Range::ConstantMax(left_range), | 2510 RangeBoundary::Sub(Range::ConstantMax(left_range), |
2511 Range::ConstantMin(right_range), | 2511 Range::ConstantMin(right_range), |
2512 RangeBoundary::OverflowedMaxSmi()); | 2512 RangeBoundary::OverflowedMaxSmi()); |
2513 } | 2513 } |
2514 break; | 2514 break; |
2515 | 2515 |
| 2516 case Token::kBIT_AND: |
| 2517 if (Range::ConstantMin(right_range).value() >= 0) { |
| 2518 min = RangeBoundary::FromConstant(0); |
| 2519 max = Range::ConstantMax(right_range); |
| 2520 break; |
| 2521 } |
| 2522 if (Range::ConstantMin(left_range).value() >= 0) { |
| 2523 min = RangeBoundary::FromConstant(0); |
| 2524 max = Range::ConstantMax(left_range); |
| 2525 break; |
| 2526 } |
| 2527 |
| 2528 if (range_ == NULL) { |
| 2529 range_ = Range::Unknown(); |
| 2530 } |
| 2531 return; |
| 2532 |
2516 default: | 2533 default: |
2517 if (range_ == NULL) { | 2534 if (range_ == NULL) { |
2518 range_ = Range::Unknown(); | 2535 range_ = Range::Unknown(); |
2519 } | 2536 } |
2520 return; | 2537 return; |
2521 } | 2538 } |
2522 | 2539 |
2523 ASSERT(!min.IsUnknown() && !max.IsUnknown()); | 2540 ASSERT(!min.IsUnknown() && !max.IsUnknown()); |
2524 set_overflow(min.LowerBound().Overflowed() || max.UpperBound().Overflowed()); | 2541 set_overflow(min.LowerBound().Overflowed() || max.UpperBound().Overflowed()); |
2525 | 2542 |
2526 if (min.IsConstant()) min.Clamp(); | 2543 if (min.IsConstant()) min.Clamp(); |
2527 if (max.IsConstant()) max.Clamp(); | 2544 if (max.IsConstant()) max.Clamp(); |
2528 | 2545 |
2529 range_ = new Range(min, max); | 2546 range_ = new Range(min, max); |
2530 } | 2547 } |
2531 | 2548 |
2532 | 2549 |
| 2550 // Inclusive. |
| 2551 bool Range::IsWithin(intptr_t min_int, intptr_t max_int) const { |
| 2552 if (min().LowerBound().value() < min_int) return false; |
| 2553 if (max().UpperBound().value() > max_int) return false; |
| 2554 return true; |
| 2555 } |
| 2556 |
| 2557 |
2533 bool CheckArrayBoundInstr::IsRedundant(RangeBoundary length) { | 2558 bool CheckArrayBoundInstr::IsRedundant(RangeBoundary length) { |
2534 // Check that array has an immutable length. | 2559 // Check that array has an immutable length. |
2535 if ((array_type() != kArrayCid) && (array_type() != kImmutableArrayCid)) { | 2560 if ((array_type() != kArrayCid) && (array_type() != kImmutableArrayCid)) { |
2536 return false; | 2561 return false; |
2537 } | 2562 } |
2538 | 2563 |
2539 Range* index_range = index()->definition()->range(); | 2564 Range* index_range = index()->definition()->range(); |
2540 | 2565 |
2541 // Range of the index is unknown can't decide if the check is redundant. | 2566 // Range of the index is unknown can't decide if the check is redundant. |
2542 if (index_range == NULL) return false; | 2567 if (index_range == NULL) return false; |
(...skipping 20 matching lines...) Expand all Loading... |
2563 } while (CanonicalizeMaxBoundary(&max) || CanonicalizeMinBoundary(&length)); | 2588 } while (CanonicalizeMaxBoundary(&max) || CanonicalizeMinBoundary(&length)); |
2564 | 2589 |
2565 // Failed to prove that maximum is bounded with array length. | 2590 // Failed to prove that maximum is bounded with array length. |
2566 return false; | 2591 return false; |
2567 } | 2592 } |
2568 | 2593 |
2569 | 2594 |
2570 #undef __ | 2595 #undef __ |
2571 | 2596 |
2572 } // namespace dart | 2597 } // namespace dart |
OLD | NEW |