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