Skip to content

Commit d445857

Browse files
committed
Define module root level context
1 parent eadad3d commit d445857

File tree

1 file changed

+97
-1
lines changed

1 file changed

+97
-1
lines changed

spec.html

+97-1
Original file line numberDiff line numberDiff line change
@@ -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,25 @@ <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 for a given module record.</dd>
1001+
</dl>
1002+
<p>The default implementation of HostGetTopLevelAsyncContextMapping performs the following steps when called:</p>
1003+
<emu-alg>
1004+
1. Return a new empty List.
1005+
</emu-alg>
1006+
<emu-note>
1007+
<p>ECMAScript hosts may add host defined async context mapping entries to the list.</p>
1008+
</emu-note>
1009+
</emu-clause>
1010+
9391011
<emu-clause id="sec-asynccontextsnapshot" type="abstract operation">
9401012
<h1>
9411013
AsyncContextSnapshot (
@@ -1358,3 +1430,27 @@ <h1>FinalizationRegistry ( _cleanupCallback_ )</h1>
13581430
</emu-clause>
13591431
</emu-clause>
13601432
</emu-clause>
1433+
1434+
<emu-annex id="sec-host-layering-points">
1435+
<h1>Host Layering Points</h1>
1436+
1437+
<emu-annex id="sec-host-hooks-summary">
1438+
<h1>Host Hooks</h1>
1439+
<p><b>HostCallJobCallback(...)</b></p>
1440+
<p><b>HostEnqueueFinalizationRegistryCleanupJob(...)</b></p>
1441+
<p><b>HostEnqueueGenericJob(...)</b></p>
1442+
<p><b>HostEnqueuePromiseJob(...)</b></p>
1443+
<p><b>HostEnqueueTimeoutJob(...)</b></p>
1444+
<p><b>HostEnsureCanCompileStrings(...)</b></p>
1445+
<p><b>HostFinalizeImportMeta(...)</b></p>
1446+
<p><b>HostGetImportMetaProperties(...)</b></p>
1447+
<p><b><ins>HostGetTopLevelAsyncContextMapping(...)</ins></b></p>
1448+
<p><b>HostGrowSharedArrayBuffer(...)</b></p>
1449+
<p><b>HostHasSourceTextAvailable(...)</b></p>
1450+
<p><b>HostLoadImportedModule(...)</b></p>
1451+
<p><b>HostMakeJobCallback(...)</b></p>
1452+
<p><b>HostPromiseRejectionTracker(...)</b></p>
1453+
<p><b>HostResizeArrayBuffer(...)</b></p>
1454+
<p><b>InitializeHostDefinedRealm(...)</b></p>
1455+
</emu-annex>
1456+
</emu-annex>

0 commit comments

Comments
 (0)