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 1689 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1700 FrameScope frame(masm, StackFrame::MANUAL); | 1700 FrameScope frame(masm, StackFrame::MANUAL); |
1701 EnterArgumentsAdaptorFrame(masm); | 1701 EnterArgumentsAdaptorFrame(masm); |
1702 __ CallRuntime(Runtime::kThrowStackOverflow, 0); | 1702 __ CallRuntime(Runtime::kThrowStackOverflow, 0); |
1703 __ int3(); | 1703 __ int3(); |
1704 } | 1704 } |
1705 } | 1705 } |
1706 | 1706 |
1707 | 1707 |
1708 // static | 1708 // static |
1709 void Builtins::Generate_CallFunction(MacroAssembler* masm) { | 1709 void Builtins::Generate_CallFunction(MacroAssembler* masm) { |
1710 // ES6 section 9.2.1 [[Call]] ( thisArgument, argumentsList) | |
1710 // ----------- S t a t e ------------- | 1711 // ----------- S t a t e ------------- |
1711 // -- rax : the number of arguments (not including the receiver) | 1712 // -- rax : the number of arguments (not including the receiver) |
1712 // -- rdi : the function to call (checked to be a JSFunction) | 1713 // -- rdi : the function to call (checked to be a JSFunction) |
1713 // ----------------------------------- | 1714 // ----------------------------------- |
1714 | 1715 |
1715 Label convert, convert_global_proxy, convert_to_object, done_convert; | 1716 Label convert, convert_global_proxy, convert_to_object, done_convert; |
1716 StackArgumentsAccessor args(rsp, rax); | 1717 StackArgumentsAccessor args(rsp, rax); |
1717 __ AssertFunction(rdi); | 1718 __ AssertFunction(rdi); |
1718 // TODO(bmeurer): Throw a TypeError if function's [[FunctionKind]] internal | 1719 STATIC_ASSERT(SharedFunctionInfo::kNativeByteOffset == |
Benedikt Meurer
2015/10/22 11:08:05
Move the STATIC_ASSERT to the actual use site.
Camillo Bruni
2015/11/03 16:05:26
done
| |
1719 // slot is "classConstructor". | 1720 SharedFunctionInfo::kStrictModeByteOffset); |
1721 | |
1722 __ movp(rdx, FieldOperand(rdi, JSFunction::kSharedFunctionInfoOffset)); | |
1723 { | |
1724 Label non_classConstructor; | |
1725 __ movp(rdx, FieldOperand(rdi, JSFunction::kSharedFunctionInfoOffset)); | |
Benedikt Meurer
2015/10/22 11:08:04
No need to load the shared function info twice.
Camillo Bruni
2015/11/03 16:05:26
done
| |
1726 // Check whether the current function is a classConstructor | |
1727 __ testb(FieldOperand(rdx, SharedFunctionInfo::kIsArrowByteOffset), | |
Benedikt Meurer
2015/10/22 11:08:04
kIsArrowByteOffset is very confusing.
Camillo Bruni
2015/11/03 16:05:26
done
| |
1728 Immediate(FunctionKind::kClassConstructor)); | |
1729 __ j(zero, &non_classConstructor); | |
Benedikt Meurer
2015/10/22 11:08:04
You can use Label::kNear here.
Camillo Bruni
2015/11/03 16:05:27
done
| |
1730 // Step: 2, If we call a classConstructor Function throw a TypeError. | |
1731 { | |
1732 FrameScope frame(masm, StackFrame::INTERNAL); | |
1733 __ CallRuntime(Runtime::kThrowConstructorNonCallableError, 0); | |
1734 } | |
1735 __ bind(&non_classConstructor); | |
Benedikt Meurer
2015/10/22 11:08:04
Nit: non_class_constructor
Camillo Bruni
2015/11/03 16:05:26
done
| |
1736 } | |
1737 | |
1720 // Enter the context of the function; ToObject has to run in the function | 1738 // Enter the context of the function; ToObject has to run in the function |
1721 // context, and we also need to take the global proxy from the function | 1739 // context, and we also need to take the global proxy from the function |
1722 // context in case of conversion. | 1740 // context in case of conversion. |
1723 // See ES6 section 9.2.1 [[Call]] ( thisArgument, argumentsList) | |
1724 STATIC_ASSERT(SharedFunctionInfo::kNativeByteOffset == | |
1725 SharedFunctionInfo::kStrictModeByteOffset); | |
1726 __ movp(rsi, FieldOperand(rdi, JSFunction::kContextOffset)); | 1741 __ movp(rsi, FieldOperand(rdi, JSFunction::kContextOffset)); |
1727 __ movp(rdx, FieldOperand(rdi, JSFunction::kSharedFunctionInfoOffset)); | 1742 |
1728 // We need to convert the receiver for non-native sloppy mode functions. | 1743 // We need to convert the receiver for non-native sloppy mode functions. |
1729 __ testb(FieldOperand(rdx, SharedFunctionInfo::kNativeByteOffset), | 1744 __ testb(FieldOperand(rdx, SharedFunctionInfo::kNativeByteOffset), |
1730 Immediate((1 << SharedFunctionInfo::kNativeBitWithinByte) | | 1745 Immediate((1 << SharedFunctionInfo::kNativeBitWithinByte) | |
1731 (1 << SharedFunctionInfo::kStrictModeBitWithinByte))); | 1746 (1 << SharedFunctionInfo::kStrictModeBitWithinByte))); |
1732 __ j(not_zero, &done_convert); | 1747 __ j(not_zero, &done_convert); |
1733 { | 1748 { |
1734 __ movp(rcx, args.GetReceiverOperand()); | 1749 __ movp(rcx, args.GetReceiverOperand()); |
1735 | 1750 |
1736 // ----------- S t a t e ------------- | 1751 // ----------- S t a t e ------------- |
1737 // -- rax : the number of arguments (not including the receiver) | 1752 // -- rax : the number of arguments (not including the receiver) |
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1978 __ ret(0); | 1993 __ ret(0); |
1979 } | 1994 } |
1980 | 1995 |
1981 | 1996 |
1982 #undef __ | 1997 #undef __ |
1983 | 1998 |
1984 } // namespace internal | 1999 } // namespace internal |
1985 } // namespace v8 | 2000 } // namespace v8 |
1986 | 2001 |
1987 #endif // V8_TARGET_ARCH_X64 | 2002 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |