Index: src/interpreter/interpreter.cc |
diff --git a/src/interpreter/interpreter.cc b/src/interpreter/interpreter.cc |
index 81ee71caf3a6ee0a77bcf9303523357546a3f4af..da663c2d879f6d68edb21b1687dd0439a6906f59 100644 |
--- a/src/interpreter/interpreter.cc |
+++ b/src/interpreter/interpreter.cc |
@@ -3242,6 +3242,50 @@ void Interpreter::DoSuspendGenerator(InterpreterAssembler* assembler) { |
} |
} |
+// AwaitGenerator <generator> |
+// |
+// Like SuspendGenerator, exports the register file and stores it into the |
+// generator, along with current context, the continuation state. The current |
+// bytecode offset is stored in the [await_input] field to prevent clobbering |
+// the sent value. |
+void Interpreter::DoAwaitGenerator(InterpreterAssembler* assembler) { |
+ Node* generator_reg = __ BytecodeOperandReg(0); |
+ Node* generator = __ LoadRegister(generator_reg); |
+ |
+ Label if_stepping(assembler, Label::kDeferred), ok(assembler); |
+ Node* step_action_address = __ ExternalConstant( |
+ ExternalReference::debug_last_step_action_address(isolate_)); |
+ Node* step_action = __ Load(MachineType::Int8(), step_action_address); |
+ STATIC_ASSERT(StepIn > StepNext); |
+ STATIC_ASSERT(StepFrame > StepNext); |
+ STATIC_ASSERT(LastStepAction == StepFrame); |
+ Node* step_next = __ Int32Constant(StepNext); |
+ __ Branch(__ Int32LessThanOrEqual(step_next, step_action), &if_stepping, &ok); |
+ __ Bind(&ok); |
+ |
+ Node* array = |
+ __ LoadObjectField(generator, JSGeneratorObject::kRegisterFileOffset); |
+ Node* context = __ GetContext(); |
+ Node* state = __ GetAccumulator(); |
+ |
+ __ ExportRegisterFile(array); |
+ __ StoreObjectField(generator, JSGeneratorObject::kContextOffset, context); |
+ __ StoreObjectField(generator, JSGeneratorObject::kContinuationOffset, state); |
+ |
+ Node* offset = __ SmiTag(__ BytecodeOffset()); |
+ __ StoreObjectField(generator, JSAsyncGeneratorObject::kAwaitInputOffset, |
+ offset); |
+ |
+ __ Dispatch(); |
+ |
+ __ Bind(&if_stepping); |
+ { |
+ Node* context = __ GetContext(); |
+ __ CallRuntime(Runtime::kDebugRecordGenerator, context, generator); |
+ __ Goto(&ok); |
+ } |
+} |
+ |
// ResumeGenerator <generator> |
// |
// Imports the register file stored in the generator. Also loads the |