X87: [generators] Implement Generator.prototype.return.

port dbd8640813 (r33744)

  original commit message:
  Note: This is currently only used by yield*, we still need to support it in
  other places (such as for-of loops).  It can be used manually of course.

  (This CL does not touch the full-codegen implementation of yield* because that
  code is already dead.  The yield* desugaring already supports return and doesn't
  need to be touched.)

BUG=

Review URL: https://codereview.chromium.org/1671783002

Cr-Commit-Position: refs/heads/master@{#33760}
This commit is contained in:
zhengxing.li 2016-02-04 23:41:04 -08:00 committed by Commit bot
parent 25bfba9329
commit c357a87a79

View File

@ -1839,8 +1839,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(ebx);
__ cmp(ebx, Immediate(Smi::FromInt(JSGeneratorObject::RETURN)));
__ j(not_equal, &resume);
__ push(result_register());
EmitCreateIteratorResult(true);
EmitUnwindBeforeReturn();
EmitReturnSequence();
__ bind(&suspend);
VisitForAccumulatorValue(expr->generator_object());
@ -2001,8 +2010,8 @@ void FullCodeGenerator::EmitGeneratorResume(Expression *generator,
// Store input value into generator object.
__ mov(FieldOperand(ebx, JSGeneratorObject::kInputOffset), result_register());
__ mov(edx, result_register());
__ RecordWriteField(ebx, JSGeneratorObject::kInputOffset, edx, ecx,
__ mov(ecx, result_register());
__ RecordWriteField(ebx, JSGeneratorObject::kInputOffset, ecx, edx,
kDontSaveFPRegs);
// Load suspended function and context.
@ -2053,6 +2062,7 @@ void FullCodeGenerator::EmitGeneratorResume(Expression *generator,
__ add(edx, ecx);
__ mov(FieldOperand(ebx, JSGeneratorObject::kContinuationOffset),
Immediate(Smi::FromInt(JSGeneratorObject::kGeneratorExecuting)));
__ Push(Smi::FromInt(resume_mode)); // Consumed in continuation.
__ jmp(edx);
__ bind(&slow_resume);
}
@ -2066,6 +2076,7 @@ void FullCodeGenerator::EmitGeneratorResume(Expression *generator,
__ push(ecx);
__ jmp(&push_operand_holes);
__ bind(&call_resume);
__ Push(Smi::FromInt(resume_mode)); // Consumed in continuation.
__ push(ebx);
__ push(result_register());
__ Push(Smi::FromInt(resume_mode));