OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 1681 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1692 Check(no_overflow, kSmiAdditionOverflow); | 1692 Check(no_overflow, kSmiAdditionOverflow); |
1693 } | 1693 } |
1694 lea(dst, Operand(src1, src2, times_1, 0)); | 1694 lea(dst, Operand(src1, src2, times_1, 0)); |
1695 } else { | 1695 } else { |
1696 addq(dst, src2); | 1696 addq(dst, src2); |
1697 Assert(no_overflow, kSmiAdditionOverflow); | 1697 Assert(no_overflow, kSmiAdditionOverflow); |
1698 } | 1698 } |
1699 } | 1699 } |
1700 | 1700 |
1701 | 1701 |
| 1702 template<class T> |
| 1703 static void SmiSubHelper(MacroAssembler* masm, |
| 1704 Register dst, |
| 1705 Register src1, |
| 1706 T src2, |
| 1707 Label* on_not_smi_result, |
| 1708 Label::Distance near_jump) { |
| 1709 if (dst.is(src1)) { |
| 1710 Label done; |
| 1711 masm->subq(dst, src2); |
| 1712 masm->j(no_overflow, &done, Label::kNear); |
| 1713 // Restore src1. |
| 1714 masm->addq(dst, src2); |
| 1715 masm->jmp(on_not_smi_result, near_jump); |
| 1716 masm->bind(&done); |
| 1717 } else { |
| 1718 masm->movq(dst, src1); |
| 1719 masm->subq(dst, src2); |
| 1720 masm->j(overflow, on_not_smi_result, near_jump); |
| 1721 } |
| 1722 } |
| 1723 |
| 1724 |
1702 void MacroAssembler::SmiSub(Register dst, | 1725 void MacroAssembler::SmiSub(Register dst, |
1703 Register src1, | 1726 Register src1, |
1704 Register src2, | 1727 Register src2, |
1705 Label* on_not_smi_result, | 1728 Label* on_not_smi_result, |
1706 Label::Distance near_jump) { | 1729 Label::Distance near_jump) { |
1707 ASSERT_NOT_NULL(on_not_smi_result); | 1730 ASSERT_NOT_NULL(on_not_smi_result); |
1708 ASSERT(!dst.is(src2)); | 1731 ASSERT(!dst.is(src2)); |
1709 if (dst.is(src1)) { | 1732 SmiSubHelper<Register>(this, dst, src1, src2, on_not_smi_result, near_jump); |
1710 cmpq(dst, src2); | |
1711 j(overflow, on_not_smi_result, near_jump); | |
1712 subq(dst, src2); | |
1713 } else { | |
1714 movq(dst, src1); | |
1715 subq(dst, src2); | |
1716 j(overflow, on_not_smi_result, near_jump); | |
1717 } | |
1718 } | 1733 } |
1719 | 1734 |
1720 | 1735 |
1721 void MacroAssembler::SmiSub(Register dst, Register src1, Register src2) { | |
1722 // No overflow checking. Use only when it's known that | |
1723 // overflowing is impossible (e.g., subtracting two positive smis). | |
1724 ASSERT(!dst.is(src2)); | |
1725 if (!dst.is(src1)) { | |
1726 movq(dst, src1); | |
1727 } | |
1728 subq(dst, src2); | |
1729 Assert(no_overflow, kSmiSubtractionOverflow); | |
1730 } | |
1731 | |
1732 | |
1733 void MacroAssembler::SmiSub(Register dst, | 1736 void MacroAssembler::SmiSub(Register dst, |
1734 Register src1, | 1737 Register src1, |
1735 const Operand& src2, | 1738 const Operand& src2, |
1736 Label* on_not_smi_result, | 1739 Label* on_not_smi_result, |
1737 Label::Distance near_jump) { | 1740 Label::Distance near_jump) { |
1738 ASSERT_NOT_NULL(on_not_smi_result); | 1741 ASSERT_NOT_NULL(on_not_smi_result); |
1739 if (dst.is(src1)) { | 1742 ASSERT(!src2.AddressUsesRegister(dst)); |
1740 movq(kScratchRegister, src2); | 1743 SmiSubHelper<Operand>(this, dst, src1, src2, on_not_smi_result, near_jump); |
1741 cmpq(src1, kScratchRegister); | 1744 } |
1742 j(overflow, on_not_smi_result, near_jump); | 1745 |
1743 subq(src1, kScratchRegister); | 1746 |
1744 } else { | 1747 template<class T> |
1745 movq(dst, src1); | 1748 static void SmiSubNoOverflowHelper(MacroAssembler* masm, |
1746 subq(dst, src2); | 1749 Register dst, |
1747 j(overflow, on_not_smi_result, near_jump); | 1750 Register src1, |
| 1751 T src2) { |
| 1752 // No overflow checking. Use only when it's known that |
| 1753 // overflowing is impossible (e.g., subtracting two positive smis). |
| 1754 if (!dst.is(src1)) { |
| 1755 masm->movq(dst, src1); |
1748 } | 1756 } |
| 1757 masm->subq(dst, src2); |
| 1758 masm->Assert(no_overflow, kSmiSubtractionOverflow); |
| 1759 } |
| 1760 |
| 1761 |
| 1762 void MacroAssembler::SmiSub(Register dst, Register src1, Register src2) { |
| 1763 ASSERT(!dst.is(src2)); |
| 1764 SmiSubNoOverflowHelper<Register>(this, dst, src1, src2); |
1749 } | 1765 } |
1750 | 1766 |
1751 | 1767 |
1752 void MacroAssembler::SmiSub(Register dst, | 1768 void MacroAssembler::SmiSub(Register dst, |
1753 Register src1, | 1769 Register src1, |
1754 const Operand& src2) { | 1770 const Operand& src2) { |
1755 // No overflow checking. Use only when it's known that | 1771 SmiSubNoOverflowHelper<Operand>(this, dst, src1, src2); |
1756 // overflowing is impossible (e.g., subtracting two positive smis). | |
1757 if (!dst.is(src1)) { | |
1758 movq(dst, src1); | |
1759 } | |
1760 subq(dst, src2); | |
1761 Assert(no_overflow, kSmiSubtractionOverflow); | |
1762 } | 1772 } |
1763 | 1773 |
1764 | 1774 |
1765 void MacroAssembler::SmiMul(Register dst, | 1775 void MacroAssembler::SmiMul(Register dst, |
1766 Register src1, | 1776 Register src1, |
1767 Register src2, | 1777 Register src2, |
1768 Label* on_not_smi_result, | 1778 Label* on_not_smi_result, |
1769 Label::Distance near_jump) { | 1779 Label::Distance near_jump) { |
1770 ASSERT(!dst.is(src2)); | 1780 ASSERT(!dst.is(src2)); |
1771 ASSERT(!dst.is(kScratchRegister)); | 1781 ASSERT(!dst.is(kScratchRegister)); |
(...skipping 3145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4917 j(greater, &no_memento_available); | 4927 j(greater, &no_memento_available); |
4918 CompareRoot(MemOperand(scratch_reg, -AllocationMemento::kSize), | 4928 CompareRoot(MemOperand(scratch_reg, -AllocationMemento::kSize), |
4919 Heap::kAllocationMementoMapRootIndex); | 4929 Heap::kAllocationMementoMapRootIndex); |
4920 bind(&no_memento_available); | 4930 bind(&no_memento_available); |
4921 } | 4931 } |
4922 | 4932 |
4923 | 4933 |
4924 } } // namespace v8::internal | 4934 } } // namespace v8::internal |
4925 | 4935 |
4926 #endif // V8_TARGET_ARCH_X64 | 4936 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |