OLD | NEW |
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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_ARM64. | 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_ARM64. |
6 #if defined(TARGET_ARCH_ARM64) | 6 #if defined(TARGET_ARCH_ARM64) |
7 | 7 |
8 #include "vm/intermediate_language.h" | 8 #include "vm/intermediate_language.h" |
9 | 9 |
10 #include "vm/dart_entry.h" | 10 #include "vm/dart_entry.h" |
(...skipping 2590 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2601 const Register left = locs()->in(0).reg(); | 2601 const Register left = locs()->in(0).reg(); |
2602 const Register result = locs()->out(0).reg(); | 2602 const Register result = locs()->out(0).reg(); |
2603 Label* deopt = NULL; | 2603 Label* deopt = NULL; |
2604 if (CanDeoptimize()) { | 2604 if (CanDeoptimize()) { |
2605 deopt = compiler->AddDeoptStub(deopt_id(), ICData::kDeoptBinarySmiOp); | 2605 deopt = compiler->AddDeoptStub(deopt_id(), ICData::kDeoptBinarySmiOp); |
2606 } | 2606 } |
2607 | 2607 |
2608 if (locs()->in(1).IsConstant()) { | 2608 if (locs()->in(1).IsConstant()) { |
2609 const Object& constant = locs()->in(1).constant(); | 2609 const Object& constant = locs()->in(1).constant(); |
2610 ASSERT(constant.IsSmi()); | 2610 ASSERT(constant.IsSmi()); |
2611 int64_t imm = reinterpret_cast<int64_t>(constant.raw()); | 2611 const int64_t imm = reinterpret_cast<int64_t>(constant.raw()); |
2612 switch (op_kind()) { | 2612 switch (op_kind()) { |
2613 case Token::kSUB: { | |
2614 imm = -imm; // TODO(regis): What if deopt != NULL && imm == 0x80000000? | |
2615 // Fall through. | |
2616 } | |
2617 case Token::kADD: { | 2613 case Token::kADD: { |
2618 if (deopt == NULL) { | 2614 if (deopt == NULL) { |
2619 __ AddImmediate(result, left, imm, PP); | 2615 __ AddImmediate(result, left, imm, PP); |
2620 } else { | 2616 } else { |
2621 __ AddImmediateSetFlags(result, left, imm, PP); | 2617 __ AddImmediateSetFlags(result, left, imm, PP); |
2622 __ b(deopt, VS); } | 2618 __ b(deopt, VS); |
| 2619 } |
| 2620 break; |
| 2621 } |
| 2622 case Token::kSUB: { |
| 2623 if (deopt == NULL) { |
| 2624 __ AddImmediate(result, left, -imm, PP); |
| 2625 } else { |
| 2626 // Negating imm and using AddImmediateSetFlags would not detect the |
| 2627 // overflow when imm == kMinInt64. |
| 2628 __ SubImmediateSetFlags(result, left, imm, PP); |
| 2629 __ b(deopt, VS); |
| 2630 } |
2623 break; | 2631 break; |
2624 } | 2632 } |
2625 case Token::kMUL: { | 2633 case Token::kMUL: { |
2626 // Keep left value tagged and untag right value. | 2634 // Keep left value tagged and untag right value. |
2627 const intptr_t value = Smi::Cast(constant).Value(); | 2635 const intptr_t value = Smi::Cast(constant).Value(); |
2628 if (deopt == NULL) { | 2636 if (deopt == NULL) { |
2629 if (value == 2) { | 2637 if (value == 2) { |
2630 __ Lsl(result, left, 1); | 2638 __ Lsl(result, left, 1); |
2631 } else { | 2639 } else { |
2632 __ LoadImmediate(TMP, value, PP); | 2640 __ LoadImmediate(TMP, value, PP); |
(...skipping 1800 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4433 compiler->GenerateCall(token_pos(), | 4441 compiler->GenerateCall(token_pos(), |
4434 &label, | 4442 &label, |
4435 PcDescriptors::kOther, | 4443 PcDescriptors::kOther, |
4436 locs()); | 4444 locs()); |
4437 __ Drop(ArgumentCount()); // Discard arguments. | 4445 __ Drop(ArgumentCount()); // Discard arguments. |
4438 } | 4446 } |
4439 | 4447 |
4440 } // namespace dart | 4448 } // namespace dart |
4441 | 4449 |
4442 #endif // defined TARGET_ARCH_ARM64 | 4450 #endif // defined TARGET_ARCH_ARM64 |
OLD | NEW |