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

Side by Side Diff: src/ia32/code-stubs-ia32.cc

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

Powered by Google App Engine
This is Rietveld 408576698