OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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 #if V8_TARGET_ARCH_PPC | 5 #if V8_TARGET_ARCH_PPC |
6 | 6 |
7 #include "src/codegen.h" | 7 #include "src/codegen.h" |
8 #include "src/debug/debug.h" | 8 #include "src/debug/debug.h" |
9 #include "src/deoptimizer.h" | 9 #include "src/deoptimizer.h" |
10 #include "src/full-codegen/full-codegen.h" | 10 #include "src/full-codegen/full-codegen.h" |
(...skipping 1410 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1421 Generate_ConstructHelper(masm); | 1421 Generate_ConstructHelper(masm); |
1422 } | 1422 } |
1423 | 1423 |
1424 | 1424 |
1425 static void ArgumentAdaptorStackCheck(MacroAssembler* masm, | 1425 static void ArgumentAdaptorStackCheck(MacroAssembler* masm, |
1426 Label* stack_overflow) { | 1426 Label* stack_overflow) { |
1427 // ----------- S t a t e ------------- | 1427 // ----------- S t a t e ------------- |
1428 // -- r3 : actual number of arguments | 1428 // -- r3 : actual number of arguments |
1429 // -- r4 : function (passed through to callee) | 1429 // -- r4 : function (passed through to callee) |
1430 // -- r5 : expected number of arguments | 1430 // -- r5 : expected number of arguments |
| 1431 // -- r6 : new target (passed through to callee) |
1431 // ----------------------------------- | 1432 // ----------------------------------- |
1432 // Check the stack for overflow. We are not trying to catch | 1433 // Check the stack for overflow. We are not trying to catch |
1433 // interruptions (e.g. debug break and preemption) here, so the "real stack | 1434 // interruptions (e.g. debug break and preemption) here, so the "real stack |
1434 // limit" is checked. | 1435 // limit" is checked. |
1435 __ LoadRoot(r8, Heap::kRealStackLimitRootIndex); | 1436 __ LoadRoot(r8, Heap::kRealStackLimitRootIndex); |
1436 // Make r8 the space we have left. The stack might already be overflowed | 1437 // Make r8 the space we have left. The stack might already be overflowed |
1437 // here which will cause r8 to become negative. | 1438 // here which will cause r8 to become negative. |
1438 __ sub(r8, sp, r8); | 1439 __ sub(r8, sp, r8); |
1439 // Check if the arguments will overflow the stack. | 1440 // Check if the arguments will overflow the stack. |
1440 __ ShiftLeftImm(r0, r5, Operand(kPointerSizeLog2)); | 1441 __ ShiftLeftImm(r0, r5, Operand(kPointerSizeLog2)); |
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1710 __ CallRuntime(Runtime::kThrowCalledNonCallable, 1); | 1711 __ CallRuntime(Runtime::kThrowCalledNonCallable, 1); |
1711 } | 1712 } |
1712 } | 1713 } |
1713 | 1714 |
1714 | 1715 |
1715 void Builtins::Generate_ArgumentsAdaptorTrampoline(MacroAssembler* masm) { | 1716 void Builtins::Generate_ArgumentsAdaptorTrampoline(MacroAssembler* masm) { |
1716 // ----------- S t a t e ------------- | 1717 // ----------- S t a t e ------------- |
1717 // -- r3 : actual number of arguments | 1718 // -- r3 : actual number of arguments |
1718 // -- r4 : function (passed through to callee) | 1719 // -- r4 : function (passed through to callee) |
1719 // -- r5 : expected number of arguments | 1720 // -- r5 : expected number of arguments |
| 1721 // -- r6 : new target (passed through to callee) |
1720 // ----------------------------------- | 1722 // ----------------------------------- |
1721 | 1723 |
1722 Label stack_overflow; | 1724 Label invoke, dont_adapt_arguments, stack_overflow; |
1723 ArgumentAdaptorStackCheck(masm, &stack_overflow); | |
1724 Label invoke, dont_adapt_arguments; | |
1725 | 1725 |
1726 Label enough, too_few; | 1726 Label enough, too_few; |
1727 __ LoadP(ip, FieldMemOperand(r4, JSFunction::kCodeEntryOffset)); | 1727 __ LoadP(ip, FieldMemOperand(r4, JSFunction::kCodeEntryOffset)); |
1728 __ cmp(r3, r5); | 1728 __ cmp(r3, r5); |
1729 __ blt(&too_few); | 1729 __ blt(&too_few); |
1730 __ cmpi(r5, Operand(SharedFunctionInfo::kDontAdaptArgumentsSentinel)); | 1730 __ cmpi(r5, Operand(SharedFunctionInfo::kDontAdaptArgumentsSentinel)); |
1731 __ beq(&dont_adapt_arguments); | 1731 __ beq(&dont_adapt_arguments); |
1732 | 1732 |
1733 { // Enough parameters: actual >= expected | 1733 { // Enough parameters: actual >= expected |
1734 __ bind(&enough); | 1734 __ bind(&enough); |
1735 EnterArgumentsAdaptorFrame(masm); | 1735 EnterArgumentsAdaptorFrame(masm); |
| 1736 ArgumentAdaptorStackCheck(masm, &stack_overflow); |
1736 | 1737 |
1737 // Calculate copy start address into r3 and copy end address into r6. | 1738 // Calculate copy start address into r3 and copy end address into r7. |
1738 // r3: actual number of arguments as a smi | 1739 // r3: actual number of arguments as a smi |
1739 // r4: function | 1740 // r4: function |
1740 // r5: expected number of arguments | 1741 // r5: expected number of arguments |
| 1742 // r6: new target (passed through to callee) |
1741 // ip: code entry to call | 1743 // ip: code entry to call |
1742 __ SmiToPtrArrayOffset(r3, r3); | 1744 __ SmiToPtrArrayOffset(r3, r3); |
1743 __ add(r3, r3, fp); | 1745 __ add(r3, r3, fp); |
1744 // adjust for return address and receiver | 1746 // adjust for return address and receiver |
1745 __ addi(r3, r3, Operand(2 * kPointerSize)); | 1747 __ addi(r3, r3, Operand(2 * kPointerSize)); |
1746 __ ShiftLeftImm(r6, r5, Operand(kPointerSizeLog2)); | 1748 __ ShiftLeftImm(r7, r5, Operand(kPointerSizeLog2)); |
1747 __ sub(r6, r3, r6); | 1749 __ sub(r7, r3, r7); |
1748 | 1750 |
1749 // Copy the arguments (including the receiver) to the new stack frame. | 1751 // Copy the arguments (including the receiver) to the new stack frame. |
1750 // r3: copy start address | 1752 // r3: copy start address |
1751 // r4: function | 1753 // r4: function |
1752 // r5: expected number of arguments | 1754 // r5: expected number of arguments |
1753 // r6: copy end address | 1755 // r6: new target (passed through to callee) |
| 1756 // r7: copy end address |
1754 // ip: code entry to call | 1757 // ip: code entry to call |
1755 | 1758 |
1756 Label copy; | 1759 Label copy; |
1757 __ bind(©); | 1760 __ bind(©); |
1758 __ LoadP(r0, MemOperand(r3, 0)); | 1761 __ LoadP(r0, MemOperand(r3, 0)); |
1759 __ push(r0); | 1762 __ push(r0); |
1760 __ cmp(r3, r6); // Compare before moving to next argument. | 1763 __ cmp(r3, r7); // Compare before moving to next argument. |
1761 __ subi(r3, r3, Operand(kPointerSize)); | 1764 __ subi(r3, r3, Operand(kPointerSize)); |
1762 __ bne(©); | 1765 __ bne(©); |
1763 | 1766 |
1764 __ b(&invoke); | 1767 __ b(&invoke); |
1765 } | 1768 } |
1766 | 1769 |
1767 { // Too few parameters: Actual < expected | 1770 { // Too few parameters: Actual < expected |
1768 __ bind(&too_few); | 1771 __ bind(&too_few); |
1769 | 1772 |
1770 // If the function is strong we need to throw an error. | 1773 // If the function is strong we need to throw an error. |
(...skipping 15 matching lines...) Expand all Loading... |
1786 __ bge(&no_strong_error); | 1789 __ bge(&no_strong_error); |
1787 | 1790 |
1788 { | 1791 { |
1789 FrameScope frame(masm, StackFrame::MANUAL); | 1792 FrameScope frame(masm, StackFrame::MANUAL); |
1790 EnterArgumentsAdaptorFrame(masm); | 1793 EnterArgumentsAdaptorFrame(masm); |
1791 __ CallRuntime(Runtime::kThrowStrongModeTooFewArguments, 0); | 1794 __ CallRuntime(Runtime::kThrowStrongModeTooFewArguments, 0); |
1792 } | 1795 } |
1793 | 1796 |
1794 __ bind(&no_strong_error); | 1797 __ bind(&no_strong_error); |
1795 EnterArgumentsAdaptorFrame(masm); | 1798 EnterArgumentsAdaptorFrame(masm); |
| 1799 ArgumentAdaptorStackCheck(masm, &stack_overflow); |
1796 | 1800 |
1797 // Calculate copy start address into r0 and copy end address is fp. | 1801 // Calculate copy start address into r0 and copy end address is fp. |
1798 // r3: actual number of arguments as a smi | 1802 // r3: actual number of arguments as a smi |
1799 // r4: function | 1803 // r4: function |
1800 // r5: expected number of arguments | 1804 // r5: expected number of arguments |
| 1805 // r6: new target (passed through to callee) |
1801 // ip: code entry to call | 1806 // ip: code entry to call |
1802 __ SmiToPtrArrayOffset(r3, r3); | 1807 __ SmiToPtrArrayOffset(r3, r3); |
1803 __ add(r3, r3, fp); | 1808 __ add(r3, r3, fp); |
1804 | 1809 |
1805 // Copy the arguments (including the receiver) to the new stack frame. | 1810 // Copy the arguments (including the receiver) to the new stack frame. |
1806 // r3: copy start address | 1811 // r3: copy start address |
1807 // r4: function | 1812 // r4: function |
1808 // r5: expected number of arguments | 1813 // r5: expected number of arguments |
| 1814 // r6: new target (passed through to callee) |
1809 // ip: code entry to call | 1815 // ip: code entry to call |
1810 Label copy; | 1816 Label copy; |
1811 __ bind(©); | 1817 __ bind(©); |
1812 // Adjust load for return address and receiver. | 1818 // Adjust load for return address and receiver. |
1813 __ LoadP(r0, MemOperand(r3, 2 * kPointerSize)); | 1819 __ LoadP(r0, MemOperand(r3, 2 * kPointerSize)); |
1814 __ push(r0); | 1820 __ push(r0); |
1815 __ cmp(r3, fp); // Compare before moving to next argument. | 1821 __ cmp(r3, fp); // Compare before moving to next argument. |
1816 __ subi(r3, r3, Operand(kPointerSize)); | 1822 __ subi(r3, r3, Operand(kPointerSize)); |
1817 __ bne(©); | 1823 __ bne(©); |
1818 | 1824 |
1819 // Fill the remaining expected arguments with undefined. | 1825 // Fill the remaining expected arguments with undefined. |
1820 // r4: function | 1826 // r4: function |
1821 // r5: expected number of arguments | 1827 // r5: expected number of arguments |
| 1828 // r6: new target (passed through to callee) |
1822 // ip: code entry to call | 1829 // ip: code entry to call |
1823 __ LoadRoot(r0, Heap::kUndefinedValueRootIndex); | 1830 __ LoadRoot(r0, Heap::kUndefinedValueRootIndex); |
1824 __ ShiftLeftImm(r6, r5, Operand(kPointerSizeLog2)); | 1831 __ ShiftLeftImm(r7, r5, Operand(kPointerSizeLog2)); |
1825 __ sub(r6, fp, r6); | 1832 __ sub(r7, fp, r7); |
1826 // Adjust for frame. | 1833 // Adjust for frame. |
1827 __ subi(r6, r6, Operand(StandardFrameConstants::kFixedFrameSizeFromFp + | 1834 __ subi(r7, r7, Operand(StandardFrameConstants::kFixedFrameSizeFromFp + |
1828 2 * kPointerSize)); | 1835 2 * kPointerSize)); |
1829 | 1836 |
1830 Label fill; | 1837 Label fill; |
1831 __ bind(&fill); | 1838 __ bind(&fill); |
1832 __ push(r0); | 1839 __ push(r0); |
1833 __ cmp(sp, r6); | 1840 __ cmp(sp, r7); |
1834 __ bne(&fill); | 1841 __ bne(&fill); |
1835 } | 1842 } |
1836 | 1843 |
1837 // Call the entry point. | 1844 // Call the entry point. |
1838 __ bind(&invoke); | 1845 __ bind(&invoke); |
1839 __ mr(r3, r5); | 1846 __ mr(r3, r5); |
1840 // r3 : expected number of arguments | 1847 // r3 : expected number of arguments |
1841 // r4 : function (passed through to callee) | 1848 // r4 : function (passed through to callee) |
| 1849 // r6 : new target (passed through to callee) |
1842 __ CallJSEntry(ip); | 1850 __ CallJSEntry(ip); |
1843 | 1851 |
1844 // Store offset of return address for deoptimizer. | 1852 // Store offset of return address for deoptimizer. |
1845 masm->isolate()->heap()->SetArgumentsAdaptorDeoptPCOffset(masm->pc_offset()); | 1853 masm->isolate()->heap()->SetArgumentsAdaptorDeoptPCOffset(masm->pc_offset()); |
1846 | 1854 |
1847 // Exit frame and return. | 1855 // Exit frame and return. |
1848 LeaveArgumentsAdaptorFrame(masm); | 1856 LeaveArgumentsAdaptorFrame(masm); |
1849 __ blr(); | 1857 __ blr(); |
1850 | 1858 |
1851 | 1859 |
1852 // ------------------------------------------- | 1860 // ------------------------------------------- |
1853 // Dont adapt arguments. | 1861 // Dont adapt arguments. |
1854 // ------------------------------------------- | 1862 // ------------------------------------------- |
1855 __ bind(&dont_adapt_arguments); | 1863 __ bind(&dont_adapt_arguments); |
1856 __ JumpToJSEntry(ip); | 1864 __ JumpToJSEntry(ip); |
1857 | 1865 |
1858 __ bind(&stack_overflow); | 1866 __ bind(&stack_overflow); |
1859 { | 1867 { |
1860 FrameScope frame(masm, StackFrame::MANUAL); | 1868 FrameScope frame(masm, StackFrame::MANUAL); |
1861 EnterArgumentsAdaptorFrame(masm); | |
1862 __ CallRuntime(Runtime::kThrowStackOverflow, 0); | 1869 __ CallRuntime(Runtime::kThrowStackOverflow, 0); |
1863 __ bkpt(0); | 1870 __ bkpt(0); |
1864 } | 1871 } |
1865 } | 1872 } |
1866 | 1873 |
1867 | 1874 |
1868 #undef __ | 1875 #undef __ |
1869 } // namespace internal | 1876 } // namespace internal |
1870 } // namespace v8 | 1877 } // namespace v8 |
1871 | 1878 |
1872 #endif // V8_TARGET_ARCH_PPC | 1879 #endif // V8_TARGET_ARCH_PPC |
OLD | NEW |