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

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

Issue 2894293003: Save/restore only live registers in the generator suspend/resume. (Closed)
Patch Set: Fix comments 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..8db8adc568a5dc5aa960ebf6c06ce7bfaae36d4b 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> <input-register-list> <flags>
rmcilroy 2017/06/01 10:44:44 nit - <input-register-list> -> <first input regist
Jarin 2017/06/01 12:48:22 Done.
//
// 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,9 @@ IGNITION_HANDLER(SuspendGenerator, InterpreterAssembler) {
Node* context = GetContext();
Node* state = GetAccumulator();
- ExportRegisterFile(array);
+ // Bytecode operand 2 is the number of registers to store to the generator.
rmcilroy 2017/06/01 10:44:44 You don't ever check operand 1 - could you add a C
Jarin 2017/06/01 12:48:22 Done.
+ Node* register_count = ChangeUint32ToWord(BytecodeOperandCount(2));
+ ExportRegisterFile(array, register_count);
StoreObjectField(generator, JSGeneratorObject::kContextOffset, context);
StoreObjectField(generator, JSGeneratorObject::kContinuationOffset, state);
@@ -3688,16 +3691,12 @@ IGNITION_HANDLER(SuspendGenerator, InterpreterAssembler) {
// 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.
+// Loads the generator's state and stores it in the accumulator,
+// before overwriting it with kGeneratorExecuting.
IGNITION_HANDLER(ResumeGenerator, 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 +3707,26 @@ IGNITION_HANDLER(ResumeGenerator, InterpreterAssembler) {
Dispatch();
}
+// RestoreGeneratorRegisters <generator> <output-register-list>
rmcilroy 2017/06/01 10:44:44 nit - <output-register-list> -> <first output regi
Jarin 2017/06/01 12:48:22 Done.
+//
+// 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.
rmcilroy 2017/06/01 10:44:44 Please add a CSA assert
Jarin 2017/06/01 12:48:22 Done.
+ // 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);
+ SetAccumulator(generator);
+
+ Dispatch();
+}
+
} // namespace
Handle<Code> GenerateBytecodeHandler(Isolate* isolate, Bytecode bytecode,

Powered by Google App Engine
This is Rietveld 408576698