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