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

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

Issue 1969783002: Collect call counts for constructor calls, too. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fixed cctest.status, and addressed mips64 comment. Created 4 years, 7 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 1768 matching lines...) Expand 10 before | Expand all | Expand 10 after
1779 1779
1780 static void GenerateRecordCallTarget(MacroAssembler* masm) { 1780 static void GenerateRecordCallTarget(MacroAssembler* masm) {
1781 // Cache the called function in a feedback vector slot. Cache states 1781 // Cache the called function in a feedback vector slot. Cache states
1782 // are uninitialized, monomorphic (indicated by a JSFunction), and 1782 // are uninitialized, monomorphic (indicated by a JSFunction), and
1783 // megamorphic. 1783 // megamorphic.
1784 // r0 : number of arguments to the construct function 1784 // r0 : number of arguments to the construct function
1785 // r1 : the function to call 1785 // r1 : the function to call
1786 // r2 : feedback vector 1786 // r2 : feedback vector
1787 // r3 : slot in feedback vector (Smi) 1787 // r3 : slot in feedback vector (Smi)
1788 Label initialize, done, miss, megamorphic, not_array_function; 1788 Label initialize, done, miss, megamorphic, not_array_function;
1789 Label done_initialize_count, done_increment_count;
1789 1790
1790 DCHECK_EQ(*TypeFeedbackVector::MegamorphicSentinel(masm->isolate()), 1791 DCHECK_EQ(*TypeFeedbackVector::MegamorphicSentinel(masm->isolate()),
1791 masm->isolate()->heap()->megamorphic_symbol()); 1792 masm->isolate()->heap()->megamorphic_symbol());
1792 DCHECK_EQ(*TypeFeedbackVector::UninitializedSentinel(masm->isolate()), 1793 DCHECK_EQ(*TypeFeedbackVector::UninitializedSentinel(masm->isolate()),
1793 masm->isolate()->heap()->uninitialized_symbol()); 1794 masm->isolate()->heap()->uninitialized_symbol());
1794 1795
1795 // Load the cache state into r5. 1796 // Load the cache state into r5.
1796 __ add(r5, r2, Operand::PointerOffsetFromSmiKey(r3)); 1797 __ add(r5, r2, Operand::PointerOffsetFromSmiKey(r3));
1797 __ ldr(r5, FieldMemOperand(r5, FixedArray::kHeaderSize)); 1798 __ ldr(r5, FieldMemOperand(r5, FixedArray::kHeaderSize));
1798 1799
1799 // A monomorphic cache hit or an already megamorphic state: invoke the 1800 // A monomorphic cache hit or an already megamorphic state: invoke the
1800 // function without changing the state. 1801 // function without changing the state.
1801 // We don't know if r5 is a WeakCell or a Symbol, but it's harmless to read at 1802 // We don't know if r5 is a WeakCell or a Symbol, but it's harmless to read at
1802 // this position in a symbol (see static asserts in type-feedback-vector.h). 1803 // this position in a symbol (see static asserts in type-feedback-vector.h).
1803 Label check_allocation_site; 1804 Label check_allocation_site;
1804 Register feedback_map = r6; 1805 Register feedback_map = r6;
1805 Register weak_value = r9; 1806 Register weak_value = r9;
1806 __ ldr(weak_value, FieldMemOperand(r5, WeakCell::kValueOffset)); 1807 __ ldr(weak_value, FieldMemOperand(r5, WeakCell::kValueOffset));
1807 __ cmp(r1, weak_value); 1808 __ cmp(r1, weak_value);
1808 __ b(eq, &done); 1809 __ b(eq, &done_increment_count);
1809 __ CompareRoot(r5, Heap::kmegamorphic_symbolRootIndex); 1810 __ CompareRoot(r5, Heap::kmegamorphic_symbolRootIndex);
1810 __ b(eq, &done); 1811 __ b(eq, &done);
1811 __ ldr(feedback_map, FieldMemOperand(r5, HeapObject::kMapOffset)); 1812 __ ldr(feedback_map, FieldMemOperand(r5, HeapObject::kMapOffset));
1812 __ CompareRoot(feedback_map, Heap::kWeakCellMapRootIndex); 1813 __ CompareRoot(feedback_map, Heap::kWeakCellMapRootIndex);
1813 __ b(ne, &check_allocation_site); 1814 __ b(ne, &check_allocation_site);
1814 1815
1815 // If the weak cell is cleared, we have a new chance to become monomorphic. 1816 // If the weak cell is cleared, we have a new chance to become monomorphic.
1816 __ JumpIfSmi(weak_value, &initialize); 1817 __ JumpIfSmi(weak_value, &initialize);
1817 __ jmp(&megamorphic); 1818 __ jmp(&megamorphic);
1818 1819
1819 __ bind(&check_allocation_site); 1820 __ bind(&check_allocation_site);
1820 // If we came here, we need to see if we are the array function. 1821 // If we came here, we need to see if we are the array function.
1821 // If we didn't have a matching function, and we didn't find the megamorph 1822 // If we didn't have a matching function, and we didn't find the megamorph
1822 // sentinel, then we have in the slot either some other function or an 1823 // sentinel, then we have in the slot either some other function or an
1823 // AllocationSite. 1824 // AllocationSite.
1824 __ CompareRoot(feedback_map, Heap::kAllocationSiteMapRootIndex); 1825 __ CompareRoot(feedback_map, Heap::kAllocationSiteMapRootIndex);
1825 __ b(ne, &miss); 1826 __ b(ne, &miss);
1826 1827
1827 // Make sure the function is the Array() function 1828 // Make sure the function is the Array() function
1828 __ LoadNativeContextSlot(Context::ARRAY_FUNCTION_INDEX, r5); 1829 __ LoadNativeContextSlot(Context::ARRAY_FUNCTION_INDEX, r5);
1829 __ cmp(r1, r5); 1830 __ cmp(r1, r5);
1830 __ b(ne, &megamorphic); 1831 __ b(ne, &megamorphic);
1831 __ jmp(&done); 1832 __ jmp(&done_increment_count);
1832 1833
1833 __ bind(&miss); 1834 __ bind(&miss);
1834 1835
1835 // A monomorphic miss (i.e, here the cache is not uninitialized) goes 1836 // A monomorphic miss (i.e, here the cache is not uninitialized) goes
1836 // megamorphic. 1837 // megamorphic.
1837 __ CompareRoot(r5, Heap::kuninitialized_symbolRootIndex); 1838 __ CompareRoot(r5, Heap::kuninitialized_symbolRootIndex);
1838 __ b(eq, &initialize); 1839 __ b(eq, &initialize);
1839 // MegamorphicSentinel is an immortal immovable object (undefined) so no 1840 // MegamorphicSentinel is an immortal immovable object (undefined) so no
1840 // write-barrier is needed. 1841 // write-barrier is needed.
1841 __ bind(&megamorphic); 1842 __ bind(&megamorphic);
1842 __ add(r5, r2, Operand::PointerOffsetFromSmiKey(r3)); 1843 __ add(r5, r2, Operand::PointerOffsetFromSmiKey(r3));
1843 __ LoadRoot(ip, Heap::kmegamorphic_symbolRootIndex); 1844 __ LoadRoot(ip, Heap::kmegamorphic_symbolRootIndex);
1844 __ str(ip, FieldMemOperand(r5, FixedArray::kHeaderSize)); 1845 __ str(ip, FieldMemOperand(r5, FixedArray::kHeaderSize));
1845 __ jmp(&done); 1846 __ jmp(&done);
1846 1847
1847 // An uninitialized cache is patched with the function 1848 // An uninitialized cache is patched with the function
1848 __ bind(&initialize); 1849 __ bind(&initialize);
1849 1850
1850 // Make sure the function is the Array() function 1851 // Make sure the function is the Array() function
1851 __ LoadNativeContextSlot(Context::ARRAY_FUNCTION_INDEX, r5); 1852 __ LoadNativeContextSlot(Context::ARRAY_FUNCTION_INDEX, r5);
1852 __ cmp(r1, r5); 1853 __ cmp(r1, r5);
1853 __ b(ne, &not_array_function); 1854 __ b(ne, &not_array_function);
1854 1855
1855 // The target function is the Array constructor, 1856 // The target function is the Array constructor,
1856 // Create an AllocationSite if we don't already have it, store it in the 1857 // Create an AllocationSite if we don't already have it, store it in the
1857 // slot. 1858 // slot.
1858 CreateAllocationSiteStub create_stub(masm->isolate()); 1859 CreateAllocationSiteStub create_stub(masm->isolate());
1859 CallStubInRecordCallTarget(masm, &create_stub); 1860 CallStubInRecordCallTarget(masm, &create_stub);
1860 __ b(&done); 1861 __ b(&done_initialize_count);
1861 1862
1862 __ bind(&not_array_function); 1863 __ bind(&not_array_function);
1863 CreateWeakCellStub weak_cell_stub(masm->isolate()); 1864 CreateWeakCellStub weak_cell_stub(masm->isolate());
1864 CallStubInRecordCallTarget(masm, &weak_cell_stub); 1865 CallStubInRecordCallTarget(masm, &weak_cell_stub);
1866
1867 __ bind(&done_initialize_count);
1868 // Initialize the call counter.
1869 __ Move(r5, Operand(Smi::FromInt(1)));
1870 __ add(r4, r2, Operand::PointerOffsetFromSmiKey(r3));
1871 __ str(r5, FieldMemOperand(r4, FixedArray::kHeaderSize + kPointerSize));
1872 __ b(&done);
1873
1874 __ bind(&done_increment_count);
1875
1876 // Increment the call count for monomorphic function calls.
1877 __ add(r5, r2, Operand::PointerOffsetFromSmiKey(r3));
1878 __ add(r5, r5, Operand(FixedArray::kHeaderSize + kPointerSize));
1879 __ ldr(r4, FieldMemOperand(r5, 0));
1880 __ add(r4, r4, Operand(Smi::FromInt(1)));
1881 __ str(r4, FieldMemOperand(r5, 0));
1882
1865 __ bind(&done); 1883 __ bind(&done);
1866 } 1884 }
1867 1885
1868 1886
1869 void CallConstructStub::Generate(MacroAssembler* masm) { 1887 void CallConstructStub::Generate(MacroAssembler* masm) {
1870 // r0 : number of arguments 1888 // r0 : number of arguments
1871 // r1 : the function to call 1889 // r1 : the function to call
1872 // r2 : feedback vector 1890 // r2 : feedback vector
1873 // r3 : slot in feedback vector (Smi, for RecordCallTarget) 1891 // r3 : slot in feedback vector (Smi, for RecordCallTarget)
1874 1892
(...skipping 3552 matching lines...) Expand 10 before | Expand all | Expand 10 after
5427 CallApiFunctionAndReturn(masm, api_function_address, thunk_ref, 5445 CallApiFunctionAndReturn(masm, api_function_address, thunk_ref,
5428 kStackUnwindSpace, NULL, return_value_operand, NULL); 5446 kStackUnwindSpace, NULL, return_value_operand, NULL);
5429 } 5447 }
5430 5448
5431 #undef __ 5449 #undef __
5432 5450
5433 } // namespace internal 5451 } // namespace internal
5434 } // namespace v8 5452 } // namespace v8
5435 5453
5436 #endif // V8_TARGET_ARCH_ARM 5454 #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