summaryrefslogtreecommitdiffstats
path: root/js/src/frontend
diff options
context:
space:
mode:
authorGaming4JC <g4jc@hyperbola.info>2019-12-14 10:30:54 -0500
committerGaming4JC <g4jc@hyperbola.info>2019-12-17 06:25:29 -0500
commit38c1d558afd03d61bd9932032f47d9c36f177b08 (patch)
treeff90c1f5c04d410a9ff706c3767869de96d3259d /js/src/frontend
parentdd1cbde1569e823e5e76e8c3ef0ecba66408719d (diff)
downloadUXP-38c1d558afd03d61bd9932032f47d9c36f177b08.tar
UXP-38c1d558afd03d61bd9932032f47d9c36f177b08.tar.gz
UXP-38c1d558afd03d61bd9932032f47d9c36f177b08.tar.lz
UXP-38c1d558afd03d61bd9932032f47d9c36f177b08.tar.xz
UXP-38c1d558afd03d61bd9932032f47d9c36f177b08.zip
Bug 1379525 - Part 1: Await on the value before yielding or returning inside async generator.
Tag #1287
Diffstat (limited to 'js/src/frontend')
-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;