| 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 2067 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2078 | 2078 |
| 2079 // Unreachable. | 2079 // Unreachable. |
| 2080 } | 2080 } |
| 2081 | 2081 |
| 2082 | 2082 |
| 2083 void CallICStub::Generate(MacroAssembler* masm) { | 2083 void CallICStub::Generate(MacroAssembler* masm) { |
| 2084 // edi - function | 2084 // edi - function |
| 2085 // edx - slot id | 2085 // edx - slot id |
| 2086 // ebx - vector | 2086 // ebx - vector |
| 2087 Isolate* isolate = masm->isolate(); | 2087 Isolate* isolate = masm->isolate(); |
| 2088 const int with_types_offset = | |
| 2089 FixedArray::OffsetOfElementAt(TypeFeedbackVector::kWithTypesIndex); | |
| 2090 const int generic_offset = | |
| 2091 FixedArray::OffsetOfElementAt(TypeFeedbackVector::kGenericCountIndex); | |
| 2092 Label extra_checks_or_miss, call, call_function; | 2088 Label extra_checks_or_miss, call, call_function; |
| 2093 int argc = arg_count(); | 2089 int argc = arg_count(); |
| 2094 ParameterCount actual(argc); | 2090 ParameterCount actual(argc); |
| 2095 | 2091 |
| 2096 // The checks. First, does edi match the recorded monomorphic target? | 2092 // The checks. First, does edi match the recorded monomorphic target? |
| 2097 __ mov(ecx, FieldOperand(ebx, edx, times_half_pointer_size, | 2093 __ mov(ecx, FieldOperand(ebx, edx, times_half_pointer_size, |
| 2098 FixedArray::kHeaderSize)); | 2094 FixedArray::kHeaderSize)); |
| 2099 | 2095 |
| 2100 // We don't know that we have a weak cell. We might have a private symbol | 2096 // We don't know that we have a weak cell. We might have a private symbol |
| 2101 // or an AllocationSite, but the memory is safe to examine. | 2097 // or an AllocationSite, but the memory is safe to examine. |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2154 __ j(equal, &uninitialized); | 2150 __ j(equal, &uninitialized); |
| 2155 | 2151 |
| 2156 // We are going megamorphic. If the feedback is a JSFunction, it is fine | 2152 // We are going megamorphic. If the feedback is a JSFunction, it is fine |
| 2157 // to handle it here. More complex cases are dealt with in the runtime. | 2153 // to handle it here. More complex cases are dealt with in the runtime. |
| 2158 __ AssertNotSmi(ecx); | 2154 __ AssertNotSmi(ecx); |
| 2159 __ CmpObjectType(ecx, JS_FUNCTION_TYPE, ecx); | 2155 __ CmpObjectType(ecx, JS_FUNCTION_TYPE, ecx); |
| 2160 __ j(not_equal, &miss); | 2156 __ j(not_equal, &miss); |
| 2161 __ mov( | 2157 __ mov( |
| 2162 FieldOperand(ebx, edx, times_half_pointer_size, FixedArray::kHeaderSize), | 2158 FieldOperand(ebx, edx, times_half_pointer_size, FixedArray::kHeaderSize), |
| 2163 Immediate(TypeFeedbackVector::MegamorphicSentinel(isolate))); | 2159 Immediate(TypeFeedbackVector::MegamorphicSentinel(isolate))); |
| 2164 // We have to update statistics for runtime profiling. | |
| 2165 __ sub(FieldOperand(ebx, with_types_offset), Immediate(Smi::FromInt(1))); | |
| 2166 __ add(FieldOperand(ebx, generic_offset), Immediate(Smi::FromInt(1))); | |
| 2167 | 2160 |
| 2168 __ bind(&call); | 2161 __ bind(&call); |
| 2169 __ Set(eax, argc); | 2162 __ Set(eax, argc); |
| 2170 __ Jump(masm->isolate()->builtins()->Call(convert_mode()), | 2163 __ Jump(masm->isolate()->builtins()->Call(convert_mode()), |
| 2171 RelocInfo::CODE_TARGET); | 2164 RelocInfo::CODE_TARGET); |
| 2172 | 2165 |
| 2173 __ bind(&uninitialized); | 2166 __ bind(&uninitialized); |
| 2174 | 2167 |
| 2175 // We are going monomorphic, provided we actually have a JSFunction. | 2168 // We are going monomorphic, provided we actually have a JSFunction. |
| 2176 __ JumpIfSmi(edi, &miss); | 2169 __ JumpIfSmi(edi, &miss); |
| 2177 | 2170 |
| 2178 // Goto miss case if we do not have a function. | 2171 // Goto miss case if we do not have a function. |
| 2179 __ CmpObjectType(edi, JS_FUNCTION_TYPE, ecx); | 2172 __ CmpObjectType(edi, JS_FUNCTION_TYPE, ecx); |
| 2180 __ j(not_equal, &miss); | 2173 __ j(not_equal, &miss); |
| 2181 | 2174 |
| 2182 // Make sure the function is not the Array() function, which requires special | 2175 // Make sure the function is not the Array() function, which requires special |
| 2183 // behavior on MISS. | 2176 // behavior on MISS. |
| 2184 __ LoadGlobalFunction(Context::ARRAY_FUNCTION_INDEX, ecx); | 2177 __ LoadGlobalFunction(Context::ARRAY_FUNCTION_INDEX, ecx); |
| 2185 __ cmp(edi, ecx); | 2178 __ cmp(edi, ecx); |
| 2186 __ j(equal, &miss); | 2179 __ j(equal, &miss); |
| 2187 | 2180 |
| 2188 // Make sure the function belongs to the same native context. | 2181 // Make sure the function belongs to the same native context. |
| 2189 __ mov(ecx, FieldOperand(edi, JSFunction::kContextOffset)); | 2182 __ mov(ecx, FieldOperand(edi, JSFunction::kContextOffset)); |
| 2190 __ mov(ecx, ContextOperand(ecx, Context::NATIVE_CONTEXT_INDEX)); | 2183 __ mov(ecx, ContextOperand(ecx, Context::NATIVE_CONTEXT_INDEX)); |
| 2191 __ cmp(ecx, NativeContextOperand()); | 2184 __ cmp(ecx, NativeContextOperand()); |
| 2192 __ j(not_equal, &miss); | 2185 __ j(not_equal, &miss); |
| 2193 | 2186 |
| 2194 // Update stats. | |
| 2195 __ add(FieldOperand(ebx, with_types_offset), Immediate(Smi::FromInt(1))); | |
| 2196 | |
| 2197 // Initialize the call counter. | 2187 // Initialize the call counter. |
| 2198 __ mov(FieldOperand(ebx, edx, times_half_pointer_size, | 2188 __ mov(FieldOperand(ebx, edx, times_half_pointer_size, |
| 2199 FixedArray::kHeaderSize + kPointerSize), | 2189 FixedArray::kHeaderSize + kPointerSize), |
| 2200 Immediate(Smi::FromInt(CallICNexus::kCallCountIncrement))); | 2190 Immediate(Smi::FromInt(CallICNexus::kCallCountIncrement))); |
| 2201 | 2191 |
| 2202 // Store the function. Use a stub since we need a frame for allocation. | 2192 // Store the function. Use a stub since we need a frame for allocation. |
| 2203 // ebx - vector | 2193 // ebx - vector |
| 2204 // edx - slot | 2194 // edx - slot |
| 2205 // edi - function | 2195 // edi - function |
| 2206 { | 2196 { |
| (...skipping 3447 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5654 Operand(ebp, 7 * kPointerSize), NULL); | 5644 Operand(ebp, 7 * kPointerSize), NULL); |
| 5655 } | 5645 } |
| 5656 | 5646 |
| 5657 | 5647 |
| 5658 #undef __ | 5648 #undef __ |
| 5659 | 5649 |
| 5660 } // namespace internal | 5650 } // namespace internal |
| 5661 } // namespace v8 | 5651 } // namespace v8 |
| 5662 | 5652 |
| 5663 #endif // V8_TARGET_ARCH_IA32 | 5653 #endif // V8_TARGET_ARCH_IA32 |
| OLD | NEW |