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

Unified Diff: src/interpreter/interpreter.cc

Issue 2622833002: WIP [esnext] implement async iteration proposal (Closed)
Patch Set: simplify AsyncIteratorValueUnwrap Created 3 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/interpreter/bytecodes.h ('k') | src/interpreter/interpreter-intrinsics.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« no previous file with comments | « src/interpreter/bytecodes.h ('k') | src/interpreter/interpreter-intrinsics.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698