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