OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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/bigint_operations.h" | 7 #include "vm/bigint_operations.h" |
8 #include "vm/bit_vector.h" | 8 #include "vm/bit_vector.h" |
9 #include "vm/cpu.h" | 9 #include "vm/cpu.h" |
10 #include "vm/dart_entry.h" | 10 #include "vm/dart_entry.h" |
(...skipping 2711 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2722 return false; | 2722 return false; |
2723 } | 2723 } |
2724 | 2724 |
2725 | 2725 |
2726 RangeBoundary RangeBoundary::Shl(const RangeBoundary& value_boundary, | 2726 RangeBoundary RangeBoundary::Shl(const RangeBoundary& value_boundary, |
2727 int64_t shift_count, | 2727 int64_t shift_count, |
2728 const RangeBoundary& overflow) { | 2728 const RangeBoundary& overflow) { |
2729 ASSERT(value_boundary.IsConstant()); | 2729 ASSERT(value_boundary.IsConstant()); |
2730 ASSERT(shift_count >= 0); | 2730 ASSERT(shift_count >= 0); |
2731 int64_t limit = 64 - shift_count; | 2731 int64_t limit = 64 - shift_count; |
2732 int64_t value = static_cast<int64_t>(value_boundary.ConstantValue()); | 2732 int64_t value = value_boundary.ConstantValue(); |
2733 | 2733 |
2734 if ((value == 0) || | 2734 if ((value == 0) || |
2735 (shift_count == 0) || | 2735 (shift_count == 0) || |
2736 ((limit > 0) && (Utils::IsInt(limit, value)))) { | 2736 ((limit > 0) && Utils::IsInt(static_cast<int>(limit), value))) { |
2737 // Result stays in 64 bit range. | 2737 // Result stays in 64 bit range. |
2738 int64_t result = value << shift_count; | 2738 int64_t result = value << shift_count; |
2739 return RangeBoundary(result); | 2739 return RangeBoundary(result); |
2740 } | 2740 } |
2741 | 2741 |
2742 return overflow; | 2742 return overflow; |
2743 } | 2743 } |
2744 | 2744 |
2745 | 2745 |
2746 static RangeBoundary CanonicalizeBoundary(const RangeBoundary& a, | 2746 static RangeBoundary CanonicalizeBoundary(const RangeBoundary& a, |
(...skipping 942 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3689 ASSERT(result_min != NULL); | 3689 ASSERT(result_min != NULL); |
3690 ASSERT(result_max != NULL); | 3690 ASSERT(result_max != NULL); |
3691 | 3691 |
3692 const int64_t left_max = ConstantAbsMax(left_range); | 3692 const int64_t left_max = ConstantAbsMax(left_range); |
3693 const int64_t right_max = ConstantAbsMax(right_range); | 3693 const int64_t right_max = ConstantAbsMax(right_range); |
3694 if ((left_max <= -kSmiMin) && (right_max <= -kSmiMin) && | 3694 if ((left_max <= -kSmiMin) && (right_max <= -kSmiMin) && |
3695 ((left_max == 0) || (right_max <= kMaxInt64 / left_max))) { | 3695 ((left_max == 0) || (right_max <= kMaxInt64 / left_max))) { |
3696 // Product of left and right max values stays in 64 bit range. | 3696 // Product of left and right max values stays in 64 bit range. |
3697 const int64_t mul_max = left_max * right_max; | 3697 const int64_t mul_max = left_max * right_max; |
3698 if (Smi::IsValid(mul_max) && Smi::IsValid(-mul_max)) { | 3698 if (Smi::IsValid(mul_max) && Smi::IsValid(-mul_max)) { |
3699 const intptr_t r_min = | 3699 const int64_t r_min = |
3700 OnlyPositiveOrZero(*left_range, *right_range) ? 0 : -mul_max; | 3700 OnlyPositiveOrZero(*left_range, *right_range) ? 0 : -mul_max; |
3701 *result_min = RangeBoundary::FromConstant(r_min); | 3701 *result_min = RangeBoundary::FromConstant(r_min); |
3702 const intptr_t r_max = | 3702 const int64_t r_max = |
3703 OnlyNegativeOrZero(*left_range, *right_range) ? 0 : mul_max; | 3703 OnlyNegativeOrZero(*left_range, *right_range) ? 0 : mul_max; |
3704 *result_max = RangeBoundary::FromConstant(r_max); | 3704 *result_max = RangeBoundary::FromConstant(r_max); |
3705 return true; | 3705 return true; |
3706 } | 3706 } |
3707 } | 3707 } |
3708 return false; | 3708 return false; |
3709 } | 3709 } |
3710 | 3710 |
3711 | 3711 |
3712 // Both the a and b ranges are >= 0. | 3712 // Both the a and b ranges are >= 0. |
(...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4109 case Token::kTRUNCDIV: return 0; | 4109 case Token::kTRUNCDIV: return 0; |
4110 case Token::kMOD: return 1; | 4110 case Token::kMOD: return 1; |
4111 default: UNIMPLEMENTED(); return -1; | 4111 default: UNIMPLEMENTED(); return -1; |
4112 } | 4112 } |
4113 } | 4113 } |
4114 | 4114 |
4115 | 4115 |
4116 #undef __ | 4116 #undef __ |
4117 | 4117 |
4118 } // namespace dart | 4118 } // namespace dart |
OLD | NEW |