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

Unified Diff: src/builtins/builtins-generator-gen.cc

Issue 2917263002: Move generator-close on exception from the generator function to the GeneratorResume builtin. (Closed)
Patch Set: Add the builtins to the uncaught exception prediction list Created 3 years, 6 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/builtins/builtins-definitions.h ('k') | src/interpreter/bytecode-generator.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/builtins/builtins-generator-gen.cc
diff --git a/src/builtins/builtins-generator-gen.cc b/src/builtins/builtins-generator-gen.cc
index b011f1e5cd724725dd034968fdcfd5d2b1be48b7..8445dd1804db46bfe9e4322f92343a2d6566a890 100644
--- a/src/builtins/builtins-generator-gen.cc
+++ b/src/builtins/builtins-generator-gen.cc
@@ -47,10 +47,14 @@ void GeneratorBuiltinsAssembler::GeneratorPrototypeResume(
GotoIf(SmiLessThan(receiver_continuation, closed), &if_receiverisrunning);
// Resume the {receiver} using our trampoline.
+ VARIABLE(var_exception, MachineRepresentation::kTagged, UndefinedConstant());
+ Label if_exception(this, Label::kDeferred);
Node* result =
CallStub(CodeFactory::ResumeGenerator(isolate()), context, value,
receiver, SmiConstant(resume_mode),
SmiConstant(static_cast<int>(SuspendFlags::kGeneratorYield)));
+ // Make sure we close the generator if there was an exception.
+ GotoIfException(result, &if_exception, &var_exception);
caitp 2017/06/03 23:14:00 also, given what I said in the top-level comment,
Jarin 2017/06/04 08:49:39 At the moment normal returns are handled in Byteco
Jarin 2017/06/04 08:56:47 Note that we can only do this for normal returns b
Return(result);
BIND(&if_receiverisincompatible);
@@ -91,6 +95,14 @@ void GeneratorBuiltinsAssembler::GeneratorPrototypeResume(
CallRuntime(Runtime::kThrowGeneratorRunning, context);
Unreachable();
}
+
+ BIND(&if_exception);
+ {
+ StoreObjectFieldNoWriteBarrier(
+ receiver, JSGeneratorObject::kContinuationOffset, closed);
+ CallRuntime(Runtime::kReThrow, context, var_exception.value());
+ Unreachable();
+ }
}
// ES6 #sec-generator.prototype.next
« no previous file with comments | « src/builtins/builtins-definitions.h ('k') | src/interpreter/bytecode-generator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698