Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Normative: Reduce the number of ticks in async/await #1250

Merged
merged 3 commits into from
Feb 26, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 11 additions & 14 deletions spec.html
Original file line number Diff line number Diff line change
Expand Up @@ -2990,22 +2990,21 @@ <h1>Await</h1>
<p>Algorithm steps that say</p>

<emu-alg>
1. Let _completion_ be Await(_promise_).
1. Let _completion_ be Await(_value_).
</emu-alg>

<p>mean the same thing as:</p>

<emu-alg>
1. Let _asyncContext_ be the running execution context.
1. Let _promiseCapability_ be ! NewPromiseCapability(%Promise%).
1. Perform ! Call(_promiseCapability_.[[Resolve]], *undefined*, &laquo; _promise_ &raquo;).
1. Let _promise_ be ? PromiseResolve(%Promise%, &laquo; _value_ &raquo;).
1. Let _stepsFulfilled_ be the algorithm steps defined in <emu-xref href="#await-fulfilled" title></emu-xref>.
1. Let _onFulfilled_ be CreateBuiltinFunction(_stepsFulfilled_, &laquo; [[AsyncContext]] &raquo;).
1. Set _onFulfilled_.[[AsyncContext]] to _asyncContext_.
1. Let _stepsRejected_ be the algorithm steps defined in <emu-xref href="#await-rejected" title></emu-xref>.
1. Let _onRejected_ be CreateBuiltinFunction(_stepsRejected_, &laquo; [[AsyncContext]] &raquo;).
1. Set _onRejected_.[[AsyncContext]] to _asyncContext_.
1. Perform ! PerformPromiseThen(_promiseCapability_.[[Promise]], _onFulfilled_, _onRejected_).
1. Perform ! PerformPromiseThen(_promise_, _onFulfilled_, _onRejected_).
1. Remove _asyncContext_ from the execution context stack and restore the execution context that is at the top of the execution context stack as the running execution context.
1. Set the code evaluation state of _asyncContext_ such that when evaluation is resumed with a Completion _completion_, the following steps of the algorithm that invoked Await will be performed, with _completion_ available.
1. Return.
Expand All @@ -3018,14 +3017,14 @@ <h1>Await</h1>
<p>Await can be combined with the `?` and `!` prefixes, so that for example</p>

<emu-alg>
1. Let _value_ be ? Await(_promise_).
1. Let _result_ be ? Await(_value_).
</emu-alg>

<p>means the same thing as:</p>

<emu-alg>
1. Let _value_ be Await(_promise_).
1. ReturnIfAbrupt(_value_).
1. Let _result_ be Await(_value_).
1. ReturnIfAbrupt(_result_).
</emu-alg>
</emu-note>

Expand Down Expand Up @@ -36901,20 +36900,19 @@ <h1>Properties of Async-from-Sync Iterator Instances</h1>
</emu-table>
</emu-clause>

<emu-clause id="sec-async-from-sync-iterator-continuation" aoid="AsyncFromSyncIteratorContinuation">
<emu-clause id="sec-asyncfromsynciteratorcontinuation" aoid="AsyncFromSyncIteratorContinuation">
<h1>AsyncFromSyncIteratorContinuation ( _result_, _promiseCapability_ )</h1>

<emu-alg>
1. Let _done_ be IteratorComplete(_result_).
1. IfAbruptRejectPromise(_done_, _promiseCapability_).
1. Let _value_ be IteratorValue(_result_).
1. IfAbruptRejectPromise(_value_, _promiseCapability_).
1. Let _valueWrapperCapability_ be ! NewPromiseCapability(%Promise%).
1. Perform ! Call(_valueWrapperCapability_.[[Resolve]], *undefined*, &laquo; _value_ &raquo;).
1. Let _valueWrapper_ be ? PromiseResolve(%Promise%, &laquo; _value_ &raquo;).
1. Let _steps_ be the algorithm steps defined in <emu-xref href="#sec-async-from-sync-iterator-value-unwrap-functions" title></emu-xref>.
1. Let _onFulfilled_ be CreateBuiltinFunction(_steps_, &laquo; [[Done]] &raquo;).
1. Set _onFulfilled_.[[Done]] to _done_.
1. Perform ! PerformPromiseThen(_valueWrapperCapability_.[[Promise]], _onFulfilled_, *undefined*, _promiseCapability_).
1. Perform ! PerformPromiseThen(_valueWrapper_, _onFulfilled_, *undefined*, _promiseCapability_).
1. Return _promiseCapability_.[[Promise]].
</emu-alg>
</emu-clause>
Expand Down Expand Up @@ -37535,15 +37533,14 @@ <h1>AsyncGeneratorResumeNext ( _generator_ )</h1>
1. If _state_ is `"completed"`, then
1. If _completion_.[[Type]] is ~return~, then
1. Set _generator_.[[AsyncGeneratorState]] to `"awaiting-return"`.
1. Let _promiseCapability_ be ! NewPromiseCapability(%Promise%).
1. Perform ! Call(_promiseCapability_.[[Resolve]], *undefined*, &laquo; _completion_.[[Value]] &raquo;).
1. Let _promise_ be ? PromiseResolve(%Promise%, &laquo; _completion_.[[Value]] &raquo;).
1. Let _stepsFulfilled_ be the algorithm steps defined in <emu-xref href="#async-generator-resume-next-return-processor-fulfilled" title></emu-xref>.
1. Let _onFulfilled_ be CreateBuiltinFunction(_stepsFulfilled_, &laquo; [[Generator]] &raquo;).
1. Set _onFulfilled_.[[Generator]] to _generator_.
1. Let _stepsRejected_ be the algorithm steps defined in <emu-xref href="#async-generator-resume-next-return-processor-rejected" title></emu-xref>.
1. Let _onRejected_ be CreateBuiltinFunction(_stepsRejected_, &laquo; [[Generator]] &raquo;).
1. Set _onRejected_.[[Generator]] to _generator_.
1. Perform ! PerformPromiseThen(_promiseCapability_.[[Promise]], _onFulfilled_, _onRejected_).
1. Perform ! PerformPromiseThen(_promise_, _onFulfilled_, _onRejected_).
1. Return *undefined*.
1. Else,
1. Assert: _completion_.[[Type]] is ~throw~.
Expand Down