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 772 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
783 } | 783 } |
784 | 784 |
785 static void Generate_InterpreterPushArgs(MacroAssembler* masm, | 785 static void Generate_InterpreterPushArgs(MacroAssembler* masm, |
786 Register num_args, | 786 Register num_args, |
787 Register start_address, | 787 Register start_address, |
788 Register scratch, bool push_receiver) { | 788 Register scratch, bool push_receiver) { |
789 // ----------- S t a t e ------------- | 789 // ----------- S t a t e ------------- |
790 // -- rax : the number of arguments (not including the receiver) | 790 // -- rax : the number of arguments (not including the receiver) |
791 // -- rbx : the address of the first argument to be pushed. Subsequent | 791 // -- rbx : the address of the first argument to be pushed. Subsequent |
792 // arguments should be consecutive above this, in the same order as | 792 // arguments should be consecutive above this, in the same order as |
793 // they are to be pushed onto the stack. | 793 // they are to be pushed onto the stack. |
rmcilroy
2016/09/06 10:59:35
This isn't really applicable here (since we don't
mythria
2016/09/07 08:59:45
Done.
| |
794 // ----------------------------------- | 794 // ----------------------------------- |
795 | 795 |
796 // Find the address of the last argument. | 796 // Find the address of the last argument. |
797 __ movp(scratch, num_args); | 797 __ movp(scratch, num_args); |
798 if (push_receiver) { | 798 if (push_receiver) { |
rmcilroy
2016/09/06 10:59:35
Ditto (if possible)
mythria
2016/09/07 08:59:45
Done.
| |
799 __ addp(scratch, Immediate(1)); // Add one for receiver. | 799 __ addp(scratch, Immediate(1)); // Add one for receiver. |
800 } | 800 } |
801 | 801 |
802 __ shlp(scratch, Immediate(kPointerSizeLog2)); | 802 __ shlp(scratch, Immediate(kPointerSizeLog2)); |
803 __ negp(scratch); | 803 __ negp(scratch); |
804 __ addp(scratch, start_address); | 804 __ addp(scratch, start_address); |
805 | 805 |
806 // Push the arguments. | 806 // Push the arguments. |
807 Label loop_header, loop_check; | 807 Label loop_header, loop_check; |
808 __ j(always, &loop_check); | 808 __ j(always, &loop_check); |
(...skipping 14 matching lines...) Expand all Loading... | |
823 // -- rbx : the address of the first argument to be pushed. Subsequent | 823 // -- rbx : the address of the first argument to be pushed. Subsequent |
824 // arguments should be consecutive above this, in the same order as | 824 // arguments should be consecutive above this, in the same order as |
825 // they are to be pushed onto the stack. | 825 // they are to be pushed onto the stack. |
826 // -- rdi : the target to call (can be any Object). | 826 // -- rdi : the target to call (can be any Object). |
827 // ----------------------------------- | 827 // ----------------------------------- |
828 | 828 |
829 // Pop return address to allow tail-call after pushing arguments. | 829 // Pop return address to allow tail-call after pushing arguments. |
830 __ PopReturnAddressTo(kScratchRegister); | 830 __ PopReturnAddressTo(kScratchRegister); |
831 | 831 |
832 // TODO(mythria): Add a stack check before pushing arguments. | 832 // TODO(mythria): Add a stack check before pushing arguments. |
833 // rax is readonly rcx and r8 will be modified. | 833 // rax is readonly rbx and rcx will be modified. |
834 Generate_InterpreterPushArgs(masm, rax, rbx, rcx, true); | 834 Generate_InterpreterPushArgs(masm, rax, rbx, rcx, true); |
835 | 835 |
836 // Call the target. | 836 // Call the target. |
837 __ PushReturnAddressFrom(kScratchRegister); // Re-push return address. | 837 __ PushReturnAddressFrom(kScratchRegister); // Re-push return address. |
838 | 838 |
839 if (function_type == CallableType::kJSFunction) { | 839 if (function_type == CallableType::kJSFunction) { |
840 __ Jump(masm->isolate()->builtins()->CallFunction(ConvertReceiverMode::kAny, | 840 __ Jump(masm->isolate()->builtins()->CallFunction(ConvertReceiverMode::kAny, |
841 tail_call_mode), | 841 tail_call_mode), |
842 RelocInfo::CODE_TARGET); | 842 RelocInfo::CODE_TARGET); |
843 } else { | 843 } else { |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
886 __ leap(rcx, FieldOperand(rcx, Code::kHeaderSize)); | 886 __ leap(rcx, FieldOperand(rcx, Code::kHeaderSize)); |
887 // Jump to the constructor function (rax, rbx, rdx passed on). | 887 // Jump to the constructor function (rax, rbx, rdx passed on). |
888 __ jmp(rcx); | 888 __ jmp(rcx); |
889 } else { | 889 } else { |
890 DCHECK_EQ(construct_type, CallableType::kAny); | 890 DCHECK_EQ(construct_type, CallableType::kAny); |
891 // Call the constructor (rax, rdx, rdi passed on). | 891 // Call the constructor (rax, rdx, rdi passed on). |
892 __ Jump(masm->isolate()->builtins()->Construct(), RelocInfo::CODE_TARGET); | 892 __ Jump(masm->isolate()->builtins()->Construct(), RelocInfo::CODE_TARGET); |
893 } | 893 } |
894 } | 894 } |
895 | 895 |
896 // static | |
897 void Builtins::Generate_InterpreterPushArgsAndConstructArray( | |
898 MacroAssembler* masm) { | |
899 // ----------- S t a t e ------------- | |
900 // -- rax : the number of arguments (not including the receiver) | |
901 // -- rdx : the target to call checked to be Array function. | |
902 // -- rbx : the allocation site feedback | |
903 // -- rcx : the address of the first argument to be pushed. Subsequent | |
904 // arguments should be consecutive above this, in the same order as | |
905 // they are to be pushed onto the stack. | |
906 // ----------------------------------- | |
907 | |
908 // Pop return address to allow tail-call after pushing arguments. | |
909 __ PopReturnAddressTo(kScratchRegister); | |
910 | |
911 // TODO(mythria): Add a stack check before pushing arguments. | |
912 // rax is readonly rcx and r8 will be modified. | |
913 Generate_InterpreterPushArgs(masm, rax, rcx, r8, true); | |
914 | |
915 // Push return address in preparation for the tail-call. | |
916 __ PushReturnAddressFrom(kScratchRegister); | |
917 | |
918 // Array constructor expects constructor in rdi. It is same as rdx here. | |
919 __ Move(rdi, rdx); | |
920 | |
921 ArrayConstructorStub stub(masm->isolate()); | |
922 __ TailCallStub(&stub); | |
923 } | |
924 | |
896 void Builtins::Generate_InterpreterEnterBytecodeDispatch(MacroAssembler* masm) { | 925 void Builtins::Generate_InterpreterEnterBytecodeDispatch(MacroAssembler* masm) { |
897 // Set the return address to the correct point in the interpreter entry | 926 // Set the return address to the correct point in the interpreter entry |
898 // trampoline. | 927 // trampoline. |
899 Smi* interpreter_entry_return_pc_offset( | 928 Smi* interpreter_entry_return_pc_offset( |
900 masm->isolate()->heap()->interpreter_entry_return_pc_offset()); | 929 masm->isolate()->heap()->interpreter_entry_return_pc_offset()); |
901 DCHECK_NE(interpreter_entry_return_pc_offset, Smi::FromInt(0)); | 930 DCHECK_NE(interpreter_entry_return_pc_offset, Smi::FromInt(0)); |
902 __ Move(rbx, masm->isolate()->builtins()->InterpreterEntryTrampoline()); | 931 __ Move(rbx, masm->isolate()->builtins()->InterpreterEntryTrampoline()); |
903 __ addp(rbx, Immediate(interpreter_entry_return_pc_offset->value() + | 932 __ addp(rbx, Immediate(interpreter_entry_return_pc_offset->value() + |
904 Code::kHeaderSize - kHeapObjectTag)); | 933 Code::kHeaderSize - kHeapObjectTag)); |
905 __ Push(rbx); | 934 __ Push(rbx); |
(...skipping 2204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3110 void Builtins::Generate_InterpreterOnStackReplacement(MacroAssembler* masm) { | 3139 void Builtins::Generate_InterpreterOnStackReplacement(MacroAssembler* masm) { |
3111 Generate_OnStackReplacementHelper(masm, true); | 3140 Generate_OnStackReplacementHelper(masm, true); |
3112 } | 3141 } |
3113 | 3142 |
3114 #undef __ | 3143 #undef __ |
3115 | 3144 |
3116 } // namespace internal | 3145 } // namespace internal |
3117 } // namespace v8 | 3146 } // namespace v8 |
3118 | 3147 |
3119 #endif // V8_TARGET_ARCH_X64 | 3148 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |