diff options
author | Gaming4JC <g4jc@hyperbola.info> | 2019-12-14 10:30:54 -0500 |
---|---|---|
committer | Gaming4JC <g4jc@hyperbola.info> | 2019-12-17 06:25:29 -0500 |
commit | 8886df0c133f1c26b7a6b90bea535c690283a05c (patch) | |
tree | ff90c1f5c04d410a9ff706c3767869de96d3259d /js/src/frontend | |
parent | c8a39577f3e117ad131dee1674258b15d6d7b39f (diff) | |
download | uxp-8886df0c133f1c26b7a6b90bea535c690283a05c.tar.gz |
Bug 1379525 - Part 1: Await on the value before yielding or returning inside async generator.
Tag mcp-graveyard/UXP#1287
Diffstat (limited to 'js/src/frontend')
-rw-r--r-- | js/src/frontend/BytecodeEmitter.cpp | 30 |
1 files changed, 21 insertions, 9 deletions
diff --git a/js/src/frontend/BytecodeEmitter.cpp b/js/src/frontend/BytecodeEmitter.cpp index f629c86e53..4710ab8e63 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; |