| 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_IA32 | 5 #if V8_TARGET_ARCH_IA32 |
| 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/deoptimizer.h" | 9 #include "src/deoptimizer.h" |
| 10 #include "src/full-codegen/full-codegen.h" | 10 #include "src/full-codegen/full-codegen.h" |
| (...skipping 1679 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1690 __ PushReturnAddressFrom(ecx); | 1690 __ PushReturnAddressFrom(ecx); |
| 1691 } | 1691 } |
| 1692 | 1692 |
| 1693 // ----------- S t a t e ------------- | 1693 // ----------- S t a t e ------------- |
| 1694 // -- ebx : argArray | 1694 // -- ebx : argArray |
| 1695 // -- edi : receiver | 1695 // -- edi : receiver |
| 1696 // -- esp[0] : return address | 1696 // -- esp[0] : return address |
| 1697 // -- esp[4] : thisArg | 1697 // -- esp[4] : thisArg |
| 1698 // ----------------------------------- | 1698 // ----------------------------------- |
| 1699 | 1699 |
| 1700 // 2. Make sure the receiver is actually callable. | 1700 // 2. We don't need to check explicitly for callable receiver here, |
| 1701 Label receiver_not_callable; | 1701 // since that's the first thing the Call/CallWithArrayLike builtins |
| 1702 __ JumpIfSmi(edi, &receiver_not_callable, Label::kNear); | 1702 // will do. |
| 1703 __ mov(ecx, FieldOperand(edi, HeapObject::kMapOffset)); | |
| 1704 __ test_b(FieldOperand(ecx, Map::kBitFieldOffset), | |
| 1705 Immediate(1 << Map::kIsCallable)); | |
| 1706 __ j(zero, &receiver_not_callable, Label::kNear); | |
| 1707 | 1703 |
| 1708 // 3. Tail call with no arguments if argArray is null or undefined. | 1704 // 3. Tail call with no arguments if argArray is null or undefined. |
| 1709 Label no_arguments; | 1705 Label no_arguments; |
| 1710 __ JumpIfRoot(ebx, Heap::kNullValueRootIndex, &no_arguments, Label::kNear); | 1706 __ JumpIfRoot(ebx, Heap::kNullValueRootIndex, &no_arguments, Label::kNear); |
| 1711 __ JumpIfRoot(ebx, Heap::kUndefinedValueRootIndex, &no_arguments, | 1707 __ JumpIfRoot(ebx, Heap::kUndefinedValueRootIndex, &no_arguments, |
| 1712 Label::kNear); | 1708 Label::kNear); |
| 1713 | 1709 |
| 1714 // 4a. Apply the receiver to the given argArray. | 1710 // 4a. Apply the receiver to the given argArray. |
| 1715 __ Jump(masm->isolate()->builtins()->CallWithArrayLike(), | 1711 __ Jump(masm->isolate()->builtins()->CallWithArrayLike(), |
| 1716 RelocInfo::CODE_TARGET); | 1712 RelocInfo::CODE_TARGET); |
| 1717 | 1713 |
| 1718 // 4b. The argArray is either null or undefined, so we tail call without any | 1714 // 4b. The argArray is either null or undefined, so we tail call without any |
| 1719 // arguments to the receiver. | 1715 // arguments to the receiver. |
| 1720 __ bind(&no_arguments); | 1716 __ bind(&no_arguments); |
| 1721 { | 1717 { |
| 1722 __ Set(eax, 0); | 1718 __ Set(eax, 0); |
| 1723 __ Jump(masm->isolate()->builtins()->Call(), RelocInfo::CODE_TARGET); | 1719 __ Jump(masm->isolate()->builtins()->Call(), RelocInfo::CODE_TARGET); |
| 1724 } | 1720 } |
| 1725 | |
| 1726 // 4c. The receiver is not callable, throw an appropriate TypeError. | |
| 1727 __ bind(&receiver_not_callable); | |
| 1728 { | |
| 1729 __ mov(Operand(esp, kPointerSize), edi); | |
| 1730 __ TailCallRuntime(Runtime::kThrowApplyNonFunction); | |
| 1731 } | |
| 1732 } | 1721 } |
| 1733 | 1722 |
| 1734 // static | 1723 // static |
| 1735 void Builtins::Generate_FunctionPrototypeCall(MacroAssembler* masm) { | 1724 void Builtins::Generate_FunctionPrototypeCall(MacroAssembler* masm) { |
| 1736 // Stack Layout: | 1725 // Stack Layout: |
| 1737 // esp[0] : Return address | 1726 // esp[0] : Return address |
| 1738 // esp[8] : Argument n | 1727 // esp[8] : Argument n |
| 1739 // esp[16] : Argument n-1 | 1728 // esp[16] : Argument n-1 |
| 1740 // ... | 1729 // ... |
| 1741 // esp[8 * n] : Argument 1 | 1730 // esp[8 * n] : Argument 1 |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1810 __ PushReturnAddressFrom(ecx); | 1799 __ PushReturnAddressFrom(ecx); |
| 1811 } | 1800 } |
| 1812 | 1801 |
| 1813 // ----------- S t a t e ------------- | 1802 // ----------- S t a t e ------------- |
| 1814 // -- ebx : argumentsList | 1803 // -- ebx : argumentsList |
| 1815 // -- edi : target | 1804 // -- edi : target |
| 1816 // -- esp[0] : return address | 1805 // -- esp[0] : return address |
| 1817 // -- esp[4] : thisArgument | 1806 // -- esp[4] : thisArgument |
| 1818 // ----------------------------------- | 1807 // ----------------------------------- |
| 1819 | 1808 |
| 1820 // 2. Make sure the target is actually callable. | 1809 // 2. We don't need to check explicitly for callable target here, |
| 1821 Label target_not_callable; | 1810 // since that's the first thing the Call/CallWithArrayLike builtins |
| 1822 __ JumpIfSmi(edi, &target_not_callable, Label::kNear); | 1811 // will do. |
| 1823 __ mov(ecx, FieldOperand(edi, HeapObject::kMapOffset)); | |
| 1824 __ test_b(FieldOperand(ecx, Map::kBitFieldOffset), | |
| 1825 Immediate(1 << Map::kIsCallable)); | |
| 1826 __ j(zero, &target_not_callable, Label::kNear); | |
| 1827 | 1812 |
| 1828 // 3a. Apply the target to the given argumentsList. | 1813 // 3. Apply the target to the given argumentsList. |
| 1829 __ Jump(masm->isolate()->builtins()->CallWithArrayLike(), | 1814 __ Jump(masm->isolate()->builtins()->CallWithArrayLike(), |
| 1830 RelocInfo::CODE_TARGET); | 1815 RelocInfo::CODE_TARGET); |
| 1831 | |
| 1832 // 3b. The target is not callable, throw an appropriate TypeError. | |
| 1833 __ bind(&target_not_callable); | |
| 1834 { | |
| 1835 __ mov(Operand(esp, kPointerSize), edi); | |
| 1836 __ TailCallRuntime(Runtime::kThrowApplyNonFunction); | |
| 1837 } | |
| 1838 } | 1816 } |
| 1839 | 1817 |
| 1840 void Builtins::Generate_ReflectConstruct(MacroAssembler* masm) { | 1818 void Builtins::Generate_ReflectConstruct(MacroAssembler* masm) { |
| 1841 // ----------- S t a t e ------------- | 1819 // ----------- S t a t e ------------- |
| 1842 // -- eax : argc | 1820 // -- eax : argc |
| 1843 // -- esp[0] : return address | 1821 // -- esp[0] : return address |
| 1844 // -- esp[4] : new.target (optional) | 1822 // -- esp[4] : new.target (optional) |
| 1845 // -- esp[8] : argumentsList | 1823 // -- esp[8] : argumentsList |
| 1846 // -- esp[12] : target | 1824 // -- esp[12] : target |
| 1847 // -- esp[16] : receiver | 1825 // -- esp[16] : receiver |
| (...skipping 1348 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3196 } | 3174 } |
| 3197 // Now jump to the instructions of the returned code object. | 3175 // Now jump to the instructions of the returned code object. |
| 3198 __ jmp(edi); | 3176 __ jmp(edi); |
| 3199 } | 3177 } |
| 3200 | 3178 |
| 3201 #undef __ | 3179 #undef __ |
| 3202 } // namespace internal | 3180 } // namespace internal |
| 3203 } // namespace v8 | 3181 } // namespace v8 |
| 3204 | 3182 |
| 3205 #endif // V8_TARGET_ARCH_IA32 | 3183 #endif // V8_TARGET_ARCH_IA32 |
| OLD | NEW |