| OLD | NEW |
| 1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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_PPC | 5 #if V8_TARGET_ARCH_PPC |
| 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 1587 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1598 } | 1598 } |
| 1599 | 1599 |
| 1600 | 1600 |
| 1601 // static | 1601 // static |
| 1602 void Builtins::Generate_Call(MacroAssembler* masm) { | 1602 void Builtins::Generate_Call(MacroAssembler* masm) { |
| 1603 // ----------- S t a t e ------------- | 1603 // ----------- S t a t e ------------- |
| 1604 // -- r3 : the number of arguments (not including the receiver) | 1604 // -- r3 : the number of arguments (not including the receiver) |
| 1605 // -- r4 : the target to call (can be any Object). | 1605 // -- r4 : the target to call (can be any Object). |
| 1606 // ----------------------------------- | 1606 // ----------------------------------- |
| 1607 | 1607 |
| 1608 Label non_smi, non_function; | 1608 Label non_callable, non_function, non_smi; |
| 1609 __ JumpIfSmi(r4, &non_function); | 1609 __ JumpIfSmi(r4, &non_callable); |
| 1610 __ bind(&non_smi); | 1610 __ bind(&non_smi); |
| 1611 __ CompareObjectType(r4, r5, r5, JS_FUNCTION_TYPE); | 1611 __ CompareObjectType(r4, r7, r8, JS_FUNCTION_TYPE); |
| 1612 __ Jump(masm->isolate()->builtins()->CallFunction(), RelocInfo::CODE_TARGET, | 1612 __ Jump(masm->isolate()->builtins()->CallFunction(), RelocInfo::CODE_TARGET, |
| 1613 eq); | 1613 eq); |
| 1614 __ cmpi(r5, Operand(JS_FUNCTION_PROXY_TYPE)); | 1614 __ cmpi(r8, Operand(JS_FUNCTION_PROXY_TYPE)); |
| 1615 __ bne(&non_function); | 1615 __ bne(&non_function); |
| 1616 | 1616 |
| 1617 // 1. Call to function proxy. | 1617 // 1. Call to function proxy. |
| 1618 // TODO(neis): This doesn't match the ES6 spec for [[Call]] on proxies. | 1618 // TODO(neis): This doesn't match the ES6 spec for [[Call]] on proxies. |
| 1619 __ LoadP(r4, FieldMemOperand(r4, JSFunctionProxy::kCallTrapOffset)); | 1619 __ LoadP(r4, FieldMemOperand(r4, JSFunctionProxy::kCallTrapOffset)); |
| 1620 __ AssertNotSmi(r4); | 1620 __ AssertNotSmi(r4); |
| 1621 __ b(&non_smi); | 1621 __ b(&non_smi); |
| 1622 | 1622 |
| 1623 // 2. Call to something else, which might have a [[Call]] internal method (if | 1623 // 2. Call to something else, which might have a [[Call]] internal method (if |
| 1624 // not we raise an exception). | 1624 // not we raise an exception). |
| 1625 __ bind(&non_function); | 1625 __ bind(&non_function); |
| 1626 // TODO(bmeurer): I wonder why we prefer to have slow API calls? This could | 1626 // Check if target has a [[Call]] internal method. |
| 1627 // be awesome instead; i.e. a trivial improvement would be to call into the | 1627 __ lbz(r7, FieldMemOperand(r7, Map::kBitFieldOffset)); |
| 1628 // runtime and just deal with the API function there instead of returning a | 1628 __ TestBit(r7, Map::kIsCallable, r0); |
| 1629 // delegate from a runtime call that just jumps back to the runtime once | 1629 __ beq(&non_callable, cr0); |
| 1630 // called. Or, bonus points, call directly into the C API function here, as | 1630 // Overwrite the original receiver the (original) target. |
| 1631 // we do in some Crankshaft fast cases. | 1631 __ ShiftLeftImm(r8, r3, Operand(kPointerSizeLog2)); |
| 1632 // Overwrite the original receiver with the (original) target. | 1632 __ StorePX(r4, MemOperand(sp, r8)); |
| 1633 __ ShiftLeftImm(r5, r3, Operand(kPointerSizeLog2)); | 1633 // Let the "call_as_function_delegate" take care of the rest. |
| 1634 __ StorePX(r4, MemOperand(sp, r5)); | 1634 __ LoadGlobalFunction(Context::CALL_AS_FUNCTION_DELEGATE_INDEX, r4); |
| 1635 __ Jump(masm->isolate()->builtins()->CallFunction(), RelocInfo::CODE_TARGET); |
| 1636 |
| 1637 // 3. Call to something that is not callable. |
| 1638 __ bind(&non_callable); |
| 1635 { | 1639 { |
| 1636 // Determine the delegate for the target (if any). | |
| 1637 FrameAndConstantPoolScope scope(masm, StackFrame::INTERNAL); | 1640 FrameAndConstantPoolScope scope(masm, StackFrame::INTERNAL); |
| 1638 __ SmiTag(r3); | 1641 __ Push(r4); |
| 1639 __ Push(r3, r4); | 1642 __ CallRuntime(Runtime::kThrowCalledNonCallable, 1); |
| 1640 __ CallRuntime(Runtime::kGetFunctionDelegate, 1); | |
| 1641 __ mr(r4, r3); | |
| 1642 __ Pop(r3); | |
| 1643 __ SmiUntag(r3); | |
| 1644 } | 1643 } |
| 1645 // The delegate is always a regular function. | |
| 1646 __ AssertFunction(r4); | |
| 1647 __ Jump(masm->isolate()->builtins()->CallFunction(), RelocInfo::CODE_TARGET); | |
| 1648 } | 1644 } |
| 1649 | 1645 |
| 1650 | 1646 |
| 1651 // static | 1647 // static |
| 1652 void Builtins::Generate_ConstructFunction(MacroAssembler* masm) { | 1648 void Builtins::Generate_ConstructFunction(MacroAssembler* masm) { |
| 1653 // ----------- S t a t e ------------- | 1649 // ----------- S t a t e ------------- |
| 1654 // -- r3 : the number of arguments (not including the receiver) | 1650 // -- r3 : the number of arguments (not including the receiver) |
| 1655 // -- r4 : the constructor to call (checked to be a JSFunction) | 1651 // -- r4 : the constructor to call (checked to be a JSFunction) |
| 1656 // -- r6 : the original constructor (checked to be a JSFunction) | 1652 // -- r6 : the original constructor (checked to be a JSFunction) |
| 1657 // ----------------------------------- | 1653 // ----------------------------------- |
| (...skipping 15 matching lines...) Expand all Loading... |
| 1673 | 1669 |
| 1674 // static | 1670 // static |
| 1675 void Builtins::Generate_Construct(MacroAssembler* masm) { | 1671 void Builtins::Generate_Construct(MacroAssembler* masm) { |
| 1676 // ----------- S t a t e ------------- | 1672 // ----------- S t a t e ------------- |
| 1677 // -- r3 : the number of arguments (not including the receiver) | 1673 // -- r3 : the number of arguments (not including the receiver) |
| 1678 // -- r4 : the constructor to call (can be any Object) | 1674 // -- r4 : the constructor to call (can be any Object) |
| 1679 // -- r6 : the original constructor (either the same as the constructor or | 1675 // -- r6 : the original constructor (either the same as the constructor or |
| 1680 // the JSFunction on which new was invoked initially) | 1676 // the JSFunction on which new was invoked initially) |
| 1681 // ----------------------------------- | 1677 // ----------------------------------- |
| 1682 | 1678 |
| 1683 Label slow; | 1679 Label non_callable, non_function; |
| 1684 __ JumpIfSmi(r4, &slow); | 1680 __ JumpIfSmi(r4, &non_callable); |
| 1685 __ CompareObjectType(r4, r8, r8, JS_FUNCTION_TYPE); | 1681 __ CompareObjectType(r4, r7, r8, JS_FUNCTION_TYPE); |
| 1686 __ Jump(masm->isolate()->builtins()->ConstructFunction(), | 1682 __ Jump(masm->isolate()->builtins()->ConstructFunction(), |
| 1687 RelocInfo::CODE_TARGET, eq); | 1683 RelocInfo::CODE_TARGET, eq); |
| 1688 __ cmpi(r8, Operand(JS_FUNCTION_PROXY_TYPE)); | 1684 __ cmpi(r8, Operand(JS_FUNCTION_PROXY_TYPE)); |
| 1689 __ bne(&slow); | 1685 __ bne(&non_function); |
| 1690 | 1686 |
| 1687 // 1. Construct of function proxy. |
| 1691 // TODO(neis): This doesn't match the ES6 spec for [[Construct]] on proxies. | 1688 // TODO(neis): This doesn't match the ES6 spec for [[Construct]] on proxies. |
| 1692 __ LoadP(r4, FieldMemOperand(r4, JSFunctionProxy::kConstructTrapOffset)); | 1689 __ LoadP(r4, FieldMemOperand(r4, JSFunctionProxy::kConstructTrapOffset)); |
| 1693 __ Jump(masm->isolate()->builtins()->Call(), RelocInfo::CODE_TARGET); | 1690 __ Jump(masm->isolate()->builtins()->Call(), RelocInfo::CODE_TARGET); |
| 1694 | 1691 |
| 1695 __ bind(&slow); | 1692 // 2. Construct of something that else, which might have a [[Construct]] |
| 1693 // internal method (if not we raise an exception). |
| 1694 __ bind(&non_function); |
| 1695 // Check if target has a [[Call]] internal method. |
| 1696 // TODO(bmeurer): This shoud use IsConstructor once available. |
| 1697 __ lbz(r7, FieldMemOperand(r7, Map::kBitFieldOffset)); |
| 1698 __ TestBit(r7, Map::kIsCallable, r0); |
| 1699 __ beq(&non_callable, cr0); |
| 1700 // Overwrite the original receiver the (original) target. |
| 1701 __ ShiftLeftImm(r8, r3, Operand(kPointerSizeLog2)); |
| 1702 __ StorePX(r4, MemOperand(sp, r8)); |
| 1703 // Let the "call_as_constructor_delegate" take care of the rest. |
| 1704 __ LoadGlobalFunction(Context::CALL_AS_CONSTRUCTOR_DELEGATE_INDEX, r4); |
| 1705 __ Jump(masm->isolate()->builtins()->CallFunction(), RelocInfo::CODE_TARGET); |
| 1706 |
| 1707 // 3. Construct of something that is not callable. |
| 1708 __ bind(&non_callable); |
| 1696 { | 1709 { |
| 1697 // Determine the delegate for the target (if any). | |
| 1698 FrameAndConstantPoolScope scope(masm, StackFrame::INTERNAL); | 1710 FrameAndConstantPoolScope scope(masm, StackFrame::INTERNAL); |
| 1699 __ SmiTag(r3); | 1711 __ Push(r4); |
| 1700 __ Push(r3, r4); | 1712 __ CallRuntime(Runtime::kThrowCalledNonCallable, 1); |
| 1701 __ CallRuntime(Runtime::kGetConstructorDelegate, 1); | |
| 1702 __ mr(r4, r3); | |
| 1703 __ Pop(r3); | |
| 1704 __ SmiUntag(r3); | |
| 1705 } | 1713 } |
| 1706 // The delegate is always a regular function. | |
| 1707 __ AssertFunction(r4); | |
| 1708 __ Jump(masm->isolate()->builtins()->CallFunction(), RelocInfo::CODE_TARGET); | |
| 1709 } | 1714 } |
| 1710 | 1715 |
| 1711 | 1716 |
| 1712 // static | 1717 // static |
| 1713 void Builtins::Generate_PushArgsAndCall(MacroAssembler* masm) { | 1718 void Builtins::Generate_PushArgsAndCall(MacroAssembler* masm) { |
| 1714 // ----------- S t a t e ------------- | 1719 // ----------- S t a t e ------------- |
| 1715 // -- r3 : the number of arguments (not including the receiver) | 1720 // -- r3 : the number of arguments (not including the receiver) |
| 1716 // -- r5 : the address of the first argument to be pushed. Subsequent | 1721 // -- r5 : the address of the first argument to be pushed. Subsequent |
| 1717 // arguments should be consecutive above this, in the same order as | 1722 // arguments should be consecutive above this, in the same order as |
| 1718 // they are to be pushed onto the stack. | 1723 // they are to be pushed onto the stack. |
| (...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1892 __ bkpt(0); | 1897 __ bkpt(0); |
| 1893 } | 1898 } |
| 1894 } | 1899 } |
| 1895 | 1900 |
| 1896 | 1901 |
| 1897 #undef __ | 1902 #undef __ |
| 1898 } // namespace internal | 1903 } // namespace internal |
| 1899 } // namespace v8 | 1904 } // namespace v8 |
| 1900 | 1905 |
| 1901 #endif // V8_TARGET_ARCH_PPC | 1906 #endif // V8_TARGET_ARCH_PPC |
| OLD | NEW |