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 1650 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1661 // Tail call to the function-specific construct stub (still in the caller | 1661 // Tail call to the function-specific construct stub (still in the caller |
1662 // context at this point). | 1662 // context at this point). |
1663 __ LoadP(r7, FieldMemOperand(r4, JSFunction::kSharedFunctionInfoOffset)); | 1663 __ LoadP(r7, FieldMemOperand(r4, JSFunction::kSharedFunctionInfoOffset)); |
1664 __ LoadP(r7, FieldMemOperand(r7, SharedFunctionInfo::kConstructStubOffset)); | 1664 __ LoadP(r7, FieldMemOperand(r7, SharedFunctionInfo::kConstructStubOffset)); |
1665 __ addi(ip, r7, Operand(Code::kHeaderSize - kHeapObjectTag)); | 1665 __ addi(ip, r7, Operand(Code::kHeaderSize - kHeapObjectTag)); |
1666 __ JumpToJSEntry(ip); | 1666 __ JumpToJSEntry(ip); |
1667 } | 1667 } |
1668 | 1668 |
1669 | 1669 |
1670 // static | 1670 // static |
| 1671 void Builtins::Generate_ConstructProxy(MacroAssembler* masm) { |
| 1672 // ----------- S t a t e ------------- |
| 1673 // -- r3 : the number of arguments (not including the receiver) |
| 1674 // -- r4 : the constructor to call (checked to be a JSFunctionProxy) |
| 1675 // -- r6 : the original constructor (either the same as the constructor or |
| 1676 // the JSFunction on which new was invoked initially) |
| 1677 // ----------------------------------- |
| 1678 |
| 1679 // TODO(neis): This doesn't match the ES6 spec for [[Construct]] on proxies. |
| 1680 __ LoadP(r4, FieldMemOperand(r4, JSFunctionProxy::kConstructTrapOffset)); |
| 1681 __ Jump(masm->isolate()->builtins()->Call(), RelocInfo::CODE_TARGET); |
| 1682 } |
| 1683 |
| 1684 |
| 1685 // static |
1671 void Builtins::Generate_Construct(MacroAssembler* masm) { | 1686 void Builtins::Generate_Construct(MacroAssembler* masm) { |
1672 // ----------- S t a t e ------------- | 1687 // ----------- S t a t e ------------- |
1673 // -- r3 : the number of arguments (not including the receiver) | 1688 // -- r3 : the number of arguments (not including the receiver) |
1674 // -- r4 : the constructor to call (can be any Object) | 1689 // -- r4 : the constructor to call (can be any Object) |
1675 // -- r6 : the original constructor (either the same as the constructor or | 1690 // -- r6 : the original constructor (either the same as the constructor or |
1676 // the JSFunction on which new was invoked initially) | 1691 // the JSFunction on which new was invoked initially) |
1677 // ----------------------------------- | 1692 // ----------------------------------- |
1678 | 1693 |
1679 Label non_callable, non_function; | 1694 // Check if target has a [[Construct]] internal method. |
1680 __ JumpIfSmi(r4, &non_callable); | 1695 Label non_constructor; |
1681 __ CompareObjectType(r4, r7, r8, JS_FUNCTION_TYPE); | 1696 __ JumpIfSmi(r4, &non_constructor); |
| 1697 __ LoadP(r7, FieldMemOperand(r4, HeapObject::kMapOffset)); |
| 1698 __ lbz(r5, FieldMemOperand(r7, Map::kBitFieldOffset)); |
| 1699 __ TestBit(r5, Map::kIsConstructor, r0); |
| 1700 __ beq(&non_constructor, cr0); |
| 1701 |
| 1702 // Dispatch based on instance type. |
| 1703 __ CompareInstanceType(r7, r8, JS_FUNCTION_TYPE); |
1682 __ Jump(masm->isolate()->builtins()->ConstructFunction(), | 1704 __ Jump(masm->isolate()->builtins()->ConstructFunction(), |
1683 RelocInfo::CODE_TARGET, eq); | 1705 RelocInfo::CODE_TARGET, eq); |
1684 __ cmpi(r8, Operand(JS_FUNCTION_PROXY_TYPE)); | 1706 __ cmpi(r8, Operand(JS_FUNCTION_PROXY_TYPE)); |
1685 __ bne(&non_function); | 1707 __ Jump(masm->isolate()->builtins()->ConstructProxy(), RelocInfo::CODE_TARGET, |
| 1708 eq); |
1686 | 1709 |
1687 // 1. Construct of function proxy. | 1710 // Called Construct on an exotic Object with a [[Construct]] internal method. |
1688 // TODO(neis): This doesn't match the ES6 spec for [[Construct]] on proxies. | 1711 { |
1689 __ LoadP(r4, FieldMemOperand(r4, JSFunctionProxy::kConstructTrapOffset)); | 1712 // Overwrite the original receiver with the (original) target. |
1690 __ Jump(masm->isolate()->builtins()->Call(), RelocInfo::CODE_TARGET); | 1713 __ ShiftLeftImm(r8, r3, Operand(kPointerSizeLog2)); |
| 1714 __ StorePX(r4, MemOperand(sp, r8)); |
| 1715 // Let the "call_as_constructor_delegate" take care of the rest. |
| 1716 __ LoadGlobalFunction(Context::CALL_AS_CONSTRUCTOR_DELEGATE_INDEX, r4); |
| 1717 __ Jump(masm->isolate()->builtins()->CallFunction(), |
| 1718 RelocInfo::CODE_TARGET); |
| 1719 } |
1691 | 1720 |
1692 // 2. Construct of something that else, which might have a [[Construct]] | 1721 // Called Construct on an Object that doesn't have a [[Construct]] internal |
1693 // internal method (if not we raise an exception). | 1722 // method. |
1694 __ bind(&non_function); | 1723 __ bind(&non_constructor); |
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); | |
1709 { | 1724 { |
1710 FrameAndConstantPoolScope scope(masm, StackFrame::INTERNAL); | 1725 FrameAndConstantPoolScope scope(masm, StackFrame::INTERNAL); |
1711 __ Push(r4); | 1726 __ Push(r4); |
1712 __ CallRuntime(Runtime::kThrowCalledNonCallable, 1); | 1727 __ CallRuntime(Runtime::kThrowCalledNonCallable, 1); |
1713 } | 1728 } |
1714 } | 1729 } |
1715 | 1730 |
1716 | 1731 |
1717 // static | 1732 // static |
1718 void Builtins::Generate_PushArgsAndCall(MacroAssembler* masm) { | 1733 void Builtins::Generate_PushArgsAndCall(MacroAssembler* masm) { |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1897 __ bkpt(0); | 1912 __ bkpt(0); |
1898 } | 1913 } |
1899 } | 1914 } |
1900 | 1915 |
1901 | 1916 |
1902 #undef __ | 1917 #undef __ |
1903 } // namespace internal | 1918 } // namespace internal |
1904 } // namespace v8 | 1919 } // namespace v8 |
1905 | 1920 |
1906 #endif // V8_TARGET_ARCH_PPC | 1921 #endif // V8_TARGET_ARCH_PPC |
OLD | NEW |