| 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_X64. | 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_X64. |
| 6 #if defined(TARGET_ARCH_X64) | 6 #if defined(TARGET_ARCH_X64) |
| 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 2166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2177 // TODO(srdjan): Implement code below for is_truncating(). | 2177 // TODO(srdjan): Implement code below for is_truncating(). |
| 2178 // If left is constant, we know the maximal allowed size for right. | 2178 // If left is constant, we know the maximal allowed size for right. |
| 2179 const Object& obj = shift_left->left()->BoundConstant(); | 2179 const Object& obj = shift_left->left()->BoundConstant(); |
| 2180 if (obj.IsSmi()) { | 2180 if (obj.IsSmi()) { |
| 2181 const intptr_t left_int = Smi::Cast(obj).Value(); | 2181 const intptr_t left_int = Smi::Cast(obj).Value(); |
| 2182 if (left_int == 0) { | 2182 if (left_int == 0) { |
| 2183 __ cmpq(right, Immediate(0)); | 2183 __ cmpq(right, Immediate(0)); |
| 2184 __ j(NEGATIVE, deopt); | 2184 __ j(NEGATIVE, deopt); |
| 2185 return; | 2185 return; |
| 2186 } | 2186 } |
| 2187 intptr_t tmp = (left_int > 0) ? left_int : ~left_int; | 2187 const intptr_t max_right = kSmiBits - Utils::HighestBit(left_int); |
| 2188 intptr_t max_right = kSmiBits; | |
| 2189 while ((tmp >>= 1) != 0) { | |
| 2190 max_right--; | |
| 2191 } | |
| 2192 const bool right_needs_check = | 2188 const bool right_needs_check = |
| 2193 (right_range == NULL) || | 2189 (right_range == NULL) || |
| 2194 !right_range->IsWithin(0, max_right - 1); | 2190 !right_range->IsWithin(0, max_right - 1); |
| 2195 if (right_needs_check) { | 2191 if (right_needs_check) { |
| 2196 __ cmpq(right, | 2192 __ cmpq(right, |
| 2197 Immediate(reinterpret_cast<int64_t>(Smi::New(max_right)))); | 2193 Immediate(reinterpret_cast<int64_t>(Smi::New(max_right)))); |
| 2198 __ j(ABOVE_EQUAL, deopt); | 2194 __ j(ABOVE_EQUAL, deopt); |
| 2199 } | 2195 } |
| 2200 __ SmiUntag(right); | 2196 __ SmiUntag(right); |
| 2201 __ shlq(left, right); | 2197 __ shlq(left, right); |
| (...skipping 2190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4392 PcDescriptors::kOther, | 4388 PcDescriptors::kOther, |
| 4393 locs()); | 4389 locs()); |
| 4394 __ Drop(2); // Discard type arguments and receiver. | 4390 __ Drop(2); // Discard type arguments and receiver. |
| 4395 } | 4391 } |
| 4396 | 4392 |
| 4397 } // namespace dart | 4393 } // namespace dart |
| 4398 | 4394 |
| 4399 #undef __ | 4395 #undef __ |
| 4400 | 4396 |
| 4401 #endif // defined TARGET_ARCH_X64 | 4397 #endif // defined TARGET_ARCH_X64 |
| OLD | NEW |