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

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

Issue 279423005: Customized support for feedback on calls to Array. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Rebase and comments. Created 6 years, 7 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 | « src/typing.cc ('k') | test/mjsunit/array-constructor-feedback.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 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_X64 7 #if V8_TARGET_ARCH_X64
8 8
9 #include "bootstrapper.h" 9 #include "bootstrapper.h"
10 #include "code-stubs.h" 10 #include "code-stubs.h"
(...skipping 2210 matching lines...) Expand 10 before | Expand all | Expand 10 after
2221 __ Push(rdi); 2221 __ Push(rdi);
2222 __ Push(rax); 2222 __ Push(rax);
2223 __ InvokeBuiltin(Builtins::TO_OBJECT, CALL_FUNCTION); 2223 __ InvokeBuiltin(Builtins::TO_OBJECT, CALL_FUNCTION);
2224 __ Pop(rdi); 2224 __ Pop(rdi);
2225 } 2225 }
2226 __ movp(args->GetReceiverOperand(), rax); 2226 __ movp(args->GetReceiverOperand(), rax);
2227 __ jmp(cont); 2227 __ jmp(cont);
2228 } 2228 }
2229 2229
2230 2230
2231 void CallFunctionStub::Generate(MacroAssembler* masm) { 2231 static void CallFunctionNoFeedback(MacroAssembler* masm,
2232 int argc, bool needs_checks,
2233 bool call_as_method) {
2232 // rdi : the function to call 2234 // rdi : the function to call
2233 2235
2234 // wrap_and_call can only be true if we are compiling a monomorphic method. 2236 // wrap_and_call can only be true if we are compiling a monomorphic method.
2235 Isolate* isolate = masm->isolate(); 2237 Isolate* isolate = masm->isolate();
2236 Label slow, non_function, wrap, cont; 2238 Label slow, non_function, wrap, cont;
2237 int argc = argc_;
2238 StackArgumentsAccessor args(rsp, argc); 2239 StackArgumentsAccessor args(rsp, argc);
2239 2240
2240 if (NeedsChecks()) { 2241 if (needs_checks) {
2241 // Check that the function really is a JavaScript function. 2242 // Check that the function really is a JavaScript function.
2242 __ JumpIfSmi(rdi, &non_function); 2243 __ JumpIfSmi(rdi, &non_function);
2243 2244
2244 // Goto slow case if we do not have a function. 2245 // Goto slow case if we do not have a function.
2245 __ CmpObjectType(rdi, JS_FUNCTION_TYPE, rcx); 2246 __ CmpObjectType(rdi, JS_FUNCTION_TYPE, rcx);
2246 __ j(not_equal, &slow); 2247 __ j(not_equal, &slow);
2247 } 2248 }
2248 2249
2249 // Fast-case: Just invoke the function. 2250 // Fast-case: Just invoke the function.
2250 ParameterCount actual(argc); 2251 ParameterCount actual(argc);
2251 2252
2252 if (CallAsMethod()) { 2253 if (call_as_method) {
2253 if (NeedsChecks()) { 2254 if (needs_checks) {
2254 EmitContinueIfStrictOrNative(masm, &cont); 2255 EmitContinueIfStrictOrNative(masm, &cont);
2255 } 2256 }
2256 2257
2257 // Load the receiver from the stack. 2258 // Load the receiver from the stack.
2258 __ movp(rax, args.GetReceiverOperand()); 2259 __ movp(rax, args.GetReceiverOperand());
2259 2260
2260 if (NeedsChecks()) { 2261 if (needs_checks) {
2261 __ JumpIfSmi(rax, &wrap); 2262 __ JumpIfSmi(rax, &wrap);
2262 2263
2263 __ CmpObjectType(rax, FIRST_SPEC_OBJECT_TYPE, rcx); 2264 __ CmpObjectType(rax, FIRST_SPEC_OBJECT_TYPE, rcx);
2264 __ j(below, &wrap); 2265 __ j(below, &wrap);
2265 } else { 2266 } else {
2266 __ jmp(&wrap); 2267 __ jmp(&wrap);
2267 } 2268 }
2268 2269
2269 __ bind(&cont); 2270 __ bind(&cont);
2270 } 2271 }
2271 2272
2272 __ InvokeFunction(rdi, actual, JUMP_FUNCTION, NullCallWrapper()); 2273 __ InvokeFunction(rdi, actual, JUMP_FUNCTION, NullCallWrapper());
2273 2274
2274 if (NeedsChecks()) { 2275 if (needs_checks) {
2275 // Slow-case: Non-function called. 2276 // Slow-case: Non-function called.
2276 __ bind(&slow); 2277 __ bind(&slow);
2277 EmitSlowCase(isolate, masm, &args, argc, &non_function); 2278 EmitSlowCase(isolate, masm, &args, argc, &non_function);
2278 } 2279 }
2279 2280
2280 if (CallAsMethod()) { 2281 if (call_as_method) {
2281 __ bind(&wrap); 2282 __ bind(&wrap);
2282 EmitWrapCase(masm, &args, &cont); 2283 EmitWrapCase(masm, &args, &cont);
2283 } 2284 }
2284 } 2285 }
2285 2286
2286 2287
2288 void CallFunctionStub::Generate(MacroAssembler* masm) {
2289 CallFunctionNoFeedback(masm, argc_, NeedsChecks(), CallAsMethod());
2290 }
2291
2292
2287 void CallConstructStub::Generate(MacroAssembler* masm) { 2293 void CallConstructStub::Generate(MacroAssembler* masm) {
2288 // rax : number of arguments 2294 // rax : number of arguments
2289 // rbx : feedback vector 2295 // rbx : feedback vector
2290 // rdx : (only if rbx is not the megamorphic symbol) slot in feedback 2296 // rdx : (only if rbx is not the megamorphic symbol) slot in feedback
2291 // vector (Smi) 2297 // vector (Smi)
2292 // rdi : constructor function 2298 // rdi : constructor function
2293 Label slow, non_function_call; 2299 Label slow, non_function_call;
2294 2300
2295 // Check that function is not a smi. 2301 // Check that function is not a smi.
2296 __ JumpIfSmi(rdi, &non_function_call); 2302 __ JumpIfSmi(rdi, &non_function_call);
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
2351 2357
2352 2358
2353 static void EmitLoadTypeFeedbackVector(MacroAssembler* masm, Register vector) { 2359 static void EmitLoadTypeFeedbackVector(MacroAssembler* masm, Register vector) {
2354 __ movp(vector, Operand(rbp, JavaScriptFrameConstants::kFunctionOffset)); 2360 __ movp(vector, Operand(rbp, JavaScriptFrameConstants::kFunctionOffset));
2355 __ movp(vector, FieldOperand(vector, JSFunction::kSharedFunctionInfoOffset)); 2361 __ movp(vector, FieldOperand(vector, JSFunction::kSharedFunctionInfoOffset));
2356 __ movp(vector, FieldOperand(vector, 2362 __ movp(vector, FieldOperand(vector,
2357 SharedFunctionInfo::kFeedbackVectorOffset)); 2363 SharedFunctionInfo::kFeedbackVectorOffset));
2358 } 2364 }
2359 2365
2360 2366
2367 void CallICStub::Generate_MonomorphicArray(MacroAssembler* masm, Label* miss) {
2368 // rdi - function
2369 // rbx - feedback vector
2370 // rdx - slot id (as integer)
2371 __ LoadGlobalFunction(Context::ARRAY_FUNCTION_INDEX, rcx);
2372 __ cmpq(rdi, rcx);
2373 __ j(not_equal, miss);
2374
2375 __ movq(rax, Immediate(arg_count()));
2376 __ movp(rbx, FieldOperand(rbx, rdx, times_pointer_size,
2377 FixedArray::kHeaderSize));
2378
2379 // Verify that ecx contains an AllocationSite
2380 __ AssertUndefinedOrAllocationSite(rbx);
2381 ArrayConstructorStub stub(masm->isolate(), arg_count());
2382 __ TailCallStub(&stub);
2383 }
2384
2385
2386 void CallICStub::Generate_CustomFeedbackCall(MacroAssembler* masm) {
2387 // rdi - function
2388 // rbx - feedback vector
2389 // rdx - slot id
2390 Label miss;
2391
2392 __ SmiToInteger32(rdx, rdx);
2393
2394 if (state_.stub_type() == CallIC::MONOMORPHIC_ARRAY) {
2395 Generate_MonomorphicArray(masm, &miss);
2396 } else {
2397 // So far there is only one customer for our custom feedback scheme.
2398 UNREACHABLE();
2399 }
2400
2401 __ bind(&miss);
2402 GenerateMiss(masm);
2403
2404 // The slow case, we need this no matter what to complete a call after a miss.
2405 CallFunctionNoFeedback(masm,
2406 arg_count(),
2407 true,
2408 CallAsMethod());
2409
2410 // Unreachable.
2411 __ int3();
2412 }
2413
2414
2361 void CallICStub::Generate(MacroAssembler* masm) { 2415 void CallICStub::Generate(MacroAssembler* masm) {
2362 // rdi - function 2416 // rdi - function
2363 // rbx - vector 2417 // rbx - vector
2364 // rdx - slot id 2418 // rdx - slot id
2365 Isolate* isolate = masm->isolate(); 2419 Isolate* isolate = masm->isolate();
2366 Label extra_checks_or_miss, slow_start; 2420 Label extra_checks_or_miss, slow_start;
2367 Label slow, non_function, wrap, cont; 2421 Label slow, non_function, wrap, cont;
2368 Label have_js_function; 2422 Label have_js_function;
2369 int argc = state_.arg_count(); 2423 int argc = state_.arg_count();
2370 StackArgumentsAccessor args(rsp, argc); 2424 StackArgumentsAccessor args(rsp, argc);
2371 ParameterCount actual(argc); 2425 ParameterCount actual(argc);
2372 2426
2373 EmitLoadTypeFeedbackVector(masm, rbx); 2427 EmitLoadTypeFeedbackVector(masm, rbx);
2374 2428
2429 if (state_.stub_type() != CallIC::DEFAULT) {
2430 Generate_CustomFeedbackCall(masm);
2431 return;
2432 }
2433
2375 // The checks. First, does rdi match the recorded monomorphic target? 2434 // The checks. First, does rdi match the recorded monomorphic target?
2376 __ SmiToInteger32(rdx, rdx); 2435 __ SmiToInteger32(rdx, rdx);
2377 __ cmpq(rdi, FieldOperand(rbx, rdx, times_pointer_size, 2436 __ cmpq(rdi, FieldOperand(rbx, rdx, times_pointer_size,
2378 FixedArray::kHeaderSize)); 2437 FixedArray::kHeaderSize));
2379 __ j(not_equal, &extra_checks_or_miss); 2438 __ j(not_equal, &extra_checks_or_miss);
2380 2439
2381 __ bind(&have_js_function); 2440 __ bind(&have_js_function);
2382 if (state_.CallAsMethod()) { 2441 if (state_.CallAsMethod()) {
2383 EmitContinueIfStrictOrNative(masm, &cont); 2442 EmitContinueIfStrictOrNative(masm, &cont);
2384 2443
(...skipping 2651 matching lines...) Expand 10 before | Expand all | Expand 10 after
5036 return_value_operand, 5095 return_value_operand,
5037 NULL); 5096 NULL);
5038 } 5097 }
5039 5098
5040 5099
5041 #undef __ 5100 #undef __
5042 5101
5043 } } // namespace v8::internal 5102 } } // namespace v8::internal
5044 5103
5045 #endif // V8_TARGET_ARCH_X64 5104 #endif // V8_TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « src/typing.cc ('k') | test/mjsunit/array-constructor-feedback.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698