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