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 777 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
788 // static | 788 // static |
789 void Builtins::Generate_InterpreterPushArgsAndCall(MacroAssembler* masm) { | 789 void Builtins::Generate_InterpreterPushArgsAndCall(MacroAssembler* masm) { |
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 // -- rdi : the target to call (can be any Object). |
796 | 796 |
797 // Pop return address to allow tail-call after pushing arguments. | 797 // Pop return address to allow tail-call after pushing arguments. |
798 __ Pop(rdx); | 798 __ PopReturnAddressTo(kScratchRegister); |
799 | 799 |
800 // Find the address of the last argument. | 800 // Find the address of the last argument. |
801 __ movp(rcx, rax); | 801 __ movp(rcx, rax); |
802 __ addp(rcx, Immediate(1)); // Add one for receiver. | 802 __ addp(rcx, Immediate(1)); // Add one for receiver. |
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 | 816 |
817 // Call the target. | 817 // Call the target. |
818 __ Push(rdx); // Re-push return address. | 818 __ PushReturnAddressFrom(kScratchRegister); // Re-push return address. |
819 __ Jump(masm->isolate()->builtins()->Call(), RelocInfo::CODE_TARGET); | 819 __ Jump(masm->isolate()->builtins()->Call(), RelocInfo::CODE_TARGET); |
820 } | 820 } |
821 | 821 |
822 | 822 |
823 // static | |
824 void Builtins::Generate_InterpreterPushArgsAndConstruct(MacroAssembler* masm) { | |
825 // ----------- S t a t e ------------- | |
826 // -- rax : the number of arguments (not including the receiver) | |
827 // -- rdx : the original constructor (either the same as the constructor or | |
828 // the JSFunction on which new was invoked initially) | |
829 // -- rdi : the constructor to call (can be any Object) | |
830 // -- rbx : the address of the first argument to be pushed. Subsequent | |
831 // arguments should be consecutive above this, in the same order as | |
832 // they are to be pushed onto the stack. | |
833 // ----------------------------------- | |
834 | |
835 // Pop return address to allow tail-call after pushing arguments. | |
836 __ PopReturnAddressTo(kScratchRegister); | |
837 | |
838 // Find the address of the last argument. | |
839 __ movp(rcx, rax); | |
840 __ addp(rcx, Immediate(1)); // Add one for receiver. | |
841 __ shlp(rcx, Immediate(kPointerSizeLog2)); | |
842 __ negp(rcx); | |
843 __ addp(rcx, rbx); | |
844 | |
845 // Push the arguments. | |
846 Label loop_header, loop_check; | |
847 __ j(always, &loop_check); | |
848 __ bind(&loop_header); | |
849 __ Push(Operand(rbx, 0)); | |
850 __ subp(rbx, Immediate(kPointerSize)); | |
851 __ bind(&loop_check); | |
852 __ cmpp(rbx, rcx); | |
853 __ j(greater, &loop_header, Label::kNear); | |
854 | |
855 // Push return address in preparation for the tail-call. | |
856 __ PushReturnAddressFrom(kScratchRegister); | |
rmcilroy
2015/10/13 14:07:30
nit - could we create a helper function for the ar
oth
2015/10/14 08:40:09
Done.
| |
857 | |
858 // Call the target. | |
859 __ Jump(masm->isolate()->builtins()->Construct(), RelocInfo::CONSTRUCT_CALL); | |
860 } | |
861 | |
862 | |
823 void Builtins::Generate_CompileLazy(MacroAssembler* masm) { | 863 void Builtins::Generate_CompileLazy(MacroAssembler* masm) { |
824 CallRuntimePassFunction(masm, Runtime::kCompileLazy); | 864 CallRuntimePassFunction(masm, Runtime::kCompileLazy); |
825 GenerateTailCallToReturnedCode(masm); | 865 GenerateTailCallToReturnedCode(masm); |
826 } | 866 } |
827 | 867 |
828 | 868 |
829 static void CallCompileOptimized(MacroAssembler* masm, | 869 static void CallCompileOptimized(MacroAssembler* masm, |
830 bool concurrent) { | 870 bool concurrent) { |
831 FrameScope scope(masm, StackFrame::INTERNAL); | 871 FrameScope scope(masm, StackFrame::INTERNAL); |
832 // Push a copy of the function onto the stack. | 872 // 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); | 1973 __ ret(0); |
1934 } | 1974 } |
1935 | 1975 |
1936 | 1976 |
1937 #undef __ | 1977 #undef __ |
1938 | 1978 |
1939 } // namespace internal | 1979 } // namespace internal |
1940 } // namespace v8 | 1980 } // namespace v8 |
1941 | 1981 |
1942 #endif // V8_TARGET_ARCH_X64 | 1982 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |