Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(61)

Side by Side Diff: src/arm64/builtins-arm64.cc

Issue 1358423002: [es6] Introduce spec compliant IsConstructor. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Address comment Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 1690 matching lines...) Expand 10 before | Expand all | Expand 10 after
1701 // Tail call to the function-specific construct stub (still in the caller 1701 // Tail call to the function-specific construct stub (still in the caller
1702 // context at this point). 1702 // context at this point).
1703 __ Ldr(x4, FieldMemOperand(x1, JSFunction::kSharedFunctionInfoOffset)); 1703 __ Ldr(x4, FieldMemOperand(x1, JSFunction::kSharedFunctionInfoOffset));
1704 __ Ldr(x4, FieldMemOperand(x4, SharedFunctionInfo::kConstructStubOffset)); 1704 __ Ldr(x4, FieldMemOperand(x4, SharedFunctionInfo::kConstructStubOffset));
1705 __ Add(x4, x4, Code::kHeaderSize - kHeapObjectTag); 1705 __ Add(x4, x4, Code::kHeaderSize - kHeapObjectTag);
1706 __ Br(x4); 1706 __ Br(x4);
1707 } 1707 }
1708 1708
1709 1709
1710 // static 1710 // static
1711 void Builtins::Generate_ConstructProxy(MacroAssembler* masm) {
1712 // ----------- S t a t e -------------
1713 // -- x0 : the number of arguments (not including the receiver)
1714 // -- x1 : the constructor to call (checked to be a JSFunctionProxy)
1715 // -- x3 : the original constructor (either the same as the constructor or
1716 // the JSFunction on which new was invoked initially)
1717 // -----------------------------------
1718
1719 // TODO(neis): This doesn't match the ES6 spec for [[Construct]] on proxies.
1720 __ Ldr(x1, FieldMemOperand(x1, JSFunctionProxy::kConstructTrapOffset));
1721 __ Jump(masm->isolate()->builtins()->Call(), RelocInfo::CODE_TARGET);
1722 }
1723
1724
1725 // static
1711 void Builtins::Generate_Construct(MacroAssembler* masm) { 1726 void Builtins::Generate_Construct(MacroAssembler* masm) {
1712 // ----------- S t a t e ------------- 1727 // ----------- S t a t e -------------
1713 // -- x0 : the number of arguments (not including the receiver) 1728 // -- x0 : the number of arguments (not including the receiver)
1714 // -- x1 : the constructor to call (can be any Object) 1729 // -- x1 : the constructor to call (can be any Object)
1715 // -- x3 : the original constructor (either the same as the constructor or 1730 // -- x3 : the original constructor (either the same as the constructor or
1716 // the JSFunction on which new was invoked initially) 1731 // the JSFunction on which new was invoked initially)
1717 // ----------------------------------- 1732 // -----------------------------------
1718 1733
1719 Label non_callable, non_function; 1734 // Check if target has a [[Construct]] internal method.
1720 __ JumpIfSmi(x1, &non_callable); 1735 Label non_constructor;
1721 __ CompareObjectType(x1, x4, x5, JS_FUNCTION_TYPE); 1736 __ JumpIfSmi(x1, &non_constructor);
1737 __ Ldr(x4, FieldMemOperand(x1, HeapObject::kMapOffset));
1738 __ Ldrb(x2, FieldMemOperand(x4, Map::kBitFieldOffset));
1739 __ TestAndBranchIfAllClear(x2, 1 << Map::kIsConstructor, &non_constructor);
1740
1741 // Dispatch based on instance type.
1742 __ CompareInstanceType(x4, x5, JS_FUNCTION_TYPE);
1722 __ Jump(masm->isolate()->builtins()->ConstructFunction(), 1743 __ Jump(masm->isolate()->builtins()->ConstructFunction(),
1723 RelocInfo::CODE_TARGET, eq); 1744 RelocInfo::CODE_TARGET, eq);
1724 __ Cmp(x5, JS_FUNCTION_PROXY_TYPE); 1745 __ Cmp(x5, JS_FUNCTION_PROXY_TYPE);
1725 __ B(ne, &non_function); 1746 __ Jump(masm->isolate()->builtins()->ConstructProxy(), RelocInfo::CODE_TARGET,
1747 eq);
1726 1748
1727 // 1. Construct of function proxy. 1749 // Called Construct on an exotic Object with a [[Construct]] internal method.
1728 // TODO(neis): This doesn't match the ES6 spec for [[Construct]] on proxies. 1750 {
1729 __ Ldr(x1, FieldMemOperand(x1, JSFunctionProxy::kConstructTrapOffset)); 1751 // Overwrite the original receiver with the (original) target.
1730 __ Jump(masm->isolate()->builtins()->Call(), RelocInfo::CODE_TARGET); 1752 __ Poke(x1, Operand(x0, LSL, kXRegSizeLog2));
1753 // Let the "call_as_constructor_delegate" take care of the rest.
1754 __ LoadGlobalFunction(Context::CALL_AS_CONSTRUCTOR_DELEGATE_INDEX, x1);
1755 __ Jump(masm->isolate()->builtins()->CallFunction(),
1756 RelocInfo::CODE_TARGET);
1757 }
1731 1758
1732 // 2. Construct of something that else, which might have a [[Construct]] 1759 // Called Construct on an Object that doesn't have a [[Construct]] internal
1733 // internal method (if not we raise an exception). 1760 // method.
1734 __ Bind(&non_function); 1761 __ bind(&non_constructor);
1735 // Check if target has a [[Call]] internal method.
1736 // TODO(bmeurer): This shoud use IsConstructor once available.
1737 __ Ldrb(x4, FieldMemOperand(x4, Map::kBitFieldOffset));
1738 __ TestAndBranchIfAllClear(x4, 1 << Map::kIsCallable, &non_callable);
1739 // Overwrite the original receiver with the (original) target.
1740 __ Poke(x1, Operand(x0, LSL, kXRegSizeLog2));
1741 // Let the "call_as_constructor_delegate" take care of the rest.
1742 __ LoadGlobalFunction(Context::CALL_AS_CONSTRUCTOR_DELEGATE_INDEX, x1);
1743 __ Jump(masm->isolate()->builtins()->CallFunction(), RelocInfo::CODE_TARGET);
1744
1745 // 3. Construct of something that is not callable.
1746 __ bind(&non_callable);
1747 { 1762 {
1748 FrameScope scope(masm, StackFrame::INTERNAL); 1763 FrameScope scope(masm, StackFrame::INTERNAL);
1749 __ Push(x1); 1764 __ Push(x1);
1750 __ CallRuntime(Runtime::kThrowCalledNonCallable, 1); 1765 __ CallRuntime(Runtime::kThrowCalledNonCallable, 1);
1751 } 1766 }
1752 } 1767 }
1753 1768
1754 1769
1755 // static 1770 // static
1756 void Builtins::Generate_PushArgsAndCall(MacroAssembler* masm) { 1771 void Builtins::Generate_PushArgsAndCall(MacroAssembler* masm) {
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
1952 } 1967 }
1953 } 1968 }
1954 1969
1955 1970
1956 #undef __ 1971 #undef __
1957 1972
1958 } // namespace internal 1973 } // namespace internal
1959 } // namespace v8 1974 } // namespace v8
1960 1975
1961 #endif // V8_TARGET_ARCH_ARM 1976 #endif // V8_TARGET_ARCH_ARM
OLDNEW
« no previous file with comments | « src/arm/builtins-arm.cc ('k') | src/bootstrapper.cc » ('j') | src/mips/builtins-mips.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698