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