From a449e370738af8f6bf69735694a5b5ec6dea9e12 Mon Sep 17 00:00:00 2001 From: Daniel Ehrenberg Date: Fri, 22 Feb 2019 17:58:56 +0100 Subject: [PATCH] Normative: Flush Job Queue between module imports Closes #47, #43, #48, #50 --- spec.html | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/spec.html b/spec.html index 4d884db..85a0f2d 100644 --- a/spec.html +++ b/spec.html @@ -370,11 +370,9 @@

InnerModuleEvaluation( _module_, _stack_, _index_ )

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. Let _stackErrorCapability_ be ! NewPromiseCapability(%Promise%). - 1. Perform ! PerformPromiseThen(_requiredModule_.[[ExecPromise]], *undefined*, _stackErrorCapability_.[[Reject]]). - 1. Add _stackErrorCapability_ to the list _dependencyExecPromises_. 1. Perform ? ModuleExecution(_module_). 1. Perform ! ExecuteModuleWhenImportsReady(_module_, _dependencyExecPromises_, _evalCapability_). + 1. Perform ! FlushJobs(). 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 @@ -384,6 +382,7 @@

InnerModuleEvaluation( _module_, _stack_, _index_ )

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. Otherwise, set _requiredModule_.[[ExecPromise]] to _module_.[[ExecPromise]]. 1. Return _index_. @@ -508,6 +507,20 @@

Runtime Semantics: TopLevelModuleEvaluationJob ( _sourceText_, _hostDefined_

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.

+ + +

FlushJobs ( )

+ + 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. + + +

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.

+

HTML and ECMAScript have different notions of how the Job Queue works, with HTML employing a willful violation to describe the layering; see Integration with the JavaScript job queue for details.See #735 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.

+

In the HTML context, the FlushJobs() algorithm would be replaced, via a willful violation, with the perform a microtask checkpoint algorithm

+
+