OLD | NEW |
---|---|
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 1534 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1545 // -- eax : the number of arguments (not including the receiver) | 1545 // -- eax : the number of arguments (not including the receiver) |
1546 // -- edi : the target to call (can be any Object). | 1546 // -- edi : the target to call (can be any Object). |
1547 // ----------------------------------- | 1547 // ----------------------------------- |
1548 | 1548 |
1549 Label non_callable, non_function, non_smi; | 1549 Label non_callable, non_function, non_smi; |
1550 __ JumpIfSmi(edi, &non_callable); | 1550 __ JumpIfSmi(edi, &non_callable); |
1551 __ bind(&non_smi); | 1551 __ bind(&non_smi); |
1552 __ CmpObjectType(edi, JS_FUNCTION_TYPE, ecx); | 1552 __ CmpObjectType(edi, JS_FUNCTION_TYPE, ecx); |
1553 __ j(equal, masm->isolate()->builtins()->CallFunction(mode), | 1553 __ j(equal, masm->isolate()->builtins()->CallFunction(mode), |
1554 RelocInfo::CODE_TARGET); | 1554 RelocInfo::CODE_TARGET); |
1555 __ CmpInstanceType(ecx, JS_FUNCTION_PROXY_TYPE); | 1555 __ CmpInstanceType(ecx, JS_PROXY_TYPE); |
1556 __ j(not_equal, &non_function); | 1556 __ j(not_equal, &non_function); |
1557 | 1557 |
1558 // 1. Call to function proxy. | 1558 // 1. Call to function proxy. |
1559 // TODO(neis): This doesn't match the ES6 spec for [[Call]] on proxies. | 1559 // TODO(neis): Implement [[Call]] on proxies. |
1560 __ mov(edi, FieldOperand(edi, JSFunctionProxy::kCallTrapOffset)); | |
1561 __ AssertNotSmi(edi); | |
1562 __ jmp(&non_smi); | 1560 __ jmp(&non_smi); |
Toon Verwaest
2015/12/03 11:48:42
drop branch
Camillo Bruni
2015/12/03 12:18:26
done
| |
1563 | 1561 |
1564 // 2. Call to something else, which might have a [[Call]] internal method (if | 1562 // 2. Call to something else, which might have a [[Call]] internal method (if |
1565 // not we raise an exception). | 1563 // not we raise an exception). |
1566 __ bind(&non_function); | 1564 __ bind(&non_function); |
1567 // Check if target has a [[Call]] internal method. | 1565 // Check if target has a [[Call]] internal method. |
1568 __ test_b(FieldOperand(ecx, Map::kBitFieldOffset), 1 << Map::kIsCallable); | 1566 __ test_b(FieldOperand(ecx, Map::kBitFieldOffset), 1 << Map::kIsCallable); |
1569 __ j(zero, &non_callable, Label::kNear); | 1567 __ j(zero, &non_callable, Label::kNear); |
1570 // Overwrite the original receiver with the (original) target. | 1568 // Overwrite the original receiver with the (original) target. |
1571 __ mov(Operand(esp, eax, times_pointer_size, kPointerSize), edi); | 1569 __ mov(Operand(esp, eax, times_pointer_size, kPointerSize), edi); |
1572 // Let the "call_as_function_delegate" take care of the rest. | 1570 // Let the "call_as_function_delegate" take care of the rest. |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1606 __ jmp(ecx); | 1604 __ jmp(ecx); |
1607 } | 1605 } |
1608 | 1606 |
1609 | 1607 |
1610 // static | 1608 // static |
1611 void Builtins::Generate_ConstructProxy(MacroAssembler* masm) { | 1609 void Builtins::Generate_ConstructProxy(MacroAssembler* masm) { |
1612 // ----------- S t a t e ------------- | 1610 // ----------- S t a t e ------------- |
1613 // -- eax : the number of arguments (not including the receiver) | 1611 // -- eax : the number of arguments (not including the receiver) |
1614 // -- edx : the new target (either the same as the constructor or | 1612 // -- edx : the new target (either the same as the constructor or |
1615 // the JSFunction on which new was invoked initially) | 1613 // the JSFunction on which new was invoked initially) |
1616 // -- edi : the constructor to call (checked to be a JSFunctionProxy) | 1614 // -- edi : the constructor to call (checked to be a JSProxy) |
1617 // ----------------------------------- | 1615 // ----------------------------------- |
1618 | 1616 |
1619 // TODO(neis): This doesn't match the ES6 spec for [[Construct]] on proxies. | 1617 // TODO(neis): This doesn't match the ES6 spec for [[Construct]] on proxies. |
1620 __ mov(edi, FieldOperand(edi, JSFunctionProxy::kConstructTrapOffset)); | |
1621 __ Jump(masm->isolate()->builtins()->Call(), RelocInfo::CODE_TARGET); | 1618 __ Jump(masm->isolate()->builtins()->Call(), RelocInfo::CODE_TARGET); |
1622 } | 1619 } |
1623 | 1620 |
1624 | 1621 |
1625 // static | 1622 // static |
1626 void Builtins::Generate_Construct(MacroAssembler* masm) { | 1623 void Builtins::Generate_Construct(MacroAssembler* masm) { |
1627 // ----------- S t a t e ------------- | 1624 // ----------- S t a t e ------------- |
1628 // -- eax : the number of arguments (not including the receiver) | 1625 // -- eax : the number of arguments (not including the receiver) |
1629 // -- edx : the new target (either the same as the constructor or | 1626 // -- edx : the new target (either the same as the constructor or |
1630 // the JSFunction on which new was invoked initially) | 1627 // the JSFunction on which new was invoked initially) |
1631 // -- edi : the constructor to call (can be any Object) | 1628 // -- edi : the constructor to call (can be any Object) |
1632 // ----------------------------------- | 1629 // ----------------------------------- |
1633 | 1630 |
1634 // Check if target is a Smi. | 1631 // Check if target is a Smi. |
1635 Label non_constructor; | 1632 Label non_constructor; |
1636 __ JumpIfSmi(edi, &non_constructor, Label::kNear); | 1633 __ JumpIfSmi(edi, &non_constructor, Label::kNear); |
1637 | 1634 |
1638 // Dispatch based on instance type. | 1635 // Dispatch based on instance type. |
1639 __ CmpObjectType(edi, JS_FUNCTION_TYPE, ecx); | 1636 __ CmpObjectType(edi, JS_FUNCTION_TYPE, ecx); |
1640 __ j(equal, masm->isolate()->builtins()->ConstructFunction(), | 1637 __ j(equal, masm->isolate()->builtins()->ConstructFunction(), |
1641 RelocInfo::CODE_TARGET); | 1638 RelocInfo::CODE_TARGET); |
1642 __ CmpInstanceType(ecx, JS_FUNCTION_PROXY_TYPE); | 1639 __ CmpInstanceType(ecx, JS_PROXY_TYPE); |
1643 __ j(equal, masm->isolate()->builtins()->ConstructProxy(), | 1640 __ j(equal, masm->isolate()->builtins()->ConstructProxy(), |
1644 RelocInfo::CODE_TARGET); | 1641 RelocInfo::CODE_TARGET); |
1645 | 1642 |
1646 // Check if target has a [[Construct]] internal method. | 1643 // Check if target has a [[Construct]] internal method. |
1647 __ test_b(FieldOperand(ecx, Map::kBitFieldOffset), 1 << Map::kIsConstructor); | 1644 __ test_b(FieldOperand(ecx, Map::kBitFieldOffset), 1 << Map::kIsConstructor); |
1648 __ j(zero, &non_constructor, Label::kNear); | 1645 __ j(zero, &non_constructor, Label::kNear); |
1649 | 1646 |
1650 // Called Construct on an exotic Object with a [[Construct]] internal method. | 1647 // Called Construct on an exotic Object with a [[Construct]] internal method. |
1651 { | 1648 { |
1652 // Overwrite the original receiver with the (original) target. | 1649 // Overwrite the original receiver with the (original) target. |
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1975 | 1972 |
1976 __ bind(&ok); | 1973 __ bind(&ok); |
1977 __ ret(0); | 1974 __ ret(0); |
1978 } | 1975 } |
1979 | 1976 |
1980 #undef __ | 1977 #undef __ |
1981 } // namespace internal | 1978 } // namespace internal |
1982 } // namespace v8 | 1979 } // namespace v8 |
1983 | 1980 |
1984 #endif // V8_TARGET_ARCH_X87 | 1981 #endif // V8_TARGET_ARCH_X87 |
OLD | NEW |