summaryrefslogtreecommitdiffstats
path: root/js/src/frontend/BytecodeEmitter.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'js/src/frontend/BytecodeEmitter.cpp')
-rw-r--r--js/src/frontend/BytecodeEmitter.cpp30
1 files changed, 21 insertions, 9 deletions
diff --git a/js/src/frontend/BytecodeEmitter.cpp b/js/src/frontend/BytecodeEmitter.cpp
index f629c86e5..4710ab8e6 100644
--- a/js/src/frontend/BytecodeEmitter.cpp
+++ b/js/src/frontend/BytecodeEmitter.cpp
@@ -8578,6 +8578,13 @@ BytecodeEmitter::emitReturn(ParseNode* pn)
if (ParseNode* pn2 = pn->pn_kid) {
if (!emitTree(pn2))
return false;
+
+ bool isAsyncGenerator = sc->asFunctionBox()->isAsync() &&
+ sc->asFunctionBox()->isStarGenerator();
+ if (isAsyncGenerator) {
+ if (!emitAwait())
+ return false;
+ }
} else {
/* No explicit return value provided */
if (!emit1(JSOP_UNDEFINED))
@@ -8690,6 +8697,14 @@ BytecodeEmitter::emitYield(ParseNode* pn)
if (!emit1(JSOP_UNDEFINED))
return false;
}
+
+ // 11.4.3.7 AsyncGeneratorYield step 5.
+ bool isAsyncGenerator = sc->asFunctionBox()->isAsync();
+ if (isAsyncGenerator) {
+ if (!emitAwait()) // RESULT
+ return false;
+ }
+
if (needsIteratorResult) {
if (!emitFinishIteratorResult(false))
return false;
@@ -8762,6 +8777,12 @@ BytecodeEmitter::emitYieldStar(ParseNode* iter)
MOZ_ASSERT(this->stackDepth == startDepth);
+ // 11.4.3.7 AsyncGeneratorYield step 5.
+ if (isAsyncGenerator) {
+ if (!emitAwait()) // ITER RESULT
+ return false;
+ }
+
// Load the generator object.
if (!emitGetDotGenerator()) // ITER RESULT GENOBJ
return false;
@@ -8910,10 +8931,6 @@ BytecodeEmitter::emitYieldStar(ParseNode* iter)
return false;
if (!emitAtomOp(cx->names().value, JSOP_GETPROP)) // ITER OLDRESULT FTYPE FVALUE VALUE
return false;
- if (isAsyncGenerator) {
- if (!emitAwait()) // ITER OLDRESULT FTYPE FVALUE VALUE
- return false;
- }
if (!emitPrepareIteratorResult()) // ITER OLDRESULT FTYPE FVALUE VALUE RESULT
return false;
if (!emit1(JSOP_SWAP)) // ITER OLDRESULT FTYPE FVALUE RESULT VALUE
@@ -9006,11 +9023,6 @@ BytecodeEmitter::emitYieldStar(ParseNode* iter)
if (!emitAtomOp(cx->names().value, JSOP_GETPROP)) // VALUE
return false;
- if (isAsyncGenerator) {
- if (!emitAwait()) // VALUE
- return false;
- }
-
MOZ_ASSERT(this->stackDepth == startDepth - 1);
return true;