OLD | NEW |
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_X64 | 5 #if V8_TARGET_ARCH_X64 |
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 767 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
778 // Drop receiver + arguments and return. | 778 // Drop receiver + arguments and return. |
779 __ movl(rbx, FieldOperand(kInterpreterBytecodeArrayRegister, | 779 __ movl(rbx, FieldOperand(kInterpreterBytecodeArrayRegister, |
780 BytecodeArray::kParameterSizeOffset)); | 780 BytecodeArray::kParameterSizeOffset)); |
781 __ PopReturnAddressTo(rcx); | 781 __ PopReturnAddressTo(rcx); |
782 __ addp(rsp, rbx); | 782 __ addp(rsp, rbx); |
783 __ PushReturnAddressFrom(rcx); | 783 __ PushReturnAddressFrom(rcx); |
784 __ ret(0); | 784 __ ret(0); |
785 } | 785 } |
786 | 786 |
787 | 787 |
788 // static | 788 static void Generate_InterpreterPushArgs(MacroAssembler* masm, |
789 void Builtins::Generate_InterpreterPushArgsAndCall(MacroAssembler* masm) { | 789 bool push_receiver) { |
790 // ----------- S t a t e ------------- | 790 // ----------- S t a t e ------------- |
791 // -- rax : the number of arguments (not including the receiver) | 791 // -- rax : the number of arguments (not including the receiver) |
792 // -- rbx : the address of the first argument to be pushed. Subsequent | 792 // -- rbx : the address of the first argument to be pushed. Subsequent |
793 // arguments should be consecutive above this, in the same order as | 793 // arguments should be consecutive above this, in the same order as |
794 // they are to be pushed onto the stack. | 794 // they are to be pushed onto the stack. |
795 // -- rdi : the target to call (can be any Object). | 795 // ----------------------------------- |
796 | |
797 // Pop return address to allow tail-call after pushing arguments. | |
798 __ Pop(rdx); | |
799 | 796 |
800 // Find the address of the last argument. | 797 // Find the address of the last argument. |
801 __ movp(rcx, rax); | 798 __ movp(rcx, rax); |
802 __ addp(rcx, Immediate(1)); // Add one for receiver. | 799 if (push_receiver) { |
| 800 __ addp(rcx, Immediate(1)); // Add one for receiver. |
| 801 } |
| 802 |
803 __ shlp(rcx, Immediate(kPointerSizeLog2)); | 803 __ shlp(rcx, Immediate(kPointerSizeLog2)); |
804 __ negp(rcx); | 804 __ negp(rcx); |
805 __ addp(rcx, rbx); | 805 __ addp(rcx, rbx); |
806 | 806 |
807 // Push the arguments. | 807 // Push the arguments. |
808 Label loop_header, loop_check; | 808 Label loop_header, loop_check; |
809 __ j(always, &loop_check); | 809 __ j(always, &loop_check); |
810 __ bind(&loop_header); | 810 __ bind(&loop_header); |
811 __ Push(Operand(rbx, 0)); | 811 __ Push(Operand(rbx, 0)); |
812 __ subp(rbx, Immediate(kPointerSize)); | 812 __ subp(rbx, Immediate(kPointerSize)); |
813 __ bind(&loop_check); | 813 __ bind(&loop_check); |
814 __ cmpp(rbx, rcx); | 814 __ cmpp(rbx, rcx); |
815 __ j(greater, &loop_header, Label::kNear); | 815 __ j(greater, &loop_header, Label::kNear); |
| 816 } |
| 817 |
| 818 |
| 819 // static |
| 820 void Builtins::Generate_InterpreterPushArgsAndCall(MacroAssembler* masm) { |
| 821 // ----------- S t a t e ------------- |
| 822 // -- rax : the number of arguments (not including the receiver) |
| 823 // -- rbx : the address of the first argument to be pushed. Subsequent |
| 824 // arguments should be consecutive above this, in the same order as |
| 825 // they are to be pushed onto the stack. |
| 826 // -- rdi : the target to call (can be any Object). |
| 827 // ----------------------------------- |
| 828 |
| 829 // Pop return address to allow tail-call after pushing arguments. |
| 830 __ PopReturnAddressTo(kScratchRegister); |
| 831 |
| 832 Generate_InterpreterPushArgs(masm, true); |
816 | 833 |
817 // Call the target. | 834 // Call the target. |
818 __ Push(rdx); // Re-push return address. | 835 __ PushReturnAddressFrom(kScratchRegister); // Re-push return address. |
819 __ Jump(masm->isolate()->builtins()->Call(), RelocInfo::CODE_TARGET); | 836 __ Jump(masm->isolate()->builtins()->Call(), RelocInfo::CODE_TARGET); |
820 } | 837 } |
821 | 838 |
822 | 839 |
| 840 // static |
| 841 void Builtins::Generate_InterpreterPushArgsAndConstruct(MacroAssembler* masm) { |
| 842 // ----------- S t a t e ------------- |
| 843 // -- rax : the number of arguments (not including the receiver) |
| 844 // -- rdx : the original constructor (either the same as the constructor or |
| 845 // the JSFunction on which new was invoked initially) |
| 846 // -- rdi : the constructor to call (can be any Object) |
| 847 // -- rbx : the address of the first argument to be pushed. Subsequent |
| 848 // arguments should be consecutive above this, in the same order as |
| 849 // they are to be pushed onto the stack. |
| 850 // ----------------------------------- |
| 851 |
| 852 // Pop return address to allow tail-call after pushing arguments. |
| 853 __ PopReturnAddressTo(kScratchRegister); |
| 854 |
| 855 // Push slot for the receiver to be constructed. |
| 856 __ Push(Immediate(0)); |
| 857 |
| 858 Generate_InterpreterPushArgs(masm, false); |
| 859 |
| 860 // Push return address in preparation for the tail-call. |
| 861 __ PushReturnAddressFrom(kScratchRegister); |
| 862 |
| 863 // Call the constructor (rax, rdx, rdi passed on). |
| 864 __ Jump(masm->isolate()->builtins()->Construct(), RelocInfo::CONSTRUCT_CALL); |
| 865 } |
| 866 |
| 867 |
823 void Builtins::Generate_CompileLazy(MacroAssembler* masm) { | 868 void Builtins::Generate_CompileLazy(MacroAssembler* masm) { |
824 CallRuntimePassFunction(masm, Runtime::kCompileLazy); | 869 CallRuntimePassFunction(masm, Runtime::kCompileLazy); |
825 GenerateTailCallToReturnedCode(masm); | 870 GenerateTailCallToReturnedCode(masm); |
826 } | 871 } |
827 | 872 |
828 | 873 |
829 static void CallCompileOptimized(MacroAssembler* masm, | 874 static void CallCompileOptimized(MacroAssembler* masm, |
830 bool concurrent) { | 875 bool concurrent) { |
831 FrameScope scope(masm, StackFrame::INTERNAL); | 876 FrameScope scope(masm, StackFrame::INTERNAL); |
832 // Push a copy of the function onto the stack. | 877 // Push a copy of the function onto the stack. |
(...skipping 1100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1933 __ ret(0); | 1978 __ ret(0); |
1934 } | 1979 } |
1935 | 1980 |
1936 | 1981 |
1937 #undef __ | 1982 #undef __ |
1938 | 1983 |
1939 } // namespace internal | 1984 } // namespace internal |
1940 } // namespace v8 | 1985 } // namespace v8 |
1941 | 1986 |
1942 #endif // V8_TARGET_ARCH_X64 | 1987 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |