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