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

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

Issue 2325083003: Record call counts also for megamorphic calls. (Closed)
Patch Set: Code comments. Created 4 years, 3 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 | « no previous file | src/arm64/code-stubs-arm64.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_ARM 5 #if V8_TARGET_ARCH_ARM
6 6
7 #include "src/code-stubs.h" 7 #include "src/code-stubs.h"
8 #include "src/api-arguments.h" 8 #include "src/api-arguments.h"
9 #include "src/base/bits.h" 9 #include "src/base/bits.h"
10 #include "src/bootstrapper.h" 10 #include "src/bootstrapper.h"
(...skipping 1767 matching lines...) Expand 10 before | Expand all | Expand 10 after
1778 // context at this point). 1778 // context at this point).
1779 __ ldr(r4, FieldMemOperand(r1, JSFunction::kSharedFunctionInfoOffset)); 1779 __ ldr(r4, FieldMemOperand(r1, JSFunction::kSharedFunctionInfoOffset));
1780 __ ldr(r4, FieldMemOperand(r4, SharedFunctionInfo::kConstructStubOffset)); 1780 __ ldr(r4, FieldMemOperand(r4, SharedFunctionInfo::kConstructStubOffset));
1781 __ add(pc, r4, Operand(Code::kHeaderSize - kHeapObjectTag)); 1781 __ add(pc, r4, Operand(Code::kHeaderSize - kHeapObjectTag));
1782 1782
1783 __ bind(&non_function); 1783 __ bind(&non_function);
1784 __ mov(r3, r1); 1784 __ mov(r3, r1);
1785 __ Jump(isolate()->builtins()->Construct(), RelocInfo::CODE_TARGET); 1785 __ Jump(isolate()->builtins()->Construct(), RelocInfo::CODE_TARGET);
1786 } 1786 }
1787 1787
1788 // Note: feedback_vector and slot are clobbered after the call.
1789 static void IncrementCallCount(MacroAssembler* masm, Register feedback_vector,
1790 Register slot) {
1791 __ add(feedback_vector, feedback_vector,
1792 Operand::PointerOffsetFromSmiKey(slot));
1793 __ add(feedback_vector, feedback_vector,
1794 Operand(FixedArray::kHeaderSize + kPointerSize));
1795 __ ldr(slot, FieldMemOperand(feedback_vector, 0));
1796 __ add(slot, slot, Operand(Smi::FromInt(1)));
1797 __ str(slot, FieldMemOperand(feedback_vector, 0));
1798 }
1788 1799
1789 void CallICStub::HandleArrayCase(MacroAssembler* masm, Label* miss) { 1800 void CallICStub::HandleArrayCase(MacroAssembler* masm, Label* miss) {
1790 // r1 - function 1801 // r1 - function
1791 // r3 - slot id 1802 // r3 - slot id
1792 // r2 - vector 1803 // r2 - vector
1793 // r4 - allocation site (loaded from vector[slot]) 1804 // r4 - allocation site (loaded from vector[slot])
1794 __ LoadNativeContextSlot(Context::ARRAY_FUNCTION_INDEX, r5); 1805 __ LoadNativeContextSlot(Context::ARRAY_FUNCTION_INDEX, r5);
1795 __ cmp(r1, r5); 1806 __ cmp(r1, r5);
1796 __ b(ne, miss); 1807 __ b(ne, miss);
1797 1808
1798 __ mov(r0, Operand(arg_count())); 1809 __ mov(r0, Operand(arg_count()));
1799 1810
1800 // Increment the call count for monomorphic function calls. 1811 // Increment the call count for monomorphic function calls.
1801 __ add(r2, r2, Operand::PointerOffsetFromSmiKey(r3)); 1812 IncrementCallCount(masm, r2, r3);
1802 __ add(r2, r2, Operand(FixedArray::kHeaderSize + kPointerSize));
1803 __ ldr(r3, FieldMemOperand(r2, 0));
1804 __ add(r3, r3, Operand(Smi::FromInt(1)));
1805 __ str(r3, FieldMemOperand(r2, 0));
1806 1813
1807 __ mov(r2, r4); 1814 __ mov(r2, r4);
1808 __ mov(r3, r1); 1815 __ mov(r3, r1);
1809 ArrayConstructorStub stub(masm->isolate(), arg_count()); 1816 ArrayConstructorStub stub(masm->isolate(), arg_count());
1810 __ TailCallStub(&stub); 1817 __ TailCallStub(&stub);
1811 } 1818 }
1812 1819
1813 1820
1814 void CallICStub::Generate(MacroAssembler* masm) { 1821 void CallICStub::Generate(MacroAssembler* masm) {
1815 // r1 - function 1822 // r1 - function
1816 // r3 - slot id (Smi) 1823 // r3 - slot id (Smi)
1817 // r2 - vector 1824 // r2 - vector
1818 Label extra_checks_or_miss, call, call_function; 1825 Label extra_checks_or_miss, call, call_function, call_count_incremented;
1819 int argc = arg_count(); 1826 int argc = arg_count();
1820 ParameterCount actual(argc); 1827 ParameterCount actual(argc);
1821 1828
1822 // The checks. First, does r1 match the recorded monomorphic target? 1829 // The checks. First, does r1 match the recorded monomorphic target?
1823 __ add(r4, r2, Operand::PointerOffsetFromSmiKey(r3)); 1830 __ add(r4, r2, Operand::PointerOffsetFromSmiKey(r3));
1824 __ ldr(r4, FieldMemOperand(r4, FixedArray::kHeaderSize)); 1831 __ ldr(r4, FieldMemOperand(r4, FixedArray::kHeaderSize));
1825 1832
1826 // We don't know that we have a weak cell. We might have a private symbol 1833 // We don't know that we have a weak cell. We might have a private symbol
1827 // or an AllocationSite, but the memory is safe to examine. 1834 // or an AllocationSite, but the memory is safe to examine.
1828 // AllocationSite::kTransitionInfoOffset - contains a Smi or pointer to 1835 // AllocationSite::kTransitionInfoOffset - contains a Smi or pointer to
1829 // FixedArray. 1836 // FixedArray.
1830 // WeakCell::kValueOffset - contains a JSFunction or Smi(0) 1837 // WeakCell::kValueOffset - contains a JSFunction or Smi(0)
1831 // Symbol::kHashFieldSlot - if the low bit is 1, then the hash is not 1838 // Symbol::kHashFieldSlot - if the low bit is 1, then the hash is not
1832 // computed, meaning that it can't appear to be a pointer. If the low bit is 1839 // computed, meaning that it can't appear to be a pointer. If the low bit is
1833 // 0, then hash is computed, but the 0 bit prevents the field from appearing 1840 // 0, then hash is computed, but the 0 bit prevents the field from appearing
1834 // to be a pointer. 1841 // to be a pointer.
1835 STATIC_ASSERT(WeakCell::kSize >= kPointerSize); 1842 STATIC_ASSERT(WeakCell::kSize >= kPointerSize);
1836 STATIC_ASSERT(AllocationSite::kTransitionInfoOffset == 1843 STATIC_ASSERT(AllocationSite::kTransitionInfoOffset ==
1837 WeakCell::kValueOffset && 1844 WeakCell::kValueOffset &&
1838 WeakCell::kValueOffset == Symbol::kHashFieldSlot); 1845 WeakCell::kValueOffset == Symbol::kHashFieldSlot);
1839 1846
1840 __ ldr(r5, FieldMemOperand(r4, WeakCell::kValueOffset)); 1847 __ ldr(r5, FieldMemOperand(r4, WeakCell::kValueOffset));
1841 __ cmp(r1, r5); 1848 __ cmp(r1, r5);
1842 __ b(ne, &extra_checks_or_miss); 1849 __ b(ne, &extra_checks_or_miss);
1843 1850
1844 // The compare above could have been a SMI/SMI comparison. Guard against this 1851 // The compare above could have been a SMI/SMI comparison. Guard against this
1845 // convincing us that we have a monomorphic JSFunction. 1852 // convincing us that we have a monomorphic JSFunction.
1846 __ JumpIfSmi(r1, &extra_checks_or_miss); 1853 __ JumpIfSmi(r1, &extra_checks_or_miss);
1847 1854
1855 __ bind(&call_function);
1856
1848 // Increment the call count for monomorphic function calls. 1857 // Increment the call count for monomorphic function calls.
1849 __ add(r2, r2, Operand::PointerOffsetFromSmiKey(r3)); 1858 IncrementCallCount(masm, r2, r3);
1850 __ add(r2, r2, Operand(FixedArray::kHeaderSize + kPointerSize));
1851 __ ldr(r3, FieldMemOperand(r2, 0));
1852 __ add(r3, r3, Operand(Smi::FromInt(1)));
1853 __ str(r3, FieldMemOperand(r2, 0));
1854 1859
1855 __ bind(&call_function);
1856 __ mov(r0, Operand(argc)); 1860 __ mov(r0, Operand(argc));
1857 __ Jump(masm->isolate()->builtins()->CallFunction(convert_mode(), 1861 __ Jump(masm->isolate()->builtins()->CallFunction(convert_mode(),
1858 tail_call_mode()), 1862 tail_call_mode()),
1859 RelocInfo::CODE_TARGET); 1863 RelocInfo::CODE_TARGET);
1860 1864
1861 __ bind(&extra_checks_or_miss); 1865 __ bind(&extra_checks_or_miss);
1862 Label uninitialized, miss, not_allocation_site; 1866 Label uninitialized, miss, not_allocation_site;
1863 1867
1864 __ CompareRoot(r4, Heap::kmegamorphic_symbolRootIndex); 1868 __ CompareRoot(r4, Heap::kmegamorphic_symbolRootIndex);
1865 __ b(eq, &call); 1869 __ b(eq, &call);
(...skipping 20 matching lines...) Expand all
1886 // We are going megamorphic. If the feedback is a JSFunction, it is fine 1890 // We are going megamorphic. If the feedback is a JSFunction, it is fine
1887 // to handle it here. More complex cases are dealt with in the runtime. 1891 // to handle it here. More complex cases are dealt with in the runtime.
1888 __ AssertNotSmi(r4); 1892 __ AssertNotSmi(r4);
1889 __ CompareObjectType(r4, r5, r5, JS_FUNCTION_TYPE); 1893 __ CompareObjectType(r4, r5, r5, JS_FUNCTION_TYPE);
1890 __ b(ne, &miss); 1894 __ b(ne, &miss);
1891 __ add(r4, r2, Operand::PointerOffsetFromSmiKey(r3)); 1895 __ add(r4, r2, Operand::PointerOffsetFromSmiKey(r3));
1892 __ LoadRoot(ip, Heap::kmegamorphic_symbolRootIndex); 1896 __ LoadRoot(ip, Heap::kmegamorphic_symbolRootIndex);
1893 __ str(ip, FieldMemOperand(r4, FixedArray::kHeaderSize)); 1897 __ str(ip, FieldMemOperand(r4, FixedArray::kHeaderSize));
1894 1898
1895 __ bind(&call); 1899 __ bind(&call);
1900
1901 // Increment the call count for megamorphic function calls.
1902 IncrementCallCount(masm, r2, r3);
1903
1904 __ bind(&call_count_incremented);
1896 __ mov(r0, Operand(argc)); 1905 __ mov(r0, Operand(argc));
1897 __ Jump(masm->isolate()->builtins()->Call(convert_mode(), tail_call_mode()), 1906 __ Jump(masm->isolate()->builtins()->Call(convert_mode(), tail_call_mode()),
1898 RelocInfo::CODE_TARGET); 1907 RelocInfo::CODE_TARGET);
1899 1908
1900 __ bind(&uninitialized); 1909 __ bind(&uninitialized);
1901 1910
1902 // We are going monomorphic, provided we actually have a JSFunction. 1911 // We are going monomorphic, provided we actually have a JSFunction.
1903 __ JumpIfSmi(r1, &miss); 1912 __ JumpIfSmi(r1, &miss);
1904 1913
1905 // Goto miss case if we do not have a function. 1914 // Goto miss case if we do not have a function.
1906 __ CompareObjectType(r1, r4, r4, JS_FUNCTION_TYPE); 1915 __ CompareObjectType(r1, r4, r4, JS_FUNCTION_TYPE);
1907 __ b(ne, &miss); 1916 __ b(ne, &miss);
1908 1917
1909 // Make sure the function is not the Array() function, which requires special 1918 // Make sure the function is not the Array() function, which requires special
1910 // behavior on MISS. 1919 // behavior on MISS.
1911 __ LoadNativeContextSlot(Context::ARRAY_FUNCTION_INDEX, r4); 1920 __ LoadNativeContextSlot(Context::ARRAY_FUNCTION_INDEX, r4);
1912 __ cmp(r1, r4); 1921 __ cmp(r1, r4);
1913 __ b(eq, &miss); 1922 __ b(eq, &miss);
1914 1923
1915 // Make sure the function belongs to the same native context. 1924 // Make sure the function belongs to the same native context.
1916 __ ldr(r4, FieldMemOperand(r1, JSFunction::kContextOffset)); 1925 __ ldr(r4, FieldMemOperand(r1, JSFunction::kContextOffset));
1917 __ ldr(r4, ContextMemOperand(r4, Context::NATIVE_CONTEXT_INDEX)); 1926 __ ldr(r4, ContextMemOperand(r4, Context::NATIVE_CONTEXT_INDEX));
1918 __ ldr(ip, NativeContextMemOperand()); 1927 __ ldr(ip, NativeContextMemOperand());
1919 __ cmp(r4, ip); 1928 __ cmp(r4, ip);
1920 __ b(ne, &miss); 1929 __ b(ne, &miss);
1921 1930
1922 // Initialize the call counter.
1923 __ Move(r5, Operand(Smi::FromInt(1)));
1924 __ add(r4, r2, Operand::PointerOffsetFromSmiKey(r3));
1925 __ str(r5, FieldMemOperand(r4, FixedArray::kHeaderSize + kPointerSize));
1926
1927 // Store the function. Use a stub since we need a frame for allocation. 1931 // Store the function. Use a stub since we need a frame for allocation.
1928 // r2 - vector 1932 // r2 - vector
1929 // r3 - slot 1933 // r3 - slot
1930 // r1 - function 1934 // r1 - function
1931 { 1935 {
1932 FrameScope scope(masm, StackFrame::INTERNAL); 1936 FrameScope scope(masm, StackFrame::INTERNAL);
1933 CreateWeakCellStub create_stub(masm->isolate()); 1937 CreateWeakCellStub create_stub(masm->isolate());
1938 __ Push(r2);
1939 __ Push(r3);
1934 __ Push(cp, r1); 1940 __ Push(cp, r1);
1935 __ CallStub(&create_stub); 1941 __ CallStub(&create_stub);
1936 __ Pop(cp, r1); 1942 __ Pop(cp, r1);
1943 __ Pop(r3);
1944 __ Pop(r2);
1937 } 1945 }
1938 1946
1939 __ jmp(&call_function); 1947 __ jmp(&call_function);
1940 1948
1941 // We are here because tracing is on or we encountered a MISS case we can't 1949 // We are here because tracing is on or we encountered a MISS case we can't
1942 // handle here. 1950 // handle here.
1943 __ bind(&miss); 1951 __ bind(&miss);
1944 GenerateMiss(masm); 1952 GenerateMiss(masm);
1945 1953
1946 __ jmp(&call); 1954 __ jmp(&call_count_incremented);
1947 } 1955 }
1948 1956
1949 1957
1950 void CallICStub::GenerateMiss(MacroAssembler* masm) { 1958 void CallICStub::GenerateMiss(MacroAssembler* masm) {
1951 FrameAndConstantPoolScope scope(masm, StackFrame::INTERNAL); 1959 FrameAndConstantPoolScope scope(masm, StackFrame::INTERNAL);
1952 1960
1953 // Push the receiver and the function and feedback info. 1961 // Push the receiver and the function and feedback info.
1954 __ Push(r1, r2, r3); 1962 __ Push(r1, r2, r3);
1955 1963
1956 // Call the entry. 1964 // Call the entry.
(...skipping 3226 matching lines...) Expand 10 before | Expand all | Expand 10 after
5183 CallApiFunctionAndReturn(masm, api_function_address, thunk_ref, 5191 CallApiFunctionAndReturn(masm, api_function_address, thunk_ref,
5184 kStackUnwindSpace, NULL, return_value_operand, NULL); 5192 kStackUnwindSpace, NULL, return_value_operand, NULL);
5185 } 5193 }
5186 5194
5187 #undef __ 5195 #undef __
5188 5196
5189 } // namespace internal 5197 } // namespace internal
5190 } // namespace v8 5198 } // namespace v8
5191 5199
5192 #endif // V8_TARGET_ARCH_ARM 5200 #endif // V8_TARGET_ARCH_ARM
OLDNEW
« no previous file with comments | « no previous file | src/arm64/code-stubs-arm64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698