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

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

Issue 2190293003: [Interpreter] Collect type feedback for 'new' in the bytecode handler (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: updated cctest.status and mjsunit.status Created 4 years, 4 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 760 matching lines...) Expand 10 before | Expand all | Expand 10 after
771 __ Push(rdi); 771 __ Push(rdi);
772 __ CallRuntime(Runtime::kCompileBaseline); 772 __ CallRuntime(Runtime::kCompileBaseline);
773 773
774 // Restore return value. 774 // Restore return value.
775 __ Pop(rax); 775 __ Pop(rax);
776 } 776 }
777 __ ret(0); 777 __ ret(0);
778 } 778 }
779 779
780 static void Generate_InterpreterPushArgs(MacroAssembler* masm, 780 static void Generate_InterpreterPushArgs(MacroAssembler* masm,
781 bool push_receiver) { 781 Register num_args,
782 Register start_address,
783 Register scratch, bool push_receiver) {
782 // ----------- S t a t e ------------- 784 // ----------- S t a t e -------------
783 // -- rax : the number of arguments (not including the receiver) 785 // -- rax : the number of arguments (not including the receiver)
784 // -- rbx : the address of the first argument to be pushed. Subsequent 786 // -- rbx : the address of the first argument to be pushed. Subsequent
785 // arguments should be consecutive above this, in the same order as 787 // arguments should be consecutive above this, in the same order as
786 // they are to be pushed onto the stack. 788 // they are to be pushed onto the stack.
787 // ----------------------------------- 789 // -----------------------------------
788 790
789 // Find the address of the last argument. 791 // Find the address of the last argument.
790 __ movp(rcx, rax); 792 __ movp(scratch, num_args);
791 if (push_receiver) { 793 if (push_receiver) {
792 __ addp(rcx, Immediate(1)); // Add one for receiver. 794 __ addp(scratch, Immediate(1)); // Add one for receiver.
793 } 795 }
794 796
795 __ shlp(rcx, Immediate(kPointerSizeLog2)); 797 __ shlp(scratch, Immediate(kPointerSizeLog2));
796 __ negp(rcx); 798 __ negp(scratch);
797 __ addp(rcx, rbx); 799 __ addp(scratch, start_address);
798 800
799 // Push the arguments. 801 // Push the arguments.
800 Label loop_header, loop_check; 802 Label loop_header, loop_check;
801 __ j(always, &loop_check); 803 __ j(always, &loop_check);
802 __ bind(&loop_header); 804 __ bind(&loop_header);
803 __ Push(Operand(rbx, 0)); 805 __ Push(Operand(start_address, 0));
804 __ subp(rbx, Immediate(kPointerSize)); 806 __ subp(start_address, Immediate(kPointerSize));
805 __ bind(&loop_check); 807 __ bind(&loop_check);
806 __ cmpp(rbx, rcx); 808 __ cmpp(start_address, scratch);
807 __ j(greater, &loop_header, Label::kNear); 809 __ j(greater, &loop_header, Label::kNear);
808 } 810 }
809 811
810 // static 812 // static
811 void Builtins::Generate_InterpreterPushArgsAndCallImpl( 813 void Builtins::Generate_InterpreterPushArgsAndCallImpl(
812 MacroAssembler* masm, TailCallMode tail_call_mode, 814 MacroAssembler* masm, TailCallMode tail_call_mode,
813 CallableType function_type) { 815 CallableType function_type) {
814 // ----------- S t a t e ------------- 816 // ----------- S t a t e -------------
815 // -- rax : the number of arguments (not including the receiver) 817 // -- rax : the number of arguments (not including the receiver)
816 // -- rbx : the address of the first argument to be pushed. Subsequent 818 // -- rbx : the address of the first argument to be pushed. Subsequent
817 // arguments should be consecutive above this, in the same order as 819 // arguments should be consecutive above this, in the same order as
818 // they are to be pushed onto the stack. 820 // they are to be pushed onto the stack.
819 // -- rdi : the target to call (can be any Object). 821 // -- rdi : the target to call (can be any Object).
820 // ----------------------------------- 822 // -----------------------------------
821 823
822 // Pop return address to allow tail-call after pushing arguments. 824 // Pop return address to allow tail-call after pushing arguments.
823 __ PopReturnAddressTo(kScratchRegister); 825 __ PopReturnAddressTo(kScratchRegister);
824 826
825 Generate_InterpreterPushArgs(masm, true); 827 // TODO(mythria): Add a stack check before pushing arguments.
828 // rax is readonly rcx and r8 will be modified.
829 Generate_InterpreterPushArgs(masm, rax, rbx, rcx, true);
826 830
827 // Call the target. 831 // Call the target.
828 __ PushReturnAddressFrom(kScratchRegister); // Re-push return address. 832 __ PushReturnAddressFrom(kScratchRegister); // Re-push return address.
829 833
830 if (function_type == CallableType::kJSFunction) { 834 if (function_type == CallableType::kJSFunction) {
831 __ Jump(masm->isolate()->builtins()->CallFunction(ConvertReceiverMode::kAny, 835 __ Jump(masm->isolate()->builtins()->CallFunction(ConvertReceiverMode::kAny,
832 tail_call_mode), 836 tail_call_mode),
833 RelocInfo::CODE_TARGET); 837 RelocInfo::CODE_TARGET);
834 } else { 838 } else {
835 DCHECK_EQ(function_type, CallableType::kAny); 839 DCHECK_EQ(function_type, CallableType::kAny);
836 __ Jump(masm->isolate()->builtins()->Call(ConvertReceiverMode::kAny, 840 __ Jump(masm->isolate()->builtins()->Call(ConvertReceiverMode::kAny,
837 tail_call_mode), 841 tail_call_mode),
838 RelocInfo::CODE_TARGET); 842 RelocInfo::CODE_TARGET);
839 } 843 }
840 } 844 }
841 845
842 // static 846 // static
843 void Builtins::Generate_InterpreterPushArgsAndConstruct(MacroAssembler* masm) { 847 void Builtins::Generate_InterpreterPushArgsAndConstructImpl(
848 MacroAssembler* masm, CallableType construct_type) {
844 // ----------- S t a t e ------------- 849 // ----------- S t a t e -------------
845 // -- rax : the number of arguments (not including the receiver) 850 // -- rax : the number of arguments (not including the receiver)
846 // -- rdx : the new target (either the same as the constructor or 851 // -- rdx : the new target (either the same as the constructor or
847 // the JSFunction on which new was invoked initially) 852 // the JSFunction on which new was invoked initially)
848 // -- rdi : the constructor to call (can be any Object) 853 // -- rdi : the constructor to call (can be any Object)
849 // -- rbx : the address of the first argument to be pushed. Subsequent 854 // -- rbx : the allocation site feedback if available, undefined otherwise
855 // -- rcx : the address of the first argument to be pushed. Subsequent
850 // arguments should be consecutive above this, in the same order as 856 // arguments should be consecutive above this, in the same order as
851 // they are to be pushed onto the stack. 857 // they are to be pushed onto the stack.
852 // ----------------------------------- 858 // -----------------------------------
853 859
854 // Pop return address to allow tail-call after pushing arguments. 860 // Pop return address to allow tail-call after pushing arguments.
855 __ PopReturnAddressTo(kScratchRegister); 861 __ PopReturnAddressTo(kScratchRegister);
856 862
857 // Push slot for the receiver to be constructed. 863 // Push slot for the receiver to be constructed.
858 __ Push(Immediate(0)); 864 __ Push(Immediate(0));
859 865
860 Generate_InterpreterPushArgs(masm, false); 866 // TODO(mythria): Add a stack check before pushing arguments.
867 // rax is readonly rcx and r8 will be modified.
868 Generate_InterpreterPushArgs(masm, rax, rcx, r8, false);
861 869
862 // Push return address in preparation for the tail-call. 870 // Push return address in preparation for the tail-call.
863 __ PushReturnAddressFrom(kScratchRegister); 871 __ PushReturnAddressFrom(kScratchRegister);
864 872
865 // Call the constructor (rax, rdx, rdi passed on). 873 __ AssertUndefinedOrAllocationSite(rbx);
866 __ Jump(masm->isolate()->builtins()->Construct(), RelocInfo::CODE_TARGET); 874 if (construct_type == CallableType::kJSFunction) {
875 // Tail call to the function-specific construct stub (still in the caller
876 // context at this point).
877 __ AssertFunction(rdi);
878
879 __ movp(rcx, FieldOperand(rdi, JSFunction::kSharedFunctionInfoOffset));
880 __ movp(rcx, FieldOperand(rcx, SharedFunctionInfo::kConstructStubOffset));
881 __ leap(rcx, FieldOperand(rcx, Code::kHeaderSize));
882 // Jump to the constructor function (rax, rbx, rdx passed on).
883 __ jmp(rcx);
884 } else {
885 DCHECK_EQ(construct_type, CallableType::kAny);
886 // Call the constructor (rax, rdx, rdi passed on).
887 __ Jump(masm->isolate()->builtins()->Construct(), RelocInfo::CODE_TARGET);
888 }
867 } 889 }
868 890
869 void Builtins::Generate_InterpreterEnterBytecodeDispatch(MacroAssembler* masm) { 891 void Builtins::Generate_InterpreterEnterBytecodeDispatch(MacroAssembler* masm) {
870 // Set the return address to the correct point in the interpreter entry 892 // Set the return address to the correct point in the interpreter entry
871 // trampoline. 893 // trampoline.
872 Smi* interpreter_entry_return_pc_offset( 894 Smi* interpreter_entry_return_pc_offset(
873 masm->isolate()->heap()->interpreter_entry_return_pc_offset()); 895 masm->isolate()->heap()->interpreter_entry_return_pc_offset());
874 DCHECK_NE(interpreter_entry_return_pc_offset, Smi::FromInt(0)); 896 DCHECK_NE(interpreter_entry_return_pc_offset, Smi::FromInt(0));
875 __ Move(rbx, masm->isolate()->builtins()->InterpreterEntryTrampoline()); 897 __ Move(rbx, masm->isolate()->builtins()->InterpreterEntryTrampoline());
876 __ addp(rbx, Immediate(interpreter_entry_return_pc_offset->value() + 898 __ addp(rbx, Immediate(interpreter_entry_return_pc_offset->value() +
(...skipping 2191 matching lines...) Expand 10 before | Expand all | Expand 10 after
3068 void Builtins::Generate_InterpreterOnStackReplacement(MacroAssembler* masm) { 3090 void Builtins::Generate_InterpreterOnStackReplacement(MacroAssembler* masm) {
3069 Generate_OnStackReplacementHelper(masm, true); 3091 Generate_OnStackReplacementHelper(masm, true);
3070 } 3092 }
3071 3093
3072 #undef __ 3094 #undef __
3073 3095
3074 } // namespace internal 3096 } // namespace internal
3075 } // namespace v8 3097 } // namespace v8
3076 3098
3077 #endif // V8_TARGET_ARCH_X64 3099 #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