Chromium Code Reviews| Index: src/builtins/builtins-generator-gen.cc |
| diff --git a/src/builtins/builtins-generator-gen.cc b/src/builtins/builtins-generator-gen.cc |
| index 4fdb4addad91878d21ff5fba7d8648ebebbda8ab..aab01afd283b5c4110ca78b68eb02ca46dbf6636 100644 |
| --- a/src/builtins/builtins-generator-gen.cc |
| +++ b/src/builtins/builtins-generator-gen.cc |
| @@ -56,18 +56,27 @@ void GeneratorBuiltinsAssembler::GeneratorPrototypeResume( |
| // Make sure we close the generator if there was an exception. |
| GotoIfException(result, &if_exception, &var_exception); |
| - // If the generator is not suspended (i.e., it's state is 'closed'), |
| - // wrap the return value in IteratorResult. |
| + // If the generator is not suspended (i.e., it's state is 'executing'), |
|
neis
2017/06/13 10:58:17
s/it's/its/
Jarin
2017/06/13 11:05:56
Done.
|
| + // close it and wrap the return value in IteratorResult. |
| Node* result_continuation = |
| LoadObjectField(receiver, JSGeneratorObject::kContinuationOffset); |
| - GotoIf(SmiEqual(result_continuation, closed), &if_final_return); |
| + |
| + // The generator function should not close the generator by itself, let's |
| + // check it is indeed not closed yet. |
| + CSA_ASSERT(this, SmiNotEqual(result_continuation, closed)); |
| + |
| + Node* executing = SmiConstant(JSGeneratorObject::kGeneratorExecuting); |
| + GotoIf(SmiEqual(result_continuation, executing), &if_final_return); |
| + |
| Return(result); |
|
neis
2017/06/13 10:58:17
Please add a comment saying that on suspend the ge
Jarin
2017/06/13 11:05:56
Done.
|
| Callable create_iter_result_object = |
| Builtins::CallableFor(isolate(), Builtins::kCreateIterResultObject); |
| - |
| BIND(&if_final_return); |
| { |
| + // Close the generator. |
| + StoreObjectFieldNoWriteBarrier( |
| + receiver, JSGeneratorObject::kContinuationOffset, closed); |
| // Return the wrapped result. |
| Return( |
| CallStub(create_iter_result_object, context, result, TrueConstant())); |