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_IA32 | 5 #if V8_TARGET_ARCH_IA32 |
6 | 6 |
7 #include "src/base/bits.h" | 7 #include "src/base/bits.h" |
8 #include "src/bootstrapper.h" | 8 #include "src/bootstrapper.h" |
9 #include "src/code-stubs.h" | 9 #include "src/code-stubs.h" |
10 #include "src/codegen.h" | 10 #include "src/codegen.h" |
(...skipping 1942 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1953 // We don't know if ecx is a WeakCell or a Symbol, but it's harmless to read | 1953 // We don't know if ecx is a WeakCell or a Symbol, but it's harmless to read |
1954 // at this position in a symbol (see static asserts in | 1954 // at this position in a symbol (see static asserts in |
1955 // type-feedback-vector.h). | 1955 // type-feedback-vector.h). |
1956 Label check_allocation_site; | 1956 Label check_allocation_site; |
1957 __ cmp(edi, FieldOperand(ecx, WeakCell::kValueOffset)); | 1957 __ cmp(edi, FieldOperand(ecx, WeakCell::kValueOffset)); |
1958 __ j(equal, &done, Label::kFar); | 1958 __ j(equal, &done, Label::kFar); |
1959 __ CompareRoot(ecx, Heap::kmegamorphic_symbolRootIndex); | 1959 __ CompareRoot(ecx, Heap::kmegamorphic_symbolRootIndex); |
1960 __ j(equal, &done, Label::kFar); | 1960 __ j(equal, &done, Label::kFar); |
1961 __ CompareRoot(FieldOperand(ecx, HeapObject::kMapOffset), | 1961 __ CompareRoot(FieldOperand(ecx, HeapObject::kMapOffset), |
1962 Heap::kWeakCellMapRootIndex); | 1962 Heap::kWeakCellMapRootIndex); |
1963 __ j(not_equal, FLAG_pretenuring_call_new ? &miss : &check_allocation_site); | 1963 __ j(not_equal, &check_allocation_site); |
1964 | 1964 |
1965 // If the weak cell is cleared, we have a new chance to become monomorphic. | 1965 // If the weak cell is cleared, we have a new chance to become monomorphic. |
1966 __ JumpIfSmi(FieldOperand(ecx, WeakCell::kValueOffset), &initialize); | 1966 __ JumpIfSmi(FieldOperand(ecx, WeakCell::kValueOffset), &initialize); |
1967 __ jmp(&megamorphic); | 1967 __ jmp(&megamorphic); |
1968 | 1968 |
1969 if (!FLAG_pretenuring_call_new) { | 1969 __ bind(&check_allocation_site); |
1970 __ bind(&check_allocation_site); | 1970 // If we came here, we need to see if we are the array function. |
1971 // If we came here, we need to see if we are the array function. | 1971 // If we didn't have a matching function, and we didn't find the megamorph |
1972 // If we didn't have a matching function, and we didn't find the megamorph | 1972 // sentinel, then we have in the slot either some other function or an |
1973 // sentinel, then we have in the slot either some other function or an | 1973 // AllocationSite. |
1974 // AllocationSite. | 1974 __ CompareRoot(FieldOperand(ecx, 0), Heap::kAllocationSiteMapRootIndex); |
1975 __ CompareRoot(FieldOperand(ecx, 0), Heap::kAllocationSiteMapRootIndex); | 1975 __ j(not_equal, &miss); |
1976 __ j(not_equal, &miss); | |
1977 | 1976 |
1978 // Make sure the function is the Array() function | 1977 // Make sure the function is the Array() function |
1979 __ LoadGlobalFunction(Context::ARRAY_FUNCTION_INDEX, ecx); | 1978 __ LoadGlobalFunction(Context::ARRAY_FUNCTION_INDEX, ecx); |
1980 __ cmp(edi, ecx); | 1979 __ cmp(edi, ecx); |
1981 __ j(not_equal, &megamorphic); | 1980 __ j(not_equal, &megamorphic); |
1982 __ jmp(&done, Label::kFar); | 1981 __ jmp(&done, Label::kFar); |
1983 } | |
1984 | 1982 |
1985 __ bind(&miss); | 1983 __ bind(&miss); |
1986 | 1984 |
1987 // A monomorphic miss (i.e, here the cache is not uninitialized) goes | 1985 // A monomorphic miss (i.e, here the cache is not uninitialized) goes |
1988 // megamorphic. | 1986 // megamorphic. |
1989 __ CompareRoot(ecx, Heap::kuninitialized_symbolRootIndex); | 1987 __ CompareRoot(ecx, Heap::kuninitialized_symbolRootIndex); |
1990 __ j(equal, &initialize); | 1988 __ j(equal, &initialize); |
1991 // MegamorphicSentinel is an immortal immovable object (undefined) so no | 1989 // MegamorphicSentinel is an immortal immovable object (undefined) so no |
1992 // write-barrier is needed. | 1990 // write-barrier is needed. |
1993 __ bind(&megamorphic); | 1991 __ bind(&megamorphic); |
1994 __ mov( | 1992 __ mov( |
1995 FieldOperand(ebx, edx, times_half_pointer_size, FixedArray::kHeaderSize), | 1993 FieldOperand(ebx, edx, times_half_pointer_size, FixedArray::kHeaderSize), |
1996 Immediate(TypeFeedbackVector::MegamorphicSentinel(isolate))); | 1994 Immediate(TypeFeedbackVector::MegamorphicSentinel(isolate))); |
1997 __ jmp(&done, Label::kFar); | 1995 __ jmp(&done, Label::kFar); |
1998 | 1996 |
1999 // An uninitialized cache is patched with the function or sentinel to | 1997 // An uninitialized cache is patched with the function or sentinel to |
2000 // indicate the ElementsKind if function is the Array constructor. | 1998 // indicate the ElementsKind if function is the Array constructor. |
2001 __ bind(&initialize); | 1999 __ bind(&initialize); |
2002 if (!FLAG_pretenuring_call_new) { | 2000 // Make sure the function is the Array() function |
2003 // Make sure the function is the Array() function | 2001 __ LoadGlobalFunction(Context::ARRAY_FUNCTION_INDEX, ecx); |
2004 __ LoadGlobalFunction(Context::ARRAY_FUNCTION_INDEX, ecx); | 2002 __ cmp(edi, ecx); |
2005 __ cmp(edi, ecx); | 2003 __ j(not_equal, ¬_array_function); |
2006 __ j(not_equal, ¬_array_function); | |
2007 | 2004 |
2008 // The target function is the Array constructor, | 2005 // The target function is the Array constructor, |
2009 // Create an AllocationSite if we don't already have it, store it in the | 2006 // Create an AllocationSite if we don't already have it, store it in the |
2010 // slot. | 2007 // slot. |
2011 CreateAllocationSiteStub create_stub(isolate); | 2008 CreateAllocationSiteStub create_stub(isolate); |
2012 CallStubInRecordCallTarget(masm, &create_stub, is_super); | 2009 CallStubInRecordCallTarget(masm, &create_stub, is_super); |
2013 __ jmp(&done); | 2010 __ jmp(&done); |
2014 | 2011 |
2015 __ bind(¬_array_function); | 2012 __ bind(¬_array_function); |
2016 } | 2013 CreateWeakCellStub weak_cell_stub(isolate); |
2017 | 2014 CallStubInRecordCallTarget(masm, &weak_cell_stub, is_super); |
2018 CreateWeakCellStub create_stub(isolate); | |
2019 CallStubInRecordCallTarget(masm, &create_stub, is_super); | |
2020 __ bind(&done); | 2015 __ bind(&done); |
2021 } | 2016 } |
2022 | 2017 |
2023 | 2018 |
2024 static void EmitContinueIfStrictOrNative(MacroAssembler* masm, Label* cont) { | 2019 static void EmitContinueIfStrictOrNative(MacroAssembler* masm, Label* cont) { |
2025 // Do not transform the receiver for strict mode functions. | 2020 // Do not transform the receiver for strict mode functions. |
2026 __ mov(ecx, FieldOperand(edi, JSFunction::kSharedFunctionInfoOffset)); | 2021 __ mov(ecx, FieldOperand(edi, JSFunction::kSharedFunctionInfoOffset)); |
2027 __ test_b(FieldOperand(ecx, SharedFunctionInfo::kStrictModeByteOffset), | 2022 __ test_b(FieldOperand(ecx, SharedFunctionInfo::kStrictModeByteOffset), |
2028 1 << SharedFunctionInfo::kStrictModeBitWithinByte); | 2023 1 << SharedFunctionInfo::kStrictModeBitWithinByte); |
2029 __ j(not_equal, cont); | 2024 __ j(not_equal, cont); |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2126 | 2121 |
2127 // Check that function is not a smi. | 2122 // Check that function is not a smi. |
2128 __ JumpIfSmi(edi, &non_function_call); | 2123 __ JumpIfSmi(edi, &non_function_call); |
2129 // Check that function is a JSFunction. | 2124 // Check that function is a JSFunction. |
2130 __ CmpObjectType(edi, JS_FUNCTION_TYPE, ecx); | 2125 __ CmpObjectType(edi, JS_FUNCTION_TYPE, ecx); |
2131 __ j(not_equal, &slow); | 2126 __ j(not_equal, &slow); |
2132 | 2127 |
2133 if (RecordCallTarget()) { | 2128 if (RecordCallTarget()) { |
2134 GenerateRecordCallTarget(masm, IsSuperConstructorCall()); | 2129 GenerateRecordCallTarget(masm, IsSuperConstructorCall()); |
2135 | 2130 |
2136 if (FLAG_pretenuring_call_new) { | 2131 Label feedback_register_initialized; |
2137 // Put the AllocationSite from the feedback vector into ebx. | 2132 // Put the AllocationSite from the feedback vector into ebx, or undefined. |
2138 // By adding kPointerSize we encode that we know the AllocationSite | 2133 __ mov(ebx, FieldOperand(ebx, edx, times_half_pointer_size, |
2139 // entry is at the feedback vector slot given by edx + 1. | 2134 FixedArray::kHeaderSize)); |
2140 __ mov(ebx, FieldOperand(ebx, edx, times_half_pointer_size, | 2135 Handle<Map> allocation_site_map = |
2141 FixedArray::kHeaderSize + kPointerSize)); | 2136 isolate()->factory()->allocation_site_map(); |
2142 } else { | 2137 __ cmp(FieldOperand(ebx, 0), Immediate(allocation_site_map)); |
2143 Label feedback_register_initialized; | 2138 __ j(equal, &feedback_register_initialized); |
2144 // Put the AllocationSite from the feedback vector into ebx, or undefined. | 2139 __ mov(ebx, isolate()->factory()->undefined_value()); |
2145 __ mov(ebx, FieldOperand(ebx, edx, times_half_pointer_size, | 2140 __ bind(&feedback_register_initialized); |
2146 FixedArray::kHeaderSize)); | |
2147 Handle<Map> allocation_site_map = | |
2148 isolate()->factory()->allocation_site_map(); | |
2149 __ cmp(FieldOperand(ebx, 0), Immediate(allocation_site_map)); | |
2150 __ j(equal, &feedback_register_initialized); | |
2151 __ mov(ebx, isolate()->factory()->undefined_value()); | |
2152 __ bind(&feedback_register_initialized); | |
2153 } | |
2154 | 2141 |
2155 __ AssertUndefinedOrAllocationSite(ebx); | 2142 __ AssertUndefinedOrAllocationSite(ebx); |
2156 } | 2143 } |
2157 | 2144 |
2158 if (IsSuperConstructorCall()) { | 2145 if (IsSuperConstructorCall()) { |
2159 __ pop(edx); | 2146 __ pop(edx); |
2160 } else { | 2147 } else { |
2161 // Pass original constructor to construct stub. | 2148 // Pass original constructor to construct stub. |
2162 __ mov(edx, edi); | 2149 __ mov(edx, edi); |
2163 } | 2150 } |
(...skipping 3648 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5812 Operand(ebp, 7 * kPointerSize), NULL); | 5799 Operand(ebp, 7 * kPointerSize), NULL); |
5813 } | 5800 } |
5814 | 5801 |
5815 | 5802 |
5816 #undef __ | 5803 #undef __ |
5817 | 5804 |
5818 } // namespace internal | 5805 } // namespace internal |
5819 } // namespace v8 | 5806 } // namespace v8 |
5820 | 5807 |
5821 #endif // V8_TARGET_ARCH_IA32 | 5808 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |