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 "src/v8.h" | 5 #include "src/v8.h" |
6 | 6 |
7 #if V8_TARGET_ARCH_X64 | 7 #if V8_TARGET_ARCH_X64 |
8 | 8 |
9 #include "src/base/bits.h" | 9 #include "src/base/bits.h" |
10 #include "src/base/division-by-constant.h" | 10 #include "src/base/division-by-constant.h" |
(...skipping 1622 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1633 masm->j(overflow, on_not_smi_result, near_jump); | 1633 masm->j(overflow, on_not_smi_result, near_jump); |
1634 } | 1634 } |
1635 } | 1635 } |
1636 | 1636 |
1637 | 1637 |
1638 void MacroAssembler::SmiAdd(Register dst, | 1638 void MacroAssembler::SmiAdd(Register dst, |
1639 Register src1, | 1639 Register src1, |
1640 Register src2, | 1640 Register src2, |
1641 Label* on_not_smi_result, | 1641 Label* on_not_smi_result, |
1642 Label::Distance near_jump) { | 1642 Label::Distance near_jump) { |
1643 DCHECK_NOT_NULL(on_not_smi_result); | 1643 DCHECK(on_not_smi_result); |
1644 DCHECK(!dst.is(src2)); | 1644 DCHECK(!dst.is(src2)); |
1645 SmiAddHelper<Register>(this, dst, src1, src2, on_not_smi_result, near_jump); | 1645 SmiAddHelper<Register>(this, dst, src1, src2, on_not_smi_result, near_jump); |
1646 } | 1646 } |
1647 | 1647 |
1648 | 1648 |
1649 void MacroAssembler::SmiAdd(Register dst, | 1649 void MacroAssembler::SmiAdd(Register dst, |
1650 Register src1, | 1650 Register src1, |
1651 const Operand& src2, | 1651 const Operand& src2, |
1652 Label* on_not_smi_result, | 1652 Label* on_not_smi_result, |
1653 Label::Distance near_jump) { | 1653 Label::Distance near_jump) { |
1654 DCHECK_NOT_NULL(on_not_smi_result); | 1654 DCHECK(on_not_smi_result); |
1655 DCHECK(!src2.AddressUsesRegister(dst)); | 1655 DCHECK(!src2.AddressUsesRegister(dst)); |
1656 SmiAddHelper<Operand>(this, dst, src1, src2, on_not_smi_result, near_jump); | 1656 SmiAddHelper<Operand>(this, dst, src1, src2, on_not_smi_result, near_jump); |
1657 } | 1657 } |
1658 | 1658 |
1659 | 1659 |
1660 void MacroAssembler::SmiAdd(Register dst, | 1660 void MacroAssembler::SmiAdd(Register dst, |
1661 Register src1, | 1661 Register src1, |
1662 Register src2) { | 1662 Register src2) { |
1663 // No overflow checking. Use only when it's known that | 1663 // No overflow checking. Use only when it's known that |
1664 // overflowing is impossible. | 1664 // overflowing is impossible. |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1697 masm->j(overflow, on_not_smi_result, near_jump); | 1697 masm->j(overflow, on_not_smi_result, near_jump); |
1698 } | 1698 } |
1699 } | 1699 } |
1700 | 1700 |
1701 | 1701 |
1702 void MacroAssembler::SmiSub(Register dst, | 1702 void MacroAssembler::SmiSub(Register dst, |
1703 Register src1, | 1703 Register src1, |
1704 Register src2, | 1704 Register src2, |
1705 Label* on_not_smi_result, | 1705 Label* on_not_smi_result, |
1706 Label::Distance near_jump) { | 1706 Label::Distance near_jump) { |
1707 DCHECK_NOT_NULL(on_not_smi_result); | 1707 DCHECK(on_not_smi_result); |
1708 DCHECK(!dst.is(src2)); | 1708 DCHECK(!dst.is(src2)); |
1709 SmiSubHelper<Register>(this, dst, src1, src2, on_not_smi_result, near_jump); | 1709 SmiSubHelper<Register>(this, dst, src1, src2, on_not_smi_result, near_jump); |
1710 } | 1710 } |
1711 | 1711 |
1712 | 1712 |
1713 void MacroAssembler::SmiSub(Register dst, | 1713 void MacroAssembler::SmiSub(Register dst, |
1714 Register src1, | 1714 Register src1, |
1715 const Operand& src2, | 1715 const Operand& src2, |
1716 Label* on_not_smi_result, | 1716 Label* on_not_smi_result, |
1717 Label::Distance near_jump) { | 1717 Label::Distance near_jump) { |
1718 DCHECK_NOT_NULL(on_not_smi_result); | 1718 DCHECK(on_not_smi_result); |
1719 DCHECK(!src2.AddressUsesRegister(dst)); | 1719 DCHECK(!src2.AddressUsesRegister(dst)); |
1720 SmiSubHelper<Operand>(this, dst, src1, src2, on_not_smi_result, near_jump); | 1720 SmiSubHelper<Operand>(this, dst, src1, src2, on_not_smi_result, near_jump); |
1721 } | 1721 } |
1722 | 1722 |
1723 | 1723 |
1724 template<class T> | 1724 template<class T> |
1725 static void SmiSubNoOverflowHelper(MacroAssembler* masm, | 1725 static void SmiSubNoOverflowHelper(MacroAssembler* masm, |
1726 Register dst, | 1726 Register dst, |
1727 Register src1, | 1727 Register src1, |
1728 T src2) { | 1728 T src2) { |
(...skipping 462 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2191 DCHECK(!src1.is(kScratchRegister)); | 2191 DCHECK(!src1.is(kScratchRegister)); |
2192 DCHECK(!src2.is(kScratchRegister)); | 2192 DCHECK(!src2.is(kScratchRegister)); |
2193 DCHECK(!dst.is(src1)); | 2193 DCHECK(!dst.is(src1)); |
2194 DCHECK(!dst.is(src2)); | 2194 DCHECK(!dst.is(src2)); |
2195 // Both operands must not be smis. | 2195 // Both operands must not be smis. |
2196 #ifdef DEBUG | 2196 #ifdef DEBUG |
2197 Condition not_both_smis = NegateCondition(CheckBothSmi(src1, src2)); | 2197 Condition not_both_smis = NegateCondition(CheckBothSmi(src1, src2)); |
2198 Check(not_both_smis, kBothRegistersWereSmisInSelectNonSmi); | 2198 Check(not_both_smis, kBothRegistersWereSmisInSelectNonSmi); |
2199 #endif | 2199 #endif |
2200 STATIC_ASSERT(kSmiTag == 0); | 2200 STATIC_ASSERT(kSmiTag == 0); |
2201 DCHECK_EQ(0, Smi::FromInt(0)); | 2201 DCHECK_EQ(static_cast<Smi*>(0), Smi::FromInt(0)); |
2202 movl(kScratchRegister, Immediate(kSmiTagMask)); | 2202 movl(kScratchRegister, Immediate(kSmiTagMask)); |
2203 andp(kScratchRegister, src1); | 2203 andp(kScratchRegister, src1); |
2204 testl(kScratchRegister, src2); | 2204 testl(kScratchRegister, src2); |
2205 // If non-zero then both are smis. | 2205 // If non-zero then both are smis. |
2206 j(not_zero, on_not_smis, near_jump); | 2206 j(not_zero, on_not_smis, near_jump); |
2207 | 2207 |
2208 // Exactly one operand is a smi. | 2208 // Exactly one operand is a smi. |
2209 DCHECK_EQ(1, static_cast<int>(kSmiTagMask)); | 2209 DCHECK_EQ(1, static_cast<int>(kSmiTagMask)); |
2210 // kScratchRegister still holds src1 & kSmiTag, which is either zero or one. | 2210 // kScratchRegister still holds src1 & kSmiTag, which is either zero or one. |
2211 subp(kScratchRegister, Immediate(1)); | 2211 subp(kScratchRegister, Immediate(1)); |
(...skipping 2979 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5191 if (mag.shift > 0) sarl(rdx, Immediate(mag.shift)); | 5191 if (mag.shift > 0) sarl(rdx, Immediate(mag.shift)); |
5192 movl(rax, dividend); | 5192 movl(rax, dividend); |
5193 shrl(rax, Immediate(31)); | 5193 shrl(rax, Immediate(31)); |
5194 addl(rdx, rax); | 5194 addl(rdx, rax); |
5195 } | 5195 } |
5196 | 5196 |
5197 | 5197 |
5198 } } // namespace v8::internal | 5198 } } // namespace v8::internal |
5199 | 5199 |
5200 #endif // V8_TARGET_ARCH_X64 | 5200 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |