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

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

Issue 295383004: Refactor CallICStub to use a different stub for each customization. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Ports. 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 | « src/code-stubs.cc ('k') | src/ic.h » ('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 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_IA32 7 #if V8_TARGET_ARCH_IA32
8 8
9 #include "bootstrapper.h" 9 #include "bootstrapper.h"
10 #include "code-stubs.h" 10 #include "code-stubs.h"
(...skipping 2452 matching lines...) Expand 10 before | Expand all | Expand 10 after
2463 2463
2464 2464
2465 static void EmitLoadTypeFeedbackVector(MacroAssembler* masm, Register vector) { 2465 static void EmitLoadTypeFeedbackVector(MacroAssembler* masm, Register vector) {
2466 __ mov(vector, Operand(ebp, JavaScriptFrameConstants::kFunctionOffset)); 2466 __ mov(vector, Operand(ebp, JavaScriptFrameConstants::kFunctionOffset));
2467 __ mov(vector, FieldOperand(vector, JSFunction::kSharedFunctionInfoOffset)); 2467 __ mov(vector, FieldOperand(vector, JSFunction::kSharedFunctionInfoOffset));
2468 __ mov(vector, FieldOperand(vector, 2468 __ mov(vector, FieldOperand(vector,
2469 SharedFunctionInfo::kFeedbackVectorOffset)); 2469 SharedFunctionInfo::kFeedbackVectorOffset));
2470 } 2470 }
2471 2471
2472 2472
2473 void CallICStub::Generate_MonomorphicArray(MacroAssembler* masm, Label* miss) { 2473 void CallIC_ArrayStub::Generate(MacroAssembler* masm) {
2474 // edi - function 2474 // edi - function
2475 // ebx - feedback vector
2476 // edx - slot id 2475 // edx - slot id
2476 Label miss;
2477 int argc = state_.arg_count();
2478 ParameterCount actual(argc);
2479
2480 EmitLoadTypeFeedbackVector(masm, ebx);
2481
2477 __ LoadGlobalFunction(Context::ARRAY_FUNCTION_INDEX, ecx); 2482 __ LoadGlobalFunction(Context::ARRAY_FUNCTION_INDEX, ecx);
2478 __ cmp(edi, ecx); 2483 __ cmp(edi, ecx);
2479 __ j(not_equal, miss); 2484 __ j(not_equal, &miss);
2480 2485
2481 __ mov(eax, arg_count()); 2486 __ mov(eax, arg_count());
2482 __ mov(ebx, FieldOperand(ebx, edx, times_half_pointer_size, 2487 __ mov(ebx, FieldOperand(ebx, edx, times_half_pointer_size,
2483 FixedArray::kHeaderSize)); 2488 FixedArray::kHeaderSize));
2484 // Verify that ecx contains an AllocationSite 2489 // Verify that ecx contains an AllocationSite
2485 __ AssertUndefinedOrAllocationSite(ebx); 2490 __ AssertUndefinedOrAllocationSite(ebx);
2486 ArrayConstructorStub stub(masm->isolate(), arg_count()); 2491 ArrayConstructorStub stub(masm->isolate(), arg_count());
2487 __ TailCallStub(&stub); 2492 __ TailCallStub(&stub);
2488 }
2489
2490
2491 void CallICStub::Generate_CustomFeedbackCall(MacroAssembler* masm) {
2492 // edi - function
2493 // ebx - feedback vector
2494 // edx - slot id
2495 Label miss;
2496
2497 if (state_.stub_type() == CallIC::MONOMORPHIC_ARRAY) {
2498 Generate_MonomorphicArray(masm, &miss);
2499 } else {
2500 // So far there is only one customer for our custom feedback scheme.
2501 UNREACHABLE();
2502 }
2503 2493
2504 __ bind(&miss); 2494 __ bind(&miss);
2505 GenerateMiss(masm); 2495 GenerateMiss(masm, IC::kCallIC_Customization_Miss);
2506 2496
2507 // The slow case, we need this no matter what to complete a call after a miss. 2497 // The slow case, we need this no matter what to complete a call after a miss.
2508 CallFunctionNoFeedback(masm, 2498 CallFunctionNoFeedback(masm,
2509 arg_count(), 2499 arg_count(),
2510 true, 2500 true,
2511 CallAsMethod()); 2501 CallAsMethod());
2512 2502
2513 // Unreachable. 2503 // Unreachable.
2514 __ int3(); 2504 __ int3();
2515 } 2505 }
2516 2506
2517 2507
2518 void CallICStub::Generate(MacroAssembler* masm) { 2508 void CallICStub::Generate(MacroAssembler* masm) {
2519 // edi - function 2509 // edi - function
2520 // edx - slot id 2510 // edx - slot id
2521 Isolate* isolate = masm->isolate(); 2511 Isolate* isolate = masm->isolate();
2522 Label extra_checks_or_miss, slow_start; 2512 Label extra_checks_or_miss, slow_start;
2523 Label slow, non_function, wrap, cont; 2513 Label slow, non_function, wrap, cont;
2524 Label have_js_function; 2514 Label have_js_function;
2525 int argc = state_.arg_count(); 2515 int argc = state_.arg_count();
2526 ParameterCount actual(argc); 2516 ParameterCount actual(argc);
2527 2517
2528 EmitLoadTypeFeedbackVector(masm, ebx); 2518 EmitLoadTypeFeedbackVector(masm, ebx);
2529 2519
2530 if (state_.stub_type() != CallIC::DEFAULT) {
2531 Generate_CustomFeedbackCall(masm);
2532 return;
2533 }
2534
2535 // The checks. First, does edi match the recorded monomorphic target? 2520 // The checks. First, does edi match the recorded monomorphic target?
2536 __ cmp(edi, FieldOperand(ebx, edx, times_half_pointer_size, 2521 __ cmp(edi, FieldOperand(ebx, edx, times_half_pointer_size,
2537 FixedArray::kHeaderSize)); 2522 FixedArray::kHeaderSize));
2538 __ j(not_equal, &extra_checks_or_miss); 2523 __ j(not_equal, &extra_checks_or_miss);
2539 2524
2540 __ bind(&have_js_function); 2525 __ bind(&have_js_function);
2541 if (state_.CallAsMethod()) { 2526 if (state_.CallAsMethod()) {
2542 EmitContinueIfStrictOrNative(masm, &cont); 2527 EmitContinueIfStrictOrNative(masm, &cont);
2543 2528
2544 // Load the receiver from the stack. 2529 // Load the receiver from the stack.
(...skipping 30 matching lines...) Expand all
2575 if (!FLAG_trace_ic) { 2560 if (!FLAG_trace_ic) {
2576 // We are going megamorphic, and we don't want to visit the runtime. 2561 // We are going megamorphic, and we don't want to visit the runtime.
2577 __ mov(FieldOperand(ebx, edx, times_half_pointer_size, 2562 __ mov(FieldOperand(ebx, edx, times_half_pointer_size,
2578 FixedArray::kHeaderSize), 2563 FixedArray::kHeaderSize),
2579 Immediate(TypeFeedbackInfo::MegamorphicSentinel(isolate))); 2564 Immediate(TypeFeedbackInfo::MegamorphicSentinel(isolate)));
2580 __ jmp(&slow_start); 2565 __ jmp(&slow_start);
2581 } 2566 }
2582 2567
2583 // We are here because tracing is on or we are going monomorphic. 2568 // We are here because tracing is on or we are going monomorphic.
2584 __ bind(&miss); 2569 __ bind(&miss);
2585 GenerateMiss(masm); 2570 GenerateMiss(masm, IC::kCallIC_Miss);
2586 2571
2587 // the slow case 2572 // the slow case
2588 __ bind(&slow_start); 2573 __ bind(&slow_start);
2589 2574
2590 // Check that the function really is a JavaScript function. 2575 // Check that the function really is a JavaScript function.
2591 __ JumpIfSmi(edi, &non_function); 2576 __ JumpIfSmi(edi, &non_function);
2592 2577
2593 // Goto slow case if we do not have a function. 2578 // Goto slow case if we do not have a function.
2594 __ CmpObjectType(edi, JS_FUNCTION_TYPE, ecx); 2579 __ CmpObjectType(edi, JS_FUNCTION_TYPE, ecx);
2595 __ j(not_equal, &slow); 2580 __ j(not_equal, &slow);
2596 __ jmp(&have_js_function); 2581 __ jmp(&have_js_function);
2597 2582
2598 // Unreachable 2583 // Unreachable
2599 __ int3(); 2584 __ int3();
2600 } 2585 }
2601 2586
2602 2587
2603 void CallICStub::GenerateMiss(MacroAssembler* masm) { 2588 void CallICStub::GenerateMiss(MacroAssembler* masm, IC::UtilityId id) {
2604 // Get the receiver of the function from the stack; 1 ~ return address. 2589 // Get the receiver of the function from the stack; 1 ~ return address.
2605 __ mov(ecx, Operand(esp, (state_.arg_count() + 1) * kPointerSize)); 2590 __ mov(ecx, Operand(esp, (state_.arg_count() + 1) * kPointerSize));
2606 2591
2607 { 2592 {
2608 FrameScope scope(masm, StackFrame::INTERNAL); 2593 FrameScope scope(masm, StackFrame::INTERNAL);
2609 2594
2610 // Push the receiver and the function and feedback info. 2595 // Push the receiver and the function and feedback info.
2611 __ push(ecx); 2596 __ push(ecx);
2612 __ push(edi); 2597 __ push(edi);
2613 __ push(ebx); 2598 __ push(ebx);
2614 __ push(edx); 2599 __ push(edx);
2615 2600
2616 // Call the entry. 2601 // Call the entry.
2617 ExternalReference miss = ExternalReference(IC_Utility(IC::kCallIC_Miss), 2602 ExternalReference miss = ExternalReference(IC_Utility(id),
2618 masm->isolate()); 2603 masm->isolate());
2619 __ CallExternalReference(miss, 4); 2604 __ CallExternalReference(miss, 4);
2620 2605
2621 // Move result to edi and exit the internal frame. 2606 // Move result to edi and exit the internal frame.
2622 __ mov(edi, eax); 2607 __ mov(edi, eax);
2623 } 2608 }
2624 } 2609 }
2625 2610
2626 2611
2627 bool CEntryStub::NeedsImmovableCode() { 2612 bool CEntryStub::NeedsImmovableCode() {
(...skipping 2504 matching lines...) Expand 10 before | Expand all | Expand 10 after
5132 Operand(ebp, 7 * kPointerSize), 5117 Operand(ebp, 7 * kPointerSize),
5133 NULL); 5118 NULL);
5134 } 5119 }
5135 5120
5136 5121
5137 #undef __ 5122 #undef __
5138 5123
5139 } } // namespace v8::internal 5124 } } // namespace v8::internal
5140 5125
5141 #endif // V8_TARGET_ARCH_IA32 5126 #endif // V8_TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « src/code-stubs.cc ('k') | src/ic.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698