| OLD | NEW |
| 1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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_X64 | 5 #if V8_TARGET_ARCH_X64 |
| 6 | 6 |
| 7 #include "src/bootstrapper.h" | 7 #include "src/bootstrapper.h" |
| 8 #include "src/code-stubs.h" | 8 #include "src/code-stubs.h" |
| 9 #include "src/codegen.h" | 9 #include "src/codegen.h" |
| 10 #include "src/ic/handler-compiler.h" | 10 #include "src/ic/handler-compiler.h" |
| (...skipping 1768 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1779 // Cache the called function in a feedback vector slot. Cache states | 1779 // Cache the called function in a feedback vector slot. Cache states |
| 1780 // are uninitialized, monomorphic (indicated by a JSFunction), and | 1780 // are uninitialized, monomorphic (indicated by a JSFunction), and |
| 1781 // megamorphic. | 1781 // megamorphic. |
| 1782 // rax : number of arguments to the construct function | 1782 // rax : number of arguments to the construct function |
| 1783 // rbx : feedback vector | 1783 // rbx : feedback vector |
| 1784 // rdx : slot in feedback vector (Smi) | 1784 // rdx : slot in feedback vector (Smi) |
| 1785 // rdi : the function to call | 1785 // rdi : the function to call |
| 1786 Isolate* isolate = masm->isolate(); | 1786 Isolate* isolate = masm->isolate(); |
| 1787 Label initialize, done, miss, megamorphic, not_array_function, | 1787 Label initialize, done, miss, megamorphic, not_array_function, |
| 1788 done_no_smi_convert; | 1788 done_no_smi_convert; |
| 1789 Label done_increment_count; | |
| 1790 | 1789 |
| 1791 // Load the cache state into r11. | 1790 // Load the cache state into r11. |
| 1792 __ SmiToInteger32(rdx, rdx); | 1791 __ SmiToInteger32(rdx, rdx); |
| 1793 __ movp(r11, | 1792 __ movp(r11, |
| 1794 FieldOperand(rbx, rdx, times_pointer_size, FixedArray::kHeaderSize)); | 1793 FieldOperand(rbx, rdx, times_pointer_size, 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 r11 is a WeakCell or a Symbol, but it's harmless to read | 1797 // We don't know if r11 is a WeakCell or a Symbol, but it's harmless to read |
| 1799 // at this position in a symbol (see static asserts in | 1798 // at this position in a symbol (see static asserts in |
| 1800 // type-feedback-vector.h). | 1799 // type-feedback-vector.h). |
| 1801 Label check_allocation_site; | 1800 Label check_allocation_site; |
| 1802 __ cmpp(rdi, FieldOperand(r11, WeakCell::kValueOffset)); | 1801 __ cmpp(rdi, FieldOperand(r11, WeakCell::kValueOffset)); |
| 1803 __ j(equal, &done_increment_count, Label::kFar); | 1802 __ j(equal, &done, Label::kFar); |
| 1804 __ CompareRoot(r11, Heap::kmegamorphic_symbolRootIndex); | 1803 __ CompareRoot(r11, Heap::kmegamorphic_symbolRootIndex); |
| 1805 __ j(equal, &done, Label::kFar); | 1804 __ j(equal, &done, Label::kFar); |
| 1806 __ CompareRoot(FieldOperand(r11, HeapObject::kMapOffset), | 1805 __ CompareRoot(FieldOperand(r11, HeapObject::kMapOffset), |
| 1807 Heap::kWeakCellMapRootIndex); | 1806 Heap::kWeakCellMapRootIndex); |
| 1808 __ j(not_equal, &check_allocation_site); | 1807 __ j(not_equal, &check_allocation_site); |
| 1809 | 1808 |
| 1810 // If the weak cell is cleared, we have a new chance to become monomorphic. | 1809 // If the weak cell is cleared, we have a new chance to become monomorphic. |
| 1811 __ CheckSmi(FieldOperand(r11, WeakCell::kValueOffset)); | 1810 __ CheckSmi(FieldOperand(r11, WeakCell::kValueOffset)); |
| 1812 __ j(equal, &initialize); | 1811 __ j(equal, &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 __ CompareRoot(FieldOperand(r11, 0), Heap::kAllocationSiteMapRootIndex); | 1819 __ CompareRoot(FieldOperand(r11, 0), Heap::kAllocationSiteMapRootIndex); |
| 1821 __ j(not_equal, &miss); | 1820 __ j(not_equal, &miss); |
| 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, r11); | 1823 __ LoadNativeContextSlot(Context::ARRAY_FUNCTION_INDEX, r11); |
| 1825 __ cmpp(rdi, r11); | 1824 __ cmpp(rdi, r11); |
| 1826 __ j(not_equal, &megamorphic); | 1825 __ j(not_equal, &megamorphic); |
| 1827 __ jmp(&done_increment_count); | 1826 __ jmp(&done); |
| 1828 | 1827 |
| 1829 __ bind(&miss); | 1828 __ bind(&miss); |
| 1830 | 1829 |
| 1831 // A monomorphic miss (i.e, here the cache is not uninitialized) goes | 1830 // A monomorphic miss (i.e, here the cache is not uninitialized) goes |
| 1832 // megamorphic. | 1831 // megamorphic. |
| 1833 __ CompareRoot(r11, Heap::kuninitialized_symbolRootIndex); | 1832 __ CompareRoot(r11, Heap::kuninitialized_symbolRootIndex); |
| 1834 __ j(equal, &initialize); | 1833 __ j(equal, &initialize); |
| 1835 // MegamorphicSentinel is an immortal immovable object (undefined) so no | 1834 // MegamorphicSentinel is an immortal immovable object (undefined) so no |
| 1836 // write-barrier is needed. | 1835 // write-barrier is needed. |
| 1837 __ bind(&megamorphic); | 1836 __ bind(&megamorphic); |
| 1838 __ Move(FieldOperand(rbx, rdx, times_pointer_size, FixedArray::kHeaderSize), | 1837 __ Move(FieldOperand(rbx, rdx, times_pointer_size, FixedArray::kHeaderSize), |
| 1839 TypeFeedbackVector::MegamorphicSentinel(isolate)); | 1838 TypeFeedbackVector::MegamorphicSentinel(isolate)); |
| 1840 __ jmp(&done); | 1839 __ jmp(&done); |
| 1841 | 1840 |
| 1842 // An uninitialized cache is patched with the function or sentinel to | 1841 // An uninitialized cache is patched with the function or sentinel to |
| 1843 // indicate the ElementsKind if function is the Array constructor. | 1842 // indicate the ElementsKind if function is the Array constructor. |
| 1844 __ bind(&initialize); | 1843 __ bind(&initialize); |
| 1845 | 1844 |
| 1846 // Initialize the call counter. | |
| 1847 __ Move(FieldOperand(rbx, rdx, times_pointer_size, | |
| 1848 FixedArray::kHeaderSize + kPointerSize), | |
| 1849 Smi::FromInt(ConstructICNexus::kCallCountIncrement)); | |
| 1850 | |
| 1851 // Make sure the function is the Array() function | 1845 // Make sure the function is the Array() function |
| 1852 __ LoadNativeContextSlot(Context::ARRAY_FUNCTION_INDEX, r11); | 1846 __ LoadNativeContextSlot(Context::ARRAY_FUNCTION_INDEX, r11); |
| 1853 __ cmpp(rdi, r11); | 1847 __ cmpp(rdi, r11); |
| 1854 __ j(not_equal, ¬_array_function); | 1848 __ j(not_equal, ¬_array_function); |
| 1855 | 1849 |
| 1856 CreateAllocationSiteStub create_stub(isolate); | 1850 CreateAllocationSiteStub create_stub(isolate); |
| 1857 CallStubInRecordCallTarget(masm, &create_stub); | 1851 CallStubInRecordCallTarget(masm, &create_stub); |
| 1858 __ jmp(&done_no_smi_convert); | 1852 __ jmp(&done_no_smi_convert); |
| 1859 | 1853 |
| 1860 __ bind(¬_array_function); | 1854 __ bind(¬_array_function); |
| 1861 CreateWeakCellStub weak_cell_stub(isolate); | 1855 CreateWeakCellStub weak_cell_stub(isolate); |
| 1862 CallStubInRecordCallTarget(masm, &weak_cell_stub); | 1856 CallStubInRecordCallTarget(masm, &weak_cell_stub); |
| 1863 __ jmp(&done_no_smi_convert); | 1857 __ jmp(&done_no_smi_convert); |
| 1864 | 1858 |
| 1865 __ bind(&done_increment_count); | |
| 1866 __ SmiAddConstant(FieldOperand(rbx, rdx, times_pointer_size, | |
| 1867 FixedArray::kHeaderSize + kPointerSize), | |
| 1868 Smi::FromInt(ConstructICNexus::kCallCountIncrement)); | |
| 1869 | |
| 1870 __ bind(&done); | 1859 __ bind(&done); |
| 1871 __ Integer32ToSmi(rdx, rdx); | 1860 __ Integer32ToSmi(rdx, rdx); |
| 1872 | 1861 |
| 1873 __ bind(&done_no_smi_convert); | 1862 __ bind(&done_no_smi_convert); |
| 1874 } | 1863 } |
| 1875 | 1864 |
| 1876 | 1865 |
| 1877 void ConstructICStub::Generate(MacroAssembler* masm) { | 1866 void CallConstructStub::Generate(MacroAssembler* masm) { |
| 1878 // rax : number of arguments | 1867 // rax : number of arguments |
| 1879 // rbx : feedback vector | 1868 // rbx : feedback vector |
| 1880 // rdx : slot in feedback vector (Smi) | 1869 // rdx : slot in feedback vector (Smi) |
| 1881 // rdi : constructor function | 1870 // rdi : constructor function |
| 1882 | 1871 |
| 1883 Label non_function; | 1872 Label non_function; |
| 1884 // Check that the constructor is not a smi. | 1873 // Check that the constructor is not a smi. |
| 1885 __ JumpIfSmi(rdi, &non_function); | 1874 __ JumpIfSmi(rdi, &non_function); |
| 1886 // Check that constructor is a JSFunction. | 1875 // Check that constructor is a JSFunction. |
| 1887 __ CmpObjectType(rdi, JS_FUNCTION_TYPE, r11); | 1876 __ CmpObjectType(rdi, JS_FUNCTION_TYPE, r11); |
| (...skipping 3510 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5398 kStackSpace, nullptr, return_value_operand, NULL); | 5387 kStackSpace, nullptr, return_value_operand, NULL); |
| 5399 } | 5388 } |
| 5400 | 5389 |
| 5401 | 5390 |
| 5402 #undef __ | 5391 #undef __ |
| 5403 | 5392 |
| 5404 } // namespace internal | 5393 } // namespace internal |
| 5405 } // namespace v8 | 5394 } // namespace v8 |
| 5406 | 5395 |
| 5407 #endif // V8_TARGET_ARCH_X64 | 5396 #endif // V8_TARGET_ARCH_X64 |
| OLD | NEW |