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

Side by Side Diff: src/arm64/full-codegen-arm64.cc

Issue 224903005: Reland "create a function call IC" (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Comments. Created 6 years, 8 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/arm64/debug-arm64.cc ('k') | src/arm64/lithium-codegen-arm64.cc » ('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 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 2319 matching lines...) Expand 10 before | Expand all | Expand 10 after
2330 void FullCodeGenerator::CallIC(Handle<Code> code, 2330 void FullCodeGenerator::CallIC(Handle<Code> code,
2331 TypeFeedbackId ast_id) { 2331 TypeFeedbackId ast_id) {
2332 ic_total_count_++; 2332 ic_total_count_++;
2333 // All calls must have a predictable size in full-codegen code to ensure that 2333 // All calls must have a predictable size in full-codegen code to ensure that
2334 // the debugger can patch them correctly. 2334 // the debugger can patch them correctly.
2335 __ Call(code, RelocInfo::CODE_TARGET, ast_id); 2335 __ Call(code, RelocInfo::CODE_TARGET, ast_id);
2336 } 2336 }
2337 2337
2338 2338
2339 // Code common for calls using the IC. 2339 // Code common for calls using the IC.
2340 void FullCodeGenerator::EmitCallWithIC(Call* expr) { 2340 void FullCodeGenerator::EmitCallWithLoadIC(Call* expr) {
2341 ASM_LOCATION("EmitCallWithIC"); 2341 Expression* callee = expr->expression();
2342 2342
2343 Expression* callee = expr->expression(); 2343 CallIC::CallType call_type = callee->IsVariableProxy()
2344 ZoneList<Expression*>* args = expr->arguments(); 2344 ? CallIC::FUNCTION
2345 int arg_count = args->length(); 2345 : CallIC::METHOD;
2346 2346
2347 CallFunctionFlags flags;
2348 // Get the target function. 2347 // Get the target function.
2349 if (callee->IsVariableProxy()) { 2348 if (call_type == CallIC::FUNCTION) {
2350 { StackValueContext context(this); 2349 { StackValueContext context(this);
2351 EmitVariableLoad(callee->AsVariableProxy()); 2350 EmitVariableLoad(callee->AsVariableProxy());
2352 PrepareForBailout(callee, NO_REGISTERS); 2351 PrepareForBailout(callee, NO_REGISTERS);
2353 } 2352 }
2354 // Push undefined as receiver. This is patched in the method prologue if it 2353 // Push undefined as receiver. This is patched in the method prologue if it
2355 // is a sloppy mode method. 2354 // is a sloppy mode method.
2356 __ Push(isolate()->factory()->undefined_value()); 2355 __ Push(isolate()->factory()->undefined_value());
2357 flags = NO_CALL_FUNCTION_FLAGS;
2358 } else { 2356 } else {
2359 // Load the function from the receiver. 2357 // Load the function from the receiver.
2360 ASSERT(callee->IsProperty()); 2358 ASSERT(callee->IsProperty());
2361 __ Peek(x0, 0); 2359 __ Peek(x0, 0);
2362 EmitNamedPropertyLoad(callee->AsProperty()); 2360 EmitNamedPropertyLoad(callee->AsProperty());
2363 PrepareForBailoutForId(callee->AsProperty()->LoadId(), TOS_REG); 2361 PrepareForBailoutForId(callee->AsProperty()->LoadId(), TOS_REG);
2364 // Push the target function under the receiver. 2362 // Push the target function under the receiver.
2365 __ Pop(x10); 2363 __ Pop(x10);
2366 __ Push(x0, x10); 2364 __ Push(x0, x10);
2367 flags = CALL_AS_METHOD;
2368 } 2365 }
2369 2366
2370 // Load the arguments. 2367 EmitCall(expr, call_type);
2371 { PreservePositionScope scope(masm()->positions_recorder());
2372 for (int i = 0; i < arg_count; i++) {
2373 VisitForStackValue(args->at(i));
2374 }
2375 }
2376
2377 // Record source position for debugger.
2378 SetSourcePosition(expr->position());
2379 CallFunctionStub stub(arg_count, flags);
2380 __ Peek(x1, (arg_count + 1) * kPointerSize);
2381 __ CallStub(&stub);
2382
2383 RecordJSReturnSite(expr);
2384
2385 // Restore context register.
2386 __ Ldr(cp, MemOperand(fp, StandardFrameConstants::kContextOffset));
2387
2388 context()->DropAndPlug(1, x0);
2389 } 2368 }
2390 2369
2391 2370
2392 // Code common for calls using the IC. 2371 // Code common for calls using the IC.
2393 void FullCodeGenerator::EmitKeyedCallWithIC(Call* expr, 2372 void FullCodeGenerator::EmitKeyedCallWithLoadIC(Call* expr,
2394 Expression* key) { 2373 Expression* key) {
2395 // Load the key. 2374 // Load the key.
2396 VisitForAccumulatorValue(key); 2375 VisitForAccumulatorValue(key);
2397 2376
2398 Expression* callee = expr->expression(); 2377 Expression* callee = expr->expression();
2399 ZoneList<Expression*>* args = expr->arguments();
2400 int arg_count = args->length();
2401 2378
2402 // Load the function from the receiver. 2379 // Load the function from the receiver.
2403 ASSERT(callee->IsProperty()); 2380 ASSERT(callee->IsProperty());
2404 __ Peek(x1, 0); 2381 __ Peek(x1, 0);
2405 EmitKeyedPropertyLoad(callee->AsProperty()); 2382 EmitKeyedPropertyLoad(callee->AsProperty());
2406 PrepareForBailoutForId(callee->AsProperty()->LoadId(), TOS_REG); 2383 PrepareForBailoutForId(callee->AsProperty()->LoadId(), TOS_REG);
2407 2384
2408 // Push the target function under the receiver. 2385 // Push the target function under the receiver.
2409 __ Pop(x10); 2386 __ Pop(x10);
2410 __ Push(x0, x10); 2387 __ Push(x0, x10);
2411 2388
2412 { PreservePositionScope scope(masm()->positions_recorder()); 2389 EmitCall(expr, CallIC::METHOD);
2413 for (int i = 0; i < arg_count; i++) {
2414 VisitForStackValue(args->at(i));
2415 }
2416 }
2417
2418 // Record source position for debugger.
2419 SetSourcePosition(expr->position());
2420 CallFunctionStub stub(arg_count, CALL_AS_METHOD);
2421 __ Peek(x1, (arg_count + 1) * kPointerSize);
2422 __ CallStub(&stub);
2423
2424 RecordJSReturnSite(expr);
2425 // Restore context register.
2426 __ Ldr(cp, MemOperand(fp, StandardFrameConstants::kContextOffset));
2427
2428 context()->DropAndPlug(1, x0);
2429 } 2390 }
2430 2391
2431 2392
2432 void FullCodeGenerator::EmitCallWithStub(Call* expr) { 2393 void FullCodeGenerator::EmitCall(Call* expr, CallIC::CallType call_type) {
2433 // Code common for calls using the call stub. 2394 // Load the arguments.
2434 ZoneList<Expression*>* args = expr->arguments(); 2395 ZoneList<Expression*>* args = expr->arguments();
2435 int arg_count = args->length(); 2396 int arg_count = args->length();
2436 { PreservePositionScope scope(masm()->positions_recorder()); 2397 { PreservePositionScope scope(masm()->positions_recorder());
2437 for (int i = 0; i < arg_count; i++) { 2398 for (int i = 0; i < arg_count; i++) {
2438 VisitForStackValue(args->at(i)); 2399 VisitForStackValue(args->at(i));
2439 } 2400 }
2440 } 2401 }
2441 // Record source position for debugger. 2402 // Record source position of the IC call.
2442 SetSourcePosition(expr->position()); 2403 SetSourcePosition(expr->position());
2443 2404
2405 Handle<Code> ic = CallIC::initialize_stub(
2406 isolate(), arg_count, call_type);
2444 Handle<Object> uninitialized = 2407 Handle<Object> uninitialized =
2445 TypeFeedbackInfo::UninitializedSentinel(isolate()); 2408 TypeFeedbackInfo::UninitializedSentinel(isolate());
2446 StoreFeedbackVectorSlot(expr->CallFeedbackSlot(), uninitialized); 2409 StoreFeedbackVectorSlot(expr->CallFeedbackSlot(), uninitialized);
2447 __ LoadObject(x2, FeedbackVector()); 2410 __ LoadObject(x2, FeedbackVector());
2448 __ Mov(x3, Smi::FromInt(expr->CallFeedbackSlot())); 2411 __ Mov(x3, Smi::FromInt(expr->CallFeedbackSlot()));
2412 __ Peek(x1, (arg_count + 1) * kXRegSize);
2413 // Don't assign a type feedback id to the IC, since type feedback is provided
2414 // by the vector above.
2415 CallIC(ic);
2449 2416
2450 // Record call targets in unoptimized code.
2451 CallFunctionStub stub(arg_count, RECORD_CALL_TARGET);
2452 __ Peek(x1, (arg_count + 1) * kXRegSize);
2453 __ CallStub(&stub);
2454 RecordJSReturnSite(expr); 2417 RecordJSReturnSite(expr);
2455 // Restore context register. 2418 // Restore context register.
2456 __ Ldr(cp, MemOperand(fp, StandardFrameConstants::kContextOffset)); 2419 __ Ldr(cp, MemOperand(fp, StandardFrameConstants::kContextOffset));
2457 context()->DropAndPlug(1, x0); 2420 context()->DropAndPlug(1, x0);
2458 } 2421 }
2459 2422
2460 2423
2461 void FullCodeGenerator::EmitResolvePossiblyDirectEval(int arg_count) { 2424 void FullCodeGenerator::EmitResolvePossiblyDirectEval(int arg_count) {
2462 ASM_LOCATION("FullCodeGenerator::EmitResolvePossiblyDirectEval"); 2425 ASM_LOCATION("FullCodeGenerator::EmitResolvePossiblyDirectEval");
2463 // Prepare to push a copy of the first argument or undefined if it doesn't 2426 // Prepare to push a copy of the first argument or undefined if it doesn't
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
2535 // Call the evaluated function. 2498 // Call the evaluated function.
2536 CallFunctionStub stub(arg_count, NO_CALL_FUNCTION_FLAGS); 2499 CallFunctionStub stub(arg_count, NO_CALL_FUNCTION_FLAGS);
2537 __ Peek(x1, (arg_count + 1) * kXRegSize); 2500 __ Peek(x1, (arg_count + 1) * kXRegSize);
2538 __ CallStub(&stub); 2501 __ CallStub(&stub);
2539 RecordJSReturnSite(expr); 2502 RecordJSReturnSite(expr);
2540 // Restore context register. 2503 // Restore context register.
2541 __ Ldr(cp, MemOperand(fp, StandardFrameConstants::kContextOffset)); 2504 __ Ldr(cp, MemOperand(fp, StandardFrameConstants::kContextOffset));
2542 context()->DropAndPlug(1, x0); 2505 context()->DropAndPlug(1, x0);
2543 2506
2544 } else if (call_type == Call::GLOBAL_CALL) { 2507 } else if (call_type == Call::GLOBAL_CALL) {
2545 EmitCallWithIC(expr); 2508 EmitCallWithLoadIC(expr);
2546 2509
2547 } else if (call_type == Call::LOOKUP_SLOT_CALL) { 2510 } else if (call_type == Call::LOOKUP_SLOT_CALL) {
2548 // Call to a lookup slot (dynamically introduced variable). 2511 // Call to a lookup slot (dynamically introduced variable).
2549 VariableProxy* proxy = callee->AsVariableProxy(); 2512 VariableProxy* proxy = callee->AsVariableProxy();
2550 Label slow, done; 2513 Label slow, done;
2551 2514
2552 { PreservePositionScope scope(masm()->positions_recorder()); 2515 { PreservePositionScope scope(masm()->positions_recorder());
2553 // Generate code for loading from variables potentially shadowed 2516 // Generate code for loading from variables potentially shadowed
2554 // by eval-introduced variables. 2517 // by eval-introduced variables.
2555 EmitDynamicLookupFastCase(proxy->var(), NOT_INSIDE_TYPEOF, &slow, &done); 2518 EmitDynamicLookupFastCase(proxy->var(), NOT_INSIDE_TYPEOF, &slow, &done);
(...skipping 19 matching lines...) Expand all
2575 __ Push(x0); 2538 __ Push(x0);
2576 // The receiver is implicitly the global receiver. Indicate this 2539 // The receiver is implicitly the global receiver. Indicate this
2577 // by passing the undefined to the call function stub. 2540 // by passing the undefined to the call function stub.
2578 __ LoadRoot(x1, Heap::kUndefinedValueRootIndex); 2541 __ LoadRoot(x1, Heap::kUndefinedValueRootIndex);
2579 __ Push(x1); 2542 __ Push(x1);
2580 __ Bind(&call); 2543 __ Bind(&call);
2581 } 2544 }
2582 2545
2583 // The receiver is either the global receiver or an object found 2546 // The receiver is either the global receiver or an object found
2584 // by LoadContextSlot. 2547 // by LoadContextSlot.
2585 EmitCallWithStub(expr); 2548 EmitCall(expr);
2586 } else if (call_type == Call::PROPERTY_CALL) { 2549 } else if (call_type == Call::PROPERTY_CALL) {
2587 Property* property = callee->AsProperty(); 2550 Property* property = callee->AsProperty();
2588 { PreservePositionScope scope(masm()->positions_recorder()); 2551 { PreservePositionScope scope(masm()->positions_recorder());
2589 VisitForStackValue(property->obj()); 2552 VisitForStackValue(property->obj());
2590 } 2553 }
2591 if (property->key()->IsPropertyName()) { 2554 if (property->key()->IsPropertyName()) {
2592 EmitCallWithIC(expr); 2555 EmitCallWithLoadIC(expr);
2593 } else { 2556 } else {
2594 EmitKeyedCallWithIC(expr, property->key()); 2557 EmitKeyedCallWithLoadIC(expr, property->key());
2595 } 2558 }
2596 2559
2597 } else { 2560 } else {
2598 ASSERT(call_type == Call::OTHER_CALL); 2561 ASSERT(call_type == Call::OTHER_CALL);
2599 // Call to an arbitrary expression not handled specially above. 2562 // Call to an arbitrary expression not handled specially above.
2600 { PreservePositionScope scope(masm()->positions_recorder()); 2563 { PreservePositionScope scope(masm()->positions_recorder());
2601 VisitForStackValue(callee); 2564 VisitForStackValue(callee);
2602 } 2565 }
2603 __ LoadRoot(x1, Heap::kUndefinedValueRootIndex); 2566 __ LoadRoot(x1, Heap::kUndefinedValueRootIndex);
2604 __ Push(x1); 2567 __ Push(x1);
2605 // Emit function call. 2568 // Emit function call.
2606 EmitCallWithStub(expr); 2569 EmitCall(expr);
2607 } 2570 }
2608 2571
2609 #ifdef DEBUG 2572 #ifdef DEBUG
2610 // RecordJSReturnSite should have been called. 2573 // RecordJSReturnSite should have been called.
2611 ASSERT(expr->return_is_recorded_); 2574 ASSERT(expr->return_is_recorded_);
2612 #endif 2575 #endif
2613 } 2576 }
2614 2577
2615 2578
2616 void FullCodeGenerator::VisitCallNew(CallNew* expr) { 2579 void FullCodeGenerator::VisitCallNew(CallNew* expr) {
(...skipping 29 matching lines...) Expand all
2646 if (FLAG_pretenuring_call_new) { 2609 if (FLAG_pretenuring_call_new) {
2647 StoreFeedbackVectorSlot(expr->AllocationSiteFeedbackSlot(), 2610 StoreFeedbackVectorSlot(expr->AllocationSiteFeedbackSlot(),
2648 isolate()->factory()->NewAllocationSite()); 2611 isolate()->factory()->NewAllocationSite());
2649 ASSERT(expr->AllocationSiteFeedbackSlot() == 2612 ASSERT(expr->AllocationSiteFeedbackSlot() ==
2650 expr->CallNewFeedbackSlot() + 1); 2613 expr->CallNewFeedbackSlot() + 1);
2651 } 2614 }
2652 2615
2653 __ LoadObject(x2, FeedbackVector()); 2616 __ LoadObject(x2, FeedbackVector());
2654 __ Mov(x3, Smi::FromInt(expr->CallNewFeedbackSlot())); 2617 __ Mov(x3, Smi::FromInt(expr->CallNewFeedbackSlot()));
2655 2618
2656 CallConstructStub stub(RECORD_CALL_TARGET); 2619 CallConstructStub stub(RECORD_CONSTRUCTOR_TARGET);
2657 __ Call(stub.GetCode(isolate()), RelocInfo::CONSTRUCT_CALL); 2620 __ Call(stub.GetCode(isolate()), RelocInfo::CONSTRUCT_CALL);
2658 PrepareForBailoutForId(expr->ReturnId(), TOS_REG); 2621 PrepareForBailoutForId(expr->ReturnId(), TOS_REG);
2659 context()->Plug(x0); 2622 context()->Plug(x0);
2660 } 2623 }
2661 2624
2662 2625
2663 void FullCodeGenerator::EmitIsSmi(CallRuntime* expr) { 2626 void FullCodeGenerator::EmitIsSmi(CallRuntime* expr) {
2664 ZoneList<Expression*>* args = expr->arguments(); 2627 ZoneList<Expression*>* args = expr->arguments();
2665 ASSERT(args->length() == 1); 2628 ASSERT(args->length() == 1);
2666 2629
(...skipping 2324 matching lines...) Expand 10 before | Expand all | Expand 10 after
4991 return previous_; 4954 return previous_;
4992 } 4955 }
4993 4956
4994 4957
4995 #undef __ 4958 #undef __
4996 4959
4997 4960
4998 } } // namespace v8::internal 4961 } } // namespace v8::internal
4999 4962
5000 #endif // V8_TARGET_ARCH_ARM64 4963 #endif // V8_TARGET_ARCH_ARM64
OLDNEW
« no previous file with comments | « src/arm64/debug-arm64.cc ('k') | src/arm64/lithium-codegen-arm64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698