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 1157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1168 // Push the constructor function as callee. | 1168 // Push the constructor function as callee. |
1169 __ Push(Operand(rbp, kFunctionOffset)); | 1169 __ Push(Operand(rbp, kFunctionOffset)); |
1170 | 1170 |
1171 // Loop over the arguments array, pushing each value to the stack | 1171 // Loop over the arguments array, pushing each value to the stack |
1172 Generate_PushAppliedArguments(masm, kVectorOffset, kArgumentsOffset, | 1172 Generate_PushAppliedArguments(masm, kVectorOffset, kArgumentsOffset, |
1173 kIndexOffset, kLimitOffset); | 1173 kIndexOffset, kLimitOffset); |
1174 | 1174 |
1175 // Use undefined feedback vector | 1175 // Use undefined feedback vector |
1176 __ LoadRoot(rbx, Heap::kUndefinedValueRootIndex); | 1176 __ LoadRoot(rbx, Heap::kUndefinedValueRootIndex); |
1177 __ movp(rdi, Operand(rbp, kFunctionOffset)); | 1177 __ movp(rdi, Operand(rbp, kFunctionOffset)); |
1178 __ movp(rcx, Operand(rbp, kNewTargetOffset)); | 1178 __ movp(rdx, Operand(rbp, kNewTargetOffset)); |
1179 | 1179 |
1180 // Call the function. | 1180 // Call the function. |
1181 CallConstructStub stub(masm->isolate(), SUPER_CONSTRUCTOR_CALL); | 1181 __ Call(masm->isolate()->builtins()->Construct(), |
1182 __ call(stub.GetCode(), RelocInfo::CONSTRUCT_CALL); | 1182 RelocInfo::CONSTRUCT_CALL); |
1183 | 1183 |
1184 // Leave internal frame. | 1184 // Leave internal frame. |
1185 } | 1185 } |
1186 // remove this, target, arguments and newTarget | 1186 // remove this, target, arguments and newTarget |
1187 __ ret(kStackSize * kPointerSize); | 1187 __ ret(kStackSize * kPointerSize); |
1188 } | 1188 } |
1189 | 1189 |
1190 | 1190 |
1191 void Builtins::Generate_FunctionApply(MacroAssembler* masm) { | 1191 void Builtins::Generate_FunctionApply(MacroAssembler* masm) { |
1192 Generate_ApplyHelper(masm, false); | 1192 Generate_ApplyHelper(masm, false); |
(...skipping 618 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1811 // static | 1811 // static |
1812 void Builtins::Generate_Construct(MacroAssembler* masm) { | 1812 void Builtins::Generate_Construct(MacroAssembler* masm) { |
1813 // ----------- S t a t e ------------- | 1813 // ----------- S t a t e ------------- |
1814 // -- rax : the number of arguments (not including the receiver) | 1814 // -- rax : the number of arguments (not including the receiver) |
1815 // -- rdx : the new target (either the same as the constructor or | 1815 // -- rdx : the new target (either the same as the constructor or |
1816 // the JSFunction on which new was invoked initially) | 1816 // the JSFunction on which new was invoked initially) |
1817 // -- rdi : the constructor to call (can be any Object) | 1817 // -- rdi : the constructor to call (can be any Object) |
1818 // ----------------------------------- | 1818 // ----------------------------------- |
1819 StackArgumentsAccessor args(rsp, rax); | 1819 StackArgumentsAccessor args(rsp, rax); |
1820 | 1820 |
1821 // Check if target has a [[Construct]] internal method. | 1821 // Check if target is a Smi. |
1822 Label non_constructor; | 1822 Label non_constructor; |
1823 __ JumpIfSmi(rdi, &non_constructor, Label::kNear); | 1823 __ JumpIfSmi(rdi, &non_constructor, Label::kNear); |
1824 __ movp(rcx, FieldOperand(rdi, HeapObject::kMapOffset)); | |
1825 __ testb(FieldOperand(rcx, Map::kBitFieldOffset), | |
1826 Immediate(1 << Map::kIsConstructor)); | |
1827 __ j(zero, &non_constructor, Label::kNear); | |
1828 | 1824 |
1829 // Dispatch based on instance type. | 1825 // Dispatch based on instance type. |
1830 __ CmpInstanceType(rcx, JS_FUNCTION_TYPE); | 1826 __ CmpObjectType(rdi, JS_FUNCTION_TYPE, rcx); |
1831 __ j(equal, masm->isolate()->builtins()->ConstructFunction(), | 1827 __ j(equal, masm->isolate()->builtins()->ConstructFunction(), |
1832 RelocInfo::CODE_TARGET); | 1828 RelocInfo::CODE_TARGET); |
1833 __ CmpInstanceType(rcx, JS_FUNCTION_PROXY_TYPE); | 1829 __ CmpInstanceType(rcx, JS_FUNCTION_PROXY_TYPE); |
1834 __ j(equal, masm->isolate()->builtins()->ConstructProxy(), | 1830 __ j(equal, masm->isolate()->builtins()->ConstructProxy(), |
1835 RelocInfo::CODE_TARGET); | 1831 RelocInfo::CODE_TARGET); |
1836 | 1832 |
| 1833 // Check if target has a [[Construct]] internal method. |
| 1834 __ testb(FieldOperand(rcx, Map::kBitFieldOffset), |
| 1835 Immediate(1 << Map::kIsConstructor)); |
| 1836 __ j(zero, &non_constructor, Label::kNear); |
| 1837 |
1837 // Called Construct on an exotic Object with a [[Construct]] internal method. | 1838 // Called Construct on an exotic Object with a [[Construct]] internal method. |
1838 { | 1839 { |
1839 // Overwrite the original receiver with the (original) target. | 1840 // Overwrite the original receiver with the (original) target. |
1840 __ movp(args.GetReceiverOperand(), rdi); | 1841 __ movp(args.GetReceiverOperand(), rdi); |
1841 // Let the "call_as_constructor_delegate" take care of the rest. | 1842 // Let the "call_as_constructor_delegate" take care of the rest. |
1842 __ LoadGlobalFunction(Context::CALL_AS_CONSTRUCTOR_DELEGATE_INDEX, rdi); | 1843 __ LoadGlobalFunction(Context::CALL_AS_CONSTRUCTOR_DELEGATE_INDEX, rdi); |
1843 __ Jump(masm->isolate()->builtins()->CallFunction(), | 1844 __ Jump(masm->isolate()->builtins()->CallFunction(), |
1844 RelocInfo::CODE_TARGET); | 1845 RelocInfo::CODE_TARGET); |
1845 } | 1846 } |
1846 | 1847 |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1907 __ ret(0); | 1908 __ ret(0); |
1908 } | 1909 } |
1909 | 1910 |
1910 | 1911 |
1911 #undef __ | 1912 #undef __ |
1912 | 1913 |
1913 } // namespace internal | 1914 } // namespace internal |
1914 } // namespace v8 | 1915 } // namespace v8 |
1915 | 1916 |
1916 #endif // V8_TARGET_ARCH_X64 | 1917 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |