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 1678 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1689 FrameScope frame(masm, StackFrame::MANUAL); | 1689 FrameScope frame(masm, StackFrame::MANUAL); |
1690 EnterArgumentsAdaptorFrame(masm); | 1690 EnterArgumentsAdaptorFrame(masm); |
1691 __ CallRuntime(Runtime::kThrowStackOverflow, 0); | 1691 __ CallRuntime(Runtime::kThrowStackOverflow, 0); |
1692 __ int3(); | 1692 __ int3(); |
1693 } | 1693 } |
1694 } | 1694 } |
1695 | 1695 |
1696 | 1696 |
1697 // static | 1697 // static |
1698 void Builtins::Generate_CallFunction(MacroAssembler* masm) { | 1698 void Builtins::Generate_CallFunction(MacroAssembler* masm) { |
| 1699 // ES6 section 9.2.1 [[Call]] ( thisArgument, argumentsList) |
1699 // ----------- S t a t e ------------- | 1700 // ----------- S t a t e ------------- |
1700 // -- rax : the number of arguments (not including the receiver) | 1701 // -- rax : the number of arguments (not including the receiver) |
1701 // -- rdi : the function to call (checked to be a JSFunction) | 1702 // -- rdi : the function to call (checked to be a JSFunction) |
1702 // ----------------------------------- | 1703 // ----------------------------------- |
1703 | 1704 |
1704 Label convert, convert_global_proxy, convert_to_object, done_convert; | 1705 Label convert, convert_global_proxy, convert_to_object, done_convert; |
1705 StackArgumentsAccessor args(rsp, rax); | 1706 StackArgumentsAccessor args(rsp, rax); |
1706 __ AssertFunction(rdi); | 1707 __ AssertFunction(rdi); |
1707 // TODO(bmeurer): Throw a TypeError if function's [[FunctionKind]] internal | 1708 __ movp(rdx, FieldOperand(rdi, JSFunction::kSharedFunctionInfoOffset)); |
1708 // slot is "classConstructor". | 1709 { |
| 1710 Label non_class_constructor; |
| 1711 // Check whether the current function is a classConstructor |
| 1712 __ testb(FieldOperand(rdx, SharedFunctionInfo::kFunctionKindByteOffset), |
| 1713 Immediate(SharedFunctionInfo::kClassConstructorBitsWithinByte)); |
| 1714 __ j(zero, &non_class_constructor); |
| 1715 // Step: 2, If we call a classConstructor Function throw a TypeError. |
| 1716 { |
| 1717 FrameScope frame(masm, StackFrame::INTERNAL); |
| 1718 __ CallRuntime(Runtime::kThrowConstructorNonCallableError, 0); |
| 1719 } |
| 1720 __ bind(&non_class_constructor); |
| 1721 } |
| 1722 |
1709 // Enter the context of the function; ToObject has to run in the function | 1723 // Enter the context of the function; ToObject has to run in the function |
1710 // context, and we also need to take the global proxy from the function | 1724 // context, and we also need to take the global proxy from the function |
1711 // context in case of conversion. | 1725 // context in case of conversion. |
1712 // See ES6 section 9.2.1 [[Call]] ( thisArgument, argumentsList) | |
1713 STATIC_ASSERT(SharedFunctionInfo::kNativeByteOffset == | 1726 STATIC_ASSERT(SharedFunctionInfo::kNativeByteOffset == |
1714 SharedFunctionInfo::kStrictModeByteOffset); | 1727 SharedFunctionInfo::kStrictModeByteOffset); |
1715 __ movp(rsi, FieldOperand(rdi, JSFunction::kContextOffset)); | 1728 __ movp(rsi, FieldOperand(rdi, JSFunction::kContextOffset)); |
1716 __ movp(rdx, FieldOperand(rdi, JSFunction::kSharedFunctionInfoOffset)); | |
1717 // We need to convert the receiver for non-native sloppy mode functions. | 1729 // We need to convert the receiver for non-native sloppy mode functions. |
1718 __ testb(FieldOperand(rdx, SharedFunctionInfo::kNativeByteOffset), | 1730 __ testb(FieldOperand(rdx, SharedFunctionInfo::kNativeByteOffset), |
1719 Immediate((1 << SharedFunctionInfo::kNativeBitWithinByte) | | 1731 Immediate((1 << SharedFunctionInfo::kNativeBitWithinByte) | |
1720 (1 << SharedFunctionInfo::kStrictModeBitWithinByte))); | 1732 (1 << SharedFunctionInfo::kStrictModeBitWithinByte))); |
1721 __ j(not_zero, &done_convert); | 1733 __ j(not_zero, &done_convert); |
1722 { | 1734 { |
1723 __ movp(rcx, args.GetReceiverOperand()); | 1735 __ movp(rcx, args.GetReceiverOperand()); |
1724 | 1736 |
1725 // ----------- S t a t e ------------- | 1737 // ----------- S t a t e ------------- |
1726 // -- rax : the number of arguments (not including the receiver) | 1738 // -- rax : the number of arguments (not including the receiver) |
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1967 __ ret(0); | 1979 __ ret(0); |
1968 } | 1980 } |
1969 | 1981 |
1970 | 1982 |
1971 #undef __ | 1983 #undef __ |
1972 | 1984 |
1973 } // namespace internal | 1985 } // namespace internal |
1974 } // namespace v8 | 1986 } // namespace v8 |
1975 | 1987 |
1976 #endif // V8_TARGET_ARCH_X64 | 1988 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |