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_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 887 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
898 { | 898 { |
899 Label done_loop, loop; | 899 Label done_loop, loop; |
900 __ bind(&loop); | 900 __ bind(&loop); |
901 __ Subu(a3, a3, Operand(Smi::FromInt(1))); | 901 __ Subu(a3, a3, Operand(Smi::FromInt(1))); |
902 __ Branch(&done_loop, lt, a3, Operand(zero_reg)); | 902 __ Branch(&done_loop, lt, a3, Operand(zero_reg)); |
903 __ PushRoot(Heap::kTheHoleValueRootIndex); | 903 __ PushRoot(Heap::kTheHoleValueRootIndex); |
904 __ Branch(&loop); | 904 __ Branch(&loop); |
905 __ bind(&done_loop); | 905 __ bind(&done_loop); |
906 } | 906 } |
907 | 907 |
908 // Dispatch on the kind of generator object. | 908 // Underlying function needs to have bytecode available. |
909 Label old_generator; | 909 if (FLAG_debug_code) { |
910 __ lw(a3, FieldMemOperand(t0, JSFunction::kSharedFunctionInfoOffset)); | 910 __ lw(a3, FieldMemOperand(t0, JSFunction::kSharedFunctionInfoOffset)); |
911 __ lw(a3, FieldMemOperand(a3, SharedFunctionInfo::kFunctionDataOffset)); | 911 __ lw(a3, FieldMemOperand(a3, SharedFunctionInfo::kFunctionDataOffset)); |
912 __ GetObjectType(a3, a3, a3); | 912 __ GetObjectType(a3, a3, a3); |
913 __ Branch(&old_generator, ne, a3, Operand(BYTECODE_ARRAY_TYPE)); | 913 __ Assert(eq, kMissingBytecodeArray, a3, Operand(BYTECODE_ARRAY_TYPE)); |
| 914 } |
914 | 915 |
915 // New-style (ignition/turbofan) generator object. | 916 // Resume (Ignition/TurboFan) generator object. |
916 { | 917 { |
917 __ lw(a0, FieldMemOperand(t0, JSFunction::kSharedFunctionInfoOffset)); | 918 __ lw(a0, FieldMemOperand(t0, JSFunction::kSharedFunctionInfoOffset)); |
918 __ lw(a0, | 919 __ lw(a0, |
919 FieldMemOperand(a0, SharedFunctionInfo::kFormalParameterCountOffset)); | 920 FieldMemOperand(a0, SharedFunctionInfo::kFormalParameterCountOffset)); |
920 __ SmiUntag(a0); | 921 __ SmiUntag(a0); |
921 // We abuse new.target both to indicate that this is a resume call and to | 922 // We abuse new.target both to indicate that this is a resume call and to |
922 // pass in the generator object. In ordinary calls, new.target is always | 923 // pass in the generator object. In ordinary calls, new.target is always |
923 // undefined because generator functions are non-constructable. | 924 // undefined because generator functions are non-constructable. |
924 __ Move(a3, a1); | 925 __ Move(a3, a1); |
925 __ Move(a1, t0); | 926 __ Move(a1, t0); |
926 __ lw(a2, FieldMemOperand(a1, JSFunction::kCodeEntryOffset)); | 927 __ lw(a2, FieldMemOperand(a1, JSFunction::kCodeEntryOffset)); |
927 __ Jump(a2); | 928 __ Jump(a2); |
928 } | 929 } |
929 | 930 |
930 // Old-style (full-codegen) generator object | |
931 __ bind(&old_generator); | |
932 { | |
933 // Enter a new JavaScript frame, and initialize its slots as they were when | |
934 // the generator was suspended. | |
935 FrameScope scope(masm, StackFrame::MANUAL); | |
936 __ Push(ra, fp); | |
937 __ Move(fp, sp); | |
938 __ Push(cp, t0); | |
939 | |
940 // Restore the operand stack. | |
941 __ lw(a0, FieldMemOperand(a1, JSGeneratorObject::kOperandStackOffset)); | |
942 __ lw(a3, FieldMemOperand(a0, FixedArray::kLengthOffset)); | |
943 __ Addu(a0, a0, Operand(FixedArray::kHeaderSize - kHeapObjectTag)); | |
944 __ Lsa(a3, a0, a3, kPointerSizeLog2 - 1); | |
945 { | |
946 Label done_loop, loop; | |
947 __ bind(&loop); | |
948 __ Branch(&done_loop, eq, a0, Operand(a3)); | |
949 __ lw(t1, MemOperand(a0)); | |
950 __ Push(t1); | |
951 __ Branch(USE_DELAY_SLOT, &loop); | |
952 __ addiu(a0, a0, kPointerSize); // In delay slot. | |
953 __ bind(&done_loop); | |
954 } | |
955 | |
956 // Reset operand stack so we don't leak. | |
957 __ LoadRoot(t1, Heap::kEmptyFixedArrayRootIndex); | |
958 __ sw(t1, FieldMemOperand(a1, JSGeneratorObject::kOperandStackOffset)); | |
959 | |
960 // Resume the generator function at the continuation. | |
961 __ lw(a3, FieldMemOperand(t0, JSFunction::kSharedFunctionInfoOffset)); | |
962 __ lw(a3, FieldMemOperand(a3, SharedFunctionInfo::kCodeOffset)); | |
963 __ Addu(a3, a3, Operand(Code::kHeaderSize - kHeapObjectTag)); | |
964 __ lw(a2, FieldMemOperand(a1, JSGeneratorObject::kContinuationOffset)); | |
965 __ SmiUntag(a2); | |
966 __ Addu(a3, a3, Operand(a2)); | |
967 __ li(a2, Operand(Smi::FromInt(JSGeneratorObject::kGeneratorExecuting))); | |
968 __ sw(a2, FieldMemOperand(a1, JSGeneratorObject::kContinuationOffset)); | |
969 __ Move(v0, a1); // Continuation expects generator object in v0. | |
970 __ Jump(a3); | |
971 } | |
972 | |
973 __ bind(&prepare_step_in_if_stepping); | 931 __ bind(&prepare_step_in_if_stepping); |
974 { | 932 { |
975 FrameScope scope(masm, StackFrame::INTERNAL); | 933 FrameScope scope(masm, StackFrame::INTERNAL); |
976 __ Push(a1, a2, t0); | 934 __ Push(a1, a2, t0); |
977 __ CallRuntime(Runtime::kDebugPrepareStepInIfStepping); | 935 __ CallRuntime(Runtime::kDebugPrepareStepInIfStepping); |
978 __ Pop(a1, a2); | 936 __ Pop(a1, a2); |
979 } | 937 } |
980 __ Branch(USE_DELAY_SLOT, &stepping_prepared); | 938 __ Branch(USE_DELAY_SLOT, &stepping_prepared); |
981 __ lw(t0, FieldMemOperand(a1, JSGeneratorObject::kFunctionOffset)); | 939 __ lw(t0, FieldMemOperand(a1, JSGeneratorObject::kFunctionOffset)); |
982 | 940 |
(...skipping 2003 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2986 __ break_(0xCC); | 2944 __ break_(0xCC); |
2987 } | 2945 } |
2988 } | 2946 } |
2989 | 2947 |
2990 #undef __ | 2948 #undef __ |
2991 | 2949 |
2992 } // namespace internal | 2950 } // namespace internal |
2993 } // namespace v8 | 2951 } // namespace v8 |
2994 | 2952 |
2995 #endif // V8_TARGET_ARCH_MIPS | 2953 #endif // V8_TARGET_ARCH_MIPS |
OLD | NEW |