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

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

Issue 1360403002: Revert of [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
« no previous file with comments | « src/ic/ic.cc ('k') | src/mips64/builtins-mips64.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 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_MIPS 5 #if V8_TARGET_ARCH_MIPS
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 1641 matching lines...) Expand 10 before | Expand all | Expand 10 after
1652 // Tail call to the function-specific construct stub (still in the caller 1652 // Tail call to the function-specific construct stub (still in the caller
1653 // context at this point). 1653 // context at this point).
1654 __ lw(t0, FieldMemOperand(a1, JSFunction::kSharedFunctionInfoOffset)); 1654 __ lw(t0, FieldMemOperand(a1, JSFunction::kSharedFunctionInfoOffset));
1655 __ lw(t0, FieldMemOperand(t0, SharedFunctionInfo::kConstructStubOffset)); 1655 __ lw(t0, FieldMemOperand(t0, SharedFunctionInfo::kConstructStubOffset));
1656 __ Addu(at, t0, Operand(Code::kHeaderSize - kHeapObjectTag)); 1656 __ Addu(at, t0, Operand(Code::kHeaderSize - kHeapObjectTag));
1657 __ Jump(at); 1657 __ Jump(at);
1658 } 1658 }
1659 1659
1660 1660
1661 // static 1661 // static
1662 void Builtins::Generate_ConstructProxy(MacroAssembler* masm) {
1663 // ----------- S t a t e -------------
1664 // -- a0 : the number of arguments (not including the receiver)
1665 // -- a1 : the constructor to call (checked to be a JSFunctionProxy)
1666 // -- a3 : the original constructor (either the same as the constructor or
1667 // the JSFunction on which new was invoked initially)
1668 // -----------------------------------
1669
1670 // TODO(neis): This doesn't match the ES6 spec for [[Construct]] on proxies.
1671 __ lw(a1, FieldMemOperand(a1, JSFunctionProxy::kConstructTrapOffset));
1672 __ Jump(masm->isolate()->builtins()->Call(), RelocInfo::CODE_TARGET);
1673 }
1674
1675
1676 // static
1677 void Builtins::Generate_Construct(MacroAssembler* masm) { 1662 void Builtins::Generate_Construct(MacroAssembler* masm) {
1678 // ----------- S t a t e ------------- 1663 // ----------- S t a t e -------------
1679 // -- a0 : the number of arguments (not including the receiver) 1664 // -- a0 : the number of arguments (not including the receiver)
1680 // -- a1 : the constructor to call (can be any Object) 1665 // -- a1 : the constructor to call (can be any Object)
1681 // -- a3 : the original constructor (either the same as the constructor or 1666 // -- a3 : the original constructor (either the same as the constructor or
1682 // the JSFunction on which new was invoked initially) 1667 // the JSFunction on which new was invoked initially)
1683 // ----------------------------------- 1668 // -----------------------------------
1684 1669
1685 // Check if target has a [[Construct]] internal method. 1670 Label non_callable, non_function;
1686 Label non_constructor; 1671 __ JumpIfSmi(a1, &non_callable);
1687 __ JumpIfSmi(a1, &non_constructor); 1672 __ GetObjectType(a1, t1, t2);
1688 __ lw(t1, FieldMemOperand(t1, HeapObject::kMapOffset));
1689 __ lbu(t2, FieldMemOperand(t1, Map::kBitFieldOffset));
1690 __ And(t2, t2, Operand(1 << Map::kIsCallable));
1691 __ Branch(&non_constructor, eq, t2, Operand(zero_reg));
1692
1693 // Dispatch based on instance type.
1694 __ lbu(t2, FieldMemOperand(t1, Map::kInstanceTypeOffset));
1695 __ Jump(masm->isolate()->builtins()->ConstructFunction(), 1673 __ Jump(masm->isolate()->builtins()->ConstructFunction(),
1696 RelocInfo::CODE_TARGET, eq, t2, Operand(JS_FUNCTION_TYPE)); 1674 RelocInfo::CODE_TARGET, eq, t2, Operand(JS_FUNCTION_TYPE));
1697 __ Jump(masm->isolate()->builtins()->ConstructProxy(), RelocInfo::CODE_TARGET, 1675 __ Branch(&non_function, ne, t2, Operand(JS_FUNCTION_PROXY_TYPE));
1698 eq, t2, Operand(JS_FUNCTION_PROXY_TYPE));
1699 1676
1700 // Called Construct on an exotic Object with a [[Construct]] internal method. 1677 // 1. Construct of function proxy.
1701 { 1678 // TODO(neis): This doesn't match the ES6 spec for [[Construct]] on proxies.
1702 // Overwrite the original receiver with the (original) target. 1679 __ lw(a1, FieldMemOperand(a1, JSFunctionProxy::kConstructTrapOffset));
1703 __ sll(at, a0, kPointerSizeLog2); 1680 __ Jump(masm->isolate()->builtins()->Call(), RelocInfo::CODE_TARGET);
1704 __ addu(at, sp, at);
1705 __ sw(a1, MemOperand(at));
1706 // Let the "call_as_constructor_delegate" take care of the rest.
1707 __ LoadGlobalFunction(Context::CALL_AS_CONSTRUCTOR_DELEGATE_INDEX, a1);
1708 __ Jump(masm->isolate()->builtins()->CallFunction(),
1709 RelocInfo::CODE_TARGET);
1710 }
1711 1681
1712 // Called Construct on an Object that doesn't have a [[Construct]] internal 1682 // 2. Construct of something that else, which might have a [[Construct]]
1713 // method. 1683 // internal method (if not we raise an exception).
1714 __ bind(&non_constructor); 1684 __ bind(&non_function);
1685 // Check if target has a [[Call]] internal method.
1686 // TODO(bmeurer): This shoud use IsConstructor once available.
1687 __ lbu(t1, FieldMemOperand(t1, Map::kBitFieldOffset));
1688 __ And(t1, t1, Operand(1 << Map::kIsCallable));
1689 __ Branch(&non_callable, eq, t1, Operand(zero_reg));
1690 // Overwrite the original receiver with the (original) target.
1691 __ sll(at, a0, kPointerSizeLog2);
1692 __ addu(at, sp, at);
1693 __ sw(a1, MemOperand(at));
1694 // Let the "call_as_constructor_delegate" take care of the rest.
1695 __ LoadGlobalFunction(Context::CALL_AS_CONSTRUCTOR_DELEGATE_INDEX, a1);
1696 __ Jump(masm->isolate()->builtins()->CallFunction(), RelocInfo::CODE_TARGET);
1697
1698 // 3. Construct of something that is not callable.
1699 __ bind(&non_callable);
1715 { 1700 {
1716 FrameScope scope(masm, StackFrame::INTERNAL); 1701 FrameScope scope(masm, StackFrame::INTERNAL);
1717 __ Push(a1); 1702 __ Push(a1);
1718 __ CallRuntime(Runtime::kThrowCalledNonCallable, 1); 1703 __ CallRuntime(Runtime::kThrowCalledNonCallable, 1);
1719 } 1704 }
1720 } 1705 }
1721 1706
1722 1707
1723 // static 1708 // static
1724 void Builtins::Generate_PushArgsAndCall(MacroAssembler* masm) { 1709 void Builtins::Generate_PushArgsAndCall(MacroAssembler* masm) {
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
1901 } 1886 }
1902 } 1887 }
1903 1888
1904 1889
1905 #undef __ 1890 #undef __
1906 1891
1907 } // namespace internal 1892 } // namespace internal
1908 } // namespace v8 1893 } // namespace v8
1909 1894
1910 #endif // V8_TARGET_ARCH_MIPS 1895 #endif // V8_TARGET_ARCH_MIPS
OLDNEW
« no previous file with comments | « src/ic/ic.cc ('k') | src/mips64/builtins-mips64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698