| 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 1893 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1904 | 1904 |
| 1905 static void GenerateRecordCallTarget(MacroAssembler* masm) { | 1905 static void GenerateRecordCallTarget(MacroAssembler* masm) { |
| 1906 // Cache the called function in a feedback vector slot. Cache states | 1906 // Cache the called function in a feedback vector slot. Cache states |
| 1907 // are uninitialized, monomorphic (indicated by a JSFunction), and | 1907 // are uninitialized, monomorphic (indicated by a JSFunction), and |
| 1908 // megamorphic. | 1908 // megamorphic. |
| 1909 // a0 : number of arguments to the construct function | 1909 // a0 : number of arguments to the construct function |
| 1910 // a1 : the function to call | 1910 // a1 : the function to call |
| 1911 // a2 : feedback vector | 1911 // a2 : feedback vector |
| 1912 // a3 : slot in feedback vector (Smi) | 1912 // a3 : slot in feedback vector (Smi) |
| 1913 Label initialize, done, miss, megamorphic, not_array_function; | 1913 Label initialize, done, miss, megamorphic, not_array_function; |
| 1914 Label done_initialize_count, done_increment_count; |
| 1914 | 1915 |
| 1915 DCHECK_EQ(*TypeFeedbackVector::MegamorphicSentinel(masm->isolate()), | 1916 DCHECK_EQ(*TypeFeedbackVector::MegamorphicSentinel(masm->isolate()), |
| 1916 masm->isolate()->heap()->megamorphic_symbol()); | 1917 masm->isolate()->heap()->megamorphic_symbol()); |
| 1917 DCHECK_EQ(*TypeFeedbackVector::UninitializedSentinel(masm->isolate()), | 1918 DCHECK_EQ(*TypeFeedbackVector::UninitializedSentinel(masm->isolate()), |
| 1918 masm->isolate()->heap()->uninitialized_symbol()); | 1919 masm->isolate()->heap()->uninitialized_symbol()); |
| 1919 | 1920 |
| 1920 // Load the cache state into a5. | 1921 // Load the cache state into a5. |
| 1921 __ dsrl(a5, a3, 32 - kPointerSizeLog2); | 1922 __ dsrl(a5, a3, 32 - kPointerSizeLog2); |
| 1922 __ Daddu(a5, a2, Operand(a5)); | 1923 __ Daddu(a5, a2, Operand(a5)); |
| 1923 __ ld(a5, FieldMemOperand(a5, FixedArray::kHeaderSize)); | 1924 __ ld(a5, FieldMemOperand(a5, FixedArray::kHeaderSize)); |
| 1924 | 1925 |
| 1925 // A monomorphic cache hit or an already megamorphic state: invoke the | 1926 // A monomorphic cache hit or an already megamorphic state: invoke the |
| 1926 // function without changing the state. | 1927 // function without changing the state. |
| 1927 // We don't know if a5 is a WeakCell or a Symbol, but it's harmless to read at | 1928 // We don't know if a5 is a WeakCell or a Symbol, but it's harmless to read at |
| 1928 // this position in a symbol (see static asserts in type-feedback-vector.h). | 1929 // this position in a symbol (see static asserts in type-feedback-vector.h). |
| 1929 Label check_allocation_site; | 1930 Label check_allocation_site; |
| 1930 Register feedback_map = a6; | 1931 Register feedback_map = a6; |
| 1931 Register weak_value = t0; | 1932 Register weak_value = t0; |
| 1932 __ ld(weak_value, FieldMemOperand(a5, WeakCell::kValueOffset)); | 1933 __ ld(weak_value, FieldMemOperand(a5, WeakCell::kValueOffset)); |
| 1933 __ Branch(&done, eq, a1, Operand(weak_value)); | 1934 __ Branch(&done_increment_count, eq, a1, Operand(weak_value)); |
| 1934 __ LoadRoot(at, Heap::kmegamorphic_symbolRootIndex); | 1935 __ LoadRoot(at, Heap::kmegamorphic_symbolRootIndex); |
| 1935 __ Branch(&done, eq, a5, Operand(at)); | 1936 __ Branch(&done, eq, a5, Operand(at)); |
| 1936 __ ld(feedback_map, FieldMemOperand(a5, HeapObject::kMapOffset)); | 1937 __ ld(feedback_map, FieldMemOperand(a5, HeapObject::kMapOffset)); |
| 1937 __ LoadRoot(at, Heap::kWeakCellMapRootIndex); | 1938 __ LoadRoot(at, Heap::kWeakCellMapRootIndex); |
| 1938 __ Branch(&check_allocation_site, ne, feedback_map, Operand(at)); | 1939 __ Branch(&check_allocation_site, ne, feedback_map, Operand(at)); |
| 1939 | 1940 |
| 1940 // If the weak cell is cleared, we have a new chance to become monomorphic. | 1941 // If the weak cell is cleared, we have a new chance to become monomorphic. |
| 1941 __ JumpIfSmi(weak_value, &initialize); | 1942 __ JumpIfSmi(weak_value, &initialize); |
| 1942 __ jmp(&megamorphic); | 1943 __ jmp(&megamorphic); |
| 1943 | 1944 |
| 1944 __ bind(&check_allocation_site); | 1945 __ bind(&check_allocation_site); |
| 1945 // If we came here, we need to see if we are the array function. | 1946 // If we came here, we need to see if we are the array function. |
| 1946 // If we didn't have a matching function, and we didn't find the megamorph | 1947 // If we didn't have a matching function, and we didn't find the megamorph |
| 1947 // sentinel, then we have in the slot either some other function or an | 1948 // sentinel, then we have in the slot either some other function or an |
| 1948 // AllocationSite. | 1949 // AllocationSite. |
| 1949 __ LoadRoot(at, Heap::kAllocationSiteMapRootIndex); | 1950 __ LoadRoot(at, Heap::kAllocationSiteMapRootIndex); |
| 1950 __ Branch(&miss, ne, feedback_map, Operand(at)); | 1951 __ Branch(&miss, ne, feedback_map, Operand(at)); |
| 1951 | 1952 |
| 1952 // Make sure the function is the Array() function | 1953 // Make sure the function is the Array() function |
| 1953 __ LoadNativeContextSlot(Context::ARRAY_FUNCTION_INDEX, a5); | 1954 __ LoadNativeContextSlot(Context::ARRAY_FUNCTION_INDEX, a5); |
| 1954 __ Branch(&megamorphic, ne, a1, Operand(a5)); | 1955 __ Branch(&megamorphic, ne, a1, Operand(a5)); |
| 1955 __ jmp(&done); | 1956 __ jmp(&done_increment_count); |
| 1956 | 1957 |
| 1957 __ bind(&miss); | 1958 __ bind(&miss); |
| 1958 | 1959 |
| 1959 // A monomorphic miss (i.e, here the cache is not uninitialized) goes | 1960 // A monomorphic miss (i.e, here the cache is not uninitialized) goes |
| 1960 // megamorphic. | 1961 // megamorphic. |
| 1961 __ LoadRoot(at, Heap::kuninitialized_symbolRootIndex); | 1962 __ LoadRoot(at, Heap::kuninitialized_symbolRootIndex); |
| 1962 __ Branch(&initialize, eq, a5, Operand(at)); | 1963 __ Branch(&initialize, eq, a5, Operand(at)); |
| 1963 // MegamorphicSentinel is an immortal immovable object (undefined) so no | 1964 // MegamorphicSentinel is an immortal immovable object (undefined) so no |
| 1964 // write-barrier is needed. | 1965 // write-barrier is needed. |
| 1965 __ bind(&megamorphic); | 1966 __ bind(&megamorphic); |
| 1966 __ dsrl(a5, a3, 32 - kPointerSizeLog2); | 1967 __ dsrl(a5, a3, 32 - kPointerSizeLog2); |
| 1967 __ Daddu(a5, a2, Operand(a5)); | 1968 __ Daddu(a5, a2, Operand(a5)); |
| 1968 __ LoadRoot(at, Heap::kmegamorphic_symbolRootIndex); | 1969 __ LoadRoot(at, Heap::kmegamorphic_symbolRootIndex); |
| 1969 __ sd(at, FieldMemOperand(a5, FixedArray::kHeaderSize)); | 1970 __ sd(at, FieldMemOperand(a5, FixedArray::kHeaderSize)); |
| 1970 __ jmp(&done); | 1971 __ jmp(&done); |
| 1971 | 1972 |
| 1972 // An uninitialized cache is patched with the function. | 1973 // An uninitialized cache is patched with the function. |
| 1973 __ bind(&initialize); | 1974 __ bind(&initialize); |
| 1974 // Make sure the function is the Array() function. | 1975 // Make sure the function is the Array() function. |
| 1975 __ LoadNativeContextSlot(Context::ARRAY_FUNCTION_INDEX, a5); | 1976 __ LoadNativeContextSlot(Context::ARRAY_FUNCTION_INDEX, a5); |
| 1976 __ Branch(¬_array_function, ne, a1, Operand(a5)); | 1977 __ Branch(¬_array_function, ne, a1, Operand(a5)); |
| 1977 | 1978 |
| 1978 // The target function is the Array constructor, | 1979 // The target function is the Array constructor, |
| 1979 // Create an AllocationSite if we don't already have it, store it in the | 1980 // Create an AllocationSite if we don't already have it, store it in the |
| 1980 // slot. | 1981 // slot. |
| 1981 CreateAllocationSiteStub create_stub(masm->isolate()); | 1982 CreateAllocationSiteStub create_stub(masm->isolate()); |
| 1982 CallStubInRecordCallTarget(masm, &create_stub); | 1983 CallStubInRecordCallTarget(masm, &create_stub); |
| 1983 __ Branch(&done); | 1984 __ Branch(&done_initialize_count); |
| 1984 | 1985 |
| 1985 __ bind(¬_array_function); | 1986 __ bind(¬_array_function); |
| 1986 | 1987 |
| 1987 CreateWeakCellStub weak_cell_stub(masm->isolate()); | 1988 CreateWeakCellStub weak_cell_stub(masm->isolate()); |
| 1988 CallStubInRecordCallTarget(masm, &weak_cell_stub); | 1989 CallStubInRecordCallTarget(masm, &weak_cell_stub); |
| 1990 |
| 1991 __ bind(&done_initialize_count); |
| 1992 // Initialize the call counter. |
| 1993 |
| 1994 __ dsrl(a4, a3, 32 - kPointerSizeLog2); |
| 1995 __ Daddu(a4, a2, Operand(a4)); |
| 1996 __ li(a5, Operand(Smi::FromInt(1))); |
| 1997 __ sd(a5, FieldMemOperand(a4, FixedArray::kHeaderSize + kPointerSize)); |
| 1998 __ bind(&done); |
| 1999 |
| 2000 __ bind(&done_increment_count); |
| 2001 |
| 2002 // Increment the call count for monomorphic function calls. |
| 2003 __ dsrl(a4, a3, 32 - kPointerSizeLog2); |
| 2004 __ Daddu(a5, a2, Operand(a4)); |
| 2005 __ ld(a4, FieldMemOperand(a5, FixedArray::kHeaderSize + kPointerSize)); |
| 2006 __ Daddu(a4, a4, Operand(Smi::FromInt(1))); |
| 2007 __ sd(a4, FieldMemOperand(a5, FixedArray::kHeaderSize + kPointerSize)); |
| 2008 |
| 1989 __ bind(&done); | 2009 __ bind(&done); |
| 1990 } | 2010 } |
| 1991 | 2011 |
| 1992 | 2012 |
| 1993 void CallConstructStub::Generate(MacroAssembler* masm) { | 2013 void CallConstructStub::Generate(MacroAssembler* masm) { |
| 1994 // a0 : number of arguments | 2014 // a0 : number of arguments |
| 1995 // a1 : the function to call | 2015 // a1 : the function to call |
| 1996 // a2 : feedback vector | 2016 // a2 : feedback vector |
| 1997 // a3 : slot in feedback vector (Smi, for RecordCallTarget) | 2017 // a3 : slot in feedback vector (Smi, for RecordCallTarget) |
| 1998 | 2018 |
| (...skipping 3647 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5646 kStackUnwindSpace, kInvalidStackOffset, | 5666 kStackUnwindSpace, kInvalidStackOffset, |
| 5647 return_value_operand, NULL); | 5667 return_value_operand, NULL); |
| 5648 } | 5668 } |
| 5649 | 5669 |
| 5650 #undef __ | 5670 #undef __ |
| 5651 | 5671 |
| 5652 } // namespace internal | 5672 } // namespace internal |
| 5653 } // namespace v8 | 5673 } // namespace v8 |
| 5654 | 5674 |
| 5655 #endif // V8_TARGET_ARCH_MIPS64 | 5675 #endif // V8_TARGET_ARCH_MIPS64 |
| OLD | NEW |