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

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

Issue 1509603005: [runtime] [proxy] implement [[Construct]] (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@2015-12-03_JSProxy_Call_1499593003
Patch Set: fimpsing Created 5 years 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/x64/builtins-x64.cc ('k') | test/mjsunit/es6/classes-proxy.js » ('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_X87 5 #if V8_TARGET_ARCH_X87
6 6
7 #include "src/code-factory.h" 7 #include "src/code-factory.h"
8 #include "src/codegen.h" 8 #include "src/codegen.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 1585 matching lines...) Expand 10 before | Expand all | Expand 10 after
1596 __ mov(ecx, FieldOperand(ecx, SharedFunctionInfo::kConstructStubOffset)); 1596 __ mov(ecx, FieldOperand(ecx, SharedFunctionInfo::kConstructStubOffset));
1597 __ lea(ecx, FieldOperand(ecx, Code::kHeaderSize)); 1597 __ lea(ecx, FieldOperand(ecx, Code::kHeaderSize));
1598 __ jmp(ecx); 1598 __ jmp(ecx);
1599 } 1599 }
1600 1600
1601 1601
1602 // static 1602 // static
1603 void Builtins::Generate_ConstructProxy(MacroAssembler* masm) { 1603 void Builtins::Generate_ConstructProxy(MacroAssembler* masm) {
1604 // ----------- S t a t e ------------- 1604 // ----------- S t a t e -------------
1605 // -- eax : the number of arguments (not including the receiver) 1605 // -- eax : the number of arguments (not including the receiver)
1606 // -- edi : the constructor to call (checked to be a JSProxy)
1606 // -- edx : the new target (either the same as the constructor or 1607 // -- edx : the new target (either the same as the constructor or
1607 // the JSFunction on which new was invoked initially) 1608 // the JSFunction on which new was invoked initially)
1608 // -- edi : the constructor to call (checked to be a JSProxy)
1609 // ----------------------------------- 1609 // -----------------------------------
1610 1610
1611 // TODO(neis): This doesn't match the ES6 spec for [[Construct]] on proxies. 1611 // Call into the Runtime for Proxy [[Construct]].
1612 __ Jump(masm->isolate()->builtins()->Call(), RelocInfo::CODE_TARGET); 1612 __ PopReturnAddressTo(ecx);
1613 __ Push(edi);
1614 __ Push(edx);
1615 __ PushReturnAddressFrom(ecx);
1616 // Include the pushed new_target, constructor and the receiver.
1617 __ add(eax, Immediate(3));
1618 // Tail-call to the runtime.
1619 __ JumpToExternalReference(
1620 ExternalReference(Runtime::kJSProxyConstruct, masm->isolate()));
1613 } 1621 }
1614 1622
1615 1623
1616 // static 1624 // static
1617 void Builtins::Generate_Construct(MacroAssembler* masm) { 1625 void Builtins::Generate_Construct(MacroAssembler* masm) {
1618 // ----------- S t a t e ------------- 1626 // ----------- S t a t e -------------
1619 // -- eax : the number of arguments (not including the receiver) 1627 // -- eax : the number of arguments (not including the receiver)
1628 // -- edi : the constructor to call (can be any Object)
1620 // -- edx : the new target (either the same as the constructor or 1629 // -- edx : the new target (either the same as the constructor or
1621 // the JSFunction on which new was invoked initially) 1630 // the JSFunction on which new was invoked initially)
1622 // -- edi : the constructor to call (can be any Object)
1623 // ----------------------------------- 1631 // -----------------------------------
1624 1632
1625 // Check if target is a Smi. 1633 // Check if target is a Smi.
1626 Label non_constructor; 1634 Label non_constructor;
1627 __ JumpIfSmi(edi, &non_constructor, Label::kNear); 1635 __ JumpIfSmi(edi, &non_constructor, Label::kNear);
1628 1636
1629 // Dispatch based on instance type. 1637 // Dispatch based on instance type.
1630 __ CmpObjectType(edi, JS_FUNCTION_TYPE, ecx); 1638 __ CmpObjectType(edi, JS_FUNCTION_TYPE, ecx);
1631 __ j(equal, masm->isolate()->builtins()->ConstructFunction(), 1639 __ j(equal, masm->isolate()->builtins()->ConstructFunction(),
1632 RelocInfo::CODE_TARGET); 1640 RelocInfo::CODE_TARGET);
1633 __ CmpInstanceType(ecx, JS_PROXY_TYPE);
1634 __ j(equal, masm->isolate()->builtins()->ConstructProxy(),
1635 RelocInfo::CODE_TARGET);
1636 1641
1637 // Check if target has a [[Construct]] internal method. 1642 // Check if target has a [[Construct]] internal method.
1638 __ test_b(FieldOperand(ecx, Map::kBitFieldOffset), 1 << Map::kIsConstructor); 1643 __ test_b(FieldOperand(ecx, Map::kBitFieldOffset), 1 << Map::kIsConstructor);
1639 __ j(zero, &non_constructor, Label::kNear); 1644 __ j(zero, &non_constructor, Label::kNear);
1640 1645
1646 // Only dispatch to proxies after checking whether they are constructors.
1647 __ CmpInstanceType(ecx, JS_PROXY_TYPE);
1648 __ j(equal, masm->isolate()->builtins()->ConstructProxy(),
1649 RelocInfo::CODE_TARGET);
1650
1641 // Called Construct on an exotic Object with a [[Construct]] internal method. 1651 // Called Construct on an exotic Object with a [[Construct]] internal method.
1642 { 1652 {
1643 // Overwrite the original receiver with the (original) target. 1653 // Overwrite the original receiver with the (original) target.
1644 __ mov(Operand(esp, eax, times_pointer_size, kPointerSize), edi); 1654 __ mov(Operand(esp, eax, times_pointer_size, kPointerSize), edi);
1645 // Let the "call_as_constructor_delegate" take care of the rest. 1655 // Let the "call_as_constructor_delegate" take care of the rest.
1646 __ LoadGlobalFunction(Context::CALL_AS_CONSTRUCTOR_DELEGATE_INDEX, edi); 1656 __ LoadGlobalFunction(Context::CALL_AS_CONSTRUCTOR_DELEGATE_INDEX, edi);
1647 __ Jump(masm->isolate()->builtins()->CallFunction(), 1657 __ Jump(masm->isolate()->builtins()->CallFunction(),
1648 RelocInfo::CODE_TARGET); 1658 RelocInfo::CODE_TARGET);
1649 } 1659 }
1650 1660
(...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after
1966 1976
1967 __ bind(&ok); 1977 __ bind(&ok);
1968 __ ret(0); 1978 __ ret(0);
1969 } 1979 }
1970 1980
1971 #undef __ 1981 #undef __
1972 } // namespace internal 1982 } // namespace internal
1973 } // namespace v8 1983 } // namespace v8
1974 1984
1975 #endif // V8_TARGET_ARCH_X87 1985 #endif // V8_TARGET_ARCH_X87
OLDNEW
« no previous file with comments | « src/x64/builtins-x64.cc ('k') | test/mjsunit/es6/classes-proxy.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698