| 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 2077 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2088 __ movq(right, Immediate(kCountLimit)); | 2088 __ movq(right, Immediate(kCountLimit)); |
| 2089 __ Bind(&count_ok); | 2089 __ Bind(&count_ok); |
| 2090 } | 2090 } |
| 2091 ASSERT(right == RCX); // Count must be in RCX | 2091 ASSERT(right == RCX); // Count must be in RCX |
| 2092 __ SmiUntag(left); | 2092 __ SmiUntag(left); |
| 2093 __ sarq(left, right); | 2093 __ sarq(left, right); |
| 2094 __ SmiTag(left); | 2094 __ SmiTag(left); |
| 2095 break; | 2095 break; |
| 2096 } | 2096 } |
| 2097 case Token::kSHL: { | 2097 case Token::kSHL: { |
| 2098 Range* right_range = this->right()->definition()->range(); |
| 2099 if (this->left()->BindsToConstant()) { |
| 2100 // If left is constant, we know the maximal allowed size for right. |
| 2101 const Object& obj = this->left()->BoundConstant(); |
| 2102 if (obj.IsSmi()) { |
| 2103 const intptr_t left_int = Smi::Cast(obj).Value(); |
| 2104 if (left_int == 0) { |
| 2105 __ cmpq(right, Immediate(0)); |
| 2106 __ j(NEGATIVE, deopt); |
| 2107 break; |
| 2108 } |
| 2109 intptr_t tmp = (left_int > 0) ? left_int : ~left_int; |
| 2110 intptr_t max_right = kSmiBits; |
| 2111 while ((tmp >>= 1) != 0) { |
| 2112 max_right--; |
| 2113 } |
| 2114 const bool right_needs_check = |
| 2115 (right_range == NULL) || |
| 2116 !right_range->IsWithin(0, max_right - 1); |
| 2117 if (right_needs_check) { |
| 2118 __ cmpq(right, |
| 2119 Immediate(reinterpret_cast<int64_t>(Smi::New(max_right)))); |
| 2120 __ j(ABOVE_EQUAL, deopt); |
| 2121 } |
| 2122 __ SmiUntag(right); |
| 2123 __ shlq(left, right); |
| 2124 break; |
| 2125 } |
| 2126 } |
| 2098 Register temp = locs()->temp(0).reg(); | 2127 Register temp = locs()->temp(0).reg(); |
| 2099 // Check if count too large for handling it inlined. | 2128 // Check if count too large for handling it inlined. |
| 2100 __ movq(temp, left); | 2129 __ movq(temp, left); |
| 2101 Range* right_range = this->right()->definition()->range(); | |
| 2102 const bool right_needs_check = | 2130 const bool right_needs_check = |
| 2103 (right_range == NULL) || !right_range->IsWithin(0, (Smi::kBits - 1)); | 2131 (right_range == NULL) || !right_range->IsWithin(0, (Smi::kBits - 1)); |
| 2104 if (right_needs_check) { | 2132 if (right_needs_check) { |
| 2105 __ cmpq(right, | 2133 __ cmpq(right, |
| 2106 Immediate(reinterpret_cast<int64_t>(Smi::New(Smi::kBits)))); | 2134 Immediate(reinterpret_cast<int64_t>(Smi::New(Smi::kBits)))); |
| 2107 __ j(ABOVE_EQUAL, deopt); | 2135 __ j(ABOVE_EQUAL, deopt); |
| 2108 } | 2136 } |
| 2109 ASSERT(right == RCX); // Count must be in RCX | 2137 ASSERT(right == RCX); // Count must be in RCX |
| 2110 __ SmiUntag(right); | 2138 __ SmiUntag(right); |
| 2111 // Overflow test (preserve temp and right); | 2139 // Overflow test (preserve temp and right); |
| (...skipping 956 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3068 PcDescriptors::kOther, | 3096 PcDescriptors::kOther, |
| 3069 locs()); | 3097 locs()); |
| 3070 __ Drop(2); // Discard type arguments and receiver. | 3098 __ Drop(2); // Discard type arguments and receiver. |
| 3071 } | 3099 } |
| 3072 | 3100 |
| 3073 } // namespace dart | 3101 } // namespace dart |
| 3074 | 3102 |
| 3075 #undef __ | 3103 #undef __ |
| 3076 | 3104 |
| 3077 #endif // defined TARGET_ARCH_X64 | 3105 #endif // defined TARGET_ARCH_X64 |
| OLD | NEW |