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

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

Issue 2307903002: [Interpreter] Collect allocation site feedback in call bytecode handler. (Closed)
Patch Set: Fixed a bug in mips implementation. Created 4 years, 3 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
« no previous file with comments | « src/builtins/mips64/builtins-mips64.cc ('k') | src/code-factory.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 #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
778 778
779 // Restore return value. 779 // Restore return value.
780 __ Pop(rax); 780 __ Pop(rax);
781 } 781 }
782 __ ret(0); 782 __ ret(0);
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) {
789 // ----------- S t a t e -------------
790 // -- rax : the number of arguments (not including the receiver)
791 // -- rbx : the address of the first argument to be pushed. Subsequent
792 // arguments should be consecutive above this, in the same order as
793 // they are to be pushed onto the stack.
794 // -----------------------------------
795
796 // Find the address of the last argument. 789 // Find the address of the last argument.
797 __ movp(scratch, num_args); 790 __ Move(scratch, num_args);
798 if (push_receiver) {
799 __ addp(scratch, Immediate(1)); // Add one for receiver.
800 }
801
802 __ shlp(scratch, Immediate(kPointerSizeLog2)); 791 __ shlp(scratch, Immediate(kPointerSizeLog2));
803 __ negp(scratch); 792 __ negp(scratch);
804 __ addp(scratch, start_address); 793 __ addp(scratch, start_address);
805 794
795 // TODO(mythria): Add a stack check before pushing arguments.
806 // Push the arguments. 796 // Push the arguments.
807 Label loop_header, loop_check; 797 Label loop_header, loop_check;
808 __ j(always, &loop_check); 798 __ j(always, &loop_check);
809 __ bind(&loop_header); 799 __ bind(&loop_header);
810 __ Push(Operand(start_address, 0)); 800 __ Push(Operand(start_address, 0));
811 __ subp(start_address, Immediate(kPointerSize)); 801 __ subp(start_address, Immediate(kPointerSize));
812 __ bind(&loop_check); 802 __ bind(&loop_check);
813 __ cmpp(start_address, scratch); 803 __ cmpp(start_address, scratch);
814 __ j(greater, &loop_header, Label::kNear); 804 __ j(greater, &loop_header, Label::kNear);
815 } 805 }
816 806
817 // static 807 // static
818 void Builtins::Generate_InterpreterPushArgsAndCallImpl( 808 void Builtins::Generate_InterpreterPushArgsAndCallImpl(
819 MacroAssembler* masm, TailCallMode tail_call_mode, 809 MacroAssembler* masm, TailCallMode tail_call_mode,
820 CallableType function_type) { 810 CallableType function_type) {
821 // ----------- S t a t e ------------- 811 // ----------- S t a t e -------------
822 // -- rax : the number of arguments (not including the receiver) 812 // -- rax : the number of arguments (not including the receiver)
823 // -- rbx : the address of the first argument to be pushed. Subsequent 813 // -- rbx : the address of the first argument to be pushed. Subsequent
824 // arguments should be consecutive above this, in the same order as 814 // arguments should be consecutive above this, in the same order as
825 // they are to be pushed onto the stack. 815 // they are to be pushed onto the stack.
826 // -- rdi : the target to call (can be any Object). 816 // -- rdi : the target to call (can be any Object).
827 // ----------------------------------- 817 // -----------------------------------
828 818
829 // Pop return address to allow tail-call after pushing arguments. 819 // Pop return address to allow tail-call after pushing arguments.
830 __ PopReturnAddressTo(kScratchRegister); 820 __ PopReturnAddressTo(kScratchRegister);
831 821
832 // TODO(mythria): Add a stack check before pushing arguments. 822 // Number of values to be pushed.
833 // rax is readonly rcx and r8 will be modified. 823 __ Move(rcx, rax);
834 Generate_InterpreterPushArgs(masm, rax, rbx, rcx, true); 824 __ addp(rcx, Immediate(1)); // Add one for receiver.
825
826 // rbx and rdx will be modified.
827 Generate_InterpreterPushArgs(masm, rcx, rbx, rdx);
835 828
836 // Call the target. 829 // Call the target.
837 __ PushReturnAddressFrom(kScratchRegister); // Re-push return address. 830 __ PushReturnAddressFrom(kScratchRegister); // Re-push return address.
838 831
839 if (function_type == CallableType::kJSFunction) { 832 if (function_type == CallableType::kJSFunction) {
840 __ Jump(masm->isolate()->builtins()->CallFunction(ConvertReceiverMode::kAny, 833 __ Jump(masm->isolate()->builtins()->CallFunction(ConvertReceiverMode::kAny,
841 tail_call_mode), 834 tail_call_mode),
842 RelocInfo::CODE_TARGET); 835 RelocInfo::CODE_TARGET);
843 } else { 836 } else {
844 DCHECK_EQ(function_type, CallableType::kAny); 837 DCHECK_EQ(function_type, CallableType::kAny);
(...skipping 16 matching lines...) Expand all
861 // arguments should be consecutive above this, in the same order as 854 // arguments should be consecutive above this, in the same order as
862 // they are to be pushed onto the stack. 855 // they are to be pushed onto the stack.
863 // ----------------------------------- 856 // -----------------------------------
864 857
865 // Pop return address to allow tail-call after pushing arguments. 858 // Pop return address to allow tail-call after pushing arguments.
866 __ PopReturnAddressTo(kScratchRegister); 859 __ PopReturnAddressTo(kScratchRegister);
867 860
868 // Push slot for the receiver to be constructed. 861 // Push slot for the receiver to be constructed.
869 __ Push(Immediate(0)); 862 __ Push(Immediate(0));
870 863
871 // TODO(mythria): Add a stack check before pushing arguments. 864 // rcx and r8 will be modified.
872 // rax is readonly rcx and r8 will be modified. 865 Generate_InterpreterPushArgs(masm, rax, rcx, r8);
873 Generate_InterpreterPushArgs(masm, rax, rcx, r8, false);
874 866
875 // Push return address in preparation for the tail-call. 867 // Push return address in preparation for the tail-call.
876 __ PushReturnAddressFrom(kScratchRegister); 868 __ PushReturnAddressFrom(kScratchRegister);
877 869
878 __ AssertUndefinedOrAllocationSite(rbx); 870 __ AssertUndefinedOrAllocationSite(rbx);
879 if (construct_type == CallableType::kJSFunction) { 871 if (construct_type == CallableType::kJSFunction) {
880 // Tail call to the function-specific construct stub (still in the caller 872 // Tail call to the function-specific construct stub (still in the caller
881 // context at this point). 873 // context at this point).
882 __ AssertFunction(rdi); 874 __ AssertFunction(rdi);
883 875
884 __ movp(rcx, FieldOperand(rdi, JSFunction::kSharedFunctionInfoOffset)); 876 __ movp(rcx, FieldOperand(rdi, JSFunction::kSharedFunctionInfoOffset));
885 __ movp(rcx, FieldOperand(rcx, SharedFunctionInfo::kConstructStubOffset)); 877 __ movp(rcx, FieldOperand(rcx, SharedFunctionInfo::kConstructStubOffset));
886 __ leap(rcx, FieldOperand(rcx, Code::kHeaderSize)); 878 __ leap(rcx, FieldOperand(rcx, Code::kHeaderSize));
887 // Jump to the constructor function (rax, rbx, rdx passed on). 879 // Jump to the constructor function (rax, rbx, rdx passed on).
888 __ jmp(rcx); 880 __ jmp(rcx);
889 } else { 881 } else {
890 DCHECK_EQ(construct_type, CallableType::kAny); 882 DCHECK_EQ(construct_type, CallableType::kAny);
891 // Call the constructor (rax, rdx, rdi passed on). 883 // Call the constructor (rax, rdx, rdi passed on).
892 __ Jump(masm->isolate()->builtins()->Construct(), RelocInfo::CODE_TARGET); 884 __ Jump(masm->isolate()->builtins()->Construct(), RelocInfo::CODE_TARGET);
893 } 885 }
894 } 886 }
895 887
888 // static
889 void Builtins::Generate_InterpreterPushArgsAndConstructArray(
890 MacroAssembler* masm) {
891 // ----------- S t a t e -------------
892 // -- rax : the number of arguments (not including the receiver)
893 // -- rdx : the target to call checked to be Array function.
894 // -- rbx : the allocation site feedback
895 // -- rcx : the address of the first argument to be pushed. Subsequent
896 // arguments should be consecutive above this, in the same order as
897 // they are to be pushed onto the stack.
898 // -----------------------------------
899
900 // Pop return address to allow tail-call after pushing arguments.
901 __ PopReturnAddressTo(kScratchRegister);
902
903 // Number of values to be pushed.
904 __ Move(r8, rax);
905 __ addp(r8, Immediate(1)); // Add one for receiver.
906
907 // rcx and rdi will be modified.
908 Generate_InterpreterPushArgs(masm, r8, rcx, rdi);
909
910 // Push return address in preparation for the tail-call.
911 __ PushReturnAddressFrom(kScratchRegister);
912
913 // Array constructor expects constructor in rdi. It is same as rdx here.
914 __ Move(rdi, rdx);
915
916 ArrayConstructorStub stub(masm->isolate());
917 __ TailCallStub(&stub);
918 }
919
896 void Builtins::Generate_InterpreterEnterBytecodeDispatch(MacroAssembler* masm) { 920 void Builtins::Generate_InterpreterEnterBytecodeDispatch(MacroAssembler* masm) {
897 // Set the return address to the correct point in the interpreter entry 921 // Set the return address to the correct point in the interpreter entry
898 // trampoline. 922 // trampoline.
899 Smi* interpreter_entry_return_pc_offset( 923 Smi* interpreter_entry_return_pc_offset(
900 masm->isolate()->heap()->interpreter_entry_return_pc_offset()); 924 masm->isolate()->heap()->interpreter_entry_return_pc_offset());
901 DCHECK_NE(interpreter_entry_return_pc_offset, Smi::FromInt(0)); 925 DCHECK_NE(interpreter_entry_return_pc_offset, Smi::FromInt(0));
902 __ Move(rbx, masm->isolate()->builtins()->InterpreterEntryTrampoline()); 926 __ Move(rbx, masm->isolate()->builtins()->InterpreterEntryTrampoline());
903 __ addp(rbx, Immediate(interpreter_entry_return_pc_offset->value() + 927 __ addp(rbx, Immediate(interpreter_entry_return_pc_offset->value() +
904 Code::kHeaderSize - kHeapObjectTag)); 928 Code::kHeaderSize - kHeapObjectTag));
905 __ Push(rbx); 929 __ Push(rbx);
(...skipping 2204 matching lines...) Expand 10 before | Expand all | Expand 10 after
3110 void Builtins::Generate_InterpreterOnStackReplacement(MacroAssembler* masm) { 3134 void Builtins::Generate_InterpreterOnStackReplacement(MacroAssembler* masm) {
3111 Generate_OnStackReplacementHelper(masm, true); 3135 Generate_OnStackReplacementHelper(masm, true);
3112 } 3136 }
3113 3137
3114 #undef __ 3138 #undef __
3115 3139
3116 } // namespace internal 3140 } // namespace internal
3117 } // namespace v8 3141 } // namespace v8
3118 3142
3119 #endif // V8_TARGET_ARCH_X64 3143 #endif // V8_TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « src/builtins/mips64/builtins-mips64.cc ('k') | src/code-factory.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698