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 1575 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1586 } | 1586 } |
1587 | 1587 |
1588 | 1588 |
1589 // static | 1589 // static |
1590 void Builtins::Generate_Call(MacroAssembler* masm) { | 1590 void Builtins::Generate_Call(MacroAssembler* masm) { |
1591 // ----------- S t a t e ------------- | 1591 // ----------- S t a t e ------------- |
1592 // -- a0 : the number of arguments (not including the receiver) | 1592 // -- a0 : the number of arguments (not including the receiver) |
1593 // -- a1 : the target to call (can be any Object). | 1593 // -- a1 : the target to call (can be any Object). |
1594 // ----------------------------------- | 1594 // ----------------------------------- |
1595 | 1595 |
1596 Label non_smi, non_function; | 1596 Label non_callable, non_function, non_smi; |
1597 __ JumpIfSmi(a1, &non_function); | 1597 __ JumpIfSmi(a1, &non_callable); |
1598 __ bind(&non_smi); | 1598 __ bind(&non_smi); |
1599 __ GetObjectType(a1, a2, a2); | 1599 __ GetObjectType(a1, t1, t2); |
1600 __ Jump(masm->isolate()->builtins()->CallFunction(), RelocInfo::CODE_TARGET, | 1600 __ Jump(masm->isolate()->builtins()->CallFunction(), RelocInfo::CODE_TARGET, |
1601 eq, a2, Operand(JS_FUNCTION_TYPE)); | 1601 eq, t2, Operand(JS_FUNCTION_TYPE)); |
1602 __ Branch(&non_function, ne, a2, Operand(JS_FUNCTION_PROXY_TYPE)); | 1602 __ Branch(&non_function, ne, t2, Operand(JS_FUNCTION_PROXY_TYPE)); |
1603 | 1603 |
1604 // 1. Call to function proxy. | 1604 // 1. Call to function proxy. |
1605 // TODO(neis): This doesn't match the ES6 spec for [[Call]] on proxies. | 1605 // TODO(neis): This doesn't match the ES6 spec for [[Call]] on proxies. |
1606 __ ld(a1, FieldMemOperand(a1, JSFunctionProxy::kCallTrapOffset)); | 1606 __ ld(a1, FieldMemOperand(a1, JSFunctionProxy::kCallTrapOffset)); |
1607 __ AssertNotSmi(a1); | 1607 __ AssertNotSmi(a1); |
1608 __ Branch(&non_smi); | 1608 __ Branch(&non_smi); |
1609 | 1609 |
1610 // 2. Call to something else, which might have a [[Call]] internal method (if | 1610 // 2. Call to something else, which might have a [[Call]] internal method (if |
1611 // not we raise an exception). | 1611 // not we raise an exception). |
1612 __ bind(&non_function); | 1612 __ bind(&non_function); |
1613 // TODO(bmeurer): I wonder why we prefer to have slow API calls? This could | 1613 // Check if target has a [[Call]] internal method. |
1614 // be awesome instead; i.e. a trivial improvement would be to call into the | 1614 __ lbu(t1, FieldMemOperand(t1, Map::kBitFieldOffset)); |
1615 // runtime and just deal with the API function there instead of returning a | 1615 __ And(t1, t1, Operand(1 << Map::kIsCallable)); |
1616 // delegate from a runtime call that just jumps back to the runtime once | 1616 __ Branch(&non_callable, eq, t1, Operand(zero_reg)); |
1617 // called. Or, bonus points, call directly into the C API function here, as | |
1618 // we do in some Crankshaft fast cases. | |
1619 // Overwrite the original receiver with the (original) target. | 1617 // Overwrite the original receiver with the (original) target. |
1620 __ dsll(at, a0, kPointerSizeLog2); | 1618 __ dsll(at, a0, kPointerSizeLog2); |
1621 __ daddu(at, sp, at); | 1619 __ daddu(at, sp, at); |
1622 __ sd(a1, MemOperand(at)); | 1620 __ sd(a1, MemOperand(at)); |
| 1621 // Let the "call_as_function_delegate" take care of the rest. |
| 1622 __ LoadGlobalFunction(Context::CALL_AS_FUNCTION_DELEGATE_INDEX, a1); |
| 1623 __ Jump(masm->isolate()->builtins()->CallFunction(), RelocInfo::CODE_TARGET); |
| 1624 |
| 1625 // 3. Call to something that is not callable. |
| 1626 __ bind(&non_callable); |
1623 { | 1627 { |
1624 // Determine the delegate for the target (if any). | 1628 FrameAndConstantPoolScope scope(masm, StackFrame::INTERNAL); |
1625 FrameScope scope(masm, StackFrame::INTERNAL); | 1629 __ Push(a1); |
1626 __ SmiTag(a0); | 1630 __ CallRuntime(Runtime::kThrowCalledNonCallable, 1); |
1627 __ Push(a0, a1); | |
1628 __ CallRuntime(Runtime::kGetFunctionDelegate, 1); | |
1629 __ mov(a1, v0); | |
1630 __ Pop(a0); | |
1631 __ SmiUntag(a0); | |
1632 } | 1631 } |
1633 // The delegate is always a regular function. | |
1634 __ AssertFunction(a1); | |
1635 __ Jump(masm->isolate()->builtins()->CallFunction(), RelocInfo::CODE_TARGET); | |
1636 } | 1632 } |
1637 | 1633 |
1638 | 1634 |
1639 void Builtins::Generate_ConstructFunction(MacroAssembler* masm) { | 1635 void Builtins::Generate_ConstructFunction(MacroAssembler* masm) { |
1640 // ----------- S t a t e ------------- | 1636 // ----------- S t a t e ------------- |
1641 // -- a0 : the number of arguments (not including the receiver) | 1637 // -- a0 : the number of arguments (not including the receiver) |
1642 // -- a1 : the constructor to call (checked to be a JSFunction) | 1638 // -- a1 : the constructor to call (checked to be a JSFunction) |
1643 // -- a3 : the original constructor (checked to be a JSFunction) | 1639 // -- a3 : the original constructor (checked to be a JSFunction) |
1644 // ----------------------------------- | 1640 // ----------------------------------- |
1645 __ AssertFunction(a1); | 1641 __ AssertFunction(a1); |
(...skipping 14 matching lines...) Expand all Loading... |
1660 | 1656 |
1661 // static | 1657 // static |
1662 void Builtins::Generate_Construct(MacroAssembler* masm) { | 1658 void Builtins::Generate_Construct(MacroAssembler* masm) { |
1663 // ----------- S t a t e ------------- | 1659 // ----------- S t a t e ------------- |
1664 // -- a0 : the number of arguments (not including the receiver) | 1660 // -- a0 : the number of arguments (not including the receiver) |
1665 // -- a1 : the constructor to call (can be any Object) | 1661 // -- a1 : the constructor to call (can be any Object) |
1666 // -- a3 : the original constructor (either the same as the constructor or | 1662 // -- a3 : the original constructor (either the same as the constructor or |
1667 // the JSFunction on which new was invoked initially) | 1663 // the JSFunction on which new was invoked initially) |
1668 // ----------------------------------- | 1664 // ----------------------------------- |
1669 | 1665 |
1670 Label slow; | 1666 Label non_callable, non_function; |
1671 __ JumpIfSmi(a1, &slow); | 1667 __ JumpIfSmi(a1, &non_callable); |
1672 __ GetObjectType(a1, a5, a5); | 1668 __ GetObjectType(a1, t1, t2); |
1673 __ Jump(masm->isolate()->builtins()->ConstructFunction(), | 1669 __ Jump(masm->isolate()->builtins()->ConstructFunction(), |
1674 RelocInfo::CODE_TARGET, eq, a5, Operand(JS_FUNCTION_TYPE)); | 1670 RelocInfo::CODE_TARGET, eq, t2, Operand(JS_FUNCTION_TYPE)); |
1675 __ Branch(&slow, ne, a5, Operand(JS_FUNCTION_PROXY_TYPE)); | 1671 __ Branch(&non_function, ne, t2, Operand(JS_FUNCTION_PROXY_TYPE)); |
1676 | 1672 |
| 1673 // 1. Construct of function proxy. |
1677 // TODO(neis): This doesn't match the ES6 spec for [[Construct]] on proxies. | 1674 // TODO(neis): This doesn't match the ES6 spec for [[Construct]] on proxies. |
1678 __ ld(a1, FieldMemOperand(a1, JSFunctionProxy::kConstructTrapOffset)); | 1675 __ ld(a1, FieldMemOperand(a1, JSFunctionProxy::kConstructTrapOffset)); |
1679 __ Jump(masm->isolate()->builtins()->Call(), RelocInfo::CODE_TARGET); | 1676 __ Jump(masm->isolate()->builtins()->Call(), RelocInfo::CODE_TARGET); |
1680 | 1677 |
1681 __ bind(&slow); | 1678 // 2. Construct of something that else, which might have a [[Construct]] |
| 1679 // internal method (if not we raise an exception). |
| 1680 __ bind(&non_function); |
| 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); |
1682 { | 1696 { |
1683 // Determine the delegate for the target (if any). | 1697 FrameAndConstantPoolScope scope(masm, StackFrame::INTERNAL); |
1684 FrameScope scope(masm, StackFrame::INTERNAL); | 1698 __ Push(a1); |
1685 __ SmiTag(a0); | 1699 __ CallRuntime(Runtime::kThrowCalledNonCallable, 1); |
1686 __ Push(a0, a1); | |
1687 __ CallRuntime(Runtime::kGetConstructorDelegate, 1); | |
1688 __ mov(a1, v0); | |
1689 __ Pop(a0); | |
1690 __ SmiUntag(a0); | |
1691 } | 1700 } |
1692 // The delegate is always a regular function. | |
1693 __ AssertFunction(a1); | |
1694 __ Jump(masm->isolate()->builtins()->CallFunction(), RelocInfo::CODE_TARGET); | |
1695 } | 1701 } |
1696 | 1702 |
1697 | 1703 |
1698 // static | 1704 // static |
1699 void Builtins::Generate_PushArgsAndCall(MacroAssembler* masm) { | 1705 void Builtins::Generate_PushArgsAndCall(MacroAssembler* masm) { |
1700 // ----------- S t a t e ------------- | 1706 // ----------- S t a t e ------------- |
1701 // -- a0 : the number of arguments (not including the receiver) | 1707 // -- a0 : the number of arguments (not including the receiver) |
1702 // -- a2 : the address of the first argument to be pushed. Subsequent | 1708 // -- a2 : the address of the first argument to be pushed. Subsequent |
1703 // arguments should be consecutive above this, in the same order as | 1709 // arguments should be consecutive above this, in the same order as |
1704 // they are to be pushed onto the stack. | 1710 // they are to be pushed onto the stack. |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1876 } | 1882 } |
1877 } | 1883 } |
1878 | 1884 |
1879 | 1885 |
1880 #undef __ | 1886 #undef __ |
1881 | 1887 |
1882 } // namespace internal | 1888 } // namespace internal |
1883 } // namespace v8 | 1889 } // namespace v8 |
1884 | 1890 |
1885 #endif // V8_TARGET_ARCH_MIPS64 | 1891 #endif // V8_TARGET_ARCH_MIPS64 |
OLD | NEW |