| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include <limits.h> // For LONG_MIN, LONG_MAX. | 5 #include <limits.h> // For LONG_MIN, LONG_MAX. |
| 6 | 6 |
| 7 #if V8_TARGET_ARCH_MIPS64 | 7 #if V8_TARGET_ARCH_MIPS64 |
| 8 | 8 |
| 9 #include "src/base/division-by-constant.h" | 9 #include "src/base/division-by-constant.h" |
| 10 #include "src/bootstrapper.h" | 10 #include "src/bootstrapper.h" |
| (...skipping 3502 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3513 return false; | 3513 return false; |
| 3514 } | 3514 } |
| 3515 | 3515 |
| 3516 | 3516 |
| 3517 void MacroAssembler::Jump(Register target, | 3517 void MacroAssembler::Jump(Register target, |
| 3518 Condition cond, | 3518 Condition cond, |
| 3519 Register rs, | 3519 Register rs, |
| 3520 const Operand& rt, | 3520 const Operand& rt, |
| 3521 BranchDelaySlot bd) { | 3521 BranchDelaySlot bd) { |
| 3522 BlockTrampolinePoolScope block_trampoline_pool(this); | 3522 BlockTrampolinePoolScope block_trampoline_pool(this); |
| 3523 if (cond == cc_always) { | 3523 if (kArchVariant == kMips64r6 && bd == PROTECT) { |
| 3524 jr(target); | 3524 if (cond == cc_always) { |
| 3525 jic(target, 0); |
| 3526 } else { |
| 3527 BRANCH_ARGS_CHECK(cond, rs, rt); |
| 3528 Branch(2, NegateCondition(cond), rs, rt); |
| 3529 jic(target, 0); |
| 3530 } |
| 3525 } else { | 3531 } else { |
| 3526 BRANCH_ARGS_CHECK(cond, rs, rt); | 3532 if (cond == cc_always) { |
| 3527 Branch(2, NegateCondition(cond), rs, rt); | 3533 jr(target); |
| 3528 jr(target); | 3534 } else { |
| 3535 BRANCH_ARGS_CHECK(cond, rs, rt); |
| 3536 Branch(2, NegateCondition(cond), rs, rt); |
| 3537 jr(target); |
| 3538 } |
| 3539 // Emit a nop in the branch delay slot if required. |
| 3540 if (bd == PROTECT) nop(); |
| 3529 } | 3541 } |
| 3530 // Emit a nop in the branch delay slot if required. | |
| 3531 if (bd == PROTECT) | |
| 3532 nop(); | |
| 3533 } | 3542 } |
| 3534 | 3543 |
| 3535 | 3544 |
| 3536 void MacroAssembler::Jump(intptr_t target, | 3545 void MacroAssembler::Jump(intptr_t target, |
| 3537 RelocInfo::Mode rmode, | 3546 RelocInfo::Mode rmode, |
| 3538 Condition cond, | 3547 Condition cond, |
| 3539 Register rs, | 3548 Register rs, |
| 3540 const Operand& rt, | 3549 const Operand& rt, |
| 3541 BranchDelaySlot bd) { | 3550 BranchDelaySlot bd) { |
| 3542 Label skip; | 3551 Label skip; |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3580 const Operand& rt, | 3589 const Operand& rt, |
| 3581 BranchDelaySlot bd) { | 3590 BranchDelaySlot bd) { |
| 3582 int size = 0; | 3591 int size = 0; |
| 3583 | 3592 |
| 3584 if (cond == cc_always) { | 3593 if (cond == cc_always) { |
| 3585 size += 1; | 3594 size += 1; |
| 3586 } else { | 3595 } else { |
| 3587 size += 3; | 3596 size += 3; |
| 3588 } | 3597 } |
| 3589 | 3598 |
| 3590 if (bd == PROTECT) | 3599 if (bd == PROTECT && kArchVariant != kMips64r6) size += 1; |
| 3591 size += 1; | |
| 3592 | 3600 |
| 3593 return size * kInstrSize; | 3601 return size * kInstrSize; |
| 3594 } | 3602 } |
| 3595 | 3603 |
| 3596 | 3604 |
| 3597 // Note: To call gcc-compiled C code on mips, you must call thru t9. | 3605 // Note: To call gcc-compiled C code on mips, you must call thru t9. |
| 3598 void MacroAssembler::Call(Register target, | 3606 void MacroAssembler::Call(Register target, |
| 3599 Condition cond, | 3607 Condition cond, |
| 3600 Register rs, | 3608 Register rs, |
| 3601 const Operand& rt, | 3609 const Operand& rt, |
| 3602 BranchDelaySlot bd) { | 3610 BranchDelaySlot bd) { |
| 3603 #ifdef DEBUG | 3611 #ifdef DEBUG |
| 3604 int size = IsPrevInstrCompactBranch() ? kInstrSize : 0; | 3612 int size = IsPrevInstrCompactBranch() ? kInstrSize : 0; |
| 3605 #endif | 3613 #endif |
| 3606 | 3614 |
| 3607 BlockTrampolinePoolScope block_trampoline_pool(this); | 3615 BlockTrampolinePoolScope block_trampoline_pool(this); |
| 3608 Label start; | 3616 Label start; |
| 3609 bind(&start); | 3617 bind(&start); |
| 3610 if (cond == cc_always) { | 3618 if (kArchVariant == kMips64r6 && bd == PROTECT) { |
| 3611 jalr(target); | 3619 if (cond == cc_always) { |
| 3620 jialc(target, 0); |
| 3621 } else { |
| 3622 BRANCH_ARGS_CHECK(cond, rs, rt); |
| 3623 Branch(2, NegateCondition(cond), rs, rt); |
| 3624 jialc(target, 0); |
| 3625 } |
| 3612 } else { | 3626 } else { |
| 3613 BRANCH_ARGS_CHECK(cond, rs, rt); | 3627 if (cond == cc_always) { |
| 3614 Branch(2, NegateCondition(cond), rs, rt); | 3628 jalr(target); |
| 3615 jalr(target); | 3629 } else { |
| 3630 BRANCH_ARGS_CHECK(cond, rs, rt); |
| 3631 Branch(2, NegateCondition(cond), rs, rt); |
| 3632 jalr(target); |
| 3633 } |
| 3634 // Emit a nop in the branch delay slot if required. |
| 3635 if (bd == PROTECT) nop(); |
| 3616 } | 3636 } |
| 3617 // Emit a nop in the branch delay slot if required. | |
| 3618 if (bd == PROTECT) | |
| 3619 nop(); | |
| 3620 | 3637 |
| 3621 #ifdef DEBUG | 3638 #ifdef DEBUG |
| 3622 CHECK_EQ(size + CallSize(target, cond, rs, rt, bd), | 3639 CHECK_EQ(size + CallSize(target, cond, rs, rt, bd), |
| 3623 SizeOfCodeGeneratedSince(&start)); | 3640 SizeOfCodeGeneratedSince(&start)); |
| 3624 #endif | 3641 #endif |
| 3625 } | 3642 } |
| 3626 | 3643 |
| 3627 | 3644 |
| 3628 int MacroAssembler::CallSize(Address target, | 3645 int MacroAssembler::CallSize(Address target, |
| 3629 RelocInfo::Mode rmode, | 3646 RelocInfo::Mode rmode, |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3732 // until associated instructions are emitted and available to be patched. | 3749 // until associated instructions are emitted and available to be patched. |
| 3733 RecordRelocInfo(RelocInfo::INTERNAL_REFERENCE_ENCODED); | 3750 RecordRelocInfo(RelocInfo::INTERNAL_REFERENCE_ENCODED); |
| 3734 jal(L); | 3751 jal(L); |
| 3735 } | 3752 } |
| 3736 // Emit a nop in the branch delay slot if required. | 3753 // Emit a nop in the branch delay slot if required. |
| 3737 if (bdslot == PROTECT) nop(); | 3754 if (bdslot == PROTECT) nop(); |
| 3738 } | 3755 } |
| 3739 } | 3756 } |
| 3740 | 3757 |
| 3741 | 3758 |
| 3742 void MacroAssembler::Jr(Label* L, BranchDelaySlot bdslot) { | |
| 3743 BlockTrampolinePoolScope block_trampoline_pool(this); | |
| 3744 | |
| 3745 uint64_t imm64; | |
| 3746 imm64 = jump_address(L); | |
| 3747 { BlockGrowBufferScope block_buf_growth(this); | |
| 3748 // Buffer growth (and relocation) must be blocked for internal references | |
| 3749 // until associated instructions are emitted and available to be patched. | |
| 3750 RecordRelocInfo(RelocInfo::INTERNAL_REFERENCE_ENCODED); | |
| 3751 li(at, Operand(imm64), ADDRESS_LOAD); | |
| 3752 } | |
| 3753 jr(at); | |
| 3754 | |
| 3755 // Emit a nop in the branch delay slot if required. | |
| 3756 if (bdslot == PROTECT) | |
| 3757 nop(); | |
| 3758 } | |
| 3759 | |
| 3760 | |
| 3761 void MacroAssembler::Jalr(Label* L, BranchDelaySlot bdslot) { | |
| 3762 BlockTrampolinePoolScope block_trampoline_pool(this); | |
| 3763 | |
| 3764 uint64_t imm64; | |
| 3765 imm64 = jump_address(L); | |
| 3766 { BlockGrowBufferScope block_buf_growth(this); | |
| 3767 // Buffer growth (and relocation) must be blocked for internal references | |
| 3768 // until associated instructions are emitted and available to be patched. | |
| 3769 RecordRelocInfo(RelocInfo::INTERNAL_REFERENCE_ENCODED); | |
| 3770 li(at, Operand(imm64), ADDRESS_LOAD); | |
| 3771 } | |
| 3772 jalr(at); | |
| 3773 | |
| 3774 // Emit a nop in the branch delay slot if required. | |
| 3775 if (bdslot == PROTECT) | |
| 3776 nop(); | |
| 3777 } | |
| 3778 | |
| 3779 | |
| 3780 void MacroAssembler::DropAndRet(int drop) { | 3759 void MacroAssembler::DropAndRet(int drop) { |
| 3781 DCHECK(is_int16(drop * kPointerSize)); | 3760 DCHECK(is_int16(drop * kPointerSize)); |
| 3782 Ret(USE_DELAY_SLOT); | 3761 Ret(USE_DELAY_SLOT); |
| 3783 daddiu(sp, sp, drop * kPointerSize); | 3762 daddiu(sp, sp, drop * kPointerSize); |
| 3784 } | 3763 } |
| 3785 | 3764 |
| 3786 void MacroAssembler::DropAndRet(int drop, | 3765 void MacroAssembler::DropAndRet(int drop, |
| 3787 Condition cond, | 3766 Condition cond, |
| 3788 Register r1, | 3767 Register r1, |
| 3789 const Operand& r2) { | 3768 const Operand& r2) { |
| (...skipping 2913 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6703 if (mag.shift > 0) sra(result, result, mag.shift); | 6682 if (mag.shift > 0) sra(result, result, mag.shift); |
| 6704 srl(at, dividend, 31); | 6683 srl(at, dividend, 31); |
| 6705 Addu(result, result, Operand(at)); | 6684 Addu(result, result, Operand(at)); |
| 6706 } | 6685 } |
| 6707 | 6686 |
| 6708 | 6687 |
| 6709 } // namespace internal | 6688 } // namespace internal |
| 6710 } // namespace v8 | 6689 } // namespace v8 |
| 6711 | 6690 |
| 6712 #endif // V8_TARGET_ARCH_MIPS64 | 6691 #endif // V8_TARGET_ARCH_MIPS64 |
| OLD | NEW |