@@ -123,7 +123,7 @@ <h1>Agents</h1>
123123 <ins >a List of Async Context Mapping Records</ins >
124124 </td >
125125 <td >
126- <ins >A map from the AsyncContext.Variable instances to the saved ECMAScript language value. Every Record in the List contains a unique [[AsyncContextKey]]. The map is initially empty .</ins >
126+ <ins >A map from the AsyncContext.Variable instances to the saved ECMAScript language value. Every Record in the List contains a unique [[AsyncContextKey]]. The map is initially the return value of HostGetTopLevelAsyncContextMapping( *null* ) .</ins >
127127 </td >
128128 </tr >
129129 </table >
@@ -255,6 +255,59 @@ <h1>
255255 </emu-clause >
256256</emu-clause >
257257
258+ <emu-clause id =" sec-ecmascript-language-scripts-and-modules" >
259+ <h1 >ECMAScript Language: Scripts and Modules</h1 >
260+
261+ <emu-clause id =" sec-modules" >
262+ <h1 >Modules</h1 >
263+
264+ <emu-clause id =" sec-module-semantics" >
265+ <h1 >Module Semantics</h1 >
266+
267+ <emu-clause id =" sec-source-text-module-records" >
268+ <h1 >Source Text Module Records</h1 >
269+ <emu-clause id =" sec-source-text-module-record-execute-module" type =" concrete method" >
270+ <h1 >
271+ ExecuteModule (
272+ optional _capability_ : a PromiseCapability Record,
273+ ): either a normal completion containing ~unused~ or a throw completion
274+ </h1 >
275+ <dl class =" header" >
276+ <dt >for</dt >
277+ <dd >a Source Text Module Record _module_ </dd >
278+ </dl >
279+
280+ <emu-alg >
281+ 1. Let _moduleContext_ be a new ECMAScript code execution context.
282+ 1. Set the Function of _moduleContext_ to *null* .
283+ 1. Set the Realm of _moduleContext_ to _module_ .[[Realm]].
284+ 1. Set the ScriptOrModule of _moduleContext_ to _module_ .
285+ 1. Assert: _module_ has been linked and declarations in its module environment have been instantiated.
286+ 1. Set the VariableEnvironment of _moduleContext_ to _module_ .[[Environment]].
287+ 1. Set the LexicalEnvironment of _moduleContext_ to _module_ .[[Environment]].
288+ 1. Suspend the running execution context.
289+ 1. <ins >Let _previousContextMapping_ be AsyncContextSwap(HostGetTopLevelAsyncContextMapping(_module_ )).</ins >
290+ 1. If _module_ .[[HasTLA]] is *false* , then
291+ 1. Assert: _capability_ is not present.
292+ 1. Push _moduleContext_ onto the execution context stack; _moduleContext_ is now the running execution context.
293+ 1. Let _result_ be Completion(Evaluation of _module_ .[[ECMAScriptCode]]).
294+ 1. <ins >AsyncContextSwap(_previousContextMapping_ ).</ins >
295+ 1. Suspend _moduleContext_ and remove it from the execution context stack.
296+ 1. Resume the context that is now on the top of the execution context stack as the running execution context.
297+ 1. If _result_ is an abrupt completion, then
298+ 1. Return ? _result_ .
299+ 1. Else,
300+ 1. Assert: _capability_ is a PromiseCapability Record.
301+ 1. Perform AsyncBlockStart(_capability_ , _module_ .[[ECMAScriptCode]], _moduleContext_ ).
302+ 1. <ins >AsyncContextSwap(_previousContextMapping_ ).</ins >
303+ 1. Return ~unused~ .
304+ </emu-alg >
305+ </emu-clause >
306+ </emu-clause >
307+ </emu-clause >
308+ </emu-clause >
309+ </emu-clause >
310+
258311<emu-clause id =" sec-control-abstraction-objects" >
259312 <h1 >Control Abstraction Objects</h1 >
260313
@@ -936,6 +989,30 @@ <h1>The AsyncContext Object</h1>
936989
937990 <emu-clause id =" sec-asynccontext-abstract-operations" >
938991 <h1 >AsyncContext Abstract Operations</h1 >
992+
993+ <emu-clause id =" sec-hostgettoplevelasynccontextmapping" type =" abstract operation" >
994+ <h1 >
995+ HostGetTopLevelAsyncContextMapping (
996+ _module_ : a Module Record or *null*
997+ ): a List of Async Context Mapping Records</h1 >
998+ <dl class =" header" >
999+ <dt >description</dt >
1000+ <dd >It allows hosts to provide the top level async context mapping.</dd >
1001+ </dl >
1002+ <p >An implementation of HostGetTopLevelAsyncContextMapping must conform to the following requirements:</p >
1003+ <ul >
1004+ <li >It must return a List of Async Context Mapping Records.</li >
1005+ <li >The result List must contain the same Async Context Mapping Records for a given module record.</li >
1006+ </ul >
1007+ <p >The default implementation of HostGetTopLevelAsyncContextMapping performs the following steps when called:</p >
1008+ <emu-alg >
1009+ 1. Return a new empty List.
1010+ </emu-alg >
1011+ <emu-note >
1012+ <p >ECMAScript hosts may add host defined async context mapping entries to the list.</p >
1013+ </emu-note >
1014+ </emu-clause >
1015+
9391016 <emu-clause id =" sec-asynccontextsnapshot" type =" abstract operation" >
9401017 <h1 >
9411018 AsyncContextSnapshot (
@@ -1358,3 +1435,27 @@ <h1>FinalizationRegistry ( _cleanupCallback_ )</h1>
13581435 </emu-clause >
13591436 </emu-clause >
13601437</emu-clause >
1438+
1439+ <emu-annex id =" sec-host-layering-points" >
1440+ <h1 >Host Layering Points</h1 >
1441+
1442+ <emu-annex id =" sec-host-hooks-summary" >
1443+ <h1 >Host Hooks</h1 >
1444+ <p ><b >HostCallJobCallback(...)</b ></p >
1445+ <p ><b >HostEnqueueFinalizationRegistryCleanupJob(...)</b ></p >
1446+ <p ><b >HostEnqueueGenericJob(...)</b ></p >
1447+ <p ><b >HostEnqueuePromiseJob(...)</b ></p >
1448+ <p ><b >HostEnqueueTimeoutJob(...)</b ></p >
1449+ <p ><b >HostEnsureCanCompileStrings(...)</b ></p >
1450+ <p ><b >HostFinalizeImportMeta(...)</b ></p >
1451+ <p ><b >HostGetImportMetaProperties(...)</b ></p >
1452+ <p ><b ><ins >HostGetTopLevelAsyncContextMapping(...)</ins ></b ></p >
1453+ <p ><b >HostGrowSharedArrayBuffer(...)</b ></p >
1454+ <p ><b >HostHasSourceTextAvailable(...)</b ></p >
1455+ <p ><b >HostLoadImportedModule(...)</b ></p >
1456+ <p ><b >HostMakeJobCallback(...)</b ></p >
1457+ <p ><b >HostPromiseRejectionTracker(...)</b ></p >
1458+ <p ><b >HostResizeArrayBuffer(...)</b ></p >
1459+ <p ><b >InitializeHostDefinedRealm(...)</b ></p >
1460+ </emu-annex >
1461+ </emu-annex >
0 commit comments