| 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_ARM64 | 5 #if V8_TARGET_ARCH_ARM64 |
| 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 1827 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1838 ASM_LOCATION("GenerateRecordCallTarget"); | 1838 ASM_LOCATION("GenerateRecordCallTarget"); |
| 1839 DCHECK(!AreAliased(scratch1, scratch2, scratch3, argc, function, | 1839 DCHECK(!AreAliased(scratch1, scratch2, scratch3, argc, function, |
| 1840 feedback_vector, index, new_target)); | 1840 feedback_vector, index, new_target)); |
| 1841 // Cache the called function in a feedback vector slot. Cache states are | 1841 // Cache the called function in a feedback vector slot. Cache states are |
| 1842 // uninitialized, monomorphic (indicated by a JSFunction), and megamorphic. | 1842 // uninitialized, monomorphic (indicated by a JSFunction), and megamorphic. |
| 1843 // argc : number of arguments to the construct function | 1843 // argc : number of arguments to the construct function |
| 1844 // function : the function to call | 1844 // function : the function to call |
| 1845 // feedback_vector : the feedback vector | 1845 // feedback_vector : the feedback vector |
| 1846 // index : slot in feedback vector (smi) | 1846 // index : slot in feedback vector (smi) |
| 1847 Label initialize, done, miss, megamorphic, not_array_function; | 1847 Label initialize, done, miss, megamorphic, not_array_function; |
| 1848 Label done_initialize_count, done_increment_count; | |
| 1849 | 1848 |
| 1850 DCHECK_EQ(*TypeFeedbackVector::MegamorphicSentinel(masm->isolate()), | 1849 DCHECK_EQ(*TypeFeedbackVector::MegamorphicSentinel(masm->isolate()), |
| 1851 masm->isolate()->heap()->megamorphic_symbol()); | 1850 masm->isolate()->heap()->megamorphic_symbol()); |
| 1852 DCHECK_EQ(*TypeFeedbackVector::UninitializedSentinel(masm->isolate()), | 1851 DCHECK_EQ(*TypeFeedbackVector::UninitializedSentinel(masm->isolate()), |
| 1853 masm->isolate()->heap()->uninitialized_symbol()); | 1852 masm->isolate()->heap()->uninitialized_symbol()); |
| 1854 | 1853 |
| 1855 // Load the cache state. | 1854 // Load the cache state. |
| 1856 Register feedback = scratch1; | 1855 Register feedback = scratch1; |
| 1857 Register feedback_map = scratch2; | 1856 Register feedback_map = scratch2; |
| 1858 Register feedback_value = scratch3; | 1857 Register feedback_value = scratch3; |
| 1859 __ Add(feedback, feedback_vector, | 1858 __ Add(feedback, feedback_vector, |
| 1860 Operand::UntagSmiAndScale(index, kPointerSizeLog2)); | 1859 Operand::UntagSmiAndScale(index, kPointerSizeLog2)); |
| 1861 __ Ldr(feedback, FieldMemOperand(feedback, FixedArray::kHeaderSize)); | 1860 __ Ldr(feedback, FieldMemOperand(feedback, FixedArray::kHeaderSize)); |
| 1862 | 1861 |
| 1863 // A monomorphic cache hit or an already megamorphic state: invoke the | 1862 // A monomorphic cache hit or an already megamorphic state: invoke the |
| 1864 // function without changing the state. | 1863 // function without changing the state. |
| 1865 // We don't know if feedback value is a WeakCell or a Symbol, but it's | 1864 // We don't know if feedback value is a WeakCell or a Symbol, but it's |
| 1866 // harmless to read at this position in a symbol (see static asserts in | 1865 // harmless to read at this position in a symbol (see static asserts in |
| 1867 // type-feedback-vector.h). | 1866 // type-feedback-vector.h). |
| 1868 Label check_allocation_site; | 1867 Label check_allocation_site; |
| 1869 __ Ldr(feedback_value, FieldMemOperand(feedback, WeakCell::kValueOffset)); | 1868 __ Ldr(feedback_value, FieldMemOperand(feedback, WeakCell::kValueOffset)); |
| 1870 __ Cmp(function, feedback_value); | 1869 __ Cmp(function, feedback_value); |
| 1871 __ B(eq, &done_increment_count); | 1870 __ B(eq, &done); |
| 1872 __ CompareRoot(feedback, Heap::kmegamorphic_symbolRootIndex); | 1871 __ CompareRoot(feedback, Heap::kmegamorphic_symbolRootIndex); |
| 1873 __ B(eq, &done); | 1872 __ B(eq, &done); |
| 1874 __ Ldr(feedback_map, FieldMemOperand(feedback, HeapObject::kMapOffset)); | 1873 __ Ldr(feedback_map, FieldMemOperand(feedback, HeapObject::kMapOffset)); |
| 1875 __ CompareRoot(feedback_map, Heap::kWeakCellMapRootIndex); | 1874 __ CompareRoot(feedback_map, Heap::kWeakCellMapRootIndex); |
| 1876 __ B(ne, &check_allocation_site); | 1875 __ B(ne, &check_allocation_site); |
| 1877 | 1876 |
| 1878 // If the weak cell is cleared, we have a new chance to become monomorphic. | 1877 // If the weak cell is cleared, we have a new chance to become monomorphic. |
| 1879 __ JumpIfSmi(feedback_value, &initialize); | 1878 __ JumpIfSmi(feedback_value, &initialize); |
| 1880 __ B(&megamorphic); | 1879 __ B(&megamorphic); |
| 1881 | 1880 |
| 1882 __ bind(&check_allocation_site); | 1881 __ bind(&check_allocation_site); |
| 1883 // If we came here, we need to see if we are the array function. | 1882 // If we came here, we need to see if we are the array function. |
| 1884 // If we didn't have a matching function, and we didn't find the megamorph | 1883 // If we didn't have a matching function, and we didn't find the megamorph |
| 1885 // sentinel, then we have in the slot either some other function or an | 1884 // sentinel, then we have in the slot either some other function or an |
| 1886 // AllocationSite. | 1885 // AllocationSite. |
| 1887 __ JumpIfNotRoot(feedback_map, Heap::kAllocationSiteMapRootIndex, &miss); | 1886 __ JumpIfNotRoot(feedback_map, Heap::kAllocationSiteMapRootIndex, &miss); |
| 1888 | 1887 |
| 1889 // Make sure the function is the Array() function | 1888 // Make sure the function is the Array() function |
| 1890 __ LoadNativeContextSlot(Context::ARRAY_FUNCTION_INDEX, scratch1); | 1889 __ LoadNativeContextSlot(Context::ARRAY_FUNCTION_INDEX, scratch1); |
| 1891 __ Cmp(function, scratch1); | 1890 __ Cmp(function, scratch1); |
| 1892 __ B(ne, &megamorphic); | 1891 __ B(ne, &megamorphic); |
| 1893 __ B(&done_increment_count); | 1892 __ B(&done); |
| 1894 | 1893 |
| 1895 __ Bind(&miss); | 1894 __ Bind(&miss); |
| 1896 | 1895 |
| 1897 // A monomorphic miss (i.e, here the cache is not uninitialized) goes | 1896 // A monomorphic miss (i.e, here the cache is not uninitialized) goes |
| 1898 // megamorphic. | 1897 // megamorphic. |
| 1899 __ JumpIfRoot(scratch1, Heap::kuninitialized_symbolRootIndex, &initialize); | 1898 __ JumpIfRoot(scratch1, Heap::kuninitialized_symbolRootIndex, &initialize); |
| 1900 // MegamorphicSentinel is an immortal immovable object (undefined) so no | 1899 // MegamorphicSentinel is an immortal immovable object (undefined) so no |
| 1901 // write-barrier is needed. | 1900 // write-barrier is needed. |
| 1902 __ Bind(&megamorphic); | 1901 __ Bind(&megamorphic); |
| 1903 __ Add(scratch1, feedback_vector, | 1902 __ Add(scratch1, feedback_vector, |
| (...skipping 10 matching lines...) Expand all Loading... |
| 1914 __ LoadNativeContextSlot(Context::ARRAY_FUNCTION_INDEX, scratch1); | 1913 __ LoadNativeContextSlot(Context::ARRAY_FUNCTION_INDEX, scratch1); |
| 1915 __ Cmp(function, scratch1); | 1914 __ Cmp(function, scratch1); |
| 1916 __ B(ne, ¬_array_function); | 1915 __ B(ne, ¬_array_function); |
| 1917 | 1916 |
| 1918 // The target function is the Array constructor, | 1917 // The target function is the Array constructor, |
| 1919 // Create an AllocationSite if we don't already have it, store it in the | 1918 // Create an AllocationSite if we don't already have it, store it in the |
| 1920 // slot. | 1919 // slot. |
| 1921 CreateAllocationSiteStub create_stub(masm->isolate()); | 1920 CreateAllocationSiteStub create_stub(masm->isolate()); |
| 1922 CallStubInRecordCallTarget(masm, &create_stub, argc, function, | 1921 CallStubInRecordCallTarget(masm, &create_stub, argc, function, |
| 1923 feedback_vector, index, new_target); | 1922 feedback_vector, index, new_target); |
| 1924 __ B(&done_initialize_count); | 1923 __ B(&done); |
| 1925 | 1924 |
| 1926 __ Bind(¬_array_function); | 1925 __ Bind(¬_array_function); |
| 1927 CreateWeakCellStub weak_cell_stub(masm->isolate()); | 1926 CreateWeakCellStub weak_cell_stub(masm->isolate()); |
| 1928 CallStubInRecordCallTarget(masm, &weak_cell_stub, argc, function, | 1927 CallStubInRecordCallTarget(masm, &weak_cell_stub, argc, function, |
| 1929 feedback_vector, index, new_target); | 1928 feedback_vector, index, new_target); |
| 1930 | 1929 |
| 1931 __ bind(&done_initialize_count); | 1930 __ Bind(&done); |
| 1932 // Initialize the call counter. | |
| 1933 __ Mov(scratch1, Operand(Smi::FromInt(1))); | |
| 1934 __ Adds(scratch2, feedback_vector, | |
| 1935 Operand::UntagSmiAndScale(index, kPointerSizeLog2)); | |
| 1936 __ Str(scratch1, | |
| 1937 FieldMemOperand(scratch2, FixedArray::kHeaderSize + kPointerSize)); | |
| 1938 __ b(&done); | |
| 1939 | 1931 |
| 1940 __ bind(&done_increment_count); | 1932 // Increment the call count for all function calls. |
| 1941 | |
| 1942 // Increment the call count for monomorphic function calls. | |
| 1943 __ Add(scratch1, feedback_vector, | 1933 __ Add(scratch1, feedback_vector, |
| 1944 Operand::UntagSmiAndScale(index, kPointerSizeLog2)); | 1934 Operand::UntagSmiAndScale(index, kPointerSizeLog2)); |
| 1945 __ Add(scratch1, scratch1, Operand(FixedArray::kHeaderSize + kPointerSize)); | 1935 __ Add(scratch1, scratch1, Operand(FixedArray::kHeaderSize + kPointerSize)); |
| 1946 __ Ldr(scratch2, FieldMemOperand(scratch1, 0)); | 1936 __ Ldr(scratch2, FieldMemOperand(scratch1, 0)); |
| 1947 __ Add(scratch2, scratch2, Operand(Smi::FromInt(1))); | 1937 __ Add(scratch2, scratch2, Operand(Smi::FromInt(1))); |
| 1948 __ Str(scratch2, FieldMemOperand(scratch1, 0)); | 1938 __ Str(scratch2, FieldMemOperand(scratch1, 0)); |
| 1949 | |
| 1950 __ Bind(&done); | |
| 1951 } | 1939 } |
| 1952 | 1940 |
| 1953 | 1941 |
| 1954 void CallConstructStub::Generate(MacroAssembler* masm) { | 1942 void CallConstructStub::Generate(MacroAssembler* masm) { |
| 1955 ASM_LOCATION("CallConstructStub::Generate"); | 1943 ASM_LOCATION("CallConstructStub::Generate"); |
| 1956 // x0 : number of arguments | 1944 // x0 : number of arguments |
| 1957 // x1 : the function to call | 1945 // x1 : the function to call |
| 1958 // x2 : feedback vector | 1946 // x2 : feedback vector |
| 1959 // x3 : slot in feedback vector (Smi, for RecordCallTarget) | 1947 // x3 : slot in feedback vector (Smi, for RecordCallTarget) |
| 1960 Register function = x1; | 1948 Register function = x1; |
| (...skipping 3586 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5547 kStackUnwindSpace, NULL, spill_offset, | 5535 kStackUnwindSpace, NULL, spill_offset, |
| 5548 return_value_operand, NULL); | 5536 return_value_operand, NULL); |
| 5549 } | 5537 } |
| 5550 | 5538 |
| 5551 #undef __ | 5539 #undef __ |
| 5552 | 5540 |
| 5553 } // namespace internal | 5541 } // namespace internal |
| 5554 } // namespace v8 | 5542 } // namespace v8 |
| 5555 | 5543 |
| 5556 #endif // V8_TARGET_ARCH_ARM64 | 5544 #endif // V8_TARGET_ARCH_ARM64 |
| OLD | NEW |