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_IA32 | 5 #if V8_TARGET_ARCH_IA32 |
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 1601 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1612 __ PushReturnAddressFrom(ecx); | 1612 __ PushReturnAddressFrom(ecx); |
1613 } | 1613 } |
1614 | 1614 |
1615 // ----------- S t a t e ------------- | 1615 // ----------- S t a t e ------------- |
1616 // -- ebx : argArray | 1616 // -- ebx : argArray |
1617 // -- edi : receiver | 1617 // -- edi : receiver |
1618 // -- esp[0] : return address | 1618 // -- esp[0] : return address |
1619 // -- esp[4] : thisArg | 1619 // -- esp[4] : thisArg |
1620 // ----------------------------------- | 1620 // ----------------------------------- |
1621 | 1621 |
1622 // 2. Make sure the receiver is actually callable. | 1622 // 2. We don't need to check explicitly for callable receiver here, |
1623 Label receiver_not_callable; | 1623 // since that's the first thing the Call/CallWithArrayLike builtins |
1624 __ JumpIfSmi(edi, &receiver_not_callable, Label::kNear); | 1624 // will do. |
1625 __ mov(ecx, FieldOperand(edi, HeapObject::kMapOffset)); | |
1626 __ test_b(FieldOperand(ecx, Map::kBitFieldOffset), | |
1627 Immediate(1 << Map::kIsCallable)); | |
1628 __ j(zero, &receiver_not_callable, Label::kNear); | |
1629 | 1625 |
1630 // 3. Tail call with no arguments if argArray is null or undefined. | 1626 // 3. Tail call with no arguments if argArray is null or undefined. |
1631 Label no_arguments; | 1627 Label no_arguments; |
1632 __ JumpIfRoot(ebx, Heap::kNullValueRootIndex, &no_arguments, Label::kNear); | 1628 __ JumpIfRoot(ebx, Heap::kNullValueRootIndex, &no_arguments, Label::kNear); |
1633 __ JumpIfRoot(ebx, Heap::kUndefinedValueRootIndex, &no_arguments, | 1629 __ JumpIfRoot(ebx, Heap::kUndefinedValueRootIndex, &no_arguments, |
1634 Label::kNear); | 1630 Label::kNear); |
1635 | 1631 |
1636 // 4a. Apply the receiver to the given argArray. | 1632 // 4a. Apply the receiver to the given argArray. |
1637 __ Jump(masm->isolate()->builtins()->CallWithArrayLike(), | 1633 __ Jump(masm->isolate()->builtins()->CallWithArrayLike(), |
1638 RelocInfo::CODE_TARGET); | 1634 RelocInfo::CODE_TARGET); |
1639 | 1635 |
1640 // 4b. The argArray is either null or undefined, so we tail call without any | 1636 // 4b. The argArray is either null or undefined, so we tail call without any |
1641 // arguments to the receiver. | 1637 // arguments to the receiver. |
1642 __ bind(&no_arguments); | 1638 __ bind(&no_arguments); |
1643 { | 1639 { |
1644 __ Set(eax, 0); | 1640 __ Set(eax, 0); |
1645 __ Jump(masm->isolate()->builtins()->Call(), RelocInfo::CODE_TARGET); | 1641 __ Jump(masm->isolate()->builtins()->Call(), RelocInfo::CODE_TARGET); |
1646 } | 1642 } |
1647 | |
1648 // 4c. The receiver is not callable, throw an appropriate TypeError. | |
1649 __ bind(&receiver_not_callable); | |
1650 { | |
1651 __ mov(Operand(esp, kPointerSize), edi); | |
1652 __ TailCallRuntime(Runtime::kThrowApplyNonFunction); | |
1653 } | |
1654 } | 1643 } |
1655 | 1644 |
1656 // static | 1645 // static |
1657 void Builtins::Generate_FunctionPrototypeCall(MacroAssembler* masm) { | 1646 void Builtins::Generate_FunctionPrototypeCall(MacroAssembler* masm) { |
1658 // Stack Layout: | 1647 // Stack Layout: |
1659 // esp[0] : Return address | 1648 // esp[0] : Return address |
1660 // esp[8] : Argument n | 1649 // esp[8] : Argument n |
1661 // esp[16] : Argument n-1 | 1650 // esp[16] : Argument n-1 |
1662 // ... | 1651 // ... |
1663 // esp[8 * n] : Argument 1 | 1652 // esp[8 * n] : Argument 1 |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1732 __ PushReturnAddressFrom(ecx); | 1721 __ PushReturnAddressFrom(ecx); |
1733 } | 1722 } |
1734 | 1723 |
1735 // ----------- S t a t e ------------- | 1724 // ----------- S t a t e ------------- |
1736 // -- ebx : argumentsList | 1725 // -- ebx : argumentsList |
1737 // -- edi : target | 1726 // -- edi : target |
1738 // -- esp[0] : return address | 1727 // -- esp[0] : return address |
1739 // -- esp[4] : thisArgument | 1728 // -- esp[4] : thisArgument |
1740 // ----------------------------------- | 1729 // ----------------------------------- |
1741 | 1730 |
1742 // 2. Make sure the target is actually callable. | 1731 // 2. We don't need to check explicitly for callable target here, |
1743 Label target_not_callable; | 1732 // since that's the first thing the Call/CallWithArrayLike builtins |
1744 __ JumpIfSmi(edi, &target_not_callable, Label::kNear); | 1733 // will do. |
1745 __ mov(ecx, FieldOperand(edi, HeapObject::kMapOffset)); | |
1746 __ test_b(FieldOperand(ecx, Map::kBitFieldOffset), | |
1747 Immediate(1 << Map::kIsCallable)); | |
1748 __ j(zero, &target_not_callable, Label::kNear); | |
1749 | 1734 |
1750 // 3a. Apply the target to the given argumentsList. | 1735 // 3. Apply the target to the given argumentsList. |
1751 __ Jump(masm->isolate()->builtins()->CallWithArrayLike(), | 1736 __ Jump(masm->isolate()->builtins()->CallWithArrayLike(), |
1752 RelocInfo::CODE_TARGET); | 1737 RelocInfo::CODE_TARGET); |
1753 | |
1754 // 3b. The target is not callable, throw an appropriate TypeError. | |
1755 __ bind(&target_not_callable); | |
1756 { | |
1757 __ mov(Operand(esp, kPointerSize), edi); | |
1758 __ TailCallRuntime(Runtime::kThrowApplyNonFunction); | |
1759 } | |
1760 } | 1738 } |
1761 | 1739 |
1762 void Builtins::Generate_ReflectConstruct(MacroAssembler* masm) { | 1740 void Builtins::Generate_ReflectConstruct(MacroAssembler* masm) { |
1763 // ----------- S t a t e ------------- | 1741 // ----------- S t a t e ------------- |
1764 // -- eax : argc | 1742 // -- eax : argc |
1765 // -- esp[0] : return address | 1743 // -- esp[0] : return address |
1766 // -- esp[4] : new.target (optional) | 1744 // -- esp[4] : new.target (optional) |
1767 // -- esp[8] : argumentsList | 1745 // -- esp[8] : argumentsList |
1768 // -- esp[12] : target | 1746 // -- esp[12] : target |
1769 // -- esp[16] : receiver | 1747 // -- esp[16] : receiver |
(...skipping 1533 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3303 } | 3281 } |
3304 // Now jump to the instructions of the returned code object. | 3282 // Now jump to the instructions of the returned code object. |
3305 __ jmp(edi); | 3283 __ jmp(edi); |
3306 } | 3284 } |
3307 | 3285 |
3308 #undef __ | 3286 #undef __ |
3309 } // namespace internal | 3287 } // namespace internal |
3310 } // namespace v8 | 3288 } // namespace v8 |
3311 | 3289 |
3312 #endif // V8_TARGET_ARCH_IA32 | 3290 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |