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

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

Issue 1965343002: [Interpreter] Support compiling for baseline on return from interpreted function. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 7 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
« src/objects-inl.h ('K') | « src/snapshot/startup-serializer.cc ('k') | no next file » | 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 707 matching lines...) Expand 10 before | Expand all | Expand 10 after
718 __ bind(&bytecode_array_not_present); 718 __ bind(&bytecode_array_not_present);
719 __ leave(); // Leave the frame so we can tail call. 719 __ leave(); // Leave the frame so we can tail call.
720 __ movp(rcx, FieldOperand(rdi, JSFunction::kSharedFunctionInfoOffset)); 720 __ movp(rcx, FieldOperand(rdi, JSFunction::kSharedFunctionInfoOffset));
721 __ movp(rcx, FieldOperand(rcx, SharedFunctionInfo::kCodeOffset)); 721 __ movp(rcx, FieldOperand(rcx, SharedFunctionInfo::kCodeOffset));
722 __ leap(rcx, FieldOperand(rcx, Code::kHeaderSize)); 722 __ leap(rcx, FieldOperand(rcx, Code::kHeaderSize));
723 __ movp(FieldOperand(rdi, JSFunction::kCodeEntryOffset), rcx); 723 __ movp(FieldOperand(rdi, JSFunction::kCodeEntryOffset), rcx);
724 __ RecordWriteCodeEntryField(rdi, rcx, r15); 724 __ RecordWriteCodeEntryField(rdi, rcx, r15);
725 __ jmp(rcx); 725 __ jmp(rcx);
726 } 726 }
727 727
728
729 void Builtins::Generate_InterpreterExitTrampoline(MacroAssembler* masm) { 728 void Builtins::Generate_InterpreterExitTrampoline(MacroAssembler* masm) {
730 // The return value is in accumulator, which is already in rax. 729 // The return value is in accumulator, which is already in rax.
731 730
732 // Leave the frame (also dropping the register file). 731 // Save the interpreter frame's function and callee pc to check if it has
732 // been marked for baseline compilation on return.
733 __ movp(rcx, Operand(rsp, 0));
734 __ movp(rdi, Operand(rbp, StandardFrameConstants::kFunctionOffset));
735
736 // Leave the frame (also dropping the register file). Do this before checking
737 // for baseline compile so that we don't count as an activation on the stack.
733 __ leave(); 738 __ leave();
734 739
740 // Check if the function has been marked for baseline compilation on return.
741 Label not_marked_for_baseline;
742 ExternalReference external(Builtins::kInterpreterMarkBaselineOnReturn,
743 masm->isolate());
744 __ movp(rbx, masm->ExternalOperand(external));
745 __ leap(rbx, FieldOperand(rbx, Code::kHeaderSize));
746 __ cmpp(rcx, rbx);
747 __ j(not_equal, &not_marked_for_baseline, Label::kNear);
748
749 {
750 FrameScope frame_scope(masm, StackFrame::INTERNAL);
751 // Push bytecode array and rax for return.
752 __ Push(kInterpreterBytecodeArrayRegister);
753 __ Push(rax);
754
755 // Push function as argument and compile for baseline.
756 __ Push(rdi);
757 __ CallRuntime(Runtime::kCompileBaseline);
758
759 // Restore bytecode array and rax.
760 __ Pop(rax);
761 __ Pop(kInterpreterBytecodeArrayRegister);
762 }
763
764 __ bind(&not_marked_for_baseline);
765
735 // Drop receiver + arguments and return. 766 // Drop receiver + arguments and return.
736 __ movl(rbx, FieldOperand(kInterpreterBytecodeArrayRegister, 767 __ movl(rbx, FieldOperand(kInterpreterBytecodeArrayRegister,
737 BytecodeArray::kParameterSizeOffset)); 768 BytecodeArray::kParameterSizeOffset));
738 __ PopReturnAddressTo(rcx); 769 __ PopReturnAddressTo(rcx);
739 __ addp(rsp, rbx); 770 __ addp(rsp, rbx);
740 __ PushReturnAddressFrom(rcx); 771 __ PushReturnAddressFrom(rcx);
772
741 __ ret(0); 773 __ ret(0);
742 } 774 }
743 775
776 void Builtins::Generate_InterpreterMarkBaselineOnReturn(MacroAssembler* masm) {
777 // This builtin is only used as a marker to be checked in
778 // InterpreterExitTrampoline and should never be called itself.
779 __ Abort(kUnexpectedCallToMarkBaselineOnReturn);
780 }
744 781
745 static void Generate_InterpreterPushArgs(MacroAssembler* masm, 782 static void Generate_InterpreterPushArgs(MacroAssembler* masm,
746 bool push_receiver) { 783 bool push_receiver) {
747 // ----------- S t a t e ------------- 784 // ----------- S t a t e -------------
748 // -- rax : the number of arguments (not including the receiver) 785 // -- rax : the number of arguments (not including the receiver)
749 // -- rbx : the address of the first argument to be pushed. Subsequent 786 // -- rbx : the address of the first argument to be pushed. Subsequent
750 // arguments should be consecutive above this, in the same order as 787 // arguments should be consecutive above this, in the same order as
751 // they are to be pushed onto the stack. 788 // they are to be pushed onto the stack.
752 // ----------------------------------- 789 // -----------------------------------
753 790
(...skipping 2212 matching lines...) Expand 10 before | Expand all | Expand 10 after
2966 __ ret(0); 3003 __ ret(0);
2967 } 3004 }
2968 3005
2969 3006
2970 #undef __ 3007 #undef __
2971 3008
2972 } // namespace internal 3009 } // namespace internal
2973 } // namespace v8 3010 } // namespace v8
2974 3011
2975 #endif // V8_TARGET_ARCH_X64 3012 #endif // V8_TARGET_ARCH_X64
OLDNEW
« src/objects-inl.h ('K') | « src/snapshot/startup-serializer.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698