| 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/globals.h" // Needed here to get TARGET_ARCH_IA32. | 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_IA32. |
| 6 #if defined(TARGET_ARCH_IA32) | 6 #if defined(TARGET_ARCH_IA32) |
| 7 | 7 |
| 8 #include "vm/intermediate_language.h" | 8 #include "vm/intermediate_language.h" |
| 9 | 9 |
| 10 #include "lib/error.h" | 10 #include "lib/error.h" |
| (...skipping 2180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2191 // TODO(srdjan): Implement code below for is_truncating(). | 2191 // TODO(srdjan): Implement code below for is_truncating(). |
| 2192 // If left is constant, we know the maximal allowed size for right. | 2192 // If left is constant, we know the maximal allowed size for right. |
| 2193 const Object& obj = shift_left->left()->BoundConstant(); | 2193 const Object& obj = shift_left->left()->BoundConstant(); |
| 2194 if (obj.IsSmi()) { | 2194 if (obj.IsSmi()) { |
| 2195 const intptr_t left_int = Smi::Cast(obj).Value(); | 2195 const intptr_t left_int = Smi::Cast(obj).Value(); |
| 2196 if (left_int == 0) { | 2196 if (left_int == 0) { |
| 2197 __ cmpl(right, Immediate(0)); | 2197 __ cmpl(right, Immediate(0)); |
| 2198 __ j(NEGATIVE, deopt); | 2198 __ j(NEGATIVE, deopt); |
| 2199 return; | 2199 return; |
| 2200 } | 2200 } |
| 2201 intptr_t tmp = (left_int > 0) ? left_int : ~left_int; | 2201 const intptr_t max_right = kSmiBits - Utils::HighestBit(left_int); |
| 2202 intptr_t max_right = kSmiBits; | |
| 2203 while ((tmp >>= 1) != 0) { | |
| 2204 max_right--; | |
| 2205 } | |
| 2206 const bool right_needs_check = | 2202 const bool right_needs_check = |
| 2207 (right_range == NULL) || | 2203 (right_range == NULL) || |
| 2208 !right_range->IsWithin(0, max_right - 1); | 2204 !right_range->IsWithin(0, max_right - 1); |
| 2209 if (right_needs_check) { | 2205 if (right_needs_check) { |
| 2210 __ cmpl(right, | 2206 __ cmpl(right, |
| 2211 Immediate(reinterpret_cast<int32_t>(Smi::New(max_right)))); | 2207 Immediate(reinterpret_cast<int32_t>(Smi::New(max_right)))); |
| 2212 __ j(ABOVE_EQUAL, deopt); | 2208 __ j(ABOVE_EQUAL, deopt); |
| 2213 } | 2209 } |
| 2214 __ SmiUntag(right); | 2210 __ SmiUntag(right); |
| 2215 __ shll(left, right); | 2211 __ shll(left, right); |
| (...skipping 2530 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4746 PcDescriptors::kOther, | 4742 PcDescriptors::kOther, |
| 4747 locs()); | 4743 locs()); |
| 4748 __ Drop(2); // Discard type arguments and receiver. | 4744 __ Drop(2); // Discard type arguments and receiver. |
| 4749 } | 4745 } |
| 4750 | 4746 |
| 4751 } // namespace dart | 4747 } // namespace dart |
| 4752 | 4748 |
| 4753 #undef __ | 4749 #undef __ |
| 4754 | 4750 |
| 4755 #endif // defined TARGET_ARCH_IA32 | 4751 #endif // defined TARGET_ARCH_IA32 |
| OLD | NEW |