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

Unified Diff: src/compiler/bytecode-graph-builder.cc

Issue 1957393004: Allow Turbofan optimization of Ignition generators (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 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 a7b39c209ebb2d1b3fd1094f9cd18131b34b757a..9fc3ede46cb340b2e77eac71776b5e59e8b155b2 100644
--- a/src/compiler/bytecode-graph-builder.cc
+++ b/src/compiler/bytecode-graph-builder.cc
@@ -1367,11 +1367,45 @@ void BytecodeGraphBuilder::VisitForInStep() {
}
void BytecodeGraphBuilder::VisitSuspendGenerator() {
- UNIMPLEMENTED();
+ Node* state = environment()->LookupAccumulator();
+ Node* generator = environment()->LookupRegister(
+ bytecode_iterator().GetRegisterOperand(0));
+
+ for (int i = 0; i < environment()->register_count(); ++i) {
+ NewNode(javascript()->CallRuntime(Runtime::kGeneratorWriteRegister),
Benedikt Meurer 2016/05/10 10:32:08 Nit: use StoreRegister or SetRegister instead of W
neis 2016/05/10 11:32:06 Done.
+ generator, jsgraph()->Constant(i),
+ environment()->LookupRegister(interpreter::Register(i)));
Michael Starzinger 2016/05/10 10:53:05 nit: Better pull out the "environment()->LookupReg
neis 2016/05/10 11:32:06 Done.
+ }
+
+ NewNode(javascript()->CallRuntime(Runtime::kGeneratorSetContext), generator);
+ NewNode(javascript()->CallRuntime(Runtime::kGeneratorSetContinuation),
+ generator, state);
}
void BytecodeGraphBuilder::VisitResumeGenerator() {
- UNIMPLEMENTED();
+ FrameStateBeforeAndAfter states(this);
+
+ Node* generator = environment()->LookupRegister(
+ bytecode_iterator().GetRegisterOperand(0));
+ Node* state = NewNode(javascript()->CallRuntime(
+ Runtime::kGeneratorGetContinuation), generator);
+
+ // Bijection between registers and array indices must match that used in
+ // InterpreterAssembler::ExportRegisterFile.
+ for (int i = 0; i < environment()->register_count(); ++i) {
+ Node* value = NewNode(
+ javascript()->CallRuntime(Runtime::kGeneratorReadRegister),
Benedikt Meurer 2016/05/10 10:32:08 Nit: use LoadRegister instead of ReadRegister
neis 2016/05/10 11:32:06 Done.
+ generator, jsgraph()->Constant(i));
+ environment()->BindRegister(interpreter::Register(i), value);
+
+ NewNode(javascript()->CallRuntime(Runtime::kGeneratorWriteRegister),
+ generator, jsgraph()->Constant(i), jsgraph()->StaleRegisterConstant());
+ }
+
+ NewNode(javascript()->CallRuntime(Runtime::kGeneratorSetContinuation),
+ generator, jsgraph()->Constant(JSGeneratorObject::kGeneratorExecuting));
+
+ environment()->BindAccumulator(state, &states);
}
void BytecodeGraphBuilder::VisitWide() {
@@ -1385,8 +1419,8 @@ void BytecodeGraphBuilder::VisitExtraWide() {
}
void BytecodeGraphBuilder::VisitIllegal() {
- // Never present in valid bytecode.
- UNREACHABLE();
+ NewNode(javascript()->CallRuntime(Runtime::kAbort),
+ jsgraph()->Constant(kIllegalBytecode));
}
void BytecodeGraphBuilder::SwitchToMergeEnvironment(int current_offset) {

Powered by Google App Engine
This is Rietveld 408576698