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 |