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

Side by Side Diff: src/ia32/builtins-ia32.cc

Issue 1688283003: [Interpreter] Implements calls through CallICStub in the interpreter. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: mips port contributed by balazs.kilvady. Created 4 years, 10 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
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 #if V8_TARGET_ARCH_IA32 5 #if V8_TARGET_ARCH_IA32
6 6
7 #include "src/code-factory.h" 7 #include "src/code-factory.h"
8 #include "src/codegen.h" 8 #include "src/codegen.h"
9 #include "src/deoptimizer.h" 9 #include "src/deoptimizer.h"
10 #include "src/full-codegen/full-codegen.h" 10 #include "src/full-codegen/full-codegen.h"
(...skipping 527 matching lines...) Expand 10 before | Expand all | Expand 10 after
538 Label loop_header, loop_check; 538 Label loop_header, loop_check;
539 __ jmp(&loop_check); 539 __ jmp(&loop_check);
540 __ bind(&loop_header); 540 __ bind(&loop_header);
541 __ Push(Operand(ebx, 0)); 541 __ Push(Operand(ebx, 0));
542 __ sub(ebx, Immediate(kPointerSize)); 542 __ sub(ebx, Immediate(kPointerSize));
543 __ bind(&loop_check); 543 __ bind(&loop_check);
544 __ cmp(ebx, array_limit); 544 __ cmp(ebx, array_limit);
545 __ j(greater, &loop_header, Label::kNear); 545 __ j(greater, &loop_header, Label::kNear);
546 } 546 }
547 547
548 static void Generate_InterpreterComputeLastArgumentAddress(MacroAssembler* masm,
549 Register r) {
550 // Find the address of the last argument.
551 // ----------- S t a t e -------------
552 // input: eax : Number of arguments.
553 // input: ebx : Address of the first argument.
554 // output: Register |r|: Address of the last argument.
555 // -----------------------------------
556 __ mov(r, eax);
557 __ add(r, Immediate(1)); // Add one for receiver.
558 __ shl(r, kPointerSizeLog2);
559 __ neg(r);
560 __ add(r, ebx);
561 }
562
563 // static
564 void Builtins::Generate_InterpreterPushArgsAndCallICImpl(
565 MacroAssembler* masm, TailCallMode tail_call_mode) {
566 // ----------- S t a t e -------------
567 // -- eax : the number of arguments (not including the receiver)
568 // -- ebx : the address of the first argument to be pushed. Subsequent
569 // arguments should be consecutive above this, in the same order as
570 // they are to be pushed onto the stack.
571 // -- edi : the target to call (can be any Object).
572 // -- edx : feedback slot id.
573 // -- ecx : type feedback vector.
574 // -----------------------------------
575
576 {
577 FrameScope scope(masm, StackFrame::INTERNAL);
578 Label no_break;
579 // Store type feedback vector on the stack since we ran out of registers.
580 __ Push(ecx);
581
582 // computes the address of last argument in ecx.
583 // ecx = ebx - (eax + 1) * kPointerSize.
584 Generate_InterpreterComputeLastArgumentAddress(masm, ecx);
585 Generate_InterpreterPushArgs(masm, ecx);
586
587 // Restore feedback vector to ebx from the stack. It was pushed
588 // before the arguments were pushed, so compute the correct offset.
589 __ mov(ebx, Operand(esp, eax, times_pointer_size, 1 * kPointerSize));
590
591 // Call via the CallIC stub.
592 CallICState call_ic_state(0, ConvertReceiverMode::kAny, tail_call_mode,
593 true);
594 CallICStub stub(masm->isolate(), call_ic_state);
595 // TODO(mythria): This should be replaced by a TailCallStub, when we
596 // update the code to find the target IC from jump instructions.
597 __ CallStub(&stub);
598 }
599 __ Ret();
600 }
548 601
549 // static 602 // static
550 void Builtins::Generate_InterpreterPushArgsAndCallImpl( 603 void Builtins::Generate_InterpreterPushArgsAndCallImpl(
551 MacroAssembler* masm, TailCallMode tail_call_mode) { 604 MacroAssembler* masm, TailCallMode tail_call_mode) {
552 // ----------- S t a t e ------------- 605 // ----------- S t a t e -------------
553 // -- eax : the number of arguments (not including the receiver) 606 // -- eax : the number of arguments (not including the receiver)
554 // -- ebx : the address of the first argument to be pushed. Subsequent 607 // -- ebx : the address of the first argument to be pushed. Subsequent
555 // arguments should be consecutive above this, in the same order as 608 // arguments should be consecutive above this, in the same order as
556 // they are to be pushed onto the stack. 609 // they are to be pushed onto the stack.
557 // -- edi : the target to call (can be any Object). 610 // -- edi : the target to call (can be any Object).
558 // ----------------------------------- 611 // -----------------------------------
559 612
560 // Pop return address to allow tail-call after pushing arguments. 613 // Pop return address to allow tail-call after pushing arguments.
561 __ Pop(edx); 614 __ Pop(edx);
562 615
563 // Find the address of the last argument. 616 // computes the address of last argument in ecx.
564 __ mov(ecx, eax); 617 // ecx = ebx - (eax + 1) * kPointerSize.
565 __ add(ecx, Immediate(1)); // Add one for receiver. 618 Generate_InterpreterComputeLastArgumentAddress(masm, ecx);
566 __ shl(ecx, kPointerSizeLog2);
567 __ neg(ecx);
568 __ add(ecx, ebx);
569
570 Generate_InterpreterPushArgs(masm, ecx); 619 Generate_InterpreterPushArgs(masm, ecx);
571 620
572 // Call the target. 621 // Call the target.
573 __ Push(edx); // Re-push return address. 622 __ Push(edx); // Re-push return address.
574 __ Jump(masm->isolate()->builtins()->Call(ConvertReceiverMode::kAny, 623 __ Jump(masm->isolate()->builtins()->Call(ConvertReceiverMode::kAny,
575 tail_call_mode), 624 tail_call_mode),
576 RelocInfo::CODE_TARGET); 625 RelocInfo::CODE_TARGET);
577 } 626 }
578 627
579
580 // static 628 // static
581 void Builtins::Generate_InterpreterPushArgsAndConstruct(MacroAssembler* masm) { 629 void Builtins::Generate_InterpreterPushArgsAndConstruct(MacroAssembler* masm) {
582 // ----------- S t a t e ------------- 630 // ----------- S t a t e -------------
583 // -- eax : the number of arguments (not including the receiver) 631 // -- eax : the number of arguments (not including the receiver)
584 // -- edx : the new target 632 // -- edx : the new target
585 // -- edi : the constructor 633 // -- edi : the constructor
586 // -- ebx : the address of the first argument to be pushed. Subsequent 634 // -- ebx : the address of the first argument to be pushed. Subsequent
587 // arguments should be consecutive above this, in the same order as 635 // arguments should be consecutive above this, in the same order as
588 // they are to be pushed onto the stack. 636 // they are to be pushed onto the stack.
589 // ----------------------------------- 637 // -----------------------------------
590 638
591 // Save number of arguments on the stack below where arguments are going
592 // to be pushed.
593 __ mov(ecx, eax);
594 __ neg(ecx);
595 __ mov(Operand(esp, ecx, times_pointer_size, -kPointerSize), eax);
596 __ mov(eax, ecx);
597
598 // Pop return address to allow tail-call after pushing arguments. 639 // Pop return address to allow tail-call after pushing arguments.
599 __ Pop(ecx); 640 __ Pop(ecx);
600 641
642 // Push edi in the slot meant for receiver. We need an extra register so
643 // store edi temporarily on the stack.
644 __ Push(edi);
645
601 // Find the address of the last argument. 646 // Find the address of the last argument.
602 __ shl(eax, kPointerSizeLog2); 647 __ mov(edi, eax);
603 __ add(eax, ebx); 648 __ neg(edi);
649 __ shl(edi, kPointerSizeLog2);
650 __ add(edi, ebx);
604 651
605 // Push padding for receiver. 652 Generate_InterpreterPushArgs(masm, edi);
606 __ Push(Immediate(0));
607 653
608 Generate_InterpreterPushArgs(masm, eax); 654 // Restore number of arguments from slot on stack. edi was pushed at
609 655 // the slot meant for receiver.
610 // Restore number of arguments from slot on stack. 656 __ mov(edi, Operand(esp, eax, times_pointer_size, 0));
611 __ mov(eax, Operand(esp, -kPointerSize));
612 657
613 // Re-push return address. 658 // Re-push return address.
614 __ Push(ecx); 659 __ Push(ecx);
615 660
616 // Call the constructor with unmodified eax, edi, ebi values. 661 // Call the constructor with unmodified eax, edi, ebi values.
617 __ Jump(masm->isolate()->builtins()->Construct(), RelocInfo::CODE_TARGET); 662 __ Jump(masm->isolate()->builtins()->Construct(), RelocInfo::CODE_TARGET);
618 } 663 }
619 664
620 665
621 static void Generate_EnterBytecodeDispatch(MacroAssembler* masm) { 666 static void Generate_EnterBytecodeDispatch(MacroAssembler* masm) {
(...skipping 1230 matching lines...) Expand 10 before | Expand all | Expand 10 after
1852 Comment cmnt(masm, "[ PrepareForTailCall"); 1897 Comment cmnt(masm, "[ PrepareForTailCall");
1853 1898
1854 // Prepare for tail call only if the debugger is not active. 1899 // Prepare for tail call only if the debugger is not active.
1855 Label done; 1900 Label done;
1856 ExternalReference debug_is_active = 1901 ExternalReference debug_is_active =
1857 ExternalReference::debug_is_active_address(masm->isolate()); 1902 ExternalReference::debug_is_active_address(masm->isolate());
1858 __ movzx_b(scratch1, Operand::StaticVariable(debug_is_active)); 1903 __ movzx_b(scratch1, Operand::StaticVariable(debug_is_active));
1859 __ cmp(scratch1, Immediate(0)); 1904 __ cmp(scratch1, Immediate(0));
1860 __ j(not_equal, &done, Label::kNear); 1905 __ j(not_equal, &done, Label::kNear);
1861 1906
1907 // Drop possible internal frame pushed for calling CallICStub.
1908 // TODO(mythria): when we tail call the CallICStub, remove this.
1909 {
1910 Label no_internal_callic_frame;
1911 __ cmp(Operand(ebp, StandardFrameConstants::kMarkerOffset),
1912 Immediate(Smi::FromInt(StackFrame::INTERNAL)));
1913 __ j(not_equal, &no_internal_callic_frame, Label::kNear);
1914 __ mov(ebp, Operand(ebp, StandardFrameConstants::kCallerFPOffset));
1915 __ bind(&no_internal_callic_frame);
1916 }
1917
1862 // Drop possible interpreter handler/stub frame. 1918 // Drop possible interpreter handler/stub frame.
1863 { 1919 {
1864 Label no_interpreter_frame; 1920 Label no_interpreter_frame;
1865 __ cmp(Operand(ebp, StandardFrameConstants::kMarkerOffset), 1921 __ cmp(Operand(ebp, StandardFrameConstants::kMarkerOffset),
1866 Immediate(Smi::FromInt(StackFrame::STUB))); 1922 Immediate(Smi::FromInt(StackFrame::STUB)));
1867 __ j(not_equal, &no_interpreter_frame, Label::kNear); 1923 __ j(not_equal, &no_interpreter_frame, Label::kNear);
1868 __ mov(ebp, Operand(ebp, StandardFrameConstants::kCallerFPOffset)); 1924 __ mov(ebp, Operand(ebp, StandardFrameConstants::kCallerFPOffset));
1869 __ bind(&no_interpreter_frame); 1925 __ bind(&no_interpreter_frame);
1870 } 1926 }
1871 1927
(...skipping 777 matching lines...) Expand 10 before | Expand all | Expand 10 after
2649 2705
2650 __ bind(&ok); 2706 __ bind(&ok);
2651 __ ret(0); 2707 __ ret(0);
2652 } 2708 }
2653 2709
2654 #undef __ 2710 #undef __
2655 } // namespace internal 2711 } // namespace internal
2656 } // namespace v8 2712 } // namespace v8
2657 2713
2658 #endif // V8_TARGET_ARCH_IA32 2714 #endif // V8_TARGET_ARCH_IA32
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698