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

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: Fix stupid fuzzer failure (constructor bit set on sloppy/strict arguments). Fix MIPS/MIPS64 typos, … 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
« no previous file with comments | « src/arm/builtins-arm.cc ('k') | src/bootstrapper.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 1675 matching lines...) Expand 10 before | Expand all | Expand 10 after
1686 // Tail call to the function-specific construct stub (still in the caller 1686 // Tail call to the function-specific construct stub (still in the caller
1687 // context at this point). 1687 // context at this point).
1688 __ Ldr(x4, FieldMemOperand(x1, JSFunction::kSharedFunctionInfoOffset)); 1688 __ Ldr(x4, FieldMemOperand(x1, JSFunction::kSharedFunctionInfoOffset));
1689 __ Ldr(x4, FieldMemOperand(x4, SharedFunctionInfo::kConstructStubOffset)); 1689 __ Ldr(x4, FieldMemOperand(x4, SharedFunctionInfo::kConstructStubOffset));
1690 __ Add(x4, x4, Code::kHeaderSize - kHeapObjectTag); 1690 __ Add(x4, x4, Code::kHeaderSize - kHeapObjectTag);
1691 __ Br(x4); 1691 __ Br(x4);
1692 } 1692 }
1693 1693
1694 1694
1695 // static 1695 // static
1696 void Builtins::Generate_ConstructProxy(MacroAssembler* masm) {
1697 // ----------- S t a t e -------------
1698 // -- x0 : the number of arguments (not including the receiver)
1699 // -- x1 : the constructor to call (checked to be a JSFunctionProxy)
1700 // -- x3 : the original constructor (either the same as the constructor or
1701 // the JSFunction on which new was invoked initially)
1702 // -----------------------------------
1703
1704 // TODO(neis): This doesn't match the ES6 spec for [[Construct]] on proxies.
1705 __ Ldr(x1, FieldMemOperand(x1, JSFunctionProxy::kConstructTrapOffset));
1706 __ Jump(masm->isolate()->builtins()->Call(), RelocInfo::CODE_TARGET);
1707 }
1708
1709
1710 // static
1696 void Builtins::Generate_Construct(MacroAssembler* masm) { 1711 void Builtins::Generate_Construct(MacroAssembler* masm) {
1697 // ----------- S t a t e ------------- 1712 // ----------- S t a t e -------------
1698 // -- x0 : the number of arguments (not including the receiver) 1713 // -- x0 : the number of arguments (not including the receiver)
1699 // -- x1 : the constructor to call (can be any Object) 1714 // -- x1 : the constructor to call (can be any Object)
1700 // -- x3 : the original constructor (either the same as the constructor or 1715 // -- x3 : the original constructor (either the same as the constructor or
1701 // the JSFunction on which new was invoked initially) 1716 // the JSFunction on which new was invoked initially)
1702 // ----------------------------------- 1717 // -----------------------------------
1703 1718
1704 Label non_callable, non_function; 1719 // Check if target has a [[Construct]] internal method.
1705 __ JumpIfSmi(x1, &non_callable); 1720 Label non_constructor;
1706 __ CompareObjectType(x1, x4, x5, JS_FUNCTION_TYPE); 1721 __ JumpIfSmi(x1, &non_constructor);
1722 __ Ldr(x4, FieldMemOperand(x1, HeapObject::kMapOffset));
1723 __ Ldrb(x2, FieldMemOperand(x4, Map::kBitFieldOffset));
1724 __ TestAndBranchIfAllClear(x2, 1 << Map::kIsConstructor, &non_constructor);
1725
1726 // Dispatch based on instance type.
1727 __ CompareInstanceType(x4, x5, JS_FUNCTION_TYPE);
1707 __ Jump(masm->isolate()->builtins()->ConstructFunction(), 1728 __ Jump(masm->isolate()->builtins()->ConstructFunction(),
1708 RelocInfo::CODE_TARGET, eq); 1729 RelocInfo::CODE_TARGET, eq);
1709 __ Cmp(x5, JS_FUNCTION_PROXY_TYPE); 1730 __ Cmp(x5, JS_FUNCTION_PROXY_TYPE);
1710 __ B(ne, &non_function); 1731 __ Jump(masm->isolate()->builtins()->ConstructProxy(), RelocInfo::CODE_TARGET,
1732 eq);
1711 1733
1712 // 1. Construct of function proxy. 1734 // Called Construct on an exotic Object with a [[Construct]] internal method.
1713 // TODO(neis): This doesn't match the ES6 spec for [[Construct]] on proxies. 1735 {
1714 __ Ldr(x1, FieldMemOperand(x1, JSFunctionProxy::kConstructTrapOffset)); 1736 // Overwrite the original receiver with the (original) target.
1715 __ Jump(masm->isolate()->builtins()->Call(), RelocInfo::CODE_TARGET); 1737 __ Poke(x1, Operand(x0, LSL, kXRegSizeLog2));
1738 // Let the "call_as_constructor_delegate" take care of the rest.
1739 __ LoadGlobalFunction(Context::CALL_AS_CONSTRUCTOR_DELEGATE_INDEX, x1);
1740 __ Jump(masm->isolate()->builtins()->CallFunction(),
1741 RelocInfo::CODE_TARGET);
1742 }
1716 1743
1717 // 2. Construct of something that else, which might have a [[Construct]] 1744 // Called Construct on an Object that doesn't have a [[Construct]] internal
1718 // internal method (if not we raise an exception). 1745 // method.
1719 __ Bind(&non_function); 1746 __ bind(&non_constructor);
1720 // Check if target has a [[Call]] internal method.
1721 // TODO(bmeurer): This shoud use IsConstructor once available.
1722 __ Ldrb(x4, FieldMemOperand(x4, Map::kBitFieldOffset));
1723 __ TestAndBranchIfAllClear(x4, 1 << Map::kIsCallable, &non_callable);
1724 // Overwrite the original receiver with the (original) target.
1725 __ Poke(x1, Operand(x0, LSL, kXRegSizeLog2));
1726 // Let the "call_as_constructor_delegate" take care of the rest.
1727 __ LoadGlobalFunction(Context::CALL_AS_CONSTRUCTOR_DELEGATE_INDEX, x1);
1728 __ Jump(masm->isolate()->builtins()->CallFunction(), RelocInfo::CODE_TARGET);
1729
1730 // 3. Construct of something that is not callable.
1731 __ bind(&non_callable);
1732 { 1747 {
1733 FrameScope scope(masm, StackFrame::INTERNAL); 1748 FrameScope scope(masm, StackFrame::INTERNAL);
1734 __ Push(x1); 1749 __ Push(x1);
1735 __ CallRuntime(Runtime::kThrowCalledNonCallable, 1); 1750 __ CallRuntime(Runtime::kThrowCalledNonCallable, 1);
1736 } 1751 }
1737 } 1752 }
1738 1753
1739 1754
1740 // static 1755 // static
1741 void Builtins::Generate_PushArgsAndCall(MacroAssembler* masm) { 1756 void Builtins::Generate_PushArgsAndCall(MacroAssembler* masm) {
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
1937 } 1952 }
1938 } 1953 }
1939 1954
1940 1955
1941 #undef __ 1956 #undef __
1942 1957
1943 } // namespace internal 1958 } // namespace internal
1944 } // namespace v8 1959 } // namespace v8
1945 1960
1946 #endif // V8_TARGET_ARCH_ARM 1961 #endif // V8_TARGET_ARCH_ARM
OLDNEW
« no previous file with comments | « src/arm/builtins-arm.cc ('k') | src/bootstrapper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698