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

Unified Diff: src/interpreter/interpreter-generator.cc

Issue 2894293003: Save/restore only live registers in the generator suspend/resume. (Closed)
Patch Set: Tweak Created 3 years, 7 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
Index: src/interpreter/interpreter-generator.cc
diff --git a/src/interpreter/interpreter-generator.cc b/src/interpreter/interpreter-generator.cc
index 85a15b2389b9cff57452cd0957b7e6be093fdd1a..51441a07d4ecf0f59276f494ebb3417b912c573c 100644
--- a/src/interpreter/interpreter-generator.cc
+++ b/src/interpreter/interpreter-generator.cc
@@ -3612,14 +3612,15 @@ IGNITION_HANDLER(Illegal, InterpreterAssembler) { Abort(kInvalidBytecode); }
// No operation.
IGNITION_HANDLER(Nop, InterpreterAssembler) { Dispatch(); }
-// SuspendGenerator <generator>
+// SuspendGenerator <generator> <first input register> <register count> <flags>
//
// Exports the register file and stores it into the generator. Also stores the
// current context, the state given in the accumulator, and the current bytecode
// offset (for debugging purposes) into the generator.
IGNITION_HANDLER(SuspendGenerator, InterpreterAssembler) {
Node* generator_reg = BytecodeOperandReg(0);
- Node* flags = BytecodeOperandFlag(1);
+ Node* flags = BytecodeOperandFlag(3);
+
Node* generator = LoadRegister(generator_reg);
Label if_stepping(this, Label::kDeferred), ok(this);
@@ -3637,7 +3638,13 @@ IGNITION_HANDLER(SuspendGenerator, InterpreterAssembler) {
Node* context = GetContext();
Node* state = GetAccumulator();
- ExportRegisterFile(array);
+ // Bytecode operand 1 should be always 0 (we are always store registers
+ // from the beginning).
+ CSA_ASSERT(this, WordEqual(BytecodeOperandReg(1),
+ IntPtrConstant(Register(0).ToOperand())));
+ // Bytecode operand 2 is the number of registers to store to the generator.
+ Node* register_count = ChangeUint32ToWord(BytecodeOperandCount(2));
+ ExportRegisterFile(array, register_count);
StoreObjectField(generator, JSGeneratorObject::kContextOffset, context);
StoreObjectField(generator, JSGeneratorObject::kContinuationOffset, state);
@@ -3686,18 +3693,14 @@ IGNITION_HANDLER(SuspendGenerator, InterpreterAssembler) {
}
}
-// ResumeGenerator <generator>
+// RestoreGeneratorState <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.
-IGNITION_HANDLER(ResumeGenerator, InterpreterAssembler) {
+// Loads the generator's state and stores it in the accumulator,
+// before overwriting it with kGeneratorExecuting.
+IGNITION_HANDLER(RestoreGeneratorState, InterpreterAssembler) {
Node* generator_reg = BytecodeOperandReg(0);
Node* generator = LoadRegister(generator_reg);
- ImportRegisterFile(
- LoadObjectField(generator, JSGeneratorObject::kRegisterFileOffset));
-
Node* old_state =
LoadObjectField(generator, JSGeneratorObject::kContinuationOffset);
Node* new_state = Int32Constant(JSGeneratorObject::kGeneratorExecuting);
@@ -3708,6 +3711,28 @@ IGNITION_HANDLER(ResumeGenerator, InterpreterAssembler) {
Dispatch();
}
+// RestoreGeneratorRegisters <generator> <first output register> <register
+// count>
+//
+// Imports the register file stored in the generator.
+IGNITION_HANDLER(RestoreGeneratorRegisters, InterpreterAssembler) {
+ Node* generator_reg = BytecodeOperandReg(0);
+ // Bytecode operand 1 is the start register. It should always be 0, so let's
+ // ignore it.
+ CSA_ASSERT(this, WordEqual(BytecodeOperandReg(1),
+ IntPtrConstant(Register(0).ToOperand())));
+ // Bytecode operand 2 is the number of registers to store to the generator.
+ Node* register_count = ChangeUint32ToWord(BytecodeOperandCount(2));
+
+ Node* generator = LoadRegister(generator_reg);
+
+ ImportRegisterFile(
+ LoadObjectField(generator, JSGeneratorObject::kRegisterFileOffset),
+ register_count);
+
+ Dispatch();
+}
+
} // namespace
Handle<Code> GenerateBytecodeHandler(Isolate* isolate, Bytecode bytecode,
« no previous file with comments | « src/interpreter/interpreter-assembler.cc ('k') | test/cctest/interpreter/bytecode_expectations/ForAwaitOf.golden » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698