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

Unified Diff: src/full-codegen/arm64/full-codegen-arm64.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/full-codegen/arm/full-codegen-arm.cc ('k') | src/full-codegen/full-codegen.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/full-codegen/arm64/full-codegen-arm64.cc
diff --git a/src/full-codegen/arm64/full-codegen-arm64.cc b/src/full-codegen/arm64/full-codegen-arm64.cc
index 3ebd627b93d2aca976e81e5630a406df8c02d170..a9482046d85489a1faa3206954b9f48992db5047 100644
--- a/src/full-codegen/arm64/full-codegen-arm64.cc
+++ b/src/full-codegen/arm64/full-codegen-arm64.cc
@@ -4355,8 +4355,17 @@ void FullCodeGenerator::VisitYield(Yield* expr) {
// looks at its pos(). Is it possible to do something more efficient here,
// perhaps using Adr?
__ 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();
- __ B(&resume);
+ __ Pop(x1);
+ __ Cmp(x1, Smi::FromInt(JSGeneratorObject::RETURN));
+ __ B(ne, &resume);
+ __ Push(result_register());
+ EmitCreateIteratorResult(true);
+ EmitUnwindBeforeReturn();
+ EmitReturnSequence();
__ Bind(&suspend);
VisitForAccumulatorValue(expr->generator_object());
@@ -4384,9 +4393,6 @@ void FullCodeGenerator::VisitYield(Yield* expr) {
case Yield::kFinal: {
VisitForAccumulatorValue(expr->generator_object());
- __ Mov(x1, Smi::FromInt(JSGeneratorObject::kGeneratorClosed));
- __ Str(x1, FieldMemOperand(result_register(),
- JSGeneratorObject::kContinuationOffset));
// Pop value from top-of-stack slot, box result into result register.
EmitCreateIteratorResult(true);
EmitUnwindBeforeReturn();
@@ -4433,6 +4439,10 @@ void FullCodeGenerator::VisitYield(Yield* expr) {
// perhaps using Adr?
__ Bind(&l_continuation);
__ RecordGeneratorContinuation();
+ __ pop(x1);
+ // 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.
__ B(&l_resume);
__ Bind(&l_suspend);
@@ -4580,6 +4590,7 @@ void FullCodeGenerator::EmitGeneratorResume(Expression *generator,
__ Mov(x12, Smi::FromInt(JSGeneratorObject::kGeneratorExecuting));
__ Str(x12, FieldMemOperand(generator_object,
JSGeneratorObject::kContinuationOffset));
+ __ Push(Smi::FromInt(resume_mode)); // Consumed in continuation.
__ Br(x10);
__ Bind(&slow_resume);
@@ -4590,6 +4601,7 @@ void FullCodeGenerator::EmitGeneratorResume(Expression *generator,
__ PushMultipleTimes(the_hole, operand_stack_size);
__ Mov(x10, Smi::FromInt(resume_mode));
+ __ Push(Smi::FromInt(resume_mode)); // Consumed in continuation.
__ Push(generator_object, result_register(), x10);
__ CallRuntime(Runtime::kResumeJSGeneratorObject);
// Not reached: the runtime call returns elsewhere.
« no previous file with comments | « src/full-codegen/arm/full-codegen-arm.cc ('k') | src/full-codegen/full-codegen.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698