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_IA32 | 5 #if V8_TARGET_ARCH_IA32 |
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 1488 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1499 __ push(ecx); | 1499 __ push(ecx); |
1500 } | 1500 } |
1501 | 1501 |
1502 | 1502 |
1503 // static | 1503 // static |
1504 void Builtins::Generate_CallFunction(MacroAssembler* masm) { | 1504 void Builtins::Generate_CallFunction(MacroAssembler* masm) { |
1505 // ----------- S t a t e ------------- | 1505 // ----------- S t a t e ------------- |
1506 // -- eax : the number of arguments (not including the receiver) | 1506 // -- eax : the number of arguments (not including the receiver) |
1507 // -- edi : the function to call (checked to be a JSFunction) | 1507 // -- edi : the function to call (checked to be a JSFunction) |
1508 // ----------------------------------- | 1508 // ----------------------------------- |
| 1509 // See ES6 section 9.2.1 [[Call]] ( thisArgument, argumentsList) |
1509 | 1510 |
1510 Label convert, convert_global_proxy, convert_to_object, done_convert; | 1511 Label convert, convert_global_proxy, convert_to_object, done_convert; |
1511 __ AssertFunction(edi); | 1512 __ AssertFunction(edi); |
1512 // TODO(bmeurer): Throw a TypeError if function's [[FunctionKind]] internal | 1513 __ mov(edx, FieldOperand(edi, JSFunction::kSharedFunctionInfoOffset)); |
1513 // slot is "classConstructor". | 1514 |
| 1515 { |
| 1516 Label non_class_constructor; |
| 1517 // Check whether the current function is a classConstructor This only works |
| 1518 // since kClassConstructor is more than 1 bit away from the byte boundary in |
| 1519 // CompilerHints (note that compiler_hints is stored as smi on 32bit |
| 1520 // architectures) |
| 1521 STATIC_ASSERT((FunctionKind::kClassConstructor << kSmiTagSize) < |
| 1522 (1 << kBitsPerByte)); |
| 1523 __ test_b(FieldOperand(edx, SharedFunctionInfo::kFunctionKindByteOffset), |
| 1524 FunctionKind::kClassConstructor << kSmiTagSize); |
| 1525 __ j(zero, &non_class_constructor, Label::kNear); |
| 1526 // Step: 2, If we call a classConstructor Function throw a TypeError. |
| 1527 { |
| 1528 FrameScope frame(masm, StackFrame::INTERNAL); |
| 1529 __ CallRuntime(Runtime::kThrowConstructorNonCallableError, 0); |
| 1530 } |
| 1531 __ bind(&non_class_constructor); |
| 1532 } |
| 1533 |
1514 // Enter the context of the function; ToObject has to run in the function | 1534 // Enter the context of the function; ToObject has to run in the function |
1515 // context, and we also need to take the global proxy from the function | 1535 // context, and we also need to take the global proxy from the function |
1516 // context in case of conversion. | 1536 // context in case of conversion. |
1517 // See ES6 section 9.2.1 [[Call]] ( thisArgument, argumentsList) | |
1518 STATIC_ASSERT(SharedFunctionInfo::kNativeByteOffset == | 1537 STATIC_ASSERT(SharedFunctionInfo::kNativeByteOffset == |
1519 SharedFunctionInfo::kStrictModeByteOffset); | 1538 SharedFunctionInfo::kStrictModeByteOffset); |
1520 __ mov(esi, FieldOperand(edi, JSFunction::kContextOffset)); | 1539 __ mov(esi, FieldOperand(edi, JSFunction::kContextOffset)); |
1521 __ mov(edx, FieldOperand(edi, JSFunction::kSharedFunctionInfoOffset)); | |
1522 // We need to convert the receiver for non-native sloppy mode functions. | 1540 // We need to convert the receiver for non-native sloppy mode functions. |
1523 __ test_b(FieldOperand(edx, SharedFunctionInfo::kNativeByteOffset), | 1541 __ test_b(FieldOperand(edx, SharedFunctionInfo::kNativeByteOffset), |
1524 (1 << SharedFunctionInfo::kNativeBitWithinByte) | | 1542 (1 << SharedFunctionInfo::kNativeBitWithinByte) | |
1525 (1 << SharedFunctionInfo::kStrictModeBitWithinByte)); | 1543 (1 << SharedFunctionInfo::kStrictModeBitWithinByte)); |
1526 __ j(not_zero, &done_convert); | 1544 __ j(not_zero, &done_convert); |
1527 { | 1545 { |
1528 __ mov(ecx, Operand(esp, eax, times_pointer_size, kPointerSize)); | 1546 __ mov(ecx, Operand(esp, eax, times_pointer_size, kPointerSize)); |
1529 | 1547 |
1530 // ----------- S t a t e ------------- | 1548 // ----------- S t a t e ------------- |
1531 // -- eax : the number of arguments (not including the receiver) | 1549 // -- eax : the number of arguments (not including the receiver) |
(...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1898 | 1916 |
1899 __ bind(&ok); | 1917 __ bind(&ok); |
1900 __ ret(0); | 1918 __ ret(0); |
1901 } | 1919 } |
1902 | 1920 |
1903 #undef __ | 1921 #undef __ |
1904 } // namespace internal | 1922 } // namespace internal |
1905 } // namespace v8 | 1923 } // namespace v8 |
1906 | 1924 |
1907 #endif // V8_TARGET_ARCH_IA32 | 1925 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |