| 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 "vm/cpu.h" | 10 #include "vm/cpu.h" |
| (...skipping 6267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6278 | 6278 |
| 6279 Label* deopt = NULL; | 6279 Label* deopt = NULL; |
| 6280 if (CanDeoptimize()) { | 6280 if (CanDeoptimize()) { |
| 6281 deopt = compiler->AddDeoptStub(deopt_id(), ICData::kDeoptShiftMintOp); | 6281 deopt = compiler->AddDeoptStub(deopt_id(), ICData::kDeoptShiftMintOp); |
| 6282 } | 6282 } |
| 6283 if (locs()->in(1).IsConstant()) { | 6283 if (locs()->in(1).IsConstant()) { |
| 6284 // Code for a constant shift amount. | 6284 // Code for a constant shift amount. |
| 6285 ASSERT(locs()->in(1).constant().IsSmi()); | 6285 ASSERT(locs()->in(1).constant().IsSmi()); |
| 6286 const int32_t shift = | 6286 const int32_t shift = |
| 6287 reinterpret_cast<int32_t>(locs()->in(1).constant().raw()) >> 1; | 6287 reinterpret_cast<int32_t>(locs()->in(1).constant().raw()) >> 1; |
| 6288 if ((shift < 0) || (shift > kMintShiftCountLimit)) { | |
| 6289 __ b(deopt); | |
| 6290 return; | |
| 6291 } else if (shift == 0) { | |
| 6292 // Nothing to do for zero shift amount. | |
| 6293 __ mov(out_lo, Operand(left_lo)); | |
| 6294 __ mov(out_hi, Operand(left_hi)); | |
| 6295 return; | |
| 6296 } | |
| 6297 switch (op_kind()) { | 6288 switch (op_kind()) { |
| 6298 case Token::kSHR: { | 6289 case Token::kSHR: { |
| 6299 if (shift < 32) { | 6290 if (shift < 32) { |
| 6300 __ Lsl(out_lo, left_hi, Operand(32 - shift)); | 6291 __ Lsl(out_lo, left_hi, Operand(32 - shift)); |
| 6301 __ orr(out_lo, out_lo, Operand(left_lo, LSR, shift)); | 6292 __ orr(out_lo, out_lo, Operand(left_lo, LSR, shift)); |
| 6302 __ Asr(out_hi, left_hi, Operand(shift)); | 6293 __ Asr(out_hi, left_hi, Operand(shift)); |
| 6303 } else { | 6294 } else { |
| 6304 if (shift == 32) { | 6295 if (shift == 32) { |
| 6305 __ mov(out_lo, Operand(left_hi)); | 6296 __ mov(out_lo, Operand(left_hi)); |
| 6306 } else { | 6297 } else { |
| (...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6517 | 6508 |
| 6518 Label* deopt = compiler->AddDeoptStub(deopt_id(), ICData::kDeoptShiftMintOp); | 6509 Label* deopt = compiler->AddDeoptStub(deopt_id(), ICData::kDeoptShiftMintOp); |
| 6519 | 6510 |
| 6520 if (locs()->in(1).IsConstant()) { | 6511 if (locs()->in(1).IsConstant()) { |
| 6521 // Shifter is constant. | 6512 // Shifter is constant. |
| 6522 | 6513 |
| 6523 const Object& constant = locs()->in(1).constant(); | 6514 const Object& constant = locs()->in(1).constant(); |
| 6524 ASSERT(constant.IsSmi()); | 6515 ASSERT(constant.IsSmi()); |
| 6525 const intptr_t shift_value = Smi::Cast(constant).Value(); | 6516 const intptr_t shift_value = Smi::Cast(constant).Value(); |
| 6526 | 6517 |
| 6527 // Check constant shift value. | 6518 // Do the shift: (shift_value > 0) && (shift_value <= kShifterLimit). |
| 6528 if (shift_value == 0) { | 6519 switch (op_kind()) { |
| 6529 // Nothing to do. | 6520 case Token::kSHR: |
| 6530 __ mov(out, Operand(left)); | 6521 __ Lsr(out, left, Operand(shift_value)); |
| 6531 } else if (shift_value < 0) { | 6522 break; |
| 6532 // Invalid shift value. | 6523 case Token::kSHL: |
| 6533 __ b(deopt); | 6524 __ Lsl(out, left, Operand(shift_value)); |
| 6534 } else if (shift_value > kShifterLimit) { | 6525 break; |
| 6535 // Result is 0. | 6526 default: |
| 6536 __ eor(out, out, Operand(out)); | 6527 UNREACHABLE(); |
| 6537 } else { | |
| 6538 // Do the shift: (shift_value > 0) && (shift_value <= kShifterLimit). | |
| 6539 switch (op_kind()) { | |
| 6540 case Token::kSHR: | |
| 6541 __ Lsr(out, left, Operand(shift_value)); | |
| 6542 break; | |
| 6543 case Token::kSHL: | |
| 6544 __ Lsl(out, left, Operand(shift_value)); | |
| 6545 break; | |
| 6546 default: | |
| 6547 UNREACHABLE(); | |
| 6548 } | |
| 6549 } | 6528 } |
| 6550 return; | 6529 return; |
| 6551 } | 6530 } |
| 6552 | 6531 |
| 6553 // Non constant shift value. | 6532 // Non constant shift value. |
| 6554 Register shifter = locs()->in(1).reg(); | 6533 Register shifter = locs()->in(1).reg(); |
| 6555 | 6534 |
| 6556 __ mov(temp, Operand(shifter)); | 6535 __ mov(temp, Operand(shifter)); |
| 6557 __ SmiUntag(temp); | 6536 __ SmiUntag(temp); |
| 6558 __ CompareImmediate(temp, 0); | 6537 __ CompareImmediate(temp, 0); |
| (...skipping 449 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7008 compiler->GenerateCall(token_pos(), &label, stub_kind_, locs()); | 6987 compiler->GenerateCall(token_pos(), &label, stub_kind_, locs()); |
| 7009 #if defined(DEBUG) | 6988 #if defined(DEBUG) |
| 7010 __ LoadImmediate(R4, kInvalidObjectPointer); | 6989 __ LoadImmediate(R4, kInvalidObjectPointer); |
| 7011 __ LoadImmediate(R5, kInvalidObjectPointer); | 6990 __ LoadImmediate(R5, kInvalidObjectPointer); |
| 7012 #endif | 6991 #endif |
| 7013 } | 6992 } |
| 7014 | 6993 |
| 7015 } // namespace dart | 6994 } // namespace dart |
| 7016 | 6995 |
| 7017 #endif // defined TARGET_ARCH_ARM | 6996 #endif // defined TARGET_ARCH_ARM |
| OLD | NEW |