| 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_MIPS | 5 #if V8_TARGET_ARCH_MIPS |
| 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 1764 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1775 | 1775 |
| 1776 static void GenerateRecordCallTarget(MacroAssembler* masm) { | 1776 static void GenerateRecordCallTarget(MacroAssembler* masm) { |
| 1777 // Cache the called function in a feedback vector slot. Cache states | 1777 // Cache the called function in a feedback vector slot. Cache states |
| 1778 // are uninitialized, monomorphic (indicated by a JSFunction), and | 1778 // are uninitialized, monomorphic (indicated by a JSFunction), and |
| 1779 // megamorphic. | 1779 // megamorphic. |
| 1780 // a0 : number of arguments to the construct function | 1780 // a0 : number of arguments to the construct function |
| 1781 // a1 : the function to call | 1781 // a1 : the function to call |
| 1782 // a2 : feedback vector | 1782 // a2 : feedback vector |
| 1783 // a3 : slot in feedback vector (Smi) | 1783 // a3 : slot in feedback vector (Smi) |
| 1784 Label initialize, done, miss, megamorphic, not_array_function; | 1784 Label initialize, done, miss, megamorphic, not_array_function; |
| 1785 Label done_initialize_count, done_increment_count; | |
| 1786 | 1785 |
| 1787 DCHECK_EQ(*TypeFeedbackVector::MegamorphicSentinel(masm->isolate()), | 1786 DCHECK_EQ(*TypeFeedbackVector::MegamorphicSentinel(masm->isolate()), |
| 1788 masm->isolate()->heap()->megamorphic_symbol()); | 1787 masm->isolate()->heap()->megamorphic_symbol()); |
| 1789 DCHECK_EQ(*TypeFeedbackVector::UninitializedSentinel(masm->isolate()), | 1788 DCHECK_EQ(*TypeFeedbackVector::UninitializedSentinel(masm->isolate()), |
| 1790 masm->isolate()->heap()->uninitialized_symbol()); | 1789 masm->isolate()->heap()->uninitialized_symbol()); |
| 1791 | 1790 |
| 1792 // Load the cache state into t2. | 1791 // Load the cache state into t2. |
| 1793 __ Lsa(t2, a2, a3, kPointerSizeLog2 - kSmiTagSize); | 1792 __ Lsa(t2, a2, a3, kPointerSizeLog2 - kSmiTagSize); |
| 1794 __ lw(t2, FieldMemOperand(t2, FixedArray::kHeaderSize)); | 1793 __ lw(t2, FieldMemOperand(t2, FixedArray::kHeaderSize)); |
| 1795 | 1794 |
| 1796 // A monomorphic cache hit or an already megamorphic state: invoke the | 1795 // A monomorphic cache hit or an already megamorphic state: invoke the |
| 1797 // function without changing the state. | 1796 // function without changing the state. |
| 1798 // We don't know if t2 is a WeakCell or a Symbol, but it's harmless to read at | 1797 // We don't know if t2 is a WeakCell or a Symbol, but it's harmless to read at |
| 1799 // this position in a symbol (see static asserts in type-feedback-vector.h). | 1798 // this position in a symbol (see static asserts in type-feedback-vector.h). |
| 1800 Label check_allocation_site; | 1799 Label check_allocation_site; |
| 1801 Register feedback_map = t1; | 1800 Register feedback_map = t1; |
| 1802 Register weak_value = t4; | 1801 Register weak_value = t4; |
| 1803 __ lw(weak_value, FieldMemOperand(t2, WeakCell::kValueOffset)); | 1802 __ lw(weak_value, FieldMemOperand(t2, WeakCell::kValueOffset)); |
| 1804 __ Branch(&done_increment_count, eq, a1, Operand(weak_value)); | 1803 __ Branch(&done, eq, a1, Operand(weak_value)); |
| 1805 __ LoadRoot(at, Heap::kmegamorphic_symbolRootIndex); | 1804 __ LoadRoot(at, Heap::kmegamorphic_symbolRootIndex); |
| 1806 __ Branch(&done, eq, t2, Operand(at)); | 1805 __ Branch(&done, eq, t2, Operand(at)); |
| 1807 __ lw(feedback_map, FieldMemOperand(t2, HeapObject::kMapOffset)); | 1806 __ lw(feedback_map, FieldMemOperand(t2, HeapObject::kMapOffset)); |
| 1808 __ LoadRoot(at, Heap::kWeakCellMapRootIndex); | 1807 __ LoadRoot(at, Heap::kWeakCellMapRootIndex); |
| 1809 __ Branch(&check_allocation_site, ne, feedback_map, Operand(at)); | 1808 __ Branch(&check_allocation_site, ne, feedback_map, Operand(at)); |
| 1810 | 1809 |
| 1811 // If the weak cell is cleared, we have a new chance to become monomorphic. | 1810 // If the weak cell is cleared, we have a new chance to become monomorphic. |
| 1812 __ JumpIfSmi(weak_value, &initialize); | 1811 __ JumpIfSmi(weak_value, &initialize); |
| 1813 __ jmp(&megamorphic); | 1812 __ jmp(&megamorphic); |
| 1814 | 1813 |
| 1815 __ bind(&check_allocation_site); | 1814 __ bind(&check_allocation_site); |
| 1816 // If we came here, we need to see if we are the array function. | 1815 // If we came here, we need to see if we are the array function. |
| 1817 // If we didn't have a matching function, and we didn't find the megamorph | 1816 // If we didn't have a matching function, and we didn't find the megamorph |
| 1818 // sentinel, then we have in the slot either some other function or an | 1817 // sentinel, then we have in the slot either some other function or an |
| 1819 // AllocationSite. | 1818 // AllocationSite. |
| 1820 __ LoadRoot(at, Heap::kAllocationSiteMapRootIndex); | 1819 __ LoadRoot(at, Heap::kAllocationSiteMapRootIndex); |
| 1821 __ Branch(&miss, ne, feedback_map, Operand(at)); | 1820 __ Branch(&miss, ne, feedback_map, Operand(at)); |
| 1822 | 1821 |
| 1823 // Make sure the function is the Array() function | 1822 // Make sure the function is the Array() function |
| 1824 __ LoadNativeContextSlot(Context::ARRAY_FUNCTION_INDEX, t2); | 1823 __ LoadNativeContextSlot(Context::ARRAY_FUNCTION_INDEX, t2); |
| 1825 __ Branch(&megamorphic, ne, a1, Operand(t2)); | 1824 __ Branch(&megamorphic, ne, a1, Operand(t2)); |
| 1826 __ jmp(&done_increment_count); | 1825 __ jmp(&done); |
| 1827 | 1826 |
| 1828 __ bind(&miss); | 1827 __ bind(&miss); |
| 1829 | 1828 |
| 1830 // A monomorphic miss (i.e, here the cache is not uninitialized) goes | 1829 // A monomorphic miss (i.e, here the cache is not uninitialized) goes |
| 1831 // megamorphic. | 1830 // megamorphic. |
| 1832 __ LoadRoot(at, Heap::kuninitialized_symbolRootIndex); | 1831 __ LoadRoot(at, Heap::kuninitialized_symbolRootIndex); |
| 1833 __ Branch(&initialize, eq, t2, Operand(at)); | 1832 __ Branch(&initialize, eq, t2, Operand(at)); |
| 1834 // MegamorphicSentinel is an immortal immovable object (undefined) so no | 1833 // MegamorphicSentinel is an immortal immovable object (undefined) so no |
| 1835 // write-barrier is needed. | 1834 // write-barrier is needed. |
| 1836 __ bind(&megamorphic); | 1835 __ bind(&megamorphic); |
| 1837 __ Lsa(t2, a2, a3, kPointerSizeLog2 - kSmiTagSize); | 1836 __ Lsa(t2, a2, a3, kPointerSizeLog2 - kSmiTagSize); |
| 1838 __ LoadRoot(at, Heap::kmegamorphic_symbolRootIndex); | 1837 __ LoadRoot(at, Heap::kmegamorphic_symbolRootIndex); |
| 1839 __ sw(at, FieldMemOperand(t2, FixedArray::kHeaderSize)); | 1838 __ sw(at, FieldMemOperand(t2, FixedArray::kHeaderSize)); |
| 1840 __ jmp(&done); | 1839 __ jmp(&done); |
| 1841 | 1840 |
| 1842 // An uninitialized cache is patched with the function. | 1841 // An uninitialized cache is patched with the function. |
| 1843 __ bind(&initialize); | 1842 __ bind(&initialize); |
| 1844 // Make sure the function is the Array() function. | 1843 // Make sure the function is the Array() function. |
| 1845 __ LoadNativeContextSlot(Context::ARRAY_FUNCTION_INDEX, t2); | 1844 __ LoadNativeContextSlot(Context::ARRAY_FUNCTION_INDEX, t2); |
| 1846 __ Branch(¬_array_function, ne, a1, Operand(t2)); | 1845 __ Branch(¬_array_function, ne, a1, Operand(t2)); |
| 1847 | 1846 |
| 1848 // The target function is the Array constructor, | 1847 // The target function is the Array constructor, |
| 1849 // Create an AllocationSite if we don't already have it, store it in the | 1848 // Create an AllocationSite if we don't already have it, store it in the |
| 1850 // slot. | 1849 // slot. |
| 1851 CreateAllocationSiteStub create_stub(masm->isolate()); | 1850 CreateAllocationSiteStub create_stub(masm->isolate()); |
| 1852 CallStubInRecordCallTarget(masm, &create_stub); | 1851 CallStubInRecordCallTarget(masm, &create_stub); |
| 1853 __ Branch(&done_initialize_count); | 1852 __ Branch(&done); |
| 1854 | 1853 |
| 1855 __ bind(¬_array_function); | 1854 __ bind(¬_array_function); |
| 1856 CreateWeakCellStub weak_cell_stub(masm->isolate()); | 1855 CreateWeakCellStub weak_cell_stub(masm->isolate()); |
| 1857 CallStubInRecordCallTarget(masm, &weak_cell_stub); | 1856 CallStubInRecordCallTarget(masm, &weak_cell_stub); |
| 1858 | 1857 |
| 1859 __ bind(&done_initialize_count); | 1858 __ bind(&done); |
| 1860 // Initialize the call counter. | |
| 1861 __ Lsa(at, a2, a3, kPointerSizeLog2 - kSmiTagSize); | |
| 1862 __ li(t0, Operand(Smi::FromInt(1))); | |
| 1863 __ Branch(USE_DELAY_SLOT, &done); | |
| 1864 __ sw(t0, FieldMemOperand(at, FixedArray::kHeaderSize + kPointerSize)); | |
| 1865 | 1859 |
| 1866 __ bind(&done_increment_count); | 1860 // Increment the call count for all function calls. |
| 1867 | |
| 1868 // Increment the call count for monomorphic function calls. | |
| 1869 __ Lsa(at, a2, a3, kPointerSizeLog2 - kSmiTagSize); | 1861 __ Lsa(at, a2, a3, kPointerSizeLog2 - kSmiTagSize); |
| 1870 __ lw(t0, FieldMemOperand(at, FixedArray::kHeaderSize + kPointerSize)); | 1862 __ lw(t0, FieldMemOperand(at, FixedArray::kHeaderSize + kPointerSize)); |
| 1871 __ Addu(t0, t0, Operand(Smi::FromInt(1))); | 1863 __ Addu(t0, t0, Operand(Smi::FromInt(1))); |
| 1872 __ sw(t0, FieldMemOperand(at, FixedArray::kHeaderSize + kPointerSize)); | 1864 __ sw(t0, FieldMemOperand(at, FixedArray::kHeaderSize + kPointerSize)); |
| 1873 | |
| 1874 __ bind(&done); | |
| 1875 } | 1865 } |
| 1876 | 1866 |
| 1877 | 1867 |
| 1878 void CallConstructStub::Generate(MacroAssembler* masm) { | 1868 void CallConstructStub::Generate(MacroAssembler* masm) { |
| 1879 // a0 : number of arguments | 1869 // a0 : number of arguments |
| 1880 // a1 : the function to call | 1870 // a1 : the function to call |
| 1881 // a2 : feedback vector | 1871 // a2 : feedback vector |
| 1882 // a3 : slot in feedback vector (Smi, for RecordCallTarget) | 1872 // a3 : slot in feedback vector (Smi, for RecordCallTarget) |
| 1883 | 1873 |
| 1884 Label non_function; | 1874 Label non_function; |
| (...skipping 3489 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5374 kStackUnwindSpace, kInvalidStackOffset, | 5364 kStackUnwindSpace, kInvalidStackOffset, |
| 5375 return_value_operand, NULL); | 5365 return_value_operand, NULL); |
| 5376 } | 5366 } |
| 5377 | 5367 |
| 5378 #undef __ | 5368 #undef __ |
| 5379 | 5369 |
| 5380 } // namespace internal | 5370 } // namespace internal |
| 5381 } // namespace v8 | 5371 } // namespace v8 |
| 5382 | 5372 |
| 5383 #endif // V8_TARGET_ARCH_MIPS | 5373 #endif // V8_TARGET_ARCH_MIPS |
| OLD | NEW |