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/deoptimizer.h" | 9 #include "src/deoptimizer.h" |
10 #include "src/full-codegen/full-codegen.h" | 10 #include "src/full-codegen/full-codegen.h" |
(...skipping 1724 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1735 // -- rdi : the target to call (can be any Object) | 1735 // -- rdi : the target to call (can be any Object) |
1736 // ----------------------------------- | 1736 // ----------------------------------- |
1737 StackArgumentsAccessor args(rsp, rax); | 1737 StackArgumentsAccessor args(rsp, rax); |
1738 | 1738 |
1739 Label non_callable, non_function, non_smi; | 1739 Label non_callable, non_function, non_smi; |
1740 __ JumpIfSmi(rdi, &non_callable); | 1740 __ JumpIfSmi(rdi, &non_callable); |
1741 __ bind(&non_smi); | 1741 __ bind(&non_smi); |
1742 __ CmpObjectType(rdi, JS_FUNCTION_TYPE, rcx); | 1742 __ CmpObjectType(rdi, JS_FUNCTION_TYPE, rcx); |
1743 __ j(equal, masm->isolate()->builtins()->CallFunction(mode), | 1743 __ j(equal, masm->isolate()->builtins()->CallFunction(mode), |
1744 RelocInfo::CODE_TARGET); | 1744 RelocInfo::CODE_TARGET); |
1745 __ CmpInstanceType(rcx, JS_FUNCTION_PROXY_TYPE); | 1745 __ CmpInstanceType(rcx, JS_PROXY_TYPE); |
1746 __ j(not_equal, &non_function); | 1746 __ j(not_equal, &non_function); |
1747 | 1747 |
1748 // 1. Call to function proxy. | 1748 // 1. Call to function proxy. |
1749 // TODO(neis): This doesn't match the ES6 spec for [[Call]] on proxies. | 1749 // TODO(neis): Implement [[Call]] on proxies. |
1750 __ movp(rdi, FieldOperand(rdi, JSFunctionProxy::kCallTrapOffset)); | |
1751 __ AssertNotSmi(rdi); | |
1752 __ jmp(&non_smi); | |
1753 | 1750 |
1754 // 2. Call to something else, which might have a [[Call]] internal method (if | 1751 // 2. Call to something else, which might have a [[Call]] internal method (if |
1755 // not we raise an exception). | 1752 // not we raise an exception). |
1756 __ bind(&non_function); | 1753 __ bind(&non_function); |
1757 // Check if target has a [[Call]] internal method. | 1754 // Check if target has a [[Call]] internal method. |
1758 __ testb(FieldOperand(rcx, Map::kBitFieldOffset), | 1755 __ testb(FieldOperand(rcx, Map::kBitFieldOffset), |
1759 Immediate(1 << Map::kIsCallable)); | 1756 Immediate(1 << Map::kIsCallable)); |
1760 __ j(zero, &non_callable, Label::kNear); | 1757 __ j(zero, &non_callable, Label::kNear); |
1761 // Overwrite the original receiver with the (original) target. | 1758 // Overwrite the original receiver with the (original) target. |
1762 __ movp(args.GetReceiverOperand(), rdi); | 1759 __ movp(args.GetReceiverOperand(), rdi); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1797 __ jmp(rcx); | 1794 __ jmp(rcx); |
1798 } | 1795 } |
1799 | 1796 |
1800 | 1797 |
1801 // static | 1798 // static |
1802 void Builtins::Generate_ConstructProxy(MacroAssembler* masm) { | 1799 void Builtins::Generate_ConstructProxy(MacroAssembler* masm) { |
1803 // ----------- S t a t e ------------- | 1800 // ----------- S t a t e ------------- |
1804 // -- rax : the number of arguments (not including the receiver) | 1801 // -- rax : the number of arguments (not including the receiver) |
1805 // -- rdx : the new target (either the same as the constructor or | 1802 // -- rdx : the new target (either the same as the constructor or |
1806 // the JSFunction on which new was invoked initially) | 1803 // the JSFunction on which new was invoked initially) |
1807 // -- rdi : the constructor to call (checked to be a JSFunctionProxy) | 1804 // -- rdi : the constructor to call (checked to be a JSProxy) |
1808 // ----------------------------------- | 1805 // ----------------------------------- |
1809 | 1806 |
1810 // TODO(neis): This doesn't match the ES6 spec for [[Construct]] on proxies. | 1807 // TODO(neis): This doesn't match the ES6 spec for [[Construct]] on proxies. |
1811 __ movp(rdi, FieldOperand(rdi, JSFunctionProxy::kConstructTrapOffset)); | |
1812 __ Jump(masm->isolate()->builtins()->Call(), RelocInfo::CODE_TARGET); | 1808 __ Jump(masm->isolate()->builtins()->Call(), RelocInfo::CODE_TARGET); |
1813 } | 1809 } |
1814 | 1810 |
1815 | 1811 |
1816 // static | 1812 // static |
1817 void Builtins::Generate_Construct(MacroAssembler* masm) { | 1813 void Builtins::Generate_Construct(MacroAssembler* masm) { |
1818 // ----------- S t a t e ------------- | 1814 // ----------- S t a t e ------------- |
1819 // -- rax : the number of arguments (not including the receiver) | 1815 // -- rax : the number of arguments (not including the receiver) |
1820 // -- rdx : the new target (either the same as the constructor or | 1816 // -- rdx : the new target (either the same as the constructor or |
1821 // the JSFunction on which new was invoked initially) | 1817 // the JSFunction on which new was invoked initially) |
1822 // -- rdi : the constructor to call (can be any Object) | 1818 // -- rdi : the constructor to call (can be any Object) |
1823 // ----------------------------------- | 1819 // ----------------------------------- |
1824 StackArgumentsAccessor args(rsp, rax); | 1820 StackArgumentsAccessor args(rsp, rax); |
1825 | 1821 |
1826 // Check if target is a Smi. | 1822 // Check if target is a Smi. |
1827 Label non_constructor; | 1823 Label non_constructor; |
1828 __ JumpIfSmi(rdi, &non_constructor, Label::kNear); | 1824 __ JumpIfSmi(rdi, &non_constructor, Label::kNear); |
1829 | 1825 |
1830 // Dispatch based on instance type. | 1826 // Dispatch based on instance type. |
1831 __ CmpObjectType(rdi, JS_FUNCTION_TYPE, rcx); | 1827 __ CmpObjectType(rdi, JS_FUNCTION_TYPE, rcx); |
1832 __ j(equal, masm->isolate()->builtins()->ConstructFunction(), | 1828 __ j(equal, masm->isolate()->builtins()->ConstructFunction(), |
1833 RelocInfo::CODE_TARGET); | 1829 RelocInfo::CODE_TARGET); |
1834 __ CmpInstanceType(rcx, JS_FUNCTION_PROXY_TYPE); | 1830 __ CmpInstanceType(rcx, JS_PROXY_TYPE); |
1835 __ j(equal, masm->isolate()->builtins()->ConstructProxy(), | 1831 __ j(equal, masm->isolate()->builtins()->ConstructProxy(), |
1836 RelocInfo::CODE_TARGET); | 1832 RelocInfo::CODE_TARGET); |
1837 | 1833 |
1838 // Check if target has a [[Construct]] internal method. | 1834 // Check if target has a [[Construct]] internal method. |
1839 __ testb(FieldOperand(rcx, Map::kBitFieldOffset), | 1835 __ testb(FieldOperand(rcx, Map::kBitFieldOffset), |
1840 Immediate(1 << Map::kIsConstructor)); | 1836 Immediate(1 << Map::kIsConstructor)); |
1841 __ j(zero, &non_constructor, Label::kNear); | 1837 __ j(zero, &non_constructor, Label::kNear); |
1842 | 1838 |
1843 // Called Construct on an exotic Object with a [[Construct]] internal method. | 1839 // Called Construct on an exotic Object with a [[Construct]] internal method. |
1844 { | 1840 { |
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2038 __ ret(0); | 2034 __ ret(0); |
2039 } | 2035 } |
2040 | 2036 |
2041 | 2037 |
2042 #undef __ | 2038 #undef __ |
2043 | 2039 |
2044 } // namespace internal | 2040 } // namespace internal |
2045 } // namespace v8 | 2041 } // namespace v8 |
2046 | 2042 |
2047 #endif // V8_TARGET_ARCH_X64 | 2043 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |