Skip to content

Commit

Permalink
Normative: Flush Job Queue between module imports
Browse files Browse the repository at this point in the history
  • Loading branch information
littledan committed Feb 22, 2019
1 parent a5abd8d commit a449e37
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions spec.html
Original file line number Diff line number Diff line change
Expand Up @@ -370,11 +370,9 @@ <h1>InnerModuleEvaluation( _module_, _stack_, _index_ )</h1>
1. If _requiredModule_.[[Status]] is `"evaluating"`, then
1. Assert: _requiredModule_ is a Source Text Module Record.
1. Set _module_.[[DFSAncestorIndex]] to min(_module_.[[DFSAncestorIndex]], _requiredModule_.[[DFSAncestorIndex]]).
1. <ins>Let _stackErrorCapability_ be ! NewPromiseCapability(%Promise%).</ins>
1. <ins>Perform ! PerformPromiseThen(_requiredModule_.[[ExecPromise]], *undefined*, _stackErrorCapability_.[[Reject]]).</ins>
1. <ins>Add _stackErrorCapability_ to the list _dependencyExecPromises_.</ins>
1. <del>Perform ? ModuleExecution(_module_).</del>
1. <ins>Perform ! ExecuteModuleWhenImportsReady(_module_, _dependencyExecPromises_, _evalCapability_).</ins>
1. <ins>Perform ! FlushJobs().</ins>
1. Assert: _module_ occurs exactly once in _stack_.
1. Assert: _module_.[[DFSAncestorIndex]] is less than or equal to _module_.[[DFSIndex]].
1. If _module_.[[DFSAncestorIndex]] equals _module_.[[DFSIndex]], then
Expand All @@ -384,6 +382,7 @@ <h1>InnerModuleEvaluation( _module_, _stack_, _index_ )</h1>
1. Remove the last element of _stack_.
1. Set _requiredModule_.[[Status]] to `"evaluated"`.
1. If _requiredModule_ and _module_ are the same Module Record, set _done_ to *true*.
1. <ins>Otherwise, set _requiredModule_.[[ExecPromise]] to _module_.[[ExecPromise]].</ins>
1. Return _index_.
</emu-alg>
<emu-note>
Expand Down Expand Up @@ -508,6 +507,20 @@ <h1>Runtime Semantics: TopLevelModuleEvaluationJob ( _sourceText_, _hostDefined_
<p>An implementation may parse a _sourceText_ as a |Module|, analyse it for Early Error conditions, and instantiate it prior to the execution of the TopLevelModuleEvaluationJob for that _sourceText_. An implementation may also resolve, pre-parse and pre-analyse, and pre-instantiate module dependencies of _sourceText_. However, the reporting of any errors detected by these actions must be deferred until the TopLevelModuleEvaluationJob is actually executed.</p>
</emu-note>
</emu-clause>

<emu-clause id="sec-flushjobs" aoid="FlushJobs">
<h1>FlushJobs ( )</h1>
<emu-alg>
1. Assert: There is no running execution context.
1. Yield control to the RunJobs algorithm.
1. When RunJobs has no more jobs to run, return from this algorithm.
</emu-alg>
<emu-note type=editor>
<p>This algorithm completes asynchronously, but is to be used synchronously within a larger ECMAScript algorithm. For this reason, it may only be called when there is no running execution context.</p>
<p>HTML and ECMAScript have different notions of how the Job Queue works, with HTML employing a willful violation to describe the layering; see <a href="https://html.spec.whatwg.org/#integration-with-the-javascript-job-queue">Integration with the JavaScript job queue</a> for details.See <a href="https://github.com/tc39/ecma262/pull/735">#735</a> for one approach to improving the layering. Until some kind of fix in this area occurs, this proposal sticks with the "willful violation" layering approach.</p>
<p>In the HTML context, the FlushJobs() algorithm would be replaced, via a willful violation, with the <a href="https://html.spec.whatwg.org/#perform-a-microtask-checkpoint">perform a microtask checkpoint</a> algorithm</p>
</emu-note>
</emu-clause>
</emu-clause>

<emu-clause id="sec-modules">
Expand Down

0 comments on commit a449e37

Please sign in to comment.