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

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

Issue 1865833002: [generators] Decouple generator resume from fullcodegen. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 8 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
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_MIPS 5 #if V8_TARGET_ARCH_MIPS
6 6
7 #include "src/codegen.h" 7 #include "src/codegen.h"
8 #include "src/debug/debug.h" 8 #include "src/debug/debug.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 807 matching lines...) Expand 10 before | Expand all | Expand 10 after
818 818
819 void Builtins::Generate_JSEntryTrampoline(MacroAssembler* masm) { 819 void Builtins::Generate_JSEntryTrampoline(MacroAssembler* masm) {
820 Generate_JSEntryTrampolineHelper(masm, false); 820 Generate_JSEntryTrampolineHelper(masm, false);
821 } 821 }
822 822
823 823
824 void Builtins::Generate_JSConstructEntryTrampoline(MacroAssembler* masm) { 824 void Builtins::Generate_JSConstructEntryTrampoline(MacroAssembler* masm) {
825 Generate_JSEntryTrampolineHelper(masm, true); 825 Generate_JSEntryTrampolineHelper(masm, true);
826 } 826 }
827 827
828 // static
829 void Builtins::Generate_ResumeGeneratorTrampoline(MacroAssembler* masm) {
830 // ----------- S t a t e -------------
831 // -- v0 : the value to pass to the generator
832 // -- a1 : the JSGeneratorObject to resume
833 // -- a2 : the resume mode (tagged)
834 // -- ra : return address
835 // -----------------------------------
836 __ AssertGeneratorObject(a1);
837
838 // Store input value into generator object.
839 __ sw(v0, FieldMemOperand(a1, JSGeneratorObject::kInputOffset));
840 __ RecordWriteField(a1, JSGeneratorObject::kInputOffset, v0, a3,
841 kRAHasNotBeenSaved, kDontSaveFPRegs);
842
843 // Load suspended function and context.
844 __ lw(cp, FieldMemOperand(a1, JSGeneratorObject::kContextOffset));
845 __ lw(t0, FieldMemOperand(a1, JSGeneratorObject::kFunctionOffset));
846
847 // Flood function if we are stepping.
848 Label skip_flooding;
849 ExternalReference step_in_enabled =
850 ExternalReference::debug_step_in_enabled_address(masm->isolate());
851 __ li(t1, Operand(step_in_enabled));
852 __ lb(t1, MemOperand(t1));
853 __ Branch(&skip_flooding, eq, t1, Operand(zero_reg));
854 {
855 FrameScope scope(masm, StackFrame::INTERNAL);
856 __ Push(a1, a2, t0);
857 __ CallRuntime(Runtime::kDebugPrepareStepInIfStepping);
858 __ Pop(a1, a2);
859 __ lw(t0, FieldMemOperand(a1, JSGeneratorObject::kFunctionOffset));
860 }
861 __ bind(&skip_flooding);
862
863 // Push receiver.
864 __ lw(t1, FieldMemOperand(a1, JSGeneratorObject::kReceiverOffset));
865 __ Push(t1);
866
867 // ----------- S t a t e -------------
868 // -- a1 : the JSGeneratorObject to resume
869 // -- a2 : the resume mode (tagged)
870 // -- t0 : generator function
871 // -- cp : generator context
872 // -- ra : return address
873 // -- sp[0] : generator receiver
874 // -----------------------------------
875
876 // Push holes for arguments to generator function. Since the parser forced
877 // context allocation for any variables in generators, the actual argument
878 // values have already been copied into the context and these dummy values
879 // will never be used.
880 __ lw(a3, FieldMemOperand(t0, JSFunction::kSharedFunctionInfoOffset));
881 __ lw(a3,
882 FieldMemOperand(a3, SharedFunctionInfo::kFormalParameterCountOffset));
883 {
884 Label done_loop, loop;
885 __ bind(&loop);
886 __ Subu(a3, a3, Operand(Smi::FromInt(1)));
887 __ Branch(&done_loop, lt, a3, Operand(zero_reg));
888 __ PushRoot(Heap::kTheHoleValueRootIndex);
889 __ Branch(&loop);
890 __ bind(&done_loop);
891 }
892
893 // Enter a new JavaScript frame, and initialize its slots as they were when
894 // the generator was suspended.
895 FrameScope scope(masm, StackFrame::MANUAL);
896 __ Push(ra, fp);
897 __ Move(fp, sp);
898 __ Push(cp, t0);
899
900 // Restore the operand stack.
901 __ lw(a0, FieldMemOperand(a1, JSGeneratorObject::kOperandStackOffset));
902 __ lw(a3, FieldMemOperand(a0, FixedArray::kLengthOffset));
903 __ Addu(a0, a0, Operand(FixedArray::kHeaderSize - kHeapObjectTag));
904 __ Lsa(a3, a0, a3, kPointerSizeLog2 - 1);
905 {
906 Label done_loop, loop;
907 __ bind(&loop);
908 __ Branch(&done_loop, eq, a0, Operand(a3));
909 __ lw(t1, MemOperand(a0));
910 __ Push(t1);
911 __ Branch(USE_DELAY_SLOT, &loop);
912 __ addiu(a0, a0, kPointerSize); // In delay slot.
913 __ bind(&done_loop);
914 }
915
916 // Push resume mode (consumed in continuation).
917 __ Push(a2);
918
919 // Reset operand stack so we don't leak.
920 __ LoadRoot(t1, Heap::kEmptyFixedArrayRootIndex);
921 __ sw(t1, FieldMemOperand(a1, JSGeneratorObject::kOperandStackOffset));
922
923 // Restore value.
924 __ lw(v0, FieldMemOperand(a1, JSGeneratorObject::kInputOffset));
925
926 // Resume the generator function at the continuation.
927 __ lw(a3, FieldMemOperand(t0, JSFunction::kSharedFunctionInfoOffset));
928 __ lw(a3, FieldMemOperand(a3, SharedFunctionInfo::kCodeOffset));
929 __ Addu(a3, a3, Operand(Code::kHeaderSize - kHeapObjectTag));
930 __ lw(a2, FieldMemOperand(a1, JSGeneratorObject::kContinuationOffset));
931 __ SmiUntag(a2);
932 __ Addu(a3, a3, Operand(a2));
933 __ li(a2, Operand(Smi::FromInt(JSGeneratorObject::kGeneratorExecuting)));
934 __ sw(a2, FieldMemOperand(a1, JSGeneratorObject::kContinuationOffset));
935 __ Jump(a3);
936 }
828 937
829 // Generate code for entering a JS function with the interpreter. 938 // Generate code for entering a JS function with the interpreter.
830 // On entry to the function the receiver and arguments have been pushed on the 939 // On entry to the function the receiver and arguments have been pushed on the
831 // stack left to right. The actual argument count matches the formal parameter 940 // stack left to right. The actual argument count matches the formal parameter
832 // count expected by the function. 941 // count expected by the function.
833 // 942 //
834 // The live registers are: 943 // The live registers are:
835 // o a1: the JS function object being called. 944 // o a1: the JS function object being called.
836 // o a3: the new target 945 // o a3: the new target
837 // o cp: our context 946 // o cp: our context
(...skipping 1763 matching lines...) Expand 10 before | Expand all | Expand 10 after
2601 } 2710 }
2602 } 2711 }
2603 2712
2604 2713
2605 #undef __ 2714 #undef __
2606 2715
2607 } // namespace internal 2716 } // namespace internal
2608 } // namespace v8 2717 } // namespace v8
2609 2718
2610 #endif // V8_TARGET_ARCH_MIPS 2719 #endif // V8_TARGET_ARCH_MIPS
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698