Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(65)

Side by Side Diff: src/x87/code-stubs-x87.cc

Issue 307823003: X87: Refactor CallICStub to use a different stub for each customization. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #include "v8.h" 5 #include "v8.h"
6 6
7 #if V8_TARGET_ARCH_X87 7 #if V8_TARGET_ARCH_X87
8 8
9 #include "bootstrapper.h" 9 #include "bootstrapper.h"
10 #include "code-stubs.h" 10 #include "code-stubs.h"
(...skipping 2134 matching lines...) Expand 10 before | Expand all | Expand 10 after
2145 2145
2146 2146
2147 static void EmitLoadTypeFeedbackVector(MacroAssembler* masm, Register vector) { 2147 static void EmitLoadTypeFeedbackVector(MacroAssembler* masm, Register vector) {
2148 __ mov(vector, Operand(ebp, JavaScriptFrameConstants::kFunctionOffset)); 2148 __ mov(vector, Operand(ebp, JavaScriptFrameConstants::kFunctionOffset));
2149 __ mov(vector, FieldOperand(vector, JSFunction::kSharedFunctionInfoOffset)); 2149 __ mov(vector, FieldOperand(vector, JSFunction::kSharedFunctionInfoOffset));
2150 __ mov(vector, FieldOperand(vector, 2150 __ mov(vector, FieldOperand(vector,
2151 SharedFunctionInfo::kFeedbackVectorOffset)); 2151 SharedFunctionInfo::kFeedbackVectorOffset));
2152 } 2152 }
2153 2153
2154 2154
2155 void CallICStub::Generate_MonomorphicArray(MacroAssembler* masm, Label* miss) { 2155 void CallIC_ArrayStub::Generate(MacroAssembler* masm) {
2156 // edi - function 2156 // edi - function
2157 // ebx - feedback vector
2158 // edx - slot id 2157 // edx - slot id
2158 Label miss;
2159 int argc = state_.arg_count();
2160 ParameterCount actual(argc);
2161
2162 EmitLoadTypeFeedbackVector(masm, ebx);
2163
2159 __ LoadGlobalFunction(Context::ARRAY_FUNCTION_INDEX, ecx); 2164 __ LoadGlobalFunction(Context::ARRAY_FUNCTION_INDEX, ecx);
2160 __ cmp(edi, ecx); 2165 __ cmp(edi, ecx);
2161 __ j(not_equal, miss); 2166 __ j(not_equal, &miss);
2162 2167
2163 __ mov(eax, arg_count()); 2168 __ mov(eax, arg_count());
2164 __ mov(ebx, FieldOperand(ebx, edx, times_half_pointer_size, 2169 __ mov(ebx, FieldOperand(ebx, edx, times_half_pointer_size,
2165 FixedArray::kHeaderSize)); 2170 FixedArray::kHeaderSize));
2166 // Verify that ecx contains an AllocationSite 2171 // Verify that ecx contains an AllocationSite
2167 __ AssertUndefinedOrAllocationSite(ebx); 2172 __ AssertUndefinedOrAllocationSite(ebx);
2168 ArrayConstructorStub stub(masm->isolate(), arg_count()); 2173 ArrayConstructorStub stub(masm->isolate(), arg_count());
2169 __ TailCallStub(&stub); 2174 __ TailCallStub(&stub);
2170 }
2171
2172
2173 void CallICStub::Generate_CustomFeedbackCall(MacroAssembler* masm) {
2174 // edi - function
2175 // ebx - feedback vector
2176 // edx - slot id
2177 Label miss;
2178
2179 if (state_.stub_type() == CallIC::MONOMORPHIC_ARRAY) {
2180 Generate_MonomorphicArray(masm, &miss);
2181 } else {
2182 // So far there is only one customer for our custom feedback scheme.
2183 UNREACHABLE();
2184 }
2185 2175
2186 __ bind(&miss); 2176 __ bind(&miss);
2187 GenerateMiss(masm); 2177 GenerateMiss(masm, IC::kCallIC_Customization_Miss);
2188 2178
2189 // The slow case, we need this no matter what to complete a call after a miss. 2179 // The slow case, we need this no matter what to complete a call after a miss.
2190 CallFunctionNoFeedback(masm, 2180 CallFunctionNoFeedback(masm,
2191 arg_count(), 2181 arg_count(),
2192 true, 2182 true,
2193 CallAsMethod()); 2183 CallAsMethod());
2194 2184
2195 // Unreachable. 2185 // Unreachable.
2196 __ int3(); 2186 __ int3();
2197 } 2187 }
2198 2188
2199 2189
2200 void CallICStub::Generate(MacroAssembler* masm) { 2190 void CallICStub::Generate(MacroAssembler* masm) {
2201 // edi - function 2191 // edi - function
2202 // edx - slot id 2192 // edx - slot id
2203 Isolate* isolate = masm->isolate(); 2193 Isolate* isolate = masm->isolate();
2204 Label extra_checks_or_miss, slow_start; 2194 Label extra_checks_or_miss, slow_start;
2205 Label slow, non_function, wrap, cont; 2195 Label slow, non_function, wrap, cont;
2206 Label have_js_function; 2196 Label have_js_function;
2207 int argc = state_.arg_count(); 2197 int argc = state_.arg_count();
2208 ParameterCount actual(argc); 2198 ParameterCount actual(argc);
2209 2199
2210 EmitLoadTypeFeedbackVector(masm, ebx); 2200 EmitLoadTypeFeedbackVector(masm, ebx);
2211 2201
2212 if (state_.stub_type() != CallIC::DEFAULT) {
2213 Generate_CustomFeedbackCall(masm);
2214 return;
2215 }
2216
2217 // The checks. First, does edi match the recorded monomorphic target? 2202 // The checks. First, does edi match the recorded monomorphic target?
2218 __ cmp(edi, FieldOperand(ebx, edx, times_half_pointer_size, 2203 __ cmp(edi, FieldOperand(ebx, edx, times_half_pointer_size,
2219 FixedArray::kHeaderSize)); 2204 FixedArray::kHeaderSize));
2220 __ j(not_equal, &extra_checks_or_miss); 2205 __ j(not_equal, &extra_checks_or_miss);
2221 2206
2222 __ bind(&have_js_function); 2207 __ bind(&have_js_function);
2223 if (state_.CallAsMethod()) { 2208 if (state_.CallAsMethod()) {
2224 EmitContinueIfStrictOrNative(masm, &cont); 2209 EmitContinueIfStrictOrNative(masm, &cont);
2225 2210
2226 // Load the receiver from the stack. 2211 // Load the receiver from the stack.
(...skipping 30 matching lines...) Expand all
2257 if (!FLAG_trace_ic) { 2242 if (!FLAG_trace_ic) {
2258 // We are going megamorphic, and we don't want to visit the runtime. 2243 // We are going megamorphic, and we don't want to visit the runtime.
2259 __ mov(FieldOperand(ebx, edx, times_half_pointer_size, 2244 __ mov(FieldOperand(ebx, edx, times_half_pointer_size,
2260 FixedArray::kHeaderSize), 2245 FixedArray::kHeaderSize),
2261 Immediate(TypeFeedbackInfo::MegamorphicSentinel(isolate))); 2246 Immediate(TypeFeedbackInfo::MegamorphicSentinel(isolate)));
2262 __ jmp(&slow_start); 2247 __ jmp(&slow_start);
2263 } 2248 }
2264 2249
2265 // We are here because tracing is on or we are going monomorphic. 2250 // We are here because tracing is on or we are going monomorphic.
2266 __ bind(&miss); 2251 __ bind(&miss);
2267 GenerateMiss(masm); 2252 GenerateMiss(masm, IC::kCallIC_Miss);
2268 2253
2269 // the slow case 2254 // the slow case
2270 __ bind(&slow_start); 2255 __ bind(&slow_start);
2271 2256
2272 // Check that the function really is a JavaScript function. 2257 // Check that the function really is a JavaScript function.
2273 __ JumpIfSmi(edi, &non_function); 2258 __ JumpIfSmi(edi, &non_function);
2274 2259
2275 // Goto slow case if we do not have a function. 2260 // Goto slow case if we do not have a function.
2276 __ CmpObjectType(edi, JS_FUNCTION_TYPE, ecx); 2261 __ CmpObjectType(edi, JS_FUNCTION_TYPE, ecx);
2277 __ j(not_equal, &slow); 2262 __ j(not_equal, &slow);
2278 __ jmp(&have_js_function); 2263 __ jmp(&have_js_function);
2279 2264
2280 // Unreachable 2265 // Unreachable
2281 __ int3(); 2266 __ int3();
2282 } 2267 }
2283 2268
2284 2269
2285 void CallICStub::GenerateMiss(MacroAssembler* masm) { 2270 void CallICStub::GenerateMiss(MacroAssembler* masm, IC::UtilityId id) {
2286 // Get the receiver of the function from the stack; 1 ~ return address. 2271 // Get the receiver of the function from the stack; 1 ~ return address.
2287 __ mov(ecx, Operand(esp, (state_.arg_count() + 1) * kPointerSize)); 2272 __ mov(ecx, Operand(esp, (state_.arg_count() + 1) * kPointerSize));
2288 2273
2289 { 2274 {
2290 FrameScope scope(masm, StackFrame::INTERNAL); 2275 FrameScope scope(masm, StackFrame::INTERNAL);
2291 2276
2292 // Push the receiver and the function and feedback info. 2277 // Push the receiver and the function and feedback info.
2293 __ push(ecx); 2278 __ push(ecx);
2294 __ push(edi); 2279 __ push(edi);
2295 __ push(ebx); 2280 __ push(ebx);
2296 __ push(edx); 2281 __ push(edx);
2297 2282
2298 // Call the entry. 2283 // Call the entry.
2299 ExternalReference miss = ExternalReference(IC_Utility(IC::kCallIC_Miss), 2284 ExternalReference miss = ExternalReference(IC_Utility(id),
2300 masm->isolate()); 2285 masm->isolate());
2301 __ CallExternalReference(miss, 4); 2286 __ CallExternalReference(miss, 4);
2302 2287
2303 // Move result to edi and exit the internal frame. 2288 // Move result to edi and exit the internal frame.
2304 __ mov(edi, eax); 2289 __ mov(edi, eax);
2305 } 2290 }
2306 } 2291 }
2307 2292
2308 2293
2309 bool CEntryStub::NeedsImmovableCode() { 2294 bool CEntryStub::NeedsImmovableCode() {
(...skipping 2461 matching lines...) Expand 10 before | Expand all | Expand 10 after
4771 Operand(ebp, 7 * kPointerSize), 4756 Operand(ebp, 7 * kPointerSize),
4772 NULL); 4757 NULL);
4773 } 4758 }
4774 4759
4775 4760
4776 #undef __ 4761 #undef __
4777 4762
4778 } } // namespace v8::internal 4763 } } // namespace v8::internal
4779 4764
4780 #endif // V8_TARGET_ARCH_X87 4765 #endif // V8_TARGET_ARCH_X87
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698