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

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

Issue 1639343005: [generators] Implement Generator.prototype.return. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@yield-star
Patch Set: Another rebase Created 4 years, 10 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/runtime/runtime.h ('k') | test/mjsunit/es6/generators-runtime.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/runtime/runtime-generator.cc
diff --git a/src/runtime/runtime-generator.cc b/src/runtime/runtime-generator.cc
index c2461337cdd965eddbb744f056c2b3458a6c62d5..f1b2fd055d94b07d397dcf5d6e94c236fd155731 100644
--- a/src/runtime/runtime-generator.cc
+++ b/src/runtime/runtime-generator.cc
@@ -87,9 +87,9 @@ RUNTIME_FUNCTION(Runtime_SuspendJSGeneratorObject) {
// called if the suspended activation had operands on the stack, stack handlers
// needing rewinding, or if the resume should throw an exception. The fast path
// is handled directly in FullCodeGenerator::EmitGeneratorResume(), which is
-// inlined into GeneratorNext and GeneratorThrow. EmitGeneratorResumeResume is
-// called in any case, as it needs to reconstruct the stack frame and make space
-// for arguments and operands.
+// inlined into GeneratorNext, GeneratorReturn, and GeneratorThrow.
+// EmitGeneratorResume is called in any case, as it needs to reconstruct the
+// stack frame and make space for arguments and operands.
RUNTIME_FUNCTION(Runtime_ResumeJSGeneratorObject) {
SealHandleScope shs(isolate);
DCHECK(args.length() == 3);
@@ -125,7 +125,10 @@ RUNTIME_FUNCTION(Runtime_ResumeJSGeneratorObject) {
JSGeneratorObject::ResumeMode resume_mode =
static_cast<JSGeneratorObject::ResumeMode>(resume_mode_int);
switch (resume_mode) {
+ // Note: this looks like NEXT and RETURN are the same but RETURN receives
+ // special treatment in the generator code (to which we return here).
case JSGeneratorObject::NEXT:
+ case JSGeneratorObject::RETURN:
return value;
case JSGeneratorObject::THROW:
return isolate->Throw(value);
@@ -213,15 +216,25 @@ RUNTIME_FUNCTION(Runtime_GeneratorGetSourcePosition) {
}
+// Optimization for the following three functions is disabled in
+// js/generator.js and compiler/ast-graph-builder.cc.
+
+
RUNTIME_FUNCTION(Runtime_GeneratorNext) {
- UNREACHABLE(); // Optimization disabled in SetUpGenerators().
- return NULL;
+ UNREACHABLE();
+ return nullptr;
+}
+
+
+RUNTIME_FUNCTION(Runtime_GeneratorReturn) {
+ UNREACHABLE();
+ return nullptr;
}
RUNTIME_FUNCTION(Runtime_GeneratorThrow) {
- UNREACHABLE(); // Optimization disabled in SetUpGenerators().
- return NULL;
+ UNREACHABLE();
+ return nullptr;
}
} // namespace internal
} // namespace v8
« no previous file with comments | « src/runtime/runtime.h ('k') | test/mjsunit/es6/generators-runtime.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698