| Index: src/full-codegen/x64/full-codegen-x64.cc
|
| diff --git a/src/full-codegen/x64/full-codegen-x64.cc b/src/full-codegen/x64/full-codegen-x64.cc
|
| index 68bb6498a1112deb49a9ff8a5eadd72b0914b334..56eca5d8b0d089ed5f73c3272f8bc6877e9fb6bc 100644
|
| --- a/src/full-codegen/x64/full-codegen-x64.cc
|
| +++ b/src/full-codegen/x64/full-codegen-x64.cc
|
| @@ -1860,8 +1860,17 @@ void FullCodeGenerator::VisitYield(Yield* expr) {
|
|
|
| __ jmp(&suspend);
|
| __ bind(&continuation);
|
| + // When we arrive here, the stack top is the resume mode and
|
| + // result_register() holds the input value (the argument given to the
|
| + // respective resume operation).
|
| __ RecordGeneratorContinuation();
|
| - __ jmp(&resume);
|
| + __ Pop(rbx);
|
| + __ SmiCompare(rbx, Smi::FromInt(JSGeneratorObject::RETURN));
|
| + __ j(not_equal, &resume);
|
| + __ Push(result_register());
|
| + EmitCreateIteratorResult(true);
|
| + EmitUnwindBeforeReturn();
|
| + EmitReturnSequence();
|
|
|
| __ bind(&suspend);
|
| VisitForAccumulatorValue(expr->generator_object());
|
| @@ -1891,9 +1900,6 @@ void FullCodeGenerator::VisitYield(Yield* expr) {
|
|
|
| case Yield::kFinal: {
|
| VisitForAccumulatorValue(expr->generator_object());
|
| - __ Move(FieldOperand(result_register(),
|
| - JSGeneratorObject::kContinuationOffset),
|
| - Smi::FromInt(JSGeneratorObject::kGeneratorClosed));
|
| // Pop value from top-of-stack slot, box result into result register.
|
| EmitCreateIteratorResult(true);
|
| EmitUnwindBeforeReturn();
|
| @@ -1938,6 +1944,10 @@ void FullCodeGenerator::VisitYield(Yield* expr) {
|
| __ jmp(&l_suspend);
|
| __ bind(&l_continuation);
|
| __ RecordGeneratorContinuation();
|
| + __ Pop(rbx);
|
| + // TODO(neis): Ignoring the resume mode here is clearly wrong. Currently,
|
| + // return is not supported for yield*. The planned desugaring of yield*
|
| + // using do-expressions will naturally solve this.
|
| __ jmp(&l_resume);
|
|
|
| __ bind(&l_suspend);
|
| @@ -2013,8 +2023,8 @@ void FullCodeGenerator::VisitYield(Yield* expr) {
|
| }
|
|
|
|
|
| -void FullCodeGenerator::EmitGeneratorResume(Expression *generator,
|
| - Expression *value,
|
| +void FullCodeGenerator::EmitGeneratorResume(
|
| + Expression* generator, Expression* value,
|
| JSGeneratorObject::ResumeMode resume_mode) {
|
| // The value stays in rax, and is ultimately read by the resumed generator, as
|
| // if CallRuntime(Runtime::kSuspendJSGeneratorObject) returned it. Or it
|
| @@ -2072,6 +2082,7 @@ void FullCodeGenerator::EmitGeneratorResume(Expression *generator,
|
| __ addp(rdx, rcx);
|
| __ Move(FieldOperand(rbx, JSGeneratorObject::kContinuationOffset),
|
| Smi::FromInt(JSGeneratorObject::kGeneratorExecuting));
|
| + __ Push(Smi::FromInt(resume_mode)); // Consumed in continuation.
|
| __ jmp(rdx);
|
| __ bind(&slow_resume);
|
| }
|
| @@ -2085,6 +2096,7 @@ void FullCodeGenerator::EmitGeneratorResume(Expression *generator,
|
| __ Push(rcx);
|
| __ jmp(&push_operand_holes);
|
| __ bind(&call_resume);
|
| + __ Push(Smi::FromInt(resume_mode)); // Consumed in continuation.
|
| __ Push(rbx);
|
| __ Push(result_register());
|
| __ Push(Smi::FromInt(resume_mode));
|
|
|