Closed Bug 1978510 Opened 23 days ago Closed 21 days ago

Update async generator implementation to the latest spec

Categories

(Core :: JavaScript Engine, task, P3)

task

Tracking

()

RESOLVED FIXED
143 Branch
Tracking Status
firefox143 --- fixed

People

(Reporter: arai, Assigned: arai)

References

(Blocks 1 open bug)

Details

Attachments

(17 files)

48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review

In the same way as bug 1724123, we need to update the implementation to match the latest spec again.

Blocks: 1978512
Blocks: sm-runtime
No longer blocks: 1978512
Blocks: 1978512
Severity: -- → N/A
Priority: -- → P3

Handling the special states is not AsyncGeneratorDrainQueue's responsibility,
and also some consumers already filter out those states.

"completed" state has two separate internal states.

One is where there's no request in the queue.
This maps to the updated spec's "completed" state.

The other is where there are some requests in the queue, and those requests
are going to be drained in upcoming AsyncGeneratorDrainQueue.
This maps to the updated spec's "draining-queue" state.

In the former case, if .next/.throw/.return is called, a new request for them
will be immediately processed.

In the latter case, if .next/.throw/.return is called before draining the
existing requests, which means those calls are performed inside
AsyncGeneratorDrainQueue, as a side-effect of promise handling.
Those calls will enqueue the request and then perform another
AsyncGeneratorDrainQueue, and all requests will be processed there.

This is actually the same situation as just enqueueing and not performing
another AsyncGeneratorDrainQueue. The next patch will remove the
AsyncGeneratorDrainQueue call.

The AsyncGeneratorDrainQueue call for the completed+non-empty-queue happens
only as a part of side-effect of promise handling which is performed
during AsyncGeneratorDrainQueue.

The requests will be handled by the outer AsyncGeneratorDrainQueue.

This patch just inlines the AsyncGeneratorDrainQueue code to each consumer,
with slight modification for the return statements.

The subsequent patches will simplify each case.

Each consumer has specific situation, where the loop and some branches can be
removed.

This is unobservable change.

This makes the else-branch match the updated spec.
The then-branch's state transition is not part of the spec, but the state
will be overwritten immediately.

This makes one of AsyncGeneratorUnwrapYieldResumption consumer to match the
updated spec.

The other consumer will be rewritten in later patch.

The state is going to immediately be overwritten to either:

  • AwaitingYieldReturn if completionKind is Return, or
  • Executing otherwise

The request enqueued in the "Completed+empty-queue" case will be immediately
dequeued and processed.
This patch removes the queue+dequeue and let each case directly pass the
completeion.

This is another consumer of AsyncGeneratorUnwrapYieldResumption,
which is added in earlier patch.

Now all consumers of AsyncGeneratorDrainQueue sets the state to "completed"
before entering AsyncGeneratorDrainQueue, and
"suspended-start" and "suspended-yield" states don't reach there,
even with side-effects.

This modifies the existing states in the following ways:

  • Completed (empty queue) -> Completed
  • Completed (non-empty queue) -> DrainingQueue
  • AwaitingYieldReturn -> Executing_AwaitingYieldReturn
  • AwaitingReturn -> DrainingQueue_AwaitingReturn

The latter 2 are not part of the updated spec, but they're our
implementation-defined state, to reflect the state during the Await calls.

Pushed by arai_a@mac.com: https://github.com/mozilla-firefox/firefox/commit/2a6521c849ca https://hg.mozilla.org/integration/autoland/rev/e16f2e94fafb Part 1: Update spec step comments, with FIXME comments for mismatching parts. r=mgaudet https://github.com/mozilla-firefox/firefox/commit/8c329787536d https://hg.mozilla.org/integration/autoland/rev/d41df4292f15 Part 2: Move early-return out of AsyncGeneratorDrainQueue. r=mgaudet https://github.com/mozilla-firefox/firefox/commit/5bf90680fdf9 https://hg.mozilla.org/integration/autoland/rev/3777ca63a7d2 Part 3: Simplify the loop in AsyncGeneratorDrainQueue. r=mgaudet https://github.com/mozilla-firefox/firefox/commit/c31f0f55cb32 https://hg.mozilla.org/integration/autoland/rev/a381c7ee6bf3 Part 4: Split the branches for AsyncGeneratorDrainQueue caller to match the spec. r=mgaudet https://github.com/mozilla-firefox/firefox/commit/bdbc3398e150 https://hg.mozilla.org/integration/autoland/rev/93f5b5332d86 Part 5: Do not re-enter AsyncGeneratorDrainQueue in completed state. r=mgaudet https://github.com/mozilla-firefox/firefox/commit/fc2ff6359aad https://hg.mozilla.org/integration/autoland/rev/9044d687cf06 Part 6: Inline AsyncGeneratorDrainQueue. r=mgaudet https://github.com/mozilla-firefox/firefox/commit/7c91b971f88a https://hg.mozilla.org/integration/autoland/rev/69a84ced2945 Part 7: Remove unused branches. r=mgaudet https://github.com/mozilla-firefox/firefox/commit/f872a5fb3bad https://hg.mozilla.org/integration/autoland/rev/13b3d1aadb36 Part 8: Move setSuspendedYield call to each branch. r=mgaudet https://github.com/mozilla-firefox/firefox/commit/fcf093b9e195 https://hg.mozilla.org/integration/autoland/rev/b1a0f12ba781 Part 9: Add AsyncGeneratorUnwrapYieldResumption. r=mgaudet https://github.com/mozilla-firefox/firefox/commit/b4a22b5cd912 https://hg.mozilla.org/integration/autoland/rev/0670b4a44063 Part 10: Move comments for AsyncGeneratorYield. r=mgaudet https://github.com/mozilla-firefox/firefox/commit/802690f99d03 https://hg.mozilla.org/integration/autoland/rev/aafd77ab2a2c Part 11: Remove unnecessary state transition. r=mgaudet https://github.com/mozilla-firefox/firefox/commit/52749339e160 https://hg.mozilla.org/integration/autoland/rev/ff097c4cc4de Part 12: Optimize out enqueue+dequeue. r=mgaudet https://github.com/mozilla-firefox/firefox/commit/d2bd290d337a https://hg.mozilla.org/integration/autoland/rev/b36d99d371a1 Part 13: Use AsyncGeneratorUnwrapYieldResumption in AsyncGeneratorReturn. r=mgaudet https://github.com/mozilla-firefox/firefox/commit/7eb33617b89a https://hg.mozilla.org/integration/autoland/rev/70a42de5f414 Part 14: Move comments for AsyncGeneratorNext/AsyncGeneratorReturn/AsyncGeneratorThrow. r=mgaudet https://github.com/mozilla-firefox/firefox/commit/01d1f1193939 https://hg.mozilla.org/integration/autoland/rev/75536f7a0080 Part 15: Remove suspended-start and suspended-yield cases from AsyncGeneratorDrainQueue. r=mgaudet https://github.com/mozilla-firefox/firefox/commit/9d7c1fb671dc https://hg.mozilla.org/integration/autoland/rev/ce5019292a43 Part 16: Update the [[AsyncGeneratorState]] variants. r=mgaudet https://github.com/mozilla-firefox/firefox/commit/580d0755219f https://hg.mozilla.org/integration/autoland/rev/940a04fd8ade Part 17: Update SMDOC for async generator. r=mgaudet
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: