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

Unified Diff: src/compiler/bytecode-graph-builder.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/compiler/bytecode-graph-builder.cc
diff --git a/src/compiler/bytecode-graph-builder.cc b/src/compiler/bytecode-graph-builder.cc
index 14c97c832f18c2e9aa329f44c3e7838c6f31bfd3..513e9ce10d5299b62ff8599375f441bbbd1b20de 100644
--- a/src/compiler/bytecode-graph-builder.cc
+++ b/src/compiler/bytecode-graph-builder.cc
@@ -2277,15 +2277,20 @@ void BytecodeGraphBuilder::VisitSuspendGenerator() {
Node* state = environment()->LookupAccumulator();
Node* generator = environment()->LookupRegister(
bytecode_iterator().GetRegisterOperand(0));
+ interpreter::Register first_reg = bytecode_iterator().GetRegisterOperand(1);
+ // We assume we are storing a range starting from index 0.
+ CHECK_EQ(0, first_reg.index());
+ int register_count =
+ static_cast<int>(bytecode_iterator().GetRegisterCountOperand(2));
SuspendFlags flags = interpreter::SuspendGeneratorBytecodeFlags::Decode(
- bytecode_iterator().GetFlagOperand(1));
+ bytecode_iterator().GetFlagOperand(3));
+
// The offsets used by the bytecode iterator are relative to a different base
// than what is used in the interpreter, hence the addition.
Node* offset =
jsgraph()->Constant(bytecode_iterator().current_offset() +
(BytecodeArray::kHeaderSize - kHeapObjectTag));
- int register_count = environment()->register_count();
int value_input_count = 3 + register_count;
Node** value_inputs = local_zone()->NewArray<Node*>(value_input_count);
@@ -2305,9 +2310,26 @@ void BytecodeGraphBuilder::VisitResumeGenerator() {
Node* generator = environment()->LookupRegister(
bytecode_iterator().GetRegisterOperand(0));
+ Node* state =
+ NewNode(javascript()->GeneratorRestoreContinuation(), generator);
+
+ environment()->BindAccumulator(state, Environment::kAttachFrameState);
+}
+
+void BytecodeGraphBuilder::VisitRestoreGeneratorRegisters() {
+ PrepareEagerCheckpoint();
+
+ Node* generator =
+ environment()->LookupRegister(bytecode_iterator().GetRegisterOperand(0));
+ interpreter::Register first_reg = bytecode_iterator().GetRegisterOperand(1);
+ // We assume we are restoring registers starting fromm index 0.
+ CHECK_EQ(0, first_reg.index());
+ int register_count =
+ static_cast<int>(bytecode_iterator().GetRegisterCountOperand(2));
+
// Bijection between registers and array indices must match that used in
// InterpreterAssembler::ExportRegisterFile.
- for (int i = 0; i < environment()->register_count(); ++i) {
+ for (int i = 0; i < register_count; ++i) {
Node* value = NewNode(javascript()->GeneratorRestoreRegister(i), generator);
environment()->BindRegister(interpreter::Register(i), value);
}

Powered by Google App Engine
This is Rietveld 408576698