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

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: Address comments 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
« no previous file with comments | « src/compiler.cc ('k') | src/compiler/js-graph.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..8fb7b69f403ea6cfe7e8a02af70a7a983044675a 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) {
+ Node* value = environment()->LookupRegister(interpreter::Register(i));
+ NewNode(javascript()->CallRuntime(Runtime::kGeneratorStoreRegister),
+ generator, jsgraph()->Constant(i), value);
+ }
+
+ 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::kGeneratorLoadRegister),
+ generator, jsgraph()->Constant(i));
+ environment()->BindRegister(interpreter::Register(i), value);
+
+ NewNode(javascript()->CallRuntime(Runtime::kGeneratorStoreRegister),
+ 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) {
« no previous file with comments | « src/compiler.cc ('k') | src/compiler/js-graph.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698