| 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_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 1780 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1791 | 1791 |
| 1792 static void GenerateRecordCallTarget(MacroAssembler* masm) { | 1792 static void GenerateRecordCallTarget(MacroAssembler* masm) { |
| 1793 // Cache the called function in a feedback vector slot. Cache states | 1793 // Cache the called function in a feedback vector slot. Cache states |
| 1794 // are uninitialized, monomorphic (indicated by a JSFunction), and | 1794 // are uninitialized, monomorphic (indicated by a JSFunction), and |
| 1795 // megamorphic. | 1795 // megamorphic. |
| 1796 // r0 : number of arguments to the construct function | 1796 // r0 : number of arguments to the construct function |
| 1797 // r1 : the function to call | 1797 // r1 : the function to call |
| 1798 // r2 : feedback vector | 1798 // r2 : feedback vector |
| 1799 // r3 : slot in feedback vector (Smi) | 1799 // r3 : slot in feedback vector (Smi) |
| 1800 Label initialize, done, miss, megamorphic, not_array_function; | 1800 Label initialize, done, miss, megamorphic, not_array_function; |
| 1801 Label done_initialize_count, done_increment_count; |
| 1801 | 1802 |
| 1802 DCHECK_EQ(*TypeFeedbackVector::MegamorphicSentinel(masm->isolate()), | 1803 DCHECK_EQ(*TypeFeedbackVector::MegamorphicSentinel(masm->isolate()), |
| 1803 masm->isolate()->heap()->megamorphic_symbol()); | 1804 masm->isolate()->heap()->megamorphic_symbol()); |
| 1804 DCHECK_EQ(*TypeFeedbackVector::UninitializedSentinel(masm->isolate()), | 1805 DCHECK_EQ(*TypeFeedbackVector::UninitializedSentinel(masm->isolate()), |
| 1805 masm->isolate()->heap()->uninitialized_symbol()); | 1806 masm->isolate()->heap()->uninitialized_symbol()); |
| 1806 | 1807 |
| 1807 // Load the cache state into r5. | 1808 // Load the cache state into r5. |
| 1808 __ add(r5, r2, Operand::PointerOffsetFromSmiKey(r3)); | 1809 __ add(r5, r2, Operand::PointerOffsetFromSmiKey(r3)); |
| 1809 __ ldr(r5, FieldMemOperand(r5, FixedArray::kHeaderSize)); | 1810 __ ldr(r5, FieldMemOperand(r5, FixedArray::kHeaderSize)); |
| 1810 | 1811 |
| 1811 // A monomorphic cache hit or an already megamorphic state: invoke the | 1812 // A monomorphic cache hit or an already megamorphic state: invoke the |
| 1812 // function without changing the state. | 1813 // function without changing the state. |
| 1813 // We don't know if r5 is a WeakCell or a Symbol, but it's harmless to read at | 1814 // We don't know if r5 is a WeakCell or a Symbol, but it's harmless to read at |
| 1814 // this position in a symbol (see static asserts in type-feedback-vector.h). | 1815 // this position in a symbol (see static asserts in type-feedback-vector.h). |
| 1815 Label check_allocation_site; | 1816 Label check_allocation_site; |
| 1816 Register feedback_map = r6; | 1817 Register feedback_map = r6; |
| 1817 Register weak_value = r9; | 1818 Register weak_value = r9; |
| 1818 __ ldr(weak_value, FieldMemOperand(r5, WeakCell::kValueOffset)); | 1819 __ ldr(weak_value, FieldMemOperand(r5, WeakCell::kValueOffset)); |
| 1819 __ cmp(r1, weak_value); | 1820 __ cmp(r1, weak_value); |
| 1820 __ b(eq, &done); | 1821 __ b(eq, &done_increment_count); |
| 1821 __ CompareRoot(r5, Heap::kmegamorphic_symbolRootIndex); | 1822 __ CompareRoot(r5, Heap::kmegamorphic_symbolRootIndex); |
| 1822 __ b(eq, &done); | 1823 __ b(eq, &done); |
| 1823 __ ldr(feedback_map, FieldMemOperand(r5, HeapObject::kMapOffset)); | 1824 __ ldr(feedback_map, FieldMemOperand(r5, HeapObject::kMapOffset)); |
| 1824 __ CompareRoot(feedback_map, Heap::kWeakCellMapRootIndex); | 1825 __ CompareRoot(feedback_map, Heap::kWeakCellMapRootIndex); |
| 1825 __ b(ne, &check_allocation_site); | 1826 __ b(ne, &check_allocation_site); |
| 1826 | 1827 |
| 1827 // If the weak cell is cleared, we have a new chance to become monomorphic. | 1828 // If the weak cell is cleared, we have a new chance to become monomorphic. |
| 1828 __ JumpIfSmi(weak_value, &initialize); | 1829 __ JumpIfSmi(weak_value, &initialize); |
| 1829 __ jmp(&megamorphic); | 1830 __ jmp(&megamorphic); |
| 1830 | 1831 |
| 1831 __ bind(&check_allocation_site); | 1832 __ bind(&check_allocation_site); |
| 1832 // If we came here, we need to see if we are the array function. | 1833 // If we came here, we need to see if we are the array function. |
| 1833 // If we didn't have a matching function, and we didn't find the megamorph | 1834 // If we didn't have a matching function, and we didn't find the megamorph |
| 1834 // sentinel, then we have in the slot either some other function or an | 1835 // sentinel, then we have in the slot either some other function or an |
| 1835 // AllocationSite. | 1836 // AllocationSite. |
| 1836 __ CompareRoot(feedback_map, Heap::kAllocationSiteMapRootIndex); | 1837 __ CompareRoot(feedback_map, Heap::kAllocationSiteMapRootIndex); |
| 1837 __ b(ne, &miss); | 1838 __ b(ne, &miss); |
| 1838 | 1839 |
| 1839 // Make sure the function is the Array() function | 1840 // Make sure the function is the Array() function |
| 1840 __ LoadNativeContextSlot(Context::ARRAY_FUNCTION_INDEX, r5); | 1841 __ LoadNativeContextSlot(Context::ARRAY_FUNCTION_INDEX, r5); |
| 1841 __ cmp(r1, r5); | 1842 __ cmp(r1, r5); |
| 1842 __ b(ne, &megamorphic); | 1843 __ b(ne, &megamorphic); |
| 1843 __ jmp(&done); | 1844 __ jmp(&done_increment_count); |
| 1844 | 1845 |
| 1845 __ bind(&miss); | 1846 __ bind(&miss); |
| 1846 | 1847 |
| 1847 // A monomorphic miss (i.e, here the cache is not uninitialized) goes | 1848 // A monomorphic miss (i.e, here the cache is not uninitialized) goes |
| 1848 // megamorphic. | 1849 // megamorphic. |
| 1849 __ CompareRoot(r5, Heap::kuninitialized_symbolRootIndex); | 1850 __ CompareRoot(r5, Heap::kuninitialized_symbolRootIndex); |
| 1850 __ b(eq, &initialize); | 1851 __ b(eq, &initialize); |
| 1851 // MegamorphicSentinel is an immortal immovable object (undefined) so no | 1852 // MegamorphicSentinel is an immortal immovable object (undefined) so no |
| 1852 // write-barrier is needed. | 1853 // write-barrier is needed. |
| 1853 __ bind(&megamorphic); | 1854 __ bind(&megamorphic); |
| 1854 __ add(r5, r2, Operand::PointerOffsetFromSmiKey(r3)); | 1855 __ add(r5, r2, Operand::PointerOffsetFromSmiKey(r3)); |
| 1855 __ LoadRoot(ip, Heap::kmegamorphic_symbolRootIndex); | 1856 __ LoadRoot(ip, Heap::kmegamorphic_symbolRootIndex); |
| 1856 __ str(ip, FieldMemOperand(r5, FixedArray::kHeaderSize)); | 1857 __ str(ip, FieldMemOperand(r5, FixedArray::kHeaderSize)); |
| 1857 __ jmp(&done); | 1858 __ jmp(&done); |
| 1858 | 1859 |
| 1859 // An uninitialized cache is patched with the function | 1860 // An uninitialized cache is patched with the function |
| 1860 __ bind(&initialize); | 1861 __ bind(&initialize); |
| 1861 | 1862 |
| 1862 // Make sure the function is the Array() function | 1863 // Make sure the function is the Array() function |
| 1863 __ LoadNativeContextSlot(Context::ARRAY_FUNCTION_INDEX, r5); | 1864 __ LoadNativeContextSlot(Context::ARRAY_FUNCTION_INDEX, r5); |
| 1864 __ cmp(r1, r5); | 1865 __ cmp(r1, r5); |
| 1865 __ b(ne, ¬_array_function); | 1866 __ b(ne, ¬_array_function); |
| 1866 | 1867 |
| 1867 // The target function is the Array constructor, | 1868 // The target function is the Array constructor, |
| 1868 // Create an AllocationSite if we don't already have it, store it in the | 1869 // Create an AllocationSite if we don't already have it, store it in the |
| 1869 // slot. | 1870 // slot. |
| 1870 CreateAllocationSiteStub create_stub(masm->isolate()); | 1871 CreateAllocationSiteStub create_stub(masm->isolate()); |
| 1871 CallStubInRecordCallTarget(masm, &create_stub); | 1872 CallStubInRecordCallTarget(masm, &create_stub); |
| 1872 __ b(&done); | 1873 __ b(&done_initialize_count); |
| 1873 | 1874 |
| 1874 __ bind(¬_array_function); | 1875 __ bind(¬_array_function); |
| 1875 CreateWeakCellStub weak_cell_stub(masm->isolate()); | 1876 CreateWeakCellStub weak_cell_stub(masm->isolate()); |
| 1876 CallStubInRecordCallTarget(masm, &weak_cell_stub); | 1877 CallStubInRecordCallTarget(masm, &weak_cell_stub); |
| 1878 |
| 1879 __ bind(&done_initialize_count); |
| 1880 // Initialize the call counter. |
| 1881 __ Move(r5, Operand(Smi::FromInt(1))); |
| 1882 __ add(r4, r2, Operand::PointerOffsetFromSmiKey(r3)); |
| 1883 __ str(r5, FieldMemOperand(r4, FixedArray::kHeaderSize + kPointerSize)); |
| 1884 __ b(&done); |
| 1885 |
| 1886 __ bind(&done_increment_count); |
| 1887 |
| 1888 // Increment the call count for monomorphic function calls. |
| 1889 __ add(r5, r2, Operand::PointerOffsetFromSmiKey(r3)); |
| 1890 __ add(r5, r5, Operand(FixedArray::kHeaderSize + kPointerSize)); |
| 1891 __ ldr(r4, FieldMemOperand(r5, 0)); |
| 1892 __ add(r4, r4, Operand(Smi::FromInt(1))); |
| 1893 __ str(r4, FieldMemOperand(r5, 0)); |
| 1894 |
| 1877 __ bind(&done); | 1895 __ bind(&done); |
| 1878 } | 1896 } |
| 1879 | 1897 |
| 1880 | 1898 |
| 1881 void CallConstructStub::Generate(MacroAssembler* masm) { | 1899 void CallConstructStub::Generate(MacroAssembler* masm) { |
| 1882 // r0 : number of arguments | 1900 // r0 : number of arguments |
| 1883 // r1 : the function to call | 1901 // r1 : the function to call |
| 1884 // r2 : feedback vector | 1902 // r2 : feedback vector |
| 1885 // r3 : slot in feedback vector (Smi, for RecordCallTarget) | 1903 // r3 : slot in feedback vector (Smi, for RecordCallTarget) |
| 1886 | 1904 |
| (...skipping 3552 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5439 CallApiFunctionAndReturn(masm, api_function_address, thunk_ref, | 5457 CallApiFunctionAndReturn(masm, api_function_address, thunk_ref, |
| 5440 kStackUnwindSpace, NULL, return_value_operand, NULL); | 5458 kStackUnwindSpace, NULL, return_value_operand, NULL); |
| 5441 } | 5459 } |
| 5442 | 5460 |
| 5443 #undef __ | 5461 #undef __ |
| 5444 | 5462 |
| 5445 } // namespace internal | 5463 } // namespace internal |
| 5446 } // namespace v8 | 5464 } // namespace v8 |
| 5447 | 5465 |
| 5448 #endif // V8_TARGET_ARCH_ARM | 5466 #endif // V8_TARGET_ARCH_ARM |
| OLD | NEW |