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

Unified Diff: src/full-codegen/arm/full-codegen-arm.cc

Issue 1606273002: Implement [Generator].prototype.return. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Port changes to other architectures. Created 4 years, 11 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/compiler/ast-graph-builder.cc ('k') | src/full-codegen/arm64/full-codegen-arm64.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/full-codegen/arm/full-codegen-arm.cc
diff --git a/src/full-codegen/arm/full-codegen-arm.cc b/src/full-codegen/arm/full-codegen-arm.cc
index cac5e6e7c3c9057cb9c2be61cdfd28efbc10bb5e..3faab7bf19f3b3edc14e4ddbe6c7169310688923 100644
--- a/src/full-codegen/arm/full-codegen-arm.cc
+++ b/src/full-codegen/arm/full-codegen-arm.cc
@@ -1928,8 +1928,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(r1);
+ __ cmp(r1, Operand(Smi::FromInt(JSGeneratorObject::RETURN)));
+ __ b(ne, &resume);
+ __ push(result_register());
+ EmitCreateIteratorResult(true);
+ EmitUnwindBeforeReturn();
+ EmitReturnSequence();
__ bind(&suspend);
VisitForAccumulatorValue(expr->generator_object());
@@ -1957,9 +1966,6 @@ void FullCodeGenerator::VisitYield(Yield* expr) {
case Yield::kFinal: {
VisitForAccumulatorValue(expr->generator_object());
- __ mov(r1, Operand(Smi::FromInt(JSGeneratorObject::kGeneratorClosed)));
- __ str(r1, FieldMemOperand(result_register(),
- JSGeneratorObject::kContinuationOffset));
// Pop value from top-of-stack slot, box result into result register.
EmitCreateIteratorResult(true);
EmitUnwindBeforeReturn();
@@ -2003,6 +2009,10 @@ void FullCodeGenerator::VisitYield(Yield* expr) {
__ jmp(&l_suspend);
__ bind(&l_continuation);
__ RecordGeneratorContinuation();
+ __ pop(r1);
+ // 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);
@@ -2148,6 +2158,7 @@ void FullCodeGenerator::EmitGeneratorResume(Expression *generator,
__ add(r3, r3, r2);
__ mov(r2, Operand(Smi::FromInt(JSGeneratorObject::kGeneratorExecuting)));
__ str(r2, FieldMemOperand(r1, JSGeneratorObject::kContinuationOffset));
+ __ Push(Smi::FromInt(resume_mode)); // Consumed in continuation.
__ Jump(r3);
}
__ bind(&slow_resume);
@@ -2162,6 +2173,7 @@ void FullCodeGenerator::EmitGeneratorResume(Expression *generator,
__ push(r2);
__ b(&push_operand_holes);
__ bind(&call_resume);
+ __ Push(Smi::FromInt(resume_mode)); // Consumed in continuation.
DCHECK(!result_register().is(r1));
__ Push(r1, result_register());
__ Push(Smi::FromInt(resume_mode));
« no previous file with comments | « src/compiler/ast-graph-builder.cc ('k') | src/full-codegen/arm64/full-codegen-arm64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698