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_MIPS64 | 5 #if V8_TARGET_ARCH_MIPS64 |
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 1627 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1638 // Tail call to the function-specific construct stub (still in the caller | 1638 // Tail call to the function-specific construct stub (still in the caller |
1639 // context at this point). | 1639 // context at this point). |
1640 __ ld(a4, FieldMemOperand(a1, JSFunction::kSharedFunctionInfoOffset)); | 1640 __ ld(a4, FieldMemOperand(a1, JSFunction::kSharedFunctionInfoOffset)); |
1641 __ ld(a4, FieldMemOperand(a4, SharedFunctionInfo::kConstructStubOffset)); | 1641 __ ld(a4, FieldMemOperand(a4, SharedFunctionInfo::kConstructStubOffset)); |
1642 __ Daddu(at, a4, Operand(Code::kHeaderSize - kHeapObjectTag)); | 1642 __ Daddu(at, a4, Operand(Code::kHeaderSize - kHeapObjectTag)); |
1643 __ Jump(at); | 1643 __ Jump(at); |
1644 } | 1644 } |
1645 | 1645 |
1646 | 1646 |
1647 // static | 1647 // static |
| 1648 void Builtins::Generate_ConstructProxy(MacroAssembler* masm) { |
| 1649 // ----------- S t a t e ------------- |
| 1650 // -- a0 : the number of arguments (not including the receiver) |
| 1651 // -- a1 : the constructor to call (checked to be a JSFunctionProxy) |
| 1652 // -- a3 : the original constructor (either the same as the constructor or |
| 1653 // the JSFunction on which new was invoked initially) |
| 1654 // ----------------------------------- |
| 1655 |
| 1656 // TODO(neis): This doesn't match the ES6 spec for [[Construct]] on proxies. |
| 1657 __ ld(a1, FieldMemOperand(a1, JSFunctionProxy::kConstructTrapOffset)); |
| 1658 __ Jump(masm->isolate()->builtins()->Call(), RelocInfo::CODE_TARGET); |
| 1659 } |
| 1660 |
| 1661 |
| 1662 // static |
1648 void Builtins::Generate_Construct(MacroAssembler* masm) { | 1663 void Builtins::Generate_Construct(MacroAssembler* masm) { |
1649 // ----------- S t a t e ------------- | 1664 // ----------- S t a t e ------------- |
1650 // -- a0 : the number of arguments (not including the receiver) | 1665 // -- a0 : the number of arguments (not including the receiver) |
1651 // -- a1 : the constructor to call (can be any Object) | 1666 // -- a1 : the constructor to call (can be any Object) |
1652 // -- a3 : the original constructor (either the same as the constructor or | 1667 // -- a3 : the original constructor (either the same as the constructor or |
1653 // the JSFunction on which new was invoked initially) | 1668 // the JSFunction on which new was invoked initially) |
1654 // ----------------------------------- | 1669 // ----------------------------------- |
1655 | 1670 |
1656 Label non_callable, non_function; | 1671 // Check if target has a [[Construct]] internal method. |
1657 __ JumpIfSmi(a1, &non_callable); | 1672 Label non_constructor; |
1658 __ GetObjectType(a1, t1, t2); | 1673 __ JumpIfSmi(a1, &non_constructor); |
| 1674 __ ld(t1, FieldMemOperand(a1, HeapObject::kMapOffset)); |
| 1675 __ lbu(t2, FieldMemOperand(t1, Map::kBitFieldOffset)); |
| 1676 __ And(t2, t2, Operand(1 << Map::kIsCallable)); |
| 1677 __ Branch(&non_constructor, eq, t2, Operand(zero_reg)); |
| 1678 |
| 1679 // Dispatch based on instance type. |
| 1680 __ lbu(t2, FieldMemOperand(t1, Map::kInstanceTypeOffset)); |
1659 __ Jump(masm->isolate()->builtins()->ConstructFunction(), | 1681 __ Jump(masm->isolate()->builtins()->ConstructFunction(), |
1660 RelocInfo::CODE_TARGET, eq, t2, Operand(JS_FUNCTION_TYPE)); | 1682 RelocInfo::CODE_TARGET, eq, t2, Operand(JS_FUNCTION_TYPE)); |
1661 __ Branch(&non_function, ne, t2, Operand(JS_FUNCTION_PROXY_TYPE)); | 1683 __ Jump(masm->isolate()->builtins()->ConstructProxy(), RelocInfo::CODE_TARGET, |
| 1684 eq, t2, Operand(JS_FUNCTION_PROXY_TYPE)); |
1662 | 1685 |
1663 // 1. Construct of function proxy. | 1686 // Called Construct on an exotic Object with a [[Construct]] internal method. |
1664 // TODO(neis): This doesn't match the ES6 spec for [[Construct]] on proxies. | 1687 { |
1665 __ ld(a1, FieldMemOperand(a1, JSFunctionProxy::kConstructTrapOffset)); | 1688 // Overwrite the original receiver with the (original) target. |
1666 __ Jump(masm->isolate()->builtins()->Call(), RelocInfo::CODE_TARGET); | 1689 __ dsll(at, a0, kPointerSizeLog2); |
| 1690 __ daddu(at, sp, at); |
| 1691 __ sd(a1, MemOperand(at)); |
| 1692 // Let the "call_as_constructor_delegate" take care of the rest. |
| 1693 __ LoadGlobalFunction(Context::CALL_AS_CONSTRUCTOR_DELEGATE_INDEX, a1); |
| 1694 __ Jump(masm->isolate()->builtins()->CallFunction(), |
| 1695 RelocInfo::CODE_TARGET); |
| 1696 } |
1667 | 1697 |
1668 // 2. Construct of something that else, which might have a [[Construct]] | 1698 // Called Construct on an Object that doesn't have a [[Construct]] internal |
1669 // internal method (if not we raise an exception). | 1699 // method. |
1670 __ bind(&non_function); | 1700 __ bind(&non_constructor); |
1671 // Check if target has a [[Call]] internal method. | |
1672 // TODO(bmeurer): This shoud use IsConstructor once available. | |
1673 __ lbu(t1, FieldMemOperand(t1, Map::kBitFieldOffset)); | |
1674 __ And(t1, t1, Operand(1 << Map::kIsCallable)); | |
1675 __ Branch(&non_callable, eq, t1, Operand(zero_reg)); | |
1676 // Overwrite the original receiver with the (original) target. | |
1677 __ dsll(at, a0, kPointerSizeLog2); | |
1678 __ daddu(at, sp, at); | |
1679 __ sd(a1, MemOperand(at)); | |
1680 // Let the "call_as_constructor_delegate" take care of the rest. | |
1681 __ LoadGlobalFunction(Context::CALL_AS_CONSTRUCTOR_DELEGATE_INDEX, a1); | |
1682 __ Jump(masm->isolate()->builtins()->CallFunction(), RelocInfo::CODE_TARGET); | |
1683 | |
1684 // 3. Construct of something that is not callable. | |
1685 __ bind(&non_callable); | |
1686 { | 1701 { |
1687 FrameScope scope(masm, StackFrame::INTERNAL); | 1702 FrameScope scope(masm, StackFrame::INTERNAL); |
1688 __ Push(a1); | 1703 __ Push(a1); |
1689 __ CallRuntime(Runtime::kThrowCalledNonCallable, 1); | 1704 __ CallRuntime(Runtime::kThrowCalledNonCallable, 1); |
1690 } | 1705 } |
1691 } | 1706 } |
1692 | 1707 |
1693 | 1708 |
1694 // static | 1709 // static |
1695 void Builtins::Generate_PushArgsAndCall(MacroAssembler* masm) { | 1710 void Builtins::Generate_PushArgsAndCall(MacroAssembler* masm) { |
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1872 } | 1887 } |
1873 } | 1888 } |
1874 | 1889 |
1875 | 1890 |
1876 #undef __ | 1891 #undef __ |
1877 | 1892 |
1878 } // namespace internal | 1893 } // namespace internal |
1879 } // namespace v8 | 1894 } // namespace v8 |
1880 | 1895 |
1881 #endif // V8_TARGET_ARCH_MIPS64 | 1896 #endif // V8_TARGET_ARCH_MIPS64 |
OLD | NEW |