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

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

Issue 1688283003: [Interpreter] Implements calls through CallICStub in the interpreter. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: 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
OLDNEW
1 // Copyright 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 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_X64 5 #if V8_TARGET_ARCH_X64
6 6
7 #include "src/bootstrapper.h" 7 #include "src/bootstrapper.h"
8 #include "src/code-stubs.h" 8 #include "src/code-stubs.h"
9 #include "src/codegen.h" 9 #include "src/codegen.h"
10 #include "src/ic/handler-compiler.h" 10 #include "src/ic/handler-compiler.h"
(...skipping 1734 matching lines...) Expand 10 before | Expand all | Expand 10 after
1745 __ bind(&non_function); 1745 __ bind(&non_function);
1746 __ movp(rdx, rdi); 1746 __ movp(rdx, rdi);
1747 __ Jump(isolate()->builtins()->Construct(), RelocInfo::CODE_TARGET); 1747 __ Jump(isolate()->builtins()->Construct(), RelocInfo::CODE_TARGET);
1748 } 1748 }
1749 1749
1750 1750
1751 void CallICStub::HandleArrayCase(MacroAssembler* masm, Label* miss) { 1751 void CallICStub::HandleArrayCase(MacroAssembler* masm, Label* miss) {
1752 // rdi - function 1752 // rdi - function
1753 // rdx - slot id 1753 // rdx - slot id
1754 // rbx - vector 1754 // rbx - vector
1755 // rcx - allocation site (loaded from vector[slot]). 1755 // rcx - allocation site (loaded from vector[slot]).
rmcilroy 2016/02/12 14:21:03 Same comment as ia32.
mythria 2016/02/17 11:02:48 Done.
1756 __ LoadNativeContextSlot(Context::ARRAY_FUNCTION_INDEX, r8); 1756 __ LoadNativeContextSlot(Context::ARRAY_FUNCTION_INDEX, r8);
1757 __ cmpp(rdi, r8); 1757 __ cmpp(rdi, r8);
1758 __ j(not_equal, miss); 1758 __ j(not_equal, miss);
1759 1759
1760 __ movp(rax, Immediate(arg_count())); 1760 if (!argc_in_register()) {
1761 __ movp(rax, Immediate(arg_count()));
1762 }
1761 1763
1762 // Increment the call count for monomorphic function calls. 1764 // Increment the call count for monomorphic function calls.
1763 __ SmiAddConstant(FieldOperand(rbx, rdx, times_pointer_size, 1765 __ SmiAddConstant(FieldOperand(rbx, rdx, times_pointer_size,
1764 FixedArray::kHeaderSize + kPointerSize), 1766 FixedArray::kHeaderSize + kPointerSize),
1765 Smi::FromInt(CallICNexus::kCallCountIncrement)); 1767 Smi::FromInt(CallICNexus::kCallCountIncrement));
1766 1768
1767 __ movp(rbx, rcx); 1769 __ movp(rbx, rcx);
1768 __ movp(rdx, rdi); 1770 __ movp(rdx, rdi);
1769 ArrayConstructorStub stub(masm->isolate(), arg_count()); 1771 if (!argc_in_register()) {
rmcilroy 2016/02/12 14:21:03 nit - Swap branches around (avoid ! in condition)
mythria 2016/02/17 11:02:48 Done.
1770 __ TailCallStub(&stub); 1772 ArrayConstructorStub stub(masm->isolate(), arg_count());
1773 __ TailCallStub(&stub);
1774 } else {
1775 ArrayConstructorStub stub(masm->isolate());
1776 __ TailCallStub(&stub);
1777 }
1771 } 1778 }
1772 1779
1773 1780
1774 void CallICStub::Generate(MacroAssembler* masm) { 1781 void CallICStub::Generate(MacroAssembler* masm) {
1775 // ----------- S t a t e ------------- 1782 // ----------- S t a t e -------------
1776 // -- rdi - function 1783 // -- rdi - function
1777 // -- rdx - slot id 1784 // -- rdx - slot id
1778 // -- rbx - vector 1785 // -- rbx - vector
1779 // ----------------------------------- 1786 // -----------------------------------
1780 Isolate* isolate = masm->isolate(); 1787 Isolate* isolate = masm->isolate();
1781 Label extra_checks_or_miss, call, call_function; 1788 Label extra_checks_or_miss, call, call_function;
1782 int argc = arg_count(); 1789 int argc = arg_count();
1783 StackArgumentsAccessor args(rsp, argc);
1784 ParameterCount actual(argc);
1785 1790
1786 // The checks. First, does rdi match the recorded monomorphic target? 1791 // The checks. First, does rdi match the recorded monomorphic target?
1787 __ SmiToInteger32(rdx, rdx); 1792 __ SmiToInteger32(rdx, rdx);
1788 __ movp(rcx, 1793 __ movp(rcx,
1789 FieldOperand(rbx, rdx, times_pointer_size, FixedArray::kHeaderSize)); 1794 FieldOperand(rbx, rdx, times_pointer_size, FixedArray::kHeaderSize));
1790 1795
1791 // We don't know that we have a weak cell. We might have a private symbol 1796 // We don't know that we have a weak cell. We might have a private symbol
1792 // or an AllocationSite, but the memory is safe to examine. 1797 // or an AllocationSite, but the memory is safe to examine.
1793 // AllocationSite::kTransitionInfoOffset - contains a Smi or pointer to 1798 // AllocationSite::kTransitionInfoOffset - contains a Smi or pointer to
1794 // FixedArray. 1799 // FixedArray.
(...skipping 13 matching lines...) Expand all
1808 // The compare above could have been a SMI/SMI comparison. Guard against this 1813 // The compare above could have been a SMI/SMI comparison. Guard against this
1809 // convincing us that we have a monomorphic JSFunction. 1814 // convincing us that we have a monomorphic JSFunction.
1810 __ JumpIfSmi(rdi, &extra_checks_or_miss); 1815 __ JumpIfSmi(rdi, &extra_checks_or_miss);
1811 1816
1812 // Increment the call count for monomorphic function calls. 1817 // Increment the call count for monomorphic function calls.
1813 __ SmiAddConstant(FieldOperand(rbx, rdx, times_pointer_size, 1818 __ SmiAddConstant(FieldOperand(rbx, rdx, times_pointer_size,
1814 FixedArray::kHeaderSize + kPointerSize), 1819 FixedArray::kHeaderSize + kPointerSize),
1815 Smi::FromInt(CallICNexus::kCallCountIncrement)); 1820 Smi::FromInt(CallICNexus::kCallCountIncrement));
1816 1821
1817 __ bind(&call_function); 1822 __ bind(&call_function);
1818 __ Set(rax, argc); 1823 if (!argc_in_register()) {
rmcilroy 2016/02/12 14:21:03 Same comment as ia32
mythria 2016/02/17 11:02:48 Done.
1824 __ Set(rax, argc);
1825 }
1819 __ Jump(masm->isolate()->builtins()->CallFunction(convert_mode(), 1826 __ Jump(masm->isolate()->builtins()->CallFunction(convert_mode(),
1820 tail_call_mode()), 1827 tail_call_mode()),
1821 RelocInfo::CODE_TARGET); 1828 RelocInfo::CODE_TARGET);
1822 1829
1823 __ bind(&extra_checks_or_miss); 1830 __ bind(&extra_checks_or_miss);
1824 Label uninitialized, miss, not_allocation_site; 1831 Label uninitialized, miss, not_allocation_site;
1825 1832
1826 __ Cmp(rcx, TypeFeedbackVector::MegamorphicSentinel(isolate)); 1833 __ Cmp(rcx, TypeFeedbackVector::MegamorphicSentinel(isolate));
1827 __ j(equal, &call); 1834 __ j(equal, &call);
1828 1835
(...skipping 18 matching lines...) Expand all
1847 1854
1848 // We are going megamorphic. If the feedback is a JSFunction, it is fine 1855 // We are going megamorphic. If the feedback is a JSFunction, it is fine
1849 // to handle it here. More complex cases are dealt with in the runtime. 1856 // to handle it here. More complex cases are dealt with in the runtime.
1850 __ AssertNotSmi(rcx); 1857 __ AssertNotSmi(rcx);
1851 __ CmpObjectType(rcx, JS_FUNCTION_TYPE, rcx); 1858 __ CmpObjectType(rcx, JS_FUNCTION_TYPE, rcx);
1852 __ j(not_equal, &miss); 1859 __ j(not_equal, &miss);
1853 __ Move(FieldOperand(rbx, rdx, times_pointer_size, FixedArray::kHeaderSize), 1860 __ Move(FieldOperand(rbx, rdx, times_pointer_size, FixedArray::kHeaderSize),
1854 TypeFeedbackVector::MegamorphicSentinel(isolate)); 1861 TypeFeedbackVector::MegamorphicSentinel(isolate));
1855 1862
1856 __ bind(&call); 1863 __ bind(&call);
1857 __ Set(rax, argc); 1864 if (!argc_in_register()) {
1865 __ Set(rax, argc);
1866 }
1858 __ Jump(masm->isolate()->builtins()->Call(convert_mode(), tail_call_mode()), 1867 __ Jump(masm->isolate()->builtins()->Call(convert_mode(), tail_call_mode()),
1859 RelocInfo::CODE_TARGET); 1868 RelocInfo::CODE_TARGET);
1860 1869
1861 __ bind(&uninitialized); 1870 __ bind(&uninitialized);
1862 1871
1863 // We are going monomorphic, provided we actually have a JSFunction. 1872 // We are going monomorphic, provided we actually have a JSFunction.
1864 __ JumpIfSmi(rdi, &miss); 1873 __ JumpIfSmi(rdi, &miss);
1865 1874
1866 // Goto miss case if we do not have a function. 1875 // Goto miss case if we do not have a function.
1867 __ CmpObjectType(rdi, JS_FUNCTION_TYPE, rcx); 1876 __ CmpObjectType(rdi, JS_FUNCTION_TYPE, rcx);
(...skipping 17 matching lines...) Expand all
1885 Smi::FromInt(CallICNexus::kCallCountIncrement)); 1894 Smi::FromInt(CallICNexus::kCallCountIncrement));
1886 1895
1887 // Store the function. Use a stub since we need a frame for allocation. 1896 // Store the function. Use a stub since we need a frame for allocation.
1888 // rbx - vector 1897 // rbx - vector
1889 // rdx - slot (needs to be in smi form) 1898 // rdx - slot (needs to be in smi form)
1890 // rdi - function 1899 // rdi - function
1891 { 1900 {
1892 FrameScope scope(masm, StackFrame::INTERNAL); 1901 FrameScope scope(masm, StackFrame::INTERNAL);
1893 CreateWeakCellStub create_stub(isolate); 1902 CreateWeakCellStub create_stub(isolate);
1894 1903
1904 if (argc_in_register()) {
1905 __ Integer32ToSmi(rax, rax);
1906 __ Push(rax);
1907 }
1895 __ Integer32ToSmi(rdx, rdx); 1908 __ Integer32ToSmi(rdx, rdx);
1896 __ Push(rdi); 1909 __ Push(rdi);
1897 __ CallStub(&create_stub); 1910 __ CallStub(&create_stub);
1898 __ Pop(rdi); 1911 __ Pop(rdi);
1912 if (argc_in_register()) {
1913 __ Pop(rax);
1914 __ SmiToInteger32(rax, rax);
1915 }
1899 } 1916 }
1900 1917
1901 __ jmp(&call_function); 1918 __ jmp(&call_function);
1902 1919
1903 // We are here because tracing is on or we encountered a MISS case we can't 1920 // We are here because tracing is on or we encountered a MISS case we can't
1904 // handle here. 1921 // handle here.
1905 __ bind(&miss); 1922 __ bind(&miss);
1906 GenerateMiss(masm); 1923 GenerateMiss(masm);
1907 1924
1908 __ jmp(&call); 1925 __ jmp(&call);
1909 1926
1910 // Unreachable 1927 // Unreachable
1911 __ int3(); 1928 __ int3();
1912 } 1929 }
1913 1930
1914 1931
1915 void CallICStub::GenerateMiss(MacroAssembler* masm) { 1932 void CallICStub::GenerateMiss(MacroAssembler* masm) {
1916 FrameScope scope(masm, StackFrame::INTERNAL); 1933 FrameScope scope(masm, StackFrame::INTERNAL);
1917 1934
1935 // Store the number of arguments to be used later.
1936 if (argc_in_register()) {
1937 __ Integer32ToSmi(rax, rax);
1938 __ Push(rax);
1939 }
1940
1918 // Push the receiver and the function and feedback info. 1941 // Push the receiver and the function and feedback info.
1919 __ Push(rdi); 1942 __ Push(rdi);
1920 __ Push(rbx); 1943 __ Push(rbx);
1921 __ Integer32ToSmi(rdx, rdx); 1944 __ Integer32ToSmi(rdx, rdx);
1922 __ Push(rdx); 1945 __ Push(rdx);
1923 1946
1924 // Call the entry. 1947 // Call the entry.
1925 __ CallRuntime(Runtime::kCallIC_Miss); 1948 __ CallRuntime(Runtime::kCallIC_Miss);
1926 1949
1927 // Move result to edi and exit the internal frame. 1950 // Move result to edi and exit the internal frame.
1928 __ movp(rdi, rax); 1951 __ movp(rdi, rax);
1952 if (argc_in_register()) {
1953 // rdi, rbx, rdx are arguments to CallIC_Miss. They will be popped by
1954 // Runtime_CallIC_Miss.
1955 __ Pop(rax);
1956 __ SmiToInteger32(rax, rax);
1957 }
1929 } 1958 }
1930 1959
1931 1960
1932 bool CEntryStub::NeedsImmovableCode() { 1961 bool CEntryStub::NeedsImmovableCode() {
1933 return false; 1962 return false;
1934 } 1963 }
1935 1964
1936 1965
1937 void CodeStub::GenerateStubsAheadOfTime(Isolate* isolate) { 1966 void CodeStub::GenerateStubsAheadOfTime(Isolate* isolate) {
1938 CEntryStub::GenerateAheadOfTime(isolate); 1967 CEntryStub::GenerateAheadOfTime(isolate);
(...skipping 3604 matching lines...) Expand 10 before | Expand all | Expand 10 after
5543 NULL); 5572 NULL);
5544 } 5573 }
5545 5574
5546 5575
5547 #undef __ 5576 #undef __
5548 5577
5549 } // namespace internal 5578 } // namespace internal
5550 } // namespace v8 5579 } // namespace v8
5551 5580
5552 #endif // V8_TARGET_ARCH_X64 5581 #endif // V8_TARGET_ARCH_X64
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698