| OLD | NEW |
| 1 // Copyright 2009 the V8 project authors. All rights reserved. | 1 // Copyright 2009 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 1719 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1730 | 1730 |
| 1731 | 1731 |
| 1732 void TestSmiShiftLeft(MacroAssembler* masm, Label* exit, int id, int x) { | 1732 void TestSmiShiftLeft(MacroAssembler* masm, Label* exit, int id, int x) { |
| 1733 const int shifts[] = { 0, 1, 7, 24, kSmiValueSize - 1}; | 1733 const int shifts[] = { 0, 1, 7, 24, kSmiValueSize - 1}; |
| 1734 const int kNumShifts = 5; | 1734 const int kNumShifts = 5; |
| 1735 __ movl(rax, Immediate(id)); | 1735 __ movl(rax, Immediate(id)); |
| 1736 for (int i = 0; i < kNumShifts; i++) { | 1736 for (int i = 0; i < kNumShifts; i++) { |
| 1737 // rax == id + i * 10. | 1737 // rax == id + i * 10. |
| 1738 int shift = shifts[i]; | 1738 int shift = shifts[i]; |
| 1739 int result = x << shift; | 1739 int result = x << shift; |
| 1740 if (Smi::IsValid(result)) { | 1740 CHECK(Smi::IsValid(result)); |
| 1741 __ Move(r8, Smi::FromInt(result)); | 1741 __ Move(r8, Smi::FromInt(result)); |
| 1742 __ Move(rcx, Smi::FromInt(x)); | 1742 __ Move(rcx, Smi::FromInt(x)); |
| 1743 __ SmiShiftLeftConstant(r9, rcx, shift, exit); | 1743 __ SmiShiftLeftConstant(r9, rcx, shift); |
| 1744 | 1744 |
| 1745 __ incq(rax); | 1745 __ incq(rax); |
| 1746 __ SmiCompare(r9, r8); | 1746 __ SmiCompare(r9, r8); |
| 1747 __ j(not_equal, exit); | 1747 __ j(not_equal, exit); |
| 1748 | 1748 |
| 1749 __ incq(rax); | 1749 __ incq(rax); |
| 1750 __ Move(rcx, Smi::FromInt(x)); | 1750 __ Move(rcx, Smi::FromInt(x)); |
| 1751 __ SmiShiftLeftConstant(rcx, rcx, shift, exit); | 1751 __ SmiShiftLeftConstant(rcx, rcx, shift); |
| 1752 | 1752 |
| 1753 __ incq(rax); | 1753 __ incq(rax); |
| 1754 __ SmiCompare(rcx, r8); | 1754 __ SmiCompare(rcx, r8); |
| 1755 __ j(not_equal, exit); | 1755 __ j(not_equal, exit); |
| 1756 | 1756 |
| 1757 __ incq(rax); | 1757 __ incq(rax); |
| 1758 __ Move(rdx, Smi::FromInt(x)); | 1758 __ Move(rdx, Smi::FromInt(x)); |
| 1759 __ Move(rcx, Smi::FromInt(shift)); | 1759 __ Move(rcx, Smi::FromInt(shift)); |
| 1760 __ SmiShiftLeft(r9, rdx, rcx, exit); | 1760 __ SmiShiftLeft(r9, rdx, rcx); |
| 1761 | 1761 |
| 1762 __ incq(rax); | 1762 __ incq(rax); |
| 1763 __ SmiCompare(r9, r8); | 1763 __ SmiCompare(r9, r8); |
| 1764 __ j(not_equal, exit); | 1764 __ j(not_equal, exit); |
| 1765 | 1765 |
| 1766 __ incq(rax); | 1766 __ incq(rax); |
| 1767 __ Move(rdx, Smi::FromInt(x)); | 1767 __ Move(rdx, Smi::FromInt(x)); |
| 1768 __ Move(r11, Smi::FromInt(shift)); | 1768 __ Move(r11, Smi::FromInt(shift)); |
| 1769 __ SmiShiftLeft(r9, rdx, r11, exit); | 1769 __ SmiShiftLeft(r9, rdx, r11); |
| 1770 | 1770 |
| 1771 __ incq(rax); | 1771 __ incq(rax); |
| 1772 __ SmiCompare(r9, r8); | 1772 __ SmiCompare(r9, r8); |
| 1773 __ j(not_equal, exit); | 1773 __ j(not_equal, exit); |
| 1774 | 1774 |
| 1775 __ incq(rax); | 1775 __ incq(rax); |
| 1776 __ Move(rdx, Smi::FromInt(x)); | 1776 __ Move(rdx, Smi::FromInt(x)); |
| 1777 __ Move(r11, Smi::FromInt(shift)); | 1777 __ Move(r11, Smi::FromInt(shift)); |
| 1778 __ SmiShiftLeft(rdx, rdx, r11, exit); | 1778 __ SmiShiftLeft(rdx, rdx, r11); |
| 1779 | 1779 |
| 1780 __ incq(rax); | 1780 __ incq(rax); |
| 1781 __ SmiCompare(rdx, r8); | 1781 __ SmiCompare(rdx, r8); |
| 1782 __ j(not_equal, exit); | 1782 __ j(not_equal, exit); |
| 1783 | 1783 |
| 1784 __ incq(rax); | 1784 __ incq(rax); |
| 1785 } else { | |
| 1786 // Cannot happen with long smis. | |
| 1787 Label fail_ok; | |
| 1788 __ Move(rcx, Smi::FromInt(x)); | |
| 1789 __ movq(r11, rcx); | |
| 1790 __ SmiShiftLeftConstant(r9, rcx, shift, &fail_ok); | |
| 1791 __ jmp(exit); | |
| 1792 __ bind(&fail_ok); | |
| 1793 | |
| 1794 __ incq(rax); | |
| 1795 __ SmiCompare(rcx, r11); | |
| 1796 __ j(not_equal, exit); | |
| 1797 | |
| 1798 __ incq(rax); | |
| 1799 Label fail_ok2; | |
| 1800 __ SmiShiftLeftConstant(rcx, rcx, shift, &fail_ok2); | |
| 1801 __ jmp(exit); | |
| 1802 __ bind(&fail_ok2); | |
| 1803 | |
| 1804 __ incq(rax); | |
| 1805 __ SmiCompare(rcx, r11); | |
| 1806 __ j(not_equal, exit); | |
| 1807 | |
| 1808 __ incq(rax); | |
| 1809 __ Move(r8, Smi::FromInt(shift)); | |
| 1810 Label fail_ok3; | |
| 1811 __ SmiShiftLeft(r9, rcx, r8, &fail_ok3); | |
| 1812 __ jmp(exit); | |
| 1813 __ bind(&fail_ok3); | |
| 1814 | |
| 1815 __ incq(rax); | |
| 1816 __ SmiCompare(rcx, r11); | |
| 1817 __ j(not_equal, exit); | |
| 1818 | |
| 1819 __ incq(rax); | |
| 1820 __ Move(r8, Smi::FromInt(shift)); | |
| 1821 __ movq(rdx, r11); | |
| 1822 Label fail_ok4; | |
| 1823 __ SmiShiftLeft(rdx, rdx, r8, &fail_ok4); | |
| 1824 __ jmp(exit); | |
| 1825 __ bind(&fail_ok4); | |
| 1826 | |
| 1827 __ incq(rax); | |
| 1828 __ SmiCompare(rdx, r11); | |
| 1829 __ j(not_equal, exit); | |
| 1830 | |
| 1831 __ addq(rax, Immediate(3)); | |
| 1832 } | |
| 1833 } | 1785 } |
| 1834 } | 1786 } |
| 1835 | 1787 |
| 1836 | 1788 |
| 1837 TEST(SmiShiftLeft) { | 1789 TEST(SmiShiftLeft) { |
| 1838 // Allocate an executable page of memory. | 1790 // Allocate an executable page of memory. |
| 1839 size_t actual_size; | 1791 size_t actual_size; |
| 1840 byte* buffer = | 1792 byte* buffer = |
| 1841 static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize * 3, | 1793 static_cast<byte*>(OS::Allocate(Assembler::kMinimalBufferSize * 3, |
| 1842 &actual_size, | 1794 &actual_size, |
| (...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2095 | 2047 |
| 2096 CodeDesc desc; | 2048 CodeDesc desc; |
| 2097 masm->GetCode(&desc); | 2049 masm->GetCode(&desc); |
| 2098 // Call the function from C++. | 2050 // Call the function from C++. |
| 2099 int result = FUNCTION_CAST<F0>(buffer)(); | 2051 int result = FUNCTION_CAST<F0>(buffer)(); |
| 2100 CHECK_EQ(0, result); | 2052 CHECK_EQ(0, result); |
| 2101 } | 2053 } |
| 2102 | 2054 |
| 2103 | 2055 |
| 2104 #undef __ | 2056 #undef __ |
| OLD | NEW |