| OLD | NEW |
| 1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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_ARM64 | 5 #if V8_TARGET_ARCH_ARM64 |
| 6 | 6 |
| 7 #include "src/arm64/frames-arm64.h" | 7 #include "src/arm64/frames-arm64.h" |
| 8 #include "src/codegen.h" | 8 #include "src/codegen.h" |
| 9 #include "src/debug/debug.h" | 9 #include "src/debug/debug.h" |
| 10 #include "src/deoptimizer.h" | 10 #include "src/deoptimizer.h" |
| (...skipping 1723 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1734 | 1734 |
| 1735 // static | 1735 // static |
| 1736 void Builtins::Generate_ConstructProxy(MacroAssembler* masm) { | 1736 void Builtins::Generate_ConstructProxy(MacroAssembler* masm) { |
| 1737 // ----------- S t a t e ------------- | 1737 // ----------- S t a t e ------------- |
| 1738 // -- x0 : the number of arguments (not including the receiver) | 1738 // -- x0 : the number of arguments (not including the receiver) |
| 1739 // -- x1 : the constructor to call (checked to be a JSProxy) | 1739 // -- x1 : the constructor to call (checked to be a JSProxy) |
| 1740 // -- x3 : the new target (either the same as the constructor or | 1740 // -- x3 : the new target (either the same as the constructor or |
| 1741 // the JSFunction on which new was invoked initially) | 1741 // the JSFunction on which new was invoked initially) |
| 1742 // ----------------------------------- | 1742 // ----------------------------------- |
| 1743 | 1743 |
| 1744 // TODO(neis): This doesn't match the ES6 spec for [[Construct]] on proxies. | 1744 // Call into the Runtime for Proxy [[Construct]]. |
| 1745 __ Jump(masm->isolate()->builtins()->Call(), RelocInfo::CODE_TARGET); | 1745 __ Push(x1); |
| 1746 __ Push(x3); |
| 1747 // Include the pushed new_target, constructor and the receiver. |
| 1748 __ Add(x0, x0, 3); |
| 1749 // Tail-call to the runtime. |
| 1750 __ JumpToExternalReference( |
| 1751 ExternalReference(Runtime::kJSProxyConstruct, masm->isolate())); |
| 1746 } | 1752 } |
| 1747 | 1753 |
| 1748 | 1754 |
| 1749 // static | 1755 // static |
| 1750 void Builtins::Generate_Construct(MacroAssembler* masm) { | 1756 void Builtins::Generate_Construct(MacroAssembler* masm) { |
| 1751 // ----------- S t a t e ------------- | 1757 // ----------- S t a t e ------------- |
| 1752 // -- x0 : the number of arguments (not including the receiver) | 1758 // -- x0 : the number of arguments (not including the receiver) |
| 1753 // -- x1 : the constructor to call (can be any Object) | 1759 // -- x1 : the constructor to call (can be any Object) |
| 1754 // -- x3 : the new target (either the same as the constructor or | 1760 // -- x3 : the new target (either the same as the constructor or |
| 1755 // the JSFunction on which new was invoked initially) | 1761 // the JSFunction on which new was invoked initially) |
| 1756 // ----------------------------------- | 1762 // ----------------------------------- |
| 1757 | 1763 |
| 1758 // Check if target is a Smi. | 1764 // Check if target is a Smi. |
| 1759 Label non_constructor; | 1765 Label non_constructor; |
| 1760 __ JumpIfSmi(x1, &non_constructor); | 1766 __ JumpIfSmi(x1, &non_constructor); |
| 1761 | 1767 |
| 1762 // Dispatch based on instance type. | 1768 // Dispatch based on instance type. |
| 1763 __ CompareObjectType(x1, x4, x5, JS_FUNCTION_TYPE); | 1769 __ CompareObjectType(x1, x4, x5, JS_FUNCTION_TYPE); |
| 1764 __ Jump(masm->isolate()->builtins()->ConstructFunction(), | 1770 __ Jump(masm->isolate()->builtins()->ConstructFunction(), |
| 1765 RelocInfo::CODE_TARGET, eq); | 1771 RelocInfo::CODE_TARGET, eq); |
| 1766 __ Cmp(x5, JS_PROXY_TYPE); | |
| 1767 __ Jump(masm->isolate()->builtins()->ConstructProxy(), RelocInfo::CODE_TARGET, | |
| 1768 eq); | |
| 1769 | 1772 |
| 1770 // Check if target has a [[Construct]] internal method. | 1773 // Check if target has a [[Construct]] internal method. |
| 1771 __ Ldrb(x2, FieldMemOperand(x4, Map::kBitFieldOffset)); | 1774 __ Ldrb(x2, FieldMemOperand(x4, Map::kBitFieldOffset)); |
| 1772 __ TestAndBranchIfAllClear(x2, 1 << Map::kIsConstructor, &non_constructor); | 1775 __ TestAndBranchIfAllClear(x2, 1 << Map::kIsConstructor, &non_constructor); |
| 1773 | 1776 |
| 1777 // Only dispatch to proxies after checking whether they are constructors. |
| 1778 __ Cmp(x5, JS_PROXY_TYPE); |
| 1779 __ Jump(masm->isolate()->builtins()->ConstructProxy(), RelocInfo::CODE_TARGET, |
| 1780 eq); |
| 1781 |
| 1774 // Called Construct on an exotic Object with a [[Construct]] internal method. | 1782 // Called Construct on an exotic Object with a [[Construct]] internal method. |
| 1775 { | 1783 { |
| 1776 // Overwrite the original receiver with the (original) target. | 1784 // Overwrite the original receiver with the (original) target. |
| 1777 __ Poke(x1, Operand(x0, LSL, kXRegSizeLog2)); | 1785 __ Poke(x1, Operand(x0, LSL, kXRegSizeLog2)); |
| 1778 // Let the "call_as_constructor_delegate" take care of the rest. | 1786 // Let the "call_as_constructor_delegate" take care of the rest. |
| 1779 __ LoadNativeContextSlot(Context::CALL_AS_CONSTRUCTOR_DELEGATE_INDEX, x1); | 1787 __ LoadNativeContextSlot(Context::CALL_AS_CONSTRUCTOR_DELEGATE_INDEX, x1); |
| 1780 __ Jump(masm->isolate()->builtins()->CallFunction(), | 1788 __ Jump(masm->isolate()->builtins()->CallFunction(), |
| 1781 RelocInfo::CODE_TARGET); | 1789 RelocInfo::CODE_TARGET); |
| 1782 } | 1790 } |
| 1783 | 1791 |
| (...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2028 } | 2036 } |
| 2029 } | 2037 } |
| 2030 | 2038 |
| 2031 | 2039 |
| 2032 #undef __ | 2040 #undef __ |
| 2033 | 2041 |
| 2034 } // namespace internal | 2042 } // namespace internal |
| 2035 } // namespace v8 | 2043 } // namespace v8 |
| 2036 | 2044 |
| 2037 #endif // V8_TARGET_ARCH_ARM | 2045 #endif // V8_TARGET_ARCH_ARM |
| OLD | NEW |