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 #if V8_TARGET_ARCH_X64 | 5 #if V8_TARGET_ARCH_X64 |
6 | 6 |
7 #include "src/code-factory.h" | 7 #include "src/code-factory.h" |
8 #include "src/codegen.h" | 8 #include "src/codegen.h" |
9 #include "src/counters.h" | 9 #include "src/counters.h" |
10 #include "src/deoptimizer.h" | 10 #include "src/deoptimizer.h" |
(...skipping 1651 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1662 __ PushReturnAddressFrom(rcx); | 1662 __ PushReturnAddressFrom(rcx); |
1663 } | 1663 } |
1664 | 1664 |
1665 // ----------- S t a t e ------------- | 1665 // ----------- S t a t e ------------- |
1666 // -- rbx : argArray | 1666 // -- rbx : argArray |
1667 // -- rdi : receiver | 1667 // -- rdi : receiver |
1668 // -- rsp[0] : return address | 1668 // -- rsp[0] : return address |
1669 // -- rsp[8] : thisArg | 1669 // -- rsp[8] : thisArg |
1670 // ----------------------------------- | 1670 // ----------------------------------- |
1671 | 1671 |
1672 // 2. Make sure the receiver is actually callable. | 1672 // 2. We don't need to check explicitly for callable receiver here, |
1673 Label receiver_not_callable; | 1673 // since that's the first thing the Call/CallWithArrayLike builtins |
1674 __ JumpIfSmi(rdi, &receiver_not_callable, Label::kNear); | 1674 // will do. |
1675 __ movp(rcx, FieldOperand(rdi, HeapObject::kMapOffset)); | |
1676 __ testb(FieldOperand(rcx, Map::kBitFieldOffset), | |
1677 Immediate(1 << Map::kIsCallable)); | |
1678 __ j(zero, &receiver_not_callable, Label::kNear); | |
1679 | 1675 |
1680 // 3. Tail call with no arguments if argArray is null or undefined. | 1676 // 3. Tail call with no arguments if argArray is null or undefined. |
1681 Label no_arguments; | 1677 Label no_arguments; |
1682 __ JumpIfRoot(rbx, Heap::kNullValueRootIndex, &no_arguments, Label::kNear); | 1678 __ JumpIfRoot(rbx, Heap::kNullValueRootIndex, &no_arguments, Label::kNear); |
1683 __ JumpIfRoot(rbx, Heap::kUndefinedValueRootIndex, &no_arguments, | 1679 __ JumpIfRoot(rbx, Heap::kUndefinedValueRootIndex, &no_arguments, |
1684 Label::kNear); | 1680 Label::kNear); |
1685 | 1681 |
1686 // 4a. Apply the receiver to the given argArray. | 1682 // 4a. Apply the receiver to the given argArray. |
1687 __ Jump(masm->isolate()->builtins()->CallWithArrayLike(), | 1683 __ Jump(masm->isolate()->builtins()->CallWithArrayLike(), |
1688 RelocInfo::CODE_TARGET); | 1684 RelocInfo::CODE_TARGET); |
1689 | 1685 |
1690 // 4b. The argArray is either null or undefined, so we tail call without any | 1686 // 4b. The argArray is either null or undefined, so we tail call without any |
1691 // arguments to the receiver. Since we did not create a frame for | 1687 // arguments to the receiver. Since we did not create a frame for |
1692 // Function.prototype.apply() yet, we use a normal Call builtin here. | 1688 // Function.prototype.apply() yet, we use a normal Call builtin here. |
1693 __ bind(&no_arguments); | 1689 __ bind(&no_arguments); |
1694 { | 1690 { |
1695 __ Set(rax, 0); | 1691 __ Set(rax, 0); |
1696 __ Jump(masm->isolate()->builtins()->Call(), RelocInfo::CODE_TARGET); | 1692 __ Jump(masm->isolate()->builtins()->Call(), RelocInfo::CODE_TARGET); |
1697 } | 1693 } |
1698 | |
1699 // 4c. The receiver is not callable, throw an appropriate TypeError. | |
1700 __ bind(&receiver_not_callable); | |
1701 { | |
1702 StackArgumentsAccessor args(rsp, 0); | |
1703 __ movp(args.GetReceiverOperand(), rdi); | |
1704 __ TailCallRuntime(Runtime::kThrowApplyNonFunction); | |
1705 } | |
1706 } | 1694 } |
1707 | 1695 |
1708 // static | 1696 // static |
1709 void Builtins::Generate_FunctionPrototypeCall(MacroAssembler* masm) { | 1697 void Builtins::Generate_FunctionPrototypeCall(MacroAssembler* masm) { |
1710 // Stack Layout: | 1698 // Stack Layout: |
1711 // rsp[0] : Return address | 1699 // rsp[0] : Return address |
1712 // rsp[8] : Argument n | 1700 // rsp[8] : Argument n |
1713 // rsp[16] : Argument n-1 | 1701 // rsp[16] : Argument n-1 |
1714 // ... | 1702 // ... |
1715 // rsp[8 * n] : Argument 1 | 1703 // rsp[8 * n] : Argument 1 |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1791 __ PushReturnAddressFrom(rcx); | 1779 __ PushReturnAddressFrom(rcx); |
1792 } | 1780 } |
1793 | 1781 |
1794 // ----------- S t a t e ------------- | 1782 // ----------- S t a t e ------------- |
1795 // -- rbx : argumentsList | 1783 // -- rbx : argumentsList |
1796 // -- rdi : target | 1784 // -- rdi : target |
1797 // -- rsp[0] : return address | 1785 // -- rsp[0] : return address |
1798 // -- rsp[8] : thisArgument | 1786 // -- rsp[8] : thisArgument |
1799 // ----------------------------------- | 1787 // ----------------------------------- |
1800 | 1788 |
1801 // 2. Make sure the target is actually callable. | 1789 // 2. We don't need to check explicitly for callable target here, |
1802 Label target_not_callable; | 1790 // since that's the first thing the Call/CallWithArrayLike builtins |
1803 __ JumpIfSmi(rdi, &target_not_callable, Label::kNear); | 1791 // will do. |
1804 __ movp(rcx, FieldOperand(rdi, HeapObject::kMapOffset)); | |
1805 __ testb(FieldOperand(rcx, Map::kBitFieldOffset), | |
1806 Immediate(1 << Map::kIsCallable)); | |
1807 __ j(zero, &target_not_callable, Label::kNear); | |
1808 | 1792 |
1809 // 3a. Apply the target to the given argumentsList. | 1793 // 3. Apply the target to the given argumentsList. |
1810 __ Jump(masm->isolate()->builtins()->CallWithArrayLike(), | 1794 __ Jump(masm->isolate()->builtins()->CallWithArrayLike(), |
1811 RelocInfo::CODE_TARGET); | 1795 RelocInfo::CODE_TARGET); |
1812 | |
1813 // 3b. The target is not callable, throw an appropriate TypeError. | |
1814 __ bind(&target_not_callable); | |
1815 { | |
1816 StackArgumentsAccessor args(rsp, 0); | |
1817 __ movp(args.GetReceiverOperand(), rdi); | |
1818 __ TailCallRuntime(Runtime::kThrowApplyNonFunction); | |
1819 } | |
1820 } | 1796 } |
1821 | 1797 |
1822 void Builtins::Generate_ReflectConstruct(MacroAssembler* masm) { | 1798 void Builtins::Generate_ReflectConstruct(MacroAssembler* masm) { |
1823 // ----------- S t a t e ------------- | 1799 // ----------- S t a t e ------------- |
1824 // -- rax : argc | 1800 // -- rax : argc |
1825 // -- rsp[0] : return address | 1801 // -- rsp[0] : return address |
1826 // -- rsp[8] : new.target (optional) | 1802 // -- rsp[8] : new.target (optional) |
1827 // -- rsp[16] : argumentsList | 1803 // -- rsp[16] : argumentsList |
1828 // -- rsp[24] : target | 1804 // -- rsp[24] : target |
1829 // -- rsp[32] : receiver | 1805 // -- rsp[32] : receiver |
(...skipping 1309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3139 // Now jump to the instructions of the returned code object. | 3115 // Now jump to the instructions of the returned code object. |
3140 __ jmp(r11); | 3116 __ jmp(r11); |
3141 } | 3117 } |
3142 | 3118 |
3143 #undef __ | 3119 #undef __ |
3144 | 3120 |
3145 } // namespace internal | 3121 } // namespace internal |
3146 } // namespace v8 | 3122 } // namespace v8 |
3147 | 3123 |
3148 #endif // V8_TARGET_ARCH_X64 | 3124 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |