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/base/bits.h" | 7 #include "src/base/bits.h" |
8 #include "src/bootstrapper.h" | 8 #include "src/bootstrapper.h" |
9 #include "src/code-stubs.h" | 9 #include "src/code-stubs.h" |
10 #include "src/codegen.h" | 10 #include "src/codegen.h" |
(...skipping 1606 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1617 __ bind(&non_function); | 1617 __ bind(&non_function); |
1618 __ mov(edx, edi); | 1618 __ mov(edx, edi); |
1619 __ Jump(isolate()->builtins()->Construct(), RelocInfo::CODE_TARGET); | 1619 __ Jump(isolate()->builtins()->Construct(), RelocInfo::CODE_TARGET); |
1620 } | 1620 } |
1621 | 1621 |
1622 | 1622 |
1623 void CallICStub::HandleArrayCase(MacroAssembler* masm, Label* miss) { | 1623 void CallICStub::HandleArrayCase(MacroAssembler* masm, Label* miss) { |
1624 // edi - function | 1624 // edi - function |
1625 // edx - slot id | 1625 // edx - slot id |
1626 // ebx - vector | 1626 // ebx - vector |
1627 // eax - number of arguments - if argc_in_register() is true. | |
1628 __ LoadGlobalFunction(Context::ARRAY_FUNCTION_INDEX, ecx); | 1627 __ LoadGlobalFunction(Context::ARRAY_FUNCTION_INDEX, ecx); |
1629 __ cmp(edi, ecx); | 1628 __ cmp(edi, ecx); |
1630 __ j(not_equal, miss); | 1629 __ j(not_equal, miss); |
1631 | 1630 |
| 1631 __ mov(eax, arg_count()); |
1632 // Reload ecx. | 1632 // Reload ecx. |
1633 __ mov(ecx, FieldOperand(ebx, edx, times_half_pointer_size, | 1633 __ mov(ecx, FieldOperand(ebx, edx, times_half_pointer_size, |
1634 FixedArray::kHeaderSize)); | 1634 FixedArray::kHeaderSize)); |
1635 | 1635 |
1636 // Increment the call count for monomorphic function calls. | 1636 // Increment the call count for monomorphic function calls. |
1637 __ add(FieldOperand(ebx, edx, times_half_pointer_size, | 1637 __ add(FieldOperand(ebx, edx, times_half_pointer_size, |
1638 FixedArray::kHeaderSize + kPointerSize), | 1638 FixedArray::kHeaderSize + kPointerSize), |
1639 Immediate(Smi::FromInt(CallICNexus::kCallCountIncrement))); | 1639 Immediate(Smi::FromInt(CallICNexus::kCallCountIncrement))); |
1640 | 1640 |
1641 __ mov(ebx, ecx); | 1641 __ mov(ebx, ecx); |
1642 __ mov(edx, edi); | 1642 __ mov(edx, edi); |
1643 if (argc_in_register()) { | 1643 ArrayConstructorStub stub(masm->isolate(), arg_count()); |
1644 // Pass a default ArgumentCountKey::Any since the argc is only available | 1644 __ TailCallStub(&stub); |
1645 // in eax. We do not have the actual count here. | 1645 |
1646 ArrayConstructorStub stub(masm->isolate()); | |
1647 __ TailCallStub(&stub); | |
1648 } else { | |
1649 // arg_count() is expected in rax if the arg_count() >= 2 | |
1650 // (ArgumentCountKey::MORE_THAN_ONE). | |
1651 ArrayConstructorStub stub(masm->isolate(), arg_count()); | |
1652 __ TailCallStub(&stub); | |
1653 } | |
1654 // Unreachable. | 1646 // Unreachable. |
1655 } | 1647 } |
1656 | 1648 |
1657 | 1649 |
1658 void CallICStub::Generate(MacroAssembler* masm) { | 1650 void CallICStub::Generate(MacroAssembler* masm) { |
1659 // edi - function | 1651 // edi - function |
1660 // edx - slot id | 1652 // edx - slot id |
1661 // ebx - vector | 1653 // ebx - vector |
1662 // eax - number of arguments - if argc_in_register() is true. | |
1663 Isolate* isolate = masm->isolate(); | 1654 Isolate* isolate = masm->isolate(); |
1664 Label extra_checks_or_miss, call, call_function; | 1655 Label extra_checks_or_miss, call, call_function; |
1665 if (!argc_in_register()) { | 1656 int argc = arg_count(); |
1666 int argc = arg_count(); | 1657 ParameterCount actual(argc); |
1667 __ Set(eax, argc); | |
1668 } | |
1669 | 1658 |
1670 // The checks. First, does edi match the recorded monomorphic target? | 1659 // The checks. First, does edi match the recorded monomorphic target? |
1671 __ mov(ecx, FieldOperand(ebx, edx, times_half_pointer_size, | 1660 __ mov(ecx, FieldOperand(ebx, edx, times_half_pointer_size, |
1672 FixedArray::kHeaderSize)); | 1661 FixedArray::kHeaderSize)); |
1673 | 1662 |
1674 // We don't know that we have a weak cell. We might have a private symbol | 1663 // We don't know that we have a weak cell. We might have a private symbol |
1675 // or an AllocationSite, but the memory is safe to examine. | 1664 // or an AllocationSite, but the memory is safe to examine. |
1676 // AllocationSite::kTransitionInfoOffset - contains a Smi or pointer to | 1665 // AllocationSite::kTransitionInfoOffset - contains a Smi or pointer to |
1677 // FixedArray. | 1666 // FixedArray. |
1678 // WeakCell::kValueOffset - contains a JSFunction or Smi(0) | 1667 // WeakCell::kValueOffset - contains a JSFunction or Smi(0) |
(...skipping 12 matching lines...) Expand all Loading... |
1691 // The compare above could have been a SMI/SMI comparison. Guard against this | 1680 // The compare above could have been a SMI/SMI comparison. Guard against this |
1692 // convincing us that we have a monomorphic JSFunction. | 1681 // convincing us that we have a monomorphic JSFunction. |
1693 __ JumpIfSmi(edi, &extra_checks_or_miss); | 1682 __ JumpIfSmi(edi, &extra_checks_or_miss); |
1694 | 1683 |
1695 // Increment the call count for monomorphic function calls. | 1684 // Increment the call count for monomorphic function calls. |
1696 __ add(FieldOperand(ebx, edx, times_half_pointer_size, | 1685 __ add(FieldOperand(ebx, edx, times_half_pointer_size, |
1697 FixedArray::kHeaderSize + kPointerSize), | 1686 FixedArray::kHeaderSize + kPointerSize), |
1698 Immediate(Smi::FromInt(CallICNexus::kCallCountIncrement))); | 1687 Immediate(Smi::FromInt(CallICNexus::kCallCountIncrement))); |
1699 | 1688 |
1700 __ bind(&call_function); | 1689 __ bind(&call_function); |
| 1690 __ Set(eax, argc); |
1701 __ Jump(masm->isolate()->builtins()->CallFunction(convert_mode(), | 1691 __ Jump(masm->isolate()->builtins()->CallFunction(convert_mode(), |
1702 tail_call_mode()), | 1692 tail_call_mode()), |
1703 RelocInfo::CODE_TARGET); | 1693 RelocInfo::CODE_TARGET); |
1704 | 1694 |
1705 __ bind(&extra_checks_or_miss); | 1695 __ bind(&extra_checks_or_miss); |
1706 Label uninitialized, miss, not_allocation_site; | 1696 Label uninitialized, miss, not_allocation_site; |
1707 | 1697 |
1708 __ cmp(ecx, Immediate(TypeFeedbackVector::MegamorphicSentinel(isolate))); | 1698 __ cmp(ecx, Immediate(TypeFeedbackVector::MegamorphicSentinel(isolate))); |
1709 __ j(equal, &call); | 1699 __ j(equal, &call); |
1710 | 1700 |
(...skipping 19 matching lines...) Expand all Loading... |
1730 // We are going megamorphic. If the feedback is a JSFunction, it is fine | 1720 // We are going megamorphic. If the feedback is a JSFunction, it is fine |
1731 // to handle it here. More complex cases are dealt with in the runtime. | 1721 // to handle it here. More complex cases are dealt with in the runtime. |
1732 __ AssertNotSmi(ecx); | 1722 __ AssertNotSmi(ecx); |
1733 __ CmpObjectType(ecx, JS_FUNCTION_TYPE, ecx); | 1723 __ CmpObjectType(ecx, JS_FUNCTION_TYPE, ecx); |
1734 __ j(not_equal, &miss); | 1724 __ j(not_equal, &miss); |
1735 __ mov( | 1725 __ mov( |
1736 FieldOperand(ebx, edx, times_half_pointer_size, FixedArray::kHeaderSize), | 1726 FieldOperand(ebx, edx, times_half_pointer_size, FixedArray::kHeaderSize), |
1737 Immediate(TypeFeedbackVector::MegamorphicSentinel(isolate))); | 1727 Immediate(TypeFeedbackVector::MegamorphicSentinel(isolate))); |
1738 | 1728 |
1739 __ bind(&call); | 1729 __ bind(&call); |
| 1730 __ Set(eax, argc); |
1740 __ Jump(masm->isolate()->builtins()->Call(convert_mode(), tail_call_mode()), | 1731 __ Jump(masm->isolate()->builtins()->Call(convert_mode(), tail_call_mode()), |
1741 RelocInfo::CODE_TARGET); | 1732 RelocInfo::CODE_TARGET); |
1742 | 1733 |
1743 __ bind(&uninitialized); | 1734 __ bind(&uninitialized); |
1744 | 1735 |
1745 // We are going monomorphic, provided we actually have a JSFunction. | 1736 // We are going monomorphic, provided we actually have a JSFunction. |
1746 __ JumpIfSmi(edi, &miss); | 1737 __ JumpIfSmi(edi, &miss); |
1747 | 1738 |
1748 // Goto miss case if we do not have a function. | 1739 // Goto miss case if we do not have a function. |
1749 __ CmpObjectType(edi, JS_FUNCTION_TYPE, ecx); | 1740 __ CmpObjectType(edi, JS_FUNCTION_TYPE, ecx); |
(...skipping 16 matching lines...) Expand all Loading... |
1766 FixedArray::kHeaderSize + kPointerSize), | 1757 FixedArray::kHeaderSize + kPointerSize), |
1767 Immediate(Smi::FromInt(CallICNexus::kCallCountIncrement))); | 1758 Immediate(Smi::FromInt(CallICNexus::kCallCountIncrement))); |
1768 | 1759 |
1769 // Store the function. Use a stub since we need a frame for allocation. | 1760 // Store the function. Use a stub since we need a frame for allocation. |
1770 // ebx - vector | 1761 // ebx - vector |
1771 // edx - slot | 1762 // edx - slot |
1772 // edi - function | 1763 // edi - function |
1773 { | 1764 { |
1774 FrameScope scope(masm, StackFrame::INTERNAL); | 1765 FrameScope scope(masm, StackFrame::INTERNAL); |
1775 CreateWeakCellStub create_stub(isolate); | 1766 CreateWeakCellStub create_stub(isolate); |
1776 __ SmiTag(eax); | |
1777 __ push(eax); | |
1778 __ push(edi); | 1767 __ push(edi); |
1779 | |
1780 __ CallStub(&create_stub); | 1768 __ CallStub(&create_stub); |
1781 | |
1782 __ pop(edi); | 1769 __ pop(edi); |
1783 __ pop(eax); | |
1784 __ SmiUntag(eax); | |
1785 } | 1770 } |
1786 | 1771 |
1787 __ jmp(&call_function); | 1772 __ jmp(&call_function); |
1788 | 1773 |
1789 // We are here because tracing is on or we encountered a MISS case we can't | 1774 // We are here because tracing is on or we encountered a MISS case we can't |
1790 // handle here. | 1775 // handle here. |
1791 __ bind(&miss); | 1776 __ bind(&miss); |
1792 GenerateMiss(masm); | 1777 GenerateMiss(masm); |
1793 | 1778 |
1794 __ jmp(&call); | 1779 __ jmp(&call); |
1795 | 1780 |
1796 // Unreachable | 1781 // Unreachable |
1797 __ int3(); | 1782 __ int3(); |
1798 } | 1783 } |
1799 | 1784 |
1800 | 1785 |
1801 void CallICStub::GenerateMiss(MacroAssembler* masm) { | 1786 void CallICStub::GenerateMiss(MacroAssembler* masm) { |
1802 FrameScope scope(masm, StackFrame::INTERNAL); | 1787 FrameScope scope(masm, StackFrame::INTERNAL); |
1803 | 1788 |
1804 // Store eax since we need it later. | |
1805 __ SmiTag(eax); | |
1806 __ push(eax); | |
1807 // Push the function and feedback info. | 1789 // Push the function and feedback info. |
1808 __ push(edi); | 1790 __ push(edi); |
1809 __ push(ebx); | 1791 __ push(ebx); |
1810 __ push(edx); | 1792 __ push(edx); |
1811 | 1793 |
1812 // Call the entry. | 1794 // Call the entry. |
1813 __ CallRuntime(Runtime::kCallIC_Miss); | 1795 __ CallRuntime(Runtime::kCallIC_Miss); |
1814 | 1796 |
1815 // Move result to edi and exit the internal frame. | 1797 // Move result to edi and exit the internal frame. |
1816 __ mov(edi, eax); | 1798 __ mov(edi, eax); |
1817 | |
1818 // Restore eax. | |
1819 __ pop(eax); | |
1820 __ SmiUntag(eax); | |
1821 } | 1799 } |
1822 | 1800 |
1823 | 1801 |
1824 bool CEntryStub::NeedsImmovableCode() { | 1802 bool CEntryStub::NeedsImmovableCode() { |
1825 return false; | 1803 return false; |
1826 } | 1804 } |
1827 | 1805 |
1828 | 1806 |
1829 void CodeStub::GenerateStubsAheadOfTime(Isolate* isolate) { | 1807 void CodeStub::GenerateStubsAheadOfTime(Isolate* isolate) { |
1830 CEntryStub::GenerateAheadOfTime(isolate); | 1808 CEntryStub::GenerateAheadOfTime(isolate); |
(...skipping 4110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5941 return_value_operand, NULL); | 5919 return_value_operand, NULL); |
5942 } | 5920 } |
5943 | 5921 |
5944 | 5922 |
5945 #undef __ | 5923 #undef __ |
5946 | 5924 |
5947 } // namespace internal | 5925 } // namespace internal |
5948 } // namespace v8 | 5926 } // namespace v8 |
5949 | 5927 |
5950 #endif // V8_TARGET_ARCH_IA32 | 5928 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |