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_MIPS | 5 #if V8_TARGET_ARCH_MIPS |
6 | 6 |
7 #include "src/codegen.h" | 7 #include "src/codegen.h" |
8 #include "src/debug/debug.h" | 8 #include "src/debug/debug.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 1545 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1556 | 1556 |
1557 // static | 1557 // static |
1558 void Builtins::Generate_CallFunction(MacroAssembler* masm) { | 1558 void Builtins::Generate_CallFunction(MacroAssembler* masm) { |
1559 // ----------- S t a t e ------------- | 1559 // ----------- S t a t e ------------- |
1560 // -- a0 : the number of arguments (not including the receiver) | 1560 // -- a0 : the number of arguments (not including the receiver) |
1561 // -- a1 : the function to call (checked to be a JSFunction) | 1561 // -- a1 : the function to call (checked to be a JSFunction) |
1562 // ----------------------------------- | 1562 // ----------------------------------- |
1563 | 1563 |
1564 Label convert, convert_global_proxy, convert_to_object, done_convert; | 1564 Label convert, convert_global_proxy, convert_to_object, done_convert; |
1565 __ AssertFunction(a1); | 1565 __ AssertFunction(a1); |
1566 // TODO(bmeurer): Throw a TypeError if function's [[FunctionKind]] internal | 1566 __ lw(a2, FieldMemOperand(a1, JSFunction::kSharedFunctionInfoOffset)); |
1567 // slot is "classConstructor". | 1567 |
| 1568 { |
| 1569 Label non_class_constructor; |
| 1570 // Check whether the current function is a classConstructor This only works |
| 1571 // since kClassConstructor is more than 1 bit away from the byte boundary in |
| 1572 // CompilerHints (note that compiler_hints is stored as smi on 32bit |
| 1573 // architectures) |
| 1574 STATIC_ASSERT((FunctionKind::kClassConstructor << kSmiTagSize) < |
| 1575 (1 << kBitsPerByte)); |
| 1576 __ lbu(a3, |
| 1577 FieldMemOperand(a2, SharedFunctionInfo::kFunctionKindByteOffset)); |
| 1578 // Left-shift to account for smi storage in 32bits. |
| 1579 __ And(at, a3, Operand(FunctionKind::kClassConstructor << kSmiTagSize)); |
| 1580 __ Branch(&non_class_constructor, eq, at, Operand(zero_reg)); |
| 1581 // Step: 2, If we call a classConstructor Function throw a TypeError. |
| 1582 { |
| 1583 FrameScope frame(masm, StackFrame::INTERNAL); |
| 1584 __ CallRuntime(Runtime::kThrowConstructorNonCallableError, 0); |
| 1585 } |
| 1586 __ bind(&non_class_constructor); |
| 1587 } |
| 1588 |
1568 // Enter the context of the function; ToObject has to run in the function | 1589 // Enter the context of the function; ToObject has to run in the function |
1569 // context, and we also need to take the global proxy from the function | 1590 // context, and we also need to take the global proxy from the function |
1570 // context in case of conversion. | 1591 // context in case of conversion. |
1571 // See ES6 section 9.2.1 [[Call]] ( thisArgument, argumentsList) | 1592 // See ES6 section 9.2.1 [[Call]] ( thisArgument, argumentsList) |
1572 STATIC_ASSERT(SharedFunctionInfo::kNativeByteOffset == | 1593 STATIC_ASSERT(SharedFunctionInfo::kNativeByteOffset == |
1573 SharedFunctionInfo::kStrictModeByteOffset); | 1594 SharedFunctionInfo::kStrictModeByteOffset); |
1574 __ lw(cp, FieldMemOperand(a1, JSFunction::kContextOffset)); | 1595 __ lw(cp, FieldMemOperand(a1, JSFunction::kContextOffset)); |
1575 __ lw(a2, FieldMemOperand(a1, JSFunction::kSharedFunctionInfoOffset)); | |
1576 // We need to convert the receiver for non-native sloppy mode functions. | 1596 // We need to convert the receiver for non-native sloppy mode functions. |
1577 __ lbu(a3, FieldMemOperand(a2, SharedFunctionInfo::kNativeByteOffset)); | 1597 __ lbu(a3, FieldMemOperand(a2, SharedFunctionInfo::kNativeByteOffset)); |
1578 __ And(at, a3, Operand((1 << SharedFunctionInfo::kNativeBitWithinByte) | | 1598 __ And(at, a3, Operand((1 << SharedFunctionInfo::kNativeBitWithinByte) | |
1579 (1 << SharedFunctionInfo::kStrictModeBitWithinByte))); | 1599 (1 << SharedFunctionInfo::kStrictModeBitWithinByte))); |
1580 __ Branch(&done_convert, ne, at, Operand(zero_reg)); | 1600 __ Branch(&done_convert, ne, at, Operand(zero_reg)); |
1581 { | 1601 { |
1582 __ sll(at, a0, kPointerSizeLog2); | 1602 __ sll(at, a0, kPointerSizeLog2); |
1583 __ addu(at, sp, at); | 1603 __ addu(at, sp, at); |
1584 __ lw(a3, MemOperand(at)); | 1604 __ lw(a3, MemOperand(at)); |
1585 | 1605 |
(...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1927 } | 1947 } |
1928 } | 1948 } |
1929 | 1949 |
1930 | 1950 |
1931 #undef __ | 1951 #undef __ |
1932 | 1952 |
1933 } // namespace internal | 1953 } // namespace internal |
1934 } // namespace v8 | 1954 } // namespace v8 |
1935 | 1955 |
1936 #endif // V8_TARGET_ARCH_MIPS | 1956 #endif // V8_TARGET_ARCH_MIPS |
OLD | NEW |