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_ARM. | 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_ARM. |
6 #if defined(TARGET_ARCH_ARM) | 6 #if defined(TARGET_ARCH_ARM) |
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 2073 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2084 Register result = locs.out().reg(); | 2084 Register result = locs.out().reg(); |
2085 Label* deopt = shift_left->CanDeoptimize() ? | 2085 Label* deopt = shift_left->CanDeoptimize() ? |
2086 compiler->AddDeoptStub(shift_left->deopt_id(), kDeoptBinarySmiOp) : NULL; | 2086 compiler->AddDeoptStub(shift_left->deopt_id(), kDeoptBinarySmiOp) : NULL; |
2087 if (locs.in(1).IsConstant()) { | 2087 if (locs.in(1).IsConstant()) { |
2088 const Object& constant = locs.in(1).constant(); | 2088 const Object& constant = locs.in(1).constant(); |
2089 ASSERT(constant.IsSmi()); | 2089 ASSERT(constant.IsSmi()); |
2090 // Immediate shift operation takes 5 bits for the count. | 2090 // Immediate shift operation takes 5 bits for the count. |
2091 const intptr_t kCountLimit = 0x1F; | 2091 const intptr_t kCountLimit = 0x1F; |
2092 const intptr_t value = Smi::Cast(constant).Value(); | 2092 const intptr_t value = Smi::Cast(constant).Value(); |
2093 if (value == 0) { | 2093 if (value == 0) { |
2094 // No code needed. | 2094 __ MoveRegister(result, left); |
2095 } else if ((value < 0) || (value >= kCountLimit)) { | 2095 } else if ((value < 0) || (value >= kCountLimit)) { |
2096 // This condition may not be known earlier in some cases because | 2096 // This condition may not be known earlier in some cases because |
2097 // of constant propagation, inlining, etc. | 2097 // of constant propagation, inlining, etc. |
2098 if ((value >= kCountLimit) && is_truncating) { | 2098 if ((value >= kCountLimit) && is_truncating) { |
2099 __ mov(result, ShifterOperand(0)); | 2099 __ mov(result, ShifterOperand(0)); |
2100 } else { | 2100 } else { |
2101 // Result is Mint or exception. | 2101 // Result is Mint or exception. |
2102 __ b(deopt); | 2102 __ b(deopt); |
2103 } | 2103 } |
2104 } else { | 2104 } else { |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2265 } | 2265 } |
2266 // IP: result bits 32..63. | 2266 // IP: result bits 32..63. |
2267 __ cmp(IP, ShifterOperand(result, ASR, 31)); | 2267 __ cmp(IP, ShifterOperand(result, ASR, 31)); |
2268 __ b(deopt, NE); | 2268 __ b(deopt, NE); |
2269 } | 2269 } |
2270 break; | 2270 break; |
2271 } | 2271 } |
2272 case Token::kTRUNCDIV: { | 2272 case Token::kTRUNCDIV: { |
2273 const intptr_t value = Smi::Cast(constant).Value(); | 2273 const intptr_t value = Smi::Cast(constant).Value(); |
2274 if (value == 1) { | 2274 if (value == 1) { |
2275 // Do nothing. | 2275 __ MoveRegister(result, left); |
2276 break; | 2276 break; |
2277 } else if (value == -1) { | 2277 } else if (value == -1) { |
2278 // Check the corner case of dividing the 'MIN_SMI' with -1, in which | 2278 // Check the corner case of dividing the 'MIN_SMI' with -1, in which |
2279 // case we cannot negate the result. | 2279 // case we cannot negate the result. |
2280 __ CompareImmediate(left, 0x80000000); | 2280 __ CompareImmediate(left, 0x80000000); |
2281 __ b(deopt, EQ); | 2281 __ b(deopt, EQ); |
2282 __ rsb(result, left, ShifterOperand(0)); | 2282 __ rsb(result, left, ShifterOperand(0)); |
2283 break; | 2283 break; |
2284 } | 2284 } |
2285 ASSERT((value != 0) && Utils::IsPowerOfTwo(Utils::Abs(value))); | 2285 ASSERT((value != 0) && Utils::IsPowerOfTwo(Utils::Abs(value))); |
(...skipping 1293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3579 compiler->GenerateCall(token_pos(), | 3579 compiler->GenerateCall(token_pos(), |
3580 &label, | 3580 &label, |
3581 PcDescriptors::kOther, | 3581 PcDescriptors::kOther, |
3582 locs()); | 3582 locs()); |
3583 __ Drop(2); // Discard type arguments and receiver. | 3583 __ Drop(2); // Discard type arguments and receiver. |
3584 } | 3584 } |
3585 | 3585 |
3586 } // namespace dart | 3586 } // namespace dart |
3587 | 3587 |
3588 #endif // defined TARGET_ARCH_ARM | 3588 #endif // defined TARGET_ARCH_ARM |
OLD | NEW |