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

Side by Side Diff: src/mips64/builtins-mips64.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, 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
« no previous file with comments | « src/mips/builtins-mips.cc ('k') | src/objects.h » ('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 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_MIPS64 5 #if V8_TARGET_ARCH_MIPS64
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 1627 matching lines...) Expand 10 before | Expand all | Expand 10 after
1638 // Tail call to the function-specific construct stub (still in the caller 1638 // Tail call to the function-specific construct stub (still in the caller
1639 // context at this point). 1639 // context at this point).
1640 __ ld(a4, FieldMemOperand(a1, JSFunction::kSharedFunctionInfoOffset)); 1640 __ ld(a4, FieldMemOperand(a1, JSFunction::kSharedFunctionInfoOffset));
1641 __ ld(a4, FieldMemOperand(a4, SharedFunctionInfo::kConstructStubOffset)); 1641 __ ld(a4, FieldMemOperand(a4, SharedFunctionInfo::kConstructStubOffset));
1642 __ Daddu(at, a4, Operand(Code::kHeaderSize - kHeapObjectTag)); 1642 __ Daddu(at, a4, Operand(Code::kHeaderSize - kHeapObjectTag));
1643 __ Jump(at); 1643 __ Jump(at);
1644 } 1644 }
1645 1645
1646 1646
1647 // static 1647 // static
1648 void Builtins::Generate_ConstructProxy(MacroAssembler* masm) {
1649 // ----------- S t a t e -------------
1650 // -- a0 : the number of arguments (not including the receiver)
1651 // -- a1 : the constructor to call (checked to be a JSFunctionProxy)
1652 // -- a3 : the original constructor (either the same as the constructor or
1653 // the JSFunction on which new was invoked initially)
1654 // -----------------------------------
1655
1656 // TODO(neis): This doesn't match the ES6 spec for [[Construct]] on proxies.
1657 __ ld(a1, FieldMemOperand(a1, JSFunctionProxy::kConstructTrapOffset));
1658 __ Jump(masm->isolate()->builtins()->Call(), RelocInfo::CODE_TARGET);
1659 }
1660
1661
1662 // static
1648 void Builtins::Generate_Construct(MacroAssembler* masm) { 1663 void Builtins::Generate_Construct(MacroAssembler* masm) {
1649 // ----------- S t a t e ------------- 1664 // ----------- S t a t e -------------
1650 // -- a0 : the number of arguments (not including the receiver) 1665 // -- a0 : the number of arguments (not including the receiver)
1651 // -- a1 : the constructor to call (can be any Object) 1666 // -- a1 : the constructor to call (can be any Object)
1652 // -- a3 : the original constructor (either the same as the constructor or 1667 // -- a3 : the original constructor (either the same as the constructor or
1653 // the JSFunction on which new was invoked initially) 1668 // the JSFunction on which new was invoked initially)
1654 // ----------------------------------- 1669 // -----------------------------------
1655 1670
1656 Label non_callable, non_function; 1671 // Check if target has a [[Construct]] internal method.
1657 __ JumpIfSmi(a1, &non_callable); 1672 Label non_constructor;
1658 __ GetObjectType(a1, t1, t2); 1673 __ JumpIfSmi(a1, &non_constructor);
1674 __ ld(t1, FieldMemOperand(a1, HeapObject::kMapOffset));
1675 __ lbu(t2, FieldMemOperand(t1, Map::kBitFieldOffset));
1676 __ And(t2, t2, Operand(1 << Map::kIsCallable));
1677 __ Branch(&non_constructor, eq, t2, Operand(zero_reg));
1678
1679 // Dispatch based on instance type.
1680 __ lbu(t2, FieldMemOperand(t1, Map::kInstanceTypeOffset));
1659 __ Jump(masm->isolate()->builtins()->ConstructFunction(), 1681 __ Jump(masm->isolate()->builtins()->ConstructFunction(),
1660 RelocInfo::CODE_TARGET, eq, t2, Operand(JS_FUNCTION_TYPE)); 1682 RelocInfo::CODE_TARGET, eq, t2, Operand(JS_FUNCTION_TYPE));
1661 __ Branch(&non_function, ne, t2, Operand(JS_FUNCTION_PROXY_TYPE)); 1683 __ Jump(masm->isolate()->builtins()->ConstructProxy(), RelocInfo::CODE_TARGET,
1684 eq, t2, Operand(JS_FUNCTION_PROXY_TYPE));
1662 1685
1663 // 1. Construct of function proxy. 1686 // Called Construct on an exotic Object with a [[Construct]] internal method.
1664 // TODO(neis): This doesn't match the ES6 spec for [[Construct]] on proxies. 1687 {
1665 __ ld(a1, FieldMemOperand(a1, JSFunctionProxy::kConstructTrapOffset)); 1688 // Overwrite the original receiver with the (original) target.
1666 __ Jump(masm->isolate()->builtins()->Call(), RelocInfo::CODE_TARGET); 1689 __ dsll(at, a0, kPointerSizeLog2);
1690 __ daddu(at, sp, at);
1691 __ sd(a1, MemOperand(at));
1692 // Let the "call_as_constructor_delegate" take care of the rest.
1693 __ LoadGlobalFunction(Context::CALL_AS_CONSTRUCTOR_DELEGATE_INDEX, a1);
1694 __ Jump(masm->isolate()->builtins()->CallFunction(),
1695 RelocInfo::CODE_TARGET);
1696 }
1667 1697
1668 // 2. Construct of something that else, which might have a [[Construct]] 1698 // Called Construct on an Object that doesn't have a [[Construct]] internal
1669 // internal method (if not we raise an exception). 1699 // method.
1670 __ bind(&non_function); 1700 __ bind(&non_constructor);
1671 // Check if target has a [[Call]] internal method.
1672 // TODO(bmeurer): This shoud use IsConstructor once available.
1673 __ lbu(t1, FieldMemOperand(t1, Map::kBitFieldOffset));
1674 __ And(t1, t1, Operand(1 << Map::kIsCallable));
1675 __ Branch(&non_callable, eq, t1, Operand(zero_reg));
1676 // Overwrite the original receiver with the (original) target.
1677 __ dsll(at, a0, kPointerSizeLog2);
1678 __ daddu(at, sp, at);
1679 __ sd(a1, MemOperand(at));
1680 // Let the "call_as_constructor_delegate" take care of the rest.
1681 __ LoadGlobalFunction(Context::CALL_AS_CONSTRUCTOR_DELEGATE_INDEX, a1);
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 FrameScope scope(masm, StackFrame::INTERNAL); 1702 FrameScope scope(masm, StackFrame::INTERNAL);
1688 __ Push(a1); 1703 __ Push(a1);
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 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
1872 } 1887 }
1873 } 1888 }
1874 1889
1875 1890
1876 #undef __ 1891 #undef __
1877 1892
1878 } // namespace internal 1893 } // namespace internal
1879 } // namespace v8 1894 } // namespace v8
1880 1895
1881 #endif // V8_TARGET_ARCH_MIPS64 1896 #endif // V8_TARGET_ARCH_MIPS64
OLDNEW
« no previous file with comments | « src/mips/builtins-mips.cc ('k') | src/objects.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698