Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(585)

Side by Side Diff: src/arm/builtins-arm.cc

Issue 1458103003: Make arguments adaptor not clobber new.target. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@local_turbofan-pass-new-target-1
Patch Set: Ported to more architectures. Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | src/arm64/builtins-arm64.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #if V8_TARGET_ARCH_ARM 5 #if V8_TARGET_ARCH_ARM
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 1407 matching lines...) Expand 10 before | Expand all | Expand 10 after
1418 Generate_ConstructHelper(masm); 1418 Generate_ConstructHelper(masm);
1419 } 1419 }
1420 1420
1421 1421
1422 static void ArgumentAdaptorStackCheck(MacroAssembler* masm, 1422 static void ArgumentAdaptorStackCheck(MacroAssembler* masm,
1423 Label* stack_overflow) { 1423 Label* stack_overflow) {
1424 // ----------- S t a t e ------------- 1424 // ----------- S t a t e -------------
1425 // -- r0 : actual number of arguments 1425 // -- r0 : actual number of arguments
1426 // -- r1 : function (passed through to callee) 1426 // -- r1 : function (passed through to callee)
1427 // -- r2 : expected number of arguments 1427 // -- r2 : expected number of arguments
1428 // -- r3 : new target (passed through to callee)
1428 // ----------------------------------- 1429 // -----------------------------------
1429 // Check the stack for overflow. We are not trying to catch 1430 // Check the stack for overflow. We are not trying to catch
1430 // interruptions (e.g. debug break and preemption) here, so the "real stack 1431 // interruptions (e.g. debug break and preemption) here, so the "real stack
1431 // limit" is checked. 1432 // limit" is checked.
1432 __ LoadRoot(r5, Heap::kRealStackLimitRootIndex); 1433 __ LoadRoot(r5, Heap::kRealStackLimitRootIndex);
1433 // Make r5 the space we have left. The stack might already be overflowed 1434 // Make r5 the space we have left. The stack might already be overflowed
1434 // here which will cause r5 to become negative. 1435 // here which will cause r5 to become negative.
1435 __ sub(r5, sp, r5); 1436 __ sub(r5, sp, r5);
1436 // Check if the arguments will overflow the stack. 1437 // Check if the arguments will overflow the stack.
1437 __ cmp(r5, Operand(r2, LSL, kPointerSizeLog2)); 1438 __ cmp(r5, Operand(r2, LSL, kPointerSizeLog2));
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after
1698 __ CallRuntime(Runtime::kThrowCalledNonCallable, 1); 1699 __ CallRuntime(Runtime::kThrowCalledNonCallable, 1);
1699 } 1700 }
1700 } 1701 }
1701 1702
1702 1703
1703 void Builtins::Generate_ArgumentsAdaptorTrampoline(MacroAssembler* masm) { 1704 void Builtins::Generate_ArgumentsAdaptorTrampoline(MacroAssembler* masm) {
1704 // ----------- S t a t e ------------- 1705 // ----------- S t a t e -------------
1705 // -- r0 : actual number of arguments 1706 // -- r0 : actual number of arguments
1706 // -- r1 : function (passed through to callee) 1707 // -- r1 : function (passed through to callee)
1707 // -- r2 : expected number of arguments 1708 // -- r2 : expected number of arguments
1709 // -- r3 : new target (passed through to callee)
1708 // ----------------------------------- 1710 // -----------------------------------
1709 1711
1710 Label stack_overflow; 1712 Label invoke, dont_adapt_arguments, stack_overflow;
1711 ArgumentAdaptorStackCheck(masm, &stack_overflow);
1712 Label invoke, dont_adapt_arguments;
1713 1713
1714 Label enough, too_few; 1714 Label enough, too_few;
1715 __ ldr(r3, FieldMemOperand(r1, JSFunction::kCodeEntryOffset));
1716 __ cmp(r0, r2); 1715 __ cmp(r0, r2);
1717 __ b(lt, &too_few); 1716 __ b(lt, &too_few);
1718 __ cmp(r2, Operand(SharedFunctionInfo::kDontAdaptArgumentsSentinel)); 1717 __ cmp(r2, Operand(SharedFunctionInfo::kDontAdaptArgumentsSentinel));
1719 __ b(eq, &dont_adapt_arguments); 1718 __ b(eq, &dont_adapt_arguments);
1720 1719
1721 { // Enough parameters: actual >= expected 1720 { // Enough parameters: actual >= expected
1722 __ bind(&enough); 1721 __ bind(&enough);
1723 EnterArgumentsAdaptorFrame(masm); 1722 EnterArgumentsAdaptorFrame(masm);
1723 ArgumentAdaptorStackCheck(masm, &stack_overflow);
1724 1724
1725 // Calculate copy start address into r0 and copy end address into r4. 1725 // Calculate copy start address into r0 and copy end address into r4.
1726 // r0: actual number of arguments as a smi 1726 // r0: actual number of arguments as a smi
1727 // r1: function 1727 // r1: function
1728 // r2: expected number of arguments 1728 // r2: expected number of arguments
1729 // r3: code entry to call 1729 // r3: new target (passed through to callee)
1730 __ add(r0, fp, Operand::PointerOffsetFromSmiKey(r0)); 1730 __ add(r0, fp, Operand::PointerOffsetFromSmiKey(r0));
1731 // adjust for return address and receiver 1731 // adjust for return address and receiver
1732 __ add(r0, r0, Operand(2 * kPointerSize)); 1732 __ add(r0, r0, Operand(2 * kPointerSize));
1733 __ sub(r4, r0, Operand(r2, LSL, kPointerSizeLog2)); 1733 __ sub(r4, r0, Operand(r2, LSL, kPointerSizeLog2));
1734 1734
1735 // Copy the arguments (including the receiver) to the new stack frame. 1735 // Copy the arguments (including the receiver) to the new stack frame.
1736 // r0: copy start address 1736 // r0: copy start address
1737 // r1: function 1737 // r1: function
1738 // r2: expected number of arguments 1738 // r2: expected number of arguments
1739 // r3: code entry to call 1739 // r3: new target (passed through to callee)
1740 // r4: copy end address 1740 // r4: copy end address
1741 1741
1742 Label copy; 1742 Label copy;
1743 __ bind(&copy); 1743 __ bind(&copy);
1744 __ ldr(ip, MemOperand(r0, 0)); 1744 __ ldr(ip, MemOperand(r0, 0));
1745 __ push(ip); 1745 __ push(ip);
1746 __ cmp(r0, r4); // Compare before moving to next argument. 1746 __ cmp(r0, r4); // Compare before moving to next argument.
1747 __ sub(r0, r0, Operand(kPointerSize)); 1747 __ sub(r0, r0, Operand(kPointerSize));
1748 __ b(ne, &copy); 1748 __ b(ne, &copy);
1749 1749
(...skipping 17 matching lines...) Expand all
1767 __ b(ge, &no_strong_error); 1767 __ b(ge, &no_strong_error);
1768 1768
1769 { 1769 {
1770 FrameScope frame(masm, StackFrame::MANUAL); 1770 FrameScope frame(masm, StackFrame::MANUAL);
1771 EnterArgumentsAdaptorFrame(masm); 1771 EnterArgumentsAdaptorFrame(masm);
1772 __ CallRuntime(Runtime::kThrowStrongModeTooFewArguments, 0); 1772 __ CallRuntime(Runtime::kThrowStrongModeTooFewArguments, 0);
1773 } 1773 }
1774 1774
1775 __ bind(&no_strong_error); 1775 __ bind(&no_strong_error);
1776 EnterArgumentsAdaptorFrame(masm); 1776 EnterArgumentsAdaptorFrame(masm);
1777 ArgumentAdaptorStackCheck(masm, &stack_overflow);
1777 1778
1778 // Calculate copy start address into r0 and copy end address is fp. 1779 // Calculate copy start address into r0 and copy end address is fp.
1779 // r0: actual number of arguments as a smi 1780 // r0: actual number of arguments as a smi
1780 // r1: function 1781 // r1: function
1781 // r2: expected number of arguments 1782 // r2: expected number of arguments
1782 // r3: code entry to call 1783 // r3: new target (passed through to callee)
1783 __ add(r0, fp, Operand::PointerOffsetFromSmiKey(r0)); 1784 __ add(r0, fp, Operand::PointerOffsetFromSmiKey(r0));
1784 1785
1785 // Copy the arguments (including the receiver) to the new stack frame. 1786 // Copy the arguments (including the receiver) to the new stack frame.
1786 // r0: copy start address 1787 // r0: copy start address
1787 // r1: function 1788 // r1: function
1788 // r2: expected number of arguments 1789 // r2: expected number of arguments
1789 // r3: code entry to call 1790 // r3: new target (passed through to callee)
1790 Label copy; 1791 Label copy;
1791 __ bind(&copy); 1792 __ bind(&copy);
1792 // Adjust load for return address and receiver. 1793 // Adjust load for return address and receiver.
1793 __ ldr(ip, MemOperand(r0, 2 * kPointerSize)); 1794 __ ldr(ip, MemOperand(r0, 2 * kPointerSize));
1794 __ push(ip); 1795 __ push(ip);
1795 __ cmp(r0, fp); // Compare before moving to next argument. 1796 __ cmp(r0, fp); // Compare before moving to next argument.
1796 __ sub(r0, r0, Operand(kPointerSize)); 1797 __ sub(r0, r0, Operand(kPointerSize));
1797 __ b(ne, &copy); 1798 __ b(ne, &copy);
1798 1799
1799 // Fill the remaining expected arguments with undefined. 1800 // Fill the remaining expected arguments with undefined.
1800 // r1: function 1801 // r1: function
1801 // r2: expected number of arguments 1802 // r2: expected number of arguments
1802 // r3: code entry to call 1803 // r3: new target (passed through to callee)
1803 __ LoadRoot(ip, Heap::kUndefinedValueRootIndex); 1804 __ LoadRoot(ip, Heap::kUndefinedValueRootIndex);
1804 __ sub(r4, fp, Operand(r2, LSL, kPointerSizeLog2)); 1805 __ sub(r4, fp, Operand(r2, LSL, kPointerSizeLog2));
1805 // Adjust for frame. 1806 // Adjust for frame.
1806 __ sub(r4, r4, Operand(StandardFrameConstants::kFixedFrameSizeFromFp + 1807 __ sub(r4, r4, Operand(StandardFrameConstants::kFixedFrameSizeFromFp +
1807 2 * kPointerSize)); 1808 2 * kPointerSize));
1808 1809
1809 Label fill; 1810 Label fill;
1810 __ bind(&fill); 1811 __ bind(&fill);
1811 __ push(ip); 1812 __ push(ip);
1812 __ cmp(sp, r4); 1813 __ cmp(sp, r4);
1813 __ b(ne, &fill); 1814 __ b(ne, &fill);
1814 } 1815 }
1815 1816
1816 // Call the entry point. 1817 // Call the entry point.
1817 __ bind(&invoke); 1818 __ bind(&invoke);
1818 __ mov(r0, r2); 1819 __ mov(r0, r2);
1819 // r0 : expected number of arguments 1820 // r0 : expected number of arguments
1820 // r1 : function (passed through to callee) 1821 // r1 : function (passed through to callee)
1821 __ Call(r3); 1822 // r3 : new target (passed through to callee)
1823 __ ldr(r4, FieldMemOperand(r1, JSFunction::kCodeEntryOffset));
1824 __ Call(r4);
1822 1825
1823 // Store offset of return address for deoptimizer. 1826 // Store offset of return address for deoptimizer.
1824 masm->isolate()->heap()->SetArgumentsAdaptorDeoptPCOffset(masm->pc_offset()); 1827 masm->isolate()->heap()->SetArgumentsAdaptorDeoptPCOffset(masm->pc_offset());
1825 1828
1826 // Exit frame and return. 1829 // Exit frame and return.
1827 LeaveArgumentsAdaptorFrame(masm); 1830 LeaveArgumentsAdaptorFrame(masm);
1828 __ Jump(lr); 1831 __ Jump(lr);
1829 1832
1830 1833
1831 // ------------------------------------------- 1834 // -------------------------------------------
1832 // Dont adapt arguments. 1835 // Dont adapt arguments.
1833 // ------------------------------------------- 1836 // -------------------------------------------
1834 __ bind(&dont_adapt_arguments); 1837 __ bind(&dont_adapt_arguments);
1835 __ Jump(r3); 1838 __ ldr(r4, FieldMemOperand(r1, JSFunction::kCodeEntryOffset));
1839 __ Jump(r4);
1836 1840
1837 __ bind(&stack_overflow); 1841 __ bind(&stack_overflow);
1838 { 1842 {
1839 FrameScope frame(masm, StackFrame::MANUAL); 1843 FrameScope frame(masm, StackFrame::MANUAL);
1840 EnterArgumentsAdaptorFrame(masm);
1841 __ CallRuntime(Runtime::kThrowStackOverflow, 0); 1844 __ CallRuntime(Runtime::kThrowStackOverflow, 0);
1842 __ bkpt(0); 1845 __ bkpt(0);
1843 } 1846 }
1844 } 1847 }
1845 1848
1846 1849
1847 #undef __ 1850 #undef __
1848 1851
1849 } // namespace internal 1852 } // namespace internal
1850 } // namespace v8 1853 } // namespace v8
1851 1854
1852 #endif // V8_TARGET_ARCH_ARM 1855 #endif // V8_TARGET_ARCH_ARM
OLDNEW
« no previous file with comments | « no previous file | src/arm64/builtins-arm64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698