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_X87 | 5 #if V8_TARGET_ARCH_X87 |
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 1514 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1525 __ push(ecx); | 1525 __ push(ecx); |
1526 } | 1526 } |
1527 | 1527 |
1528 | 1528 |
1529 // static | 1529 // static |
1530 void Builtins::Generate_CallFunction(MacroAssembler* masm) { | 1530 void Builtins::Generate_CallFunction(MacroAssembler* masm) { |
1531 // ----------- S t a t e ------------- | 1531 // ----------- S t a t e ------------- |
1532 // -- eax : the number of arguments (not including the receiver) | 1532 // -- eax : the number of arguments (not including the receiver) |
1533 // -- edi : the function to call (checked to be a JSFunction) | 1533 // -- edi : the function to call (checked to be a JSFunction) |
1534 // ----------------------------------- | 1534 // ----------------------------------- |
| 1535 // See ES6 section 9.2.1 [[Call]] ( thisArgument, argumentsList) |
1535 | 1536 |
1536 Label convert, convert_global_proxy, convert_to_object, done_convert; | 1537 Label convert, convert_global_proxy, convert_to_object, done_convert; |
1537 __ AssertFunction(edi); | 1538 __ AssertFunction(edi); |
1538 // TODO(bmeurer): Throw a TypeError if function's [[FunctionKind]] internal | 1539 __ mov(edx, FieldOperand(edi, JSFunction::kSharedFunctionInfoOffset)); |
1539 // slot is "classConstructor". | 1540 |
| 1541 { |
| 1542 Label non_class_constructor; |
| 1543 // Check whether the current function is a classConstructor. |
| 1544 __ test_b(FieldOperand(edx, SharedFunctionInfo::kFunctionKindByteOffset), |
| 1545 SharedFunctionInfo::kClassConstructorBitsWithinByte); |
| 1546 __ j(zero, &non_class_constructor, Label::kNear); |
| 1547 // Step: 2, If we call a classConstructor Function throw a TypeError. |
| 1548 { |
| 1549 FrameScope frame(masm, StackFrame::INTERNAL); |
| 1550 __ CallRuntime(Runtime::kThrowConstructorNonCallableError, 0); |
| 1551 } |
| 1552 __ bind(&non_class_constructor); |
| 1553 } |
| 1554 |
1540 // Enter the context of the function; ToObject has to run in the function | 1555 // Enter the context of the function; ToObject has to run in the function |
1541 // context, and we also need to take the global proxy from the function | 1556 // context, and we also need to take the global proxy from the function |
1542 // context in case of conversion. | 1557 // context in case of conversion. |
1543 // See ES6 section 9.2.1 [[Call]] ( thisArgument, argumentsList) | |
1544 STATIC_ASSERT(SharedFunctionInfo::kNativeByteOffset == | 1558 STATIC_ASSERT(SharedFunctionInfo::kNativeByteOffset == |
1545 SharedFunctionInfo::kStrictModeByteOffset); | 1559 SharedFunctionInfo::kStrictModeByteOffset); |
1546 __ mov(esi, FieldOperand(edi, JSFunction::kContextOffset)); | 1560 __ mov(esi, FieldOperand(edi, JSFunction::kContextOffset)); |
1547 __ mov(edx, FieldOperand(edi, JSFunction::kSharedFunctionInfoOffset)); | |
1548 // We need to convert the receiver for non-native sloppy mode functions. | 1561 // We need to convert the receiver for non-native sloppy mode functions. |
1549 __ test_b(FieldOperand(edx, SharedFunctionInfo::kNativeByteOffset), | 1562 __ test_b(FieldOperand(edx, SharedFunctionInfo::kNativeByteOffset), |
1550 (1 << SharedFunctionInfo::kNativeBitWithinByte) | | 1563 (1 << SharedFunctionInfo::kNativeBitWithinByte) | |
1551 (1 << SharedFunctionInfo::kStrictModeBitWithinByte)); | 1564 (1 << SharedFunctionInfo::kStrictModeBitWithinByte)); |
1552 __ j(not_zero, &done_convert); | 1565 __ j(not_zero, &done_convert); |
1553 { | 1566 { |
1554 __ mov(ecx, Operand(esp, eax, times_pointer_size, kPointerSize)); | 1567 __ mov(ecx, Operand(esp, eax, times_pointer_size, kPointerSize)); |
1555 | 1568 |
1556 // ----------- S t a t e ------------- | 1569 // ----------- S t a t e ------------- |
1557 // -- eax : the number of arguments (not including the receiver) | 1570 // -- eax : the number of arguments (not including the receiver) |
(...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1924 | 1937 |
1925 __ bind(&ok); | 1938 __ bind(&ok); |
1926 __ ret(0); | 1939 __ ret(0); |
1927 } | 1940 } |
1928 | 1941 |
1929 #undef __ | 1942 #undef __ |
1930 } // namespace internal | 1943 } // namespace internal |
1931 } // namespace v8 | 1944 } // namespace v8 |
1932 | 1945 |
1933 #endif // V8_TARGET_ARCH_X87 | 1946 #endif // V8_TARGET_ARCH_X87 |
OLD | NEW |