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