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

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

Issue 1358423002: [es6] Introduce spec compliant IsConstructor. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 3 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 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 1628 matching lines...) Expand 10 before | Expand all | Expand 10 after
1639 1639
1640 // Tail call to the function-specific construct stub (still in the caller 1640 // Tail call to the function-specific construct stub (still in the caller
1641 // context at this point). 1641 // context at this point).
1642 __ ldr(r4, FieldMemOperand(r1, JSFunction::kSharedFunctionInfoOffset)); 1642 __ ldr(r4, FieldMemOperand(r1, JSFunction::kSharedFunctionInfoOffset));
1643 __ ldr(r4, FieldMemOperand(r4, SharedFunctionInfo::kConstructStubOffset)); 1643 __ ldr(r4, FieldMemOperand(r4, SharedFunctionInfo::kConstructStubOffset));
1644 __ add(pc, r4, Operand(Code::kHeaderSize - kHeapObjectTag)); 1644 __ add(pc, r4, Operand(Code::kHeaderSize - kHeapObjectTag));
1645 } 1645 }
1646 1646
1647 1647
1648 // static 1648 // static
1649 void Builtins::Generate_ConstructProxy(MacroAssembler* masm) {
1650 // ----------- S t a t e -------------
1651 // -- r0 : the number of arguments (not including the receiver)
1652 // -- r1 : the constructor to call (checked to be a JSFunctionProxy)
1653 // -- r3 : the original constructor (either the same as the constructor or
1654 // the JSFunction on which new was invoked initially)
1655 // -----------------------------------
1656
1657 // TODO(neis): This doesn't match the ES6 spec for [[Construct]] on proxies.
1658 __ ldr(r1, FieldMemOperand(r1, JSFunctionProxy::kConstructTrapOffset));
1659 __ Jump(masm->isolate()->builtins()->Call(), RelocInfo::CODE_TARGET);
1660 }
1661
1662
1663 // static
1649 void Builtins::Generate_Construct(MacroAssembler* masm) { 1664 void Builtins::Generate_Construct(MacroAssembler* masm) {
1650 // ----------- S t a t e ------------- 1665 // ----------- S t a t e -------------
1651 // -- r0 : the number of arguments (not including the receiver) 1666 // -- r0 : the number of arguments (not including the receiver)
1652 // -- r1 : the constructor to call (can be any Object) 1667 // -- r1 : the constructor to call (can be any Object)
1653 // -- r3 : the original constructor (either the same as the constructor or 1668 // -- r3 : the original constructor (either the same as the constructor or
1654 // the JSFunction on which new was invoked initially) 1669 // the JSFunction on which new was invoked initially)
1655 // ----------------------------------- 1670 // -----------------------------------
1656 1671
1657 Label non_callable, non_function; 1672 // Check if target has a [[Construct]] internal method.
1658 __ JumpIfSmi(r1, &non_callable); 1673 Label non_constructor;
1659 __ CompareObjectType(r1, r4, r5, JS_FUNCTION_TYPE); 1674 __ JumpIfSmi(r1, &non_constructor);
1675 __ ldr(r4, FieldMemOperand(r1, HeapObject::kMapOffset));
1676 __ ldrb(r2, FieldMemOperand(r4, Map::kBitFieldOffset));
1677 __ tst(r2, Operand(1 << Map::kIsConstructor));
1678 __ b(eq, &non_constructor);
1679
1680 // Dispatch based on instance type.
1681 __ CompareInstanceType(r4, r5, JS_FUNCTION_TYPE);
1660 __ Jump(masm->isolate()->builtins()->ConstructFunction(), 1682 __ Jump(masm->isolate()->builtins()->ConstructFunction(),
1661 RelocInfo::CODE_TARGET, eq); 1683 RelocInfo::CODE_TARGET, eq);
1662 __ cmp(r5, Operand(JS_FUNCTION_PROXY_TYPE)); 1684 __ cmp(r5, Operand(JS_FUNCTION_PROXY_TYPE));
1663 __ b(ne, &non_function); 1685 __ Jump(masm->isolate()->builtins()->ConstructProxy(), RelocInfo::CODE_TARGET,
1686 eq);
1664 1687
1665 // 1. Construct of function proxy. 1688 // Called Construct on an exotic Object with a [[Construct]] internal method.
1666 // TODO(neis): This doesn't match the ES6 spec for [[Construct]] on proxies. 1689 {
1667 __ ldr(r1, FieldMemOperand(r1, JSFunctionProxy::kConstructTrapOffset)); 1690 // Overwrite the original receiver with the (original) target.
1668 __ Jump(masm->isolate()->builtins()->Call(), RelocInfo::CODE_TARGET); 1691 __ str(r1, MemOperand(sp, r0, LSL, kPointerSizeLog2));
1692 // Let the "call_as_constructor_delegate" take care of the rest.
1693 __ LoadGlobalFunction(Context::CALL_AS_CONSTRUCTOR_DELEGATE_INDEX, r1);
1694 __ Jump(masm->isolate()->builtins()->CallFunction(),
1695 RelocInfo::CODE_TARGET);
1696 }
1669 1697
1670 // 2. Construct of something that else, which might have a [[Construct]] 1698 // Called Construct on an Object that doesn't have a [[Construct]] internal
1671 // internal method (if not we raise an exception). 1699 // method.
1672 __ bind(&non_function); 1700 __ bind(&non_constructor);
1673 // Check if target has a [[Call]] internal method.
1674 // TODO(bmeurer): This shoud use IsConstructor once available.
1675 __ ldrb(r4, FieldMemOperand(r4, Map::kBitFieldOffset));
1676 __ tst(r4, Operand(1 << Map::kIsCallable));
1677 __ b(eq, &non_callable);
1678 // Overwrite the original receiver the (original) target.
1679 __ str(r1, MemOperand(sp, r0, LSL, kPointerSizeLog2));
1680 // Let the "call_as_constructor_delegate" take care of the rest.
1681 __ LoadGlobalFunction(Context::CALL_AS_CONSTRUCTOR_DELEGATE_INDEX, r1);
1682 __ Jump(masm->isolate()->builtins()->CallFunction(), RelocInfo::CODE_TARGET);
1683
1684 // 3. Construct of something that is not callable.
1685 __ bind(&non_callable);
1686 { 1701 {
1687 FrameAndConstantPoolScope scope(masm, StackFrame::INTERNAL); 1702 FrameAndConstantPoolScope scope(masm, StackFrame::INTERNAL);
1688 __ Push(r1); 1703 __ Push(r1);
1689 __ CallRuntime(Runtime::kThrowCalledNonCallable, 1); 1704 __ CallRuntime(Runtime::kThrowCalledNonCallable, 1);
1690 } 1705 }
1691 } 1706 }
1692 1707
1693 1708
1694 // static 1709 // static
1695 void Builtins::Generate_PushArgsAndCall(MacroAssembler* masm) { 1710 void Builtins::Generate_PushArgsAndCall(MacroAssembler* masm) {
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
1863 } 1878 }
1864 } 1879 }
1865 1880
1866 1881
1867 #undef __ 1882 #undef __
1868 1883
1869 } // namespace internal 1884 } // namespace internal
1870 } // namespace v8 1885 } // namespace v8
1871 1886
1872 #endif // V8_TARGET_ARCH_ARM 1887 #endif // V8_TARGET_ARCH_ARM
OLDNEW
« no previous file with comments | « src/api-natives.cc ('k') | src/arm64/builtins-arm64.cc » ('j') | src/bootstrapper.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698