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 1731 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1742 | 1742 |
1743 // static | 1743 // static |
1744 void Builtins::Generate_ConstructProxy(MacroAssembler* masm) { | 1744 void Builtins::Generate_ConstructProxy(MacroAssembler* masm) { |
1745 // ----------- S t a t e ------------- | 1745 // ----------- S t a t e ------------- |
1746 // -- r0 : the number of arguments (not including the receiver) | 1746 // -- r0 : the number of arguments (not including the receiver) |
1747 // -- r1 : the constructor to call (checked to be a JSProxy) | 1747 // -- r1 : the constructor to call (checked to be a JSProxy) |
1748 // -- r3 : the new target (either the same as the constructor or | 1748 // -- r3 : the new target (either the same as the constructor or |
1749 // the JSFunction on which new was invoked initially) | 1749 // the JSFunction on which new was invoked initially) |
1750 // ----------------------------------- | 1750 // ----------------------------------- |
1751 | 1751 |
1752 // TODO(neis): This doesn't match the ES6 spec for [[Construct]] on proxies. | 1752 // Call into the Runtime for Proxy [[Construct]]. |
1753 __ Jump(masm->isolate()->builtins()->Call(), RelocInfo::CODE_TARGET); | 1753 __ Push(r1); |
| 1754 __ Push(r3); |
| 1755 // Include the pushed new_target, constructor and the receiver. |
| 1756 __ add(r0, r0, Operand(3)); |
| 1757 // Tail-call to the runtime. |
| 1758 __ JumpToExternalReference( |
| 1759 ExternalReference(Runtime::kJSProxyConstruct, masm->isolate())); |
1754 } | 1760 } |
1755 | 1761 |
1756 | 1762 |
1757 // static | 1763 // static |
1758 void Builtins::Generate_Construct(MacroAssembler* masm) { | 1764 void Builtins::Generate_Construct(MacroAssembler* masm) { |
1759 // ----------- S t a t e ------------- | 1765 // ----------- S t a t e ------------- |
1760 // -- r0 : the number of arguments (not including the receiver) | 1766 // -- r0 : the number of arguments (not including the receiver) |
1761 // -- r1 : the constructor to call (can be any Object) | 1767 // -- r1 : the constructor to call (can be any Object) |
1762 // -- r3 : the new target (either the same as the constructor or | 1768 // -- r3 : the new target (either the same as the constructor or |
1763 // the JSFunction on which new was invoked initially) | 1769 // the JSFunction on which new was invoked initially) |
1764 // ----------------------------------- | 1770 // ----------------------------------- |
1765 | 1771 |
1766 // Check if target is a Smi. | 1772 // Check if target is a Smi. |
1767 Label non_constructor; | 1773 Label non_constructor; |
1768 __ JumpIfSmi(r1, &non_constructor); | 1774 __ JumpIfSmi(r1, &non_constructor); |
1769 | 1775 |
1770 // Dispatch based on instance type. | 1776 // Dispatch based on instance type. |
1771 __ CompareObjectType(r1, r4, r5, JS_FUNCTION_TYPE); | 1777 __ CompareObjectType(r1, r4, r5, JS_FUNCTION_TYPE); |
1772 __ Jump(masm->isolate()->builtins()->ConstructFunction(), | 1778 __ Jump(masm->isolate()->builtins()->ConstructFunction(), |
1773 RelocInfo::CODE_TARGET, eq); | 1779 RelocInfo::CODE_TARGET, eq); |
1774 __ cmp(r5, Operand(JS_PROXY_TYPE)); | |
1775 __ Jump(masm->isolate()->builtins()->ConstructProxy(), RelocInfo::CODE_TARGET, | |
1776 eq); | |
1777 | 1780 |
1778 // Check if target has a [[Construct]] internal method. | 1781 // Check if target has a [[Construct]] internal method. |
1779 __ ldrb(r2, FieldMemOperand(r4, Map::kBitFieldOffset)); | 1782 __ ldrb(r2, FieldMemOperand(r4, Map::kBitFieldOffset)); |
1780 __ tst(r2, Operand(1 << Map::kIsConstructor)); | 1783 __ tst(r2, Operand(1 << Map::kIsConstructor)); |
1781 __ b(eq, &non_constructor); | 1784 __ b(eq, &non_constructor); |
1782 | 1785 |
| 1786 // Only dispatch to proxies after checking whether they are constructors. |
| 1787 __ cmp(r5, Operand(JS_PROXY_TYPE)); |
| 1788 __ Jump(masm->isolate()->builtins()->ConstructProxy(), RelocInfo::CODE_TARGET, |
| 1789 eq); |
| 1790 |
1783 // Called Construct on an exotic Object with a [[Construct]] internal method. | 1791 // Called Construct on an exotic Object with a [[Construct]] internal method. |
1784 { | 1792 { |
1785 // Overwrite the original receiver with the (original) target. | 1793 // Overwrite the original receiver with the (original) target. |
1786 __ str(r1, MemOperand(sp, r0, LSL, kPointerSizeLog2)); | 1794 __ str(r1, MemOperand(sp, r0, LSL, kPointerSizeLog2)); |
1787 // Let the "call_as_constructor_delegate" take care of the rest. | 1795 // Let the "call_as_constructor_delegate" take care of the rest. |
1788 __ LoadNativeContextSlot(Context::CALL_AS_CONSTRUCTOR_DELEGATE_INDEX, r1); | 1796 __ LoadNativeContextSlot(Context::CALL_AS_CONSTRUCTOR_DELEGATE_INDEX, r1); |
1789 __ Jump(masm->isolate()->builtins()->CallFunction(), | 1797 __ Jump(masm->isolate()->builtins()->CallFunction(), |
1790 RelocInfo::CODE_TARGET); | 1798 RelocInfo::CODE_TARGET); |
1791 } | 1799 } |
1792 | 1800 |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1943 } | 1951 } |
1944 } | 1952 } |
1945 | 1953 |
1946 | 1954 |
1947 #undef __ | 1955 #undef __ |
1948 | 1956 |
1949 } // namespace internal | 1957 } // namespace internal |
1950 } // namespace v8 | 1958 } // namespace v8 |
1951 | 1959 |
1952 #endif // V8_TARGET_ARCH_ARM | 1960 #endif // V8_TARGET_ARCH_ARM |
OLD | NEW |