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_ARM | 5 #if V8_TARGET_ARCH_ARM |
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 1618 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1629 | 1629 |
1630 // Tail call to the function-specific construct stub (still in the caller | 1630 // Tail call to the function-specific construct stub (still in the caller |
1631 // context at this point). | 1631 // context at this point). |
1632 __ ldr(r4, FieldMemOperand(r1, JSFunction::kSharedFunctionInfoOffset)); | 1632 __ ldr(r4, FieldMemOperand(r1, JSFunction::kSharedFunctionInfoOffset)); |
1633 __ ldr(r4, FieldMemOperand(r4, SharedFunctionInfo::kConstructStubOffset)); | 1633 __ ldr(r4, FieldMemOperand(r4, SharedFunctionInfo::kConstructStubOffset)); |
1634 __ add(pc, r4, Operand(Code::kHeaderSize - kHeapObjectTag)); | 1634 __ add(pc, r4, Operand(Code::kHeaderSize - kHeapObjectTag)); |
1635 } | 1635 } |
1636 | 1636 |
1637 | 1637 |
1638 // static | 1638 // static |
| 1639 void Builtins::Generate_ConstructProxy(MacroAssembler* masm) { |
| 1640 // ----------- S t a t e ------------- |
| 1641 // -- r0 : the number of arguments (not including the receiver) |
| 1642 // -- r1 : the constructor to call (checked to be a JSFunctionProxy) |
| 1643 // -- r3 : the original constructor (either the same as the constructor or |
| 1644 // the JSFunction on which new was invoked initially) |
| 1645 // ----------------------------------- |
| 1646 |
| 1647 // TODO(neis): This doesn't match the ES6 spec for [[Construct]] on proxies. |
| 1648 __ ldr(r1, FieldMemOperand(r1, JSFunctionProxy::kConstructTrapOffset)); |
| 1649 __ Jump(masm->isolate()->builtins()->Call(), RelocInfo::CODE_TARGET); |
| 1650 } |
| 1651 |
| 1652 |
| 1653 // static |
1639 void Builtins::Generate_Construct(MacroAssembler* masm) { | 1654 void Builtins::Generate_Construct(MacroAssembler* masm) { |
1640 // ----------- S t a t e ------------- | 1655 // ----------- S t a t e ------------- |
1641 // -- r0 : the number of arguments (not including the receiver) | 1656 // -- r0 : the number of arguments (not including the receiver) |
1642 // -- r1 : the constructor to call (can be any Object) | 1657 // -- r1 : the constructor to call (can be any Object) |
1643 // -- r3 : the original constructor (either the same as the constructor or | 1658 // -- r3 : the original constructor (either the same as the constructor or |
1644 // the JSFunction on which new was invoked initially) | 1659 // the JSFunction on which new was invoked initially) |
1645 // ----------------------------------- | 1660 // ----------------------------------- |
1646 | 1661 |
1647 Label non_callable, non_function; | 1662 // Check if target has a [[Construct]] internal method. |
1648 __ JumpIfSmi(r1, &non_callable); | 1663 Label non_constructor; |
1649 __ CompareObjectType(r1, r4, r5, JS_FUNCTION_TYPE); | 1664 __ JumpIfSmi(r1, &non_constructor); |
| 1665 __ ldr(r4, FieldMemOperand(r1, HeapObject::kMapOffset)); |
| 1666 __ ldrb(r2, FieldMemOperand(r4, Map::kBitFieldOffset)); |
| 1667 __ tst(r2, Operand(1 << Map::kIsConstructor)); |
| 1668 __ b(eq, &non_constructor); |
| 1669 |
| 1670 // Dispatch based on instance type. |
| 1671 __ CompareInstanceType(r4, r5, JS_FUNCTION_TYPE); |
1650 __ Jump(masm->isolate()->builtins()->ConstructFunction(), | 1672 __ Jump(masm->isolate()->builtins()->ConstructFunction(), |
1651 RelocInfo::CODE_TARGET, eq); | 1673 RelocInfo::CODE_TARGET, eq); |
1652 __ cmp(r5, Operand(JS_FUNCTION_PROXY_TYPE)); | 1674 __ cmp(r5, Operand(JS_FUNCTION_PROXY_TYPE)); |
1653 __ b(ne, &non_function); | 1675 __ Jump(masm->isolate()->builtins()->ConstructProxy(), RelocInfo::CODE_TARGET, |
| 1676 eq); |
1654 | 1677 |
1655 // 1. Construct of function proxy. | 1678 // Called Construct on an exotic Object with a [[Construct]] internal method. |
1656 // TODO(neis): This doesn't match the ES6 spec for [[Construct]] on proxies. | 1679 { |
1657 __ ldr(r1, FieldMemOperand(r1, JSFunctionProxy::kConstructTrapOffset)); | 1680 // Overwrite the original receiver with the (original) target. |
1658 __ Jump(masm->isolate()->builtins()->Call(), RelocInfo::CODE_TARGET); | 1681 __ str(r1, MemOperand(sp, r0, LSL, kPointerSizeLog2)); |
| 1682 // Let the "call_as_constructor_delegate" take care of the rest. |
| 1683 __ LoadGlobalFunction(Context::CALL_AS_CONSTRUCTOR_DELEGATE_INDEX, r1); |
| 1684 __ Jump(masm->isolate()->builtins()->CallFunction(), |
| 1685 RelocInfo::CODE_TARGET); |
| 1686 } |
1659 | 1687 |
1660 // 2. Construct of something that else, which might have a [[Construct]] | 1688 // Called Construct on an Object that doesn't have a [[Construct]] internal |
1661 // internal method (if not we raise an exception). | 1689 // method. |
1662 __ bind(&non_function); | 1690 __ bind(&non_constructor); |
1663 // Check if target has a [[Call]] internal method. | |
1664 // TODO(bmeurer): This shoud use IsConstructor once available. | |
1665 __ ldrb(r4, FieldMemOperand(r4, Map::kBitFieldOffset)); | |
1666 __ tst(r4, Operand(1 << Map::kIsCallable)); | |
1667 __ b(eq, &non_callable); | |
1668 // Overwrite the original receiver the (original) target. | |
1669 __ str(r1, MemOperand(sp, r0, LSL, kPointerSizeLog2)); | |
1670 // Let the "call_as_constructor_delegate" take care of the rest. | |
1671 __ LoadGlobalFunction(Context::CALL_AS_CONSTRUCTOR_DELEGATE_INDEX, r1); | |
1672 __ Jump(masm->isolate()->builtins()->CallFunction(), RelocInfo::CODE_TARGET); | |
1673 | |
1674 // 3. Construct of something that is not callable. | |
1675 __ bind(&non_callable); | |
1676 { | 1691 { |
1677 FrameAndConstantPoolScope scope(masm, StackFrame::INTERNAL); | 1692 FrameAndConstantPoolScope scope(masm, StackFrame::INTERNAL); |
1678 __ Push(r1); | 1693 __ Push(r1); |
1679 __ CallRuntime(Runtime::kThrowCalledNonCallable, 1); | 1694 __ CallRuntime(Runtime::kThrowCalledNonCallable, 1); |
1680 } | 1695 } |
1681 } | 1696 } |
1682 | 1697 |
1683 | 1698 |
1684 // static | 1699 // static |
1685 void Builtins::Generate_PushArgsAndCall(MacroAssembler* masm) { | 1700 void Builtins::Generate_PushArgsAndCall(MacroAssembler* masm) { |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1853 } | 1868 } |
1854 } | 1869 } |
1855 | 1870 |
1856 | 1871 |
1857 #undef __ | 1872 #undef __ |
1858 | 1873 |
1859 } // namespace internal | 1874 } // namespace internal |
1860 } // namespace v8 | 1875 } // namespace v8 |
1861 | 1876 |
1862 #endif // V8_TARGET_ARCH_ARM | 1877 #endif // V8_TARGET_ARCH_ARM |
OLD | NEW |