| OLD | NEW |
| 1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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_S390 | 5 #if V8_TARGET_ARCH_S390 |
| 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 1846 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1857 | 1857 |
| 1858 static void GenerateRecordCallTarget(MacroAssembler* masm) { | 1858 static void GenerateRecordCallTarget(MacroAssembler* masm) { |
| 1859 // Cache the called function in a feedback vector slot. Cache states | 1859 // Cache the called function in a feedback vector slot. Cache states |
| 1860 // are uninitialized, monomorphic (indicated by a JSFunction), and | 1860 // are uninitialized, monomorphic (indicated by a JSFunction), and |
| 1861 // megamorphic. | 1861 // megamorphic. |
| 1862 // r2 : number of arguments to the construct function | 1862 // r2 : number of arguments to the construct function |
| 1863 // r3 : the function to call | 1863 // r3 : the function to call |
| 1864 // r4 : feedback vector | 1864 // r4 : feedback vector |
| 1865 // r5 : slot in feedback vector (Smi) | 1865 // r5 : slot in feedback vector (Smi) |
| 1866 Label initialize, done, miss, megamorphic, not_array_function; | 1866 Label initialize, done, miss, megamorphic, not_array_function; |
| 1867 Label done_initialize_count, done_increment_count; |
| 1867 | 1868 |
| 1868 DCHECK_EQ(*TypeFeedbackVector::MegamorphicSentinel(masm->isolate()), | 1869 DCHECK_EQ(*TypeFeedbackVector::MegamorphicSentinel(masm->isolate()), |
| 1869 masm->isolate()->heap()->megamorphic_symbol()); | 1870 masm->isolate()->heap()->megamorphic_symbol()); |
| 1870 DCHECK_EQ(*TypeFeedbackVector::UninitializedSentinel(masm->isolate()), | 1871 DCHECK_EQ(*TypeFeedbackVector::UninitializedSentinel(masm->isolate()), |
| 1871 masm->isolate()->heap()->uninitialized_symbol()); | 1872 masm->isolate()->heap()->uninitialized_symbol()); |
| 1872 | 1873 |
| 1874 const int count_offset = FixedArray::kHeaderSize + kPointerSize; |
| 1875 |
| 1873 // Load the cache state into r7. | 1876 // Load the cache state into r7. |
| 1874 __ SmiToPtrArrayOffset(r7, r5); | 1877 __ SmiToPtrArrayOffset(r7, r5); |
| 1875 __ AddP(r7, r4, r7); | 1878 __ AddP(r7, r4, r7); |
| 1876 __ LoadP(r7, FieldMemOperand(r7, FixedArray::kHeaderSize)); | 1879 __ LoadP(r7, FieldMemOperand(r7, FixedArray::kHeaderSize)); |
| 1877 | 1880 |
| 1878 // A monomorphic cache hit or an already megamorphic state: invoke the | 1881 // A monomorphic cache hit or an already megamorphic state: invoke the |
| 1879 // function without changing the state. | 1882 // function without changing the state. |
| 1880 // We don't know if r7 is a WeakCell or a Symbol, but it's harmless to read at | 1883 // We don't know if r7 is a WeakCell or a Symbol, but it's harmless to read at |
| 1881 // this position in a symbol (see static asserts in type-feedback-vector.h). | 1884 // this position in a symbol (see static asserts in type-feedback-vector.h). |
| 1882 Label check_allocation_site; | 1885 Label check_allocation_site; |
| 1883 Register feedback_map = r8; | 1886 Register feedback_map = r8; |
| 1884 Register weak_value = r9; | 1887 Register weak_value = r9; |
| 1885 __ LoadP(weak_value, FieldMemOperand(r7, WeakCell::kValueOffset)); | 1888 __ LoadP(weak_value, FieldMemOperand(r7, WeakCell::kValueOffset)); |
| 1886 __ CmpP(r3, weak_value); | 1889 __ CmpP(r3, weak_value); |
| 1887 __ beq(&done); | 1890 __ beq(&done_increment_count, Label::kNear); |
| 1888 __ CompareRoot(r7, Heap::kmegamorphic_symbolRootIndex); | 1891 __ CompareRoot(r7, Heap::kmegamorphic_symbolRootIndex); |
| 1889 __ beq(&done); | 1892 __ beq(&done, Label::kNear); |
| 1890 __ LoadP(feedback_map, FieldMemOperand(r7, HeapObject::kMapOffset)); | 1893 __ LoadP(feedback_map, FieldMemOperand(r7, HeapObject::kMapOffset)); |
| 1891 __ CompareRoot(feedback_map, Heap::kWeakCellMapRootIndex); | 1894 __ CompareRoot(feedback_map, Heap::kWeakCellMapRootIndex); |
| 1892 __ bne(&check_allocation_site); | 1895 __ bne(&check_allocation_site); |
| 1893 | 1896 |
| 1894 // If the weak cell is cleared, we have a new chance to become monomorphic. | 1897 // If the weak cell is cleared, we have a new chance to become monomorphic. |
| 1895 __ JumpIfSmi(weak_value, &initialize); | 1898 __ JumpIfSmi(weak_value, &initialize); |
| 1896 __ b(&megamorphic); | 1899 __ b(&megamorphic); |
| 1897 | 1900 |
| 1898 __ bind(&check_allocation_site); | 1901 __ bind(&check_allocation_site); |
| 1899 // If we came here, we need to see if we are the array function. | 1902 // If we came here, we need to see if we are the array function. |
| 1900 // If we didn't have a matching function, and we didn't find the megamorph | 1903 // If we didn't have a matching function, and we didn't find the megamorph |
| 1901 // sentinel, then we have in the slot either some other function or an | 1904 // sentinel, then we have in the slot either some other function or an |
| 1902 // AllocationSite. | 1905 // AllocationSite. |
| 1903 __ CompareRoot(feedback_map, Heap::kAllocationSiteMapRootIndex); | 1906 __ CompareRoot(feedback_map, Heap::kAllocationSiteMapRootIndex); |
| 1904 __ bne(&miss); | 1907 __ bne(&miss); |
| 1905 | 1908 |
| 1906 // Make sure the function is the Array() function | 1909 // Make sure the function is the Array() function |
| 1907 __ LoadNativeContextSlot(Context::ARRAY_FUNCTION_INDEX, r7); | 1910 __ LoadNativeContextSlot(Context::ARRAY_FUNCTION_INDEX, r7); |
| 1908 __ CmpP(r3, r7); | 1911 __ CmpP(r3, r7); |
| 1909 __ bne(&megamorphic); | 1912 __ bne(&megamorphic); |
| 1910 __ b(&done); | 1913 __ b(&done_increment_count, Label::kNear); |
| 1911 | 1914 |
| 1912 __ bind(&miss); | 1915 __ bind(&miss); |
| 1913 | 1916 |
| 1914 // A monomorphic miss (i.e, here the cache is not uninitialized) goes | 1917 // A monomorphic miss (i.e, here the cache is not uninitialized) goes |
| 1915 // megamorphic. | 1918 // megamorphic. |
| 1916 __ CompareRoot(r7, Heap::kuninitialized_symbolRootIndex); | 1919 __ CompareRoot(r7, Heap::kuninitialized_symbolRootIndex); |
| 1917 __ beq(&initialize); | 1920 __ beq(&initialize); |
| 1918 // MegamorphicSentinel is an immortal immovable object (undefined) so no | 1921 // MegamorphicSentinel is an immortal immovable object (undefined) so no |
| 1919 // write-barrier is needed. | 1922 // write-barrier is needed. |
| 1920 __ bind(&megamorphic); | 1923 __ bind(&megamorphic); |
| 1921 __ SmiToPtrArrayOffset(r7, r5); | 1924 __ SmiToPtrArrayOffset(r7, r5); |
| 1922 __ AddP(r7, r4, r7); | 1925 __ AddP(r7, r4, r7); |
| 1923 __ LoadRoot(ip, Heap::kmegamorphic_symbolRootIndex); | 1926 __ LoadRoot(ip, Heap::kmegamorphic_symbolRootIndex); |
| 1924 __ StoreP(ip, FieldMemOperand(r7, FixedArray::kHeaderSize), r0); | 1927 __ StoreP(ip, FieldMemOperand(r7, FixedArray::kHeaderSize), r0); |
| 1925 __ jmp(&done); | 1928 __ jmp(&done); |
| 1926 | 1929 |
| 1927 // An uninitialized cache is patched with the function | 1930 // An uninitialized cache is patched with the function |
| 1928 __ bind(&initialize); | 1931 __ bind(&initialize); |
| 1929 | 1932 |
| 1930 // Make sure the function is the Array() function. | 1933 // Make sure the function is the Array() function. |
| 1931 __ LoadNativeContextSlot(Context::ARRAY_FUNCTION_INDEX, r7); | 1934 __ LoadNativeContextSlot(Context::ARRAY_FUNCTION_INDEX, r7); |
| 1932 __ CmpP(r3, r7); | 1935 __ CmpP(r3, r7); |
| 1933 __ bne(¬_array_function); | 1936 __ bne(¬_array_function); |
| 1934 | 1937 |
| 1935 // The target function is the Array constructor, | 1938 // The target function is the Array constructor, |
| 1936 // Create an AllocationSite if we don't already have it, store it in the | 1939 // Create an AllocationSite if we don't already have it, store it in the |
| 1937 // slot. | 1940 // slot. |
| 1938 CreateAllocationSiteStub create_stub(masm->isolate()); | 1941 CreateAllocationSiteStub create_stub(masm->isolate()); |
| 1939 CallStubInRecordCallTarget(masm, &create_stub); | 1942 CallStubInRecordCallTarget(masm, &create_stub); |
| 1940 __ b(&done); | 1943 __ b(&done_initialize_count, Label::kNear); |
| 1941 | 1944 |
| 1942 __ bind(¬_array_function); | 1945 __ bind(¬_array_function); |
| 1943 | 1946 |
| 1944 CreateWeakCellStub weak_cell_stub(masm->isolate()); | 1947 CreateWeakCellStub weak_cell_stub(masm->isolate()); |
| 1945 CallStubInRecordCallTarget(masm, &weak_cell_stub); | 1948 CallStubInRecordCallTarget(masm, &weak_cell_stub); |
| 1949 |
| 1950 __ bind(&done_initialize_count); |
| 1951 // Initialize the call counter. |
| 1952 __ LoadSmiLiteral(r7, Smi::FromInt(1)); |
| 1953 __ SmiToPtrArrayOffset(r6, r5); |
| 1954 __ AddP(r6, r4, r6); |
| 1955 __ StoreP(r7, FieldMemOperand(r6, count_offset), r0); |
| 1956 __ b(&done, Label::kNear); |
| 1957 |
| 1958 __ bind(&done_increment_count); |
| 1959 |
| 1960 // Increment the call count for monomorphic function calls. |
| 1961 __ SmiToPtrArrayOffset(r7, r5); |
| 1962 __ AddP(r7, r4, r7); |
| 1963 |
| 1964 __ LoadP(r6, FieldMemOperand(r7, count_offset)); |
| 1965 __ AddSmiLiteral(r6, r6, Smi::FromInt(1), r0); |
| 1966 __ StoreP(r6, FieldMemOperand(r7, count_offset), r0); |
| 1967 |
| 1946 __ bind(&done); | 1968 __ bind(&done); |
| 1947 } | 1969 } |
| 1948 | 1970 |
| 1949 void CallConstructStub::Generate(MacroAssembler* masm) { | 1971 void CallConstructStub::Generate(MacroAssembler* masm) { |
| 1950 // r2 : number of arguments | 1972 // r2 : number of arguments |
| 1951 // r3 : the function to call | 1973 // r3 : the function to call |
| 1952 // r4 : feedback vector | 1974 // r4 : feedback vector |
| 1953 // r5 : slot in feedback vector (Smi, for RecordCallTarget) | 1975 // r5 : slot in feedback vector (Smi, for RecordCallTarget) |
| 1954 | 1976 |
| 1955 Label non_function; | 1977 Label non_function; |
| (...skipping 3639 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5595 CallApiFunctionAndReturn(masm, api_function_address, thunk_ref, | 5617 CallApiFunctionAndReturn(masm, api_function_address, thunk_ref, |
| 5596 kStackUnwindSpace, NULL, return_value_operand, NULL); | 5618 kStackUnwindSpace, NULL, return_value_operand, NULL); |
| 5597 } | 5619 } |
| 5598 | 5620 |
| 5599 #undef __ | 5621 #undef __ |
| 5600 | 5622 |
| 5601 } // namespace internal | 5623 } // namespace internal |
| 5602 } // namespace v8 | 5624 } // namespace v8 |
| 5603 | 5625 |
| 5604 #endif // V8_TARGET_ARCH_S390 | 5626 #endif // V8_TARGET_ARCH_S390 |
| OLD | NEW |