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

Unified Diff: src/interpreter/interpreter.cc

Issue 1904933002: Introduce bytecodes for assisting generator suspend and resume. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Nix 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/interpreter/bytecodes.h ('k') | src/interpreter/interpreter-assembler.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 d24750aaf24dd5591115a30e6f2e54b742da12f4..f0ef83aa135bc0c147303e765487bdabe5abfdd9 100644
--- a/src/interpreter/interpreter.cc
+++ b/src/interpreter/interpreter.cc
@@ -1685,6 +1685,49 @@ void Interpreter::DoIllegal(InterpreterAssembler* assembler) {
__ Abort(kInvalidBytecode);
}
+// SuspendGenerator <generator>
+//
+// Exports the register file and stores it into the generator. Also stores the
+// current context and the state given in the accumulator into the generator.
+void Interpreter::DoSuspendGenerator(InterpreterAssembler* assembler) {
+ Node* generator_reg = __ BytecodeOperandReg(0);
+ Node* generator = __ LoadRegister(generator_reg);
+
+ Node* array = __ ExportRegisterFile();
+ Node* context = __ GetContext();
+ Node* state = __ GetAccumulator();
+
+ __ StoreObjectField(generator, JSGeneratorObject::kOperandStackOffset, array);
+ __ StoreObjectField(generator, JSGeneratorObject::kContextOffset, context);
+ __ StoreObjectField(generator, JSGeneratorObject::kContinuationOffset, state);
+
+ __ Dispatch();
+}
+
+// ResumeGenerator <generator>
+//
+// Imports the register file stored in the generator. Also loads the
+// generator's state and stores it in the accumulator, before overwriting it
+// with kGeneratorExecuting.
+void Interpreter::DoResumeGenerator(InterpreterAssembler* assembler) {
+ Node* generator_reg = __ BytecodeOperandReg(0);
+ Node* generator = __ LoadRegister(generator_reg);
+
+ __ ImportRegisterFile(
+ __ LoadObjectField(generator, JSGeneratorObject::kOperandStackOffset));
+ __ StoreObjectField(generator, JSGeneratorObject::kOperandStackOffset,
+ __ HeapConstant(isolate_->factory()->empty_fixed_array()));
+
+ Node* old_state =
+ __ LoadObjectField(generator, JSGeneratorObject::kContinuationOffset);
+ Node* new_state = __ Int32Constant(JSGeneratorObject::kGeneratorExecuting);
+ __ StoreObjectField(generator, JSGeneratorObject::kContinuationOffset,
+ __ SmiTag(new_state));
+ __ SetAccumulator(old_state);
+
+ __ Dispatch();
+}
+
} // namespace interpreter
} // namespace internal
} // namespace v8
« no previous file with comments | « src/interpreter/bytecodes.h ('k') | src/interpreter/interpreter-assembler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698