Skip to content

Commit 6e393ee

Browse files
committed
wip
1 parent 1641b98 commit 6e393ee

File tree

4 files changed

+4
-164
lines changed

4 files changed

+4
-164
lines changed

document/core/appendix/embedding.rst

Lines changed: 0 additions & 97 deletions
Original file line numberDiff line numberDiff line change
@@ -137,37 +137,6 @@ Modules
137137
\F{module\_validate}(m) &=& \ERROR && (\otherwise) \\
138138
\end{array}
139139
140-
.. index:: matching, external type
141-
.. _embed-extern-subtype:
142-
143-
:math:`\F{module\_extern\_subtype}(\externtype_1, \externtype_2) : \bool`
144-
.........................................................................
145-
146-
1. If :math:`\externtype_1` and :math:`\externtype_2` are both of the form :math:`\ETFUNC~\functype_1` and :math:`\ETFUNC~\functype_2` respectively:
147-
148-
a. Return true if and only if :math:`\vdashexterntypematch \ETFUNC~\functype_1 \matchesexterntype \ETFUNC~\functype_2`.
149-
150-
2. If :math:`\externtype_1` and :math:`\externtype_2` are both of the form :math:`\ETTABLE~\tabletype_1` and :math:`\ETTABLE~\tabletype_2` respectively:
151-
152-
a. Return true if and only if :math:`\vdashexterntypematch \ETTABLE~\tabletype_1 \matchesexterntype \ETTABLE~\tabletype_2`.
153-
154-
3. If :math:`\externtype_1` and :math:`\externtype_2` are both of the form :math:`\ETMEM~\memtype_1` and :math:`\ETMEM~\memtype_2` respectively:
155-
156-
a. Return true if and only if :math:`\vdashexterntypematch \ETMEM~\memtype_1 \matchesexterntype \ETMEM~\memtype_2`.
157-
158-
4. If :math:`\externtype_1` and :math:`\externtype_2` are both of the form :math:`\ETGLOBAL~\globaltype_1` and :math:`\ETGLOBAL~\globaltype_2` respectively:
159-
160-
a. Return true if and only if :math:`\vdashexterntypematch \ETGLOBAL~\globaltype_1 \matchesexterntype \ETGLOBAL~\globaltype_2`.
161-
162-
5. Return false.
163-
164-
.. math::
165-
\begin{array}{lclll}
166-
\F{module\_extern\_subtype}(\externtype_1, \externtype_2) &\iff& \vdashexterntypematch \externtype_1 \matchesexterntype \externtype_2 \\
167-
\end{array}
168-
169-
.. note::
170-
This function encapsulates the external type matching relation defined in the :ref:`Import Subtyping <match>` of the validation section, where the :math:`\vdashexterntypematch \externtype_1 \matchesexterntype \externtype_2` judgment establishes compatibility between external types. This allows for explicit checking of type compatibility when linking modules or validating imports against exports.
171140
172141
.. index:: instantiation, module instance
173142
.. _embed-module-instantiate:
@@ -249,72 +218,6 @@ Modules
249218
\end{array}
250219
251220
252-
.. index:: direct export
253-
.. _embed-direct-exports:
254-
255-
:math:`\F{module\_direct\_exports}(\module) : (\name, \externtype)^\ast`
256-
........................................................................
257-
258-
1. Pre-condition: :math:`\module` is :ref:`valid <valid-module>` with external import types :math:`\externtype^\ast` and external export types :math:`{\externtype'}^\ast`.
259-
260-
2. Let :math:`\export^\ast` be the :ref:`exports <syntax-export>` :math:`\module.\MEXPORTS`.
261-
262-
3. Let :math:`\X{result}` be the empty sequence.
263-
264-
4. For each :math:`\export_i` in :math:`\export^\ast` and corresponding :math:`\externtype'_i` in :math:`{\externtype'}^\ast`, do:
265-
266-
a. Let :math:`\import_j = \edexportimport(\module, \export_i.\EDESC)`.
267-
268-
b. If :math:`\import_j = \epsilon`, then append the pair :math:`(\export_i.\ENAME, \externtype'_i)` to :math:`\X{result}`.
269-
270-
5. Return :math:`\X{result}`.
271-
272-
.. math::
273-
~ \\
274-
\begin{array}{lclll}
275-
\F{module\_direct\_exports}(m) &=& (\X{ex}.\ENAME, \externtype')^\ast \\
276-
&& \qquad (\iff \X{ex}^\ast = m.\MEXPORTS \\
277-
&& \qquad\quad \wedge~\edexportimport(m, \X{ex}.\EDESC) = \epsilon \\
278-
&& \qquad\quad \wedge~\vdashmodule m : \externtype^\ast \to {\externtype'}^\ast \\
279-
&& \qquad\quad \wedge~\externtype' = \X{ex}.\EDESC) \\
280-
\end{array}
281-
282-
283-
.. index:: indirect export, re-export
284-
.. _embed-indirect-exports:
285-
286-
:math:`\F{module\_indirect\_exports}(\module) : (\name, \name, \name)^\ast`
287-
...........................................................................
288-
289-
1. Pre-condition: :math:`\module` is :ref:`valid <valid-module>` with external import types :math:`\externtype^\ast` and external export types :math:`{\externtype'}^\ast`.
290-
291-
2. Let :math:`\import^\ast` be the :ref:`imports <syntax-import>` :math:`\module.\MIMPORTS`.
292-
293-
3. Let :math:`\export^\ast` be the :ref:`exports <syntax-export>` :math:`\module.\MEXPORTS`.
294-
295-
4. Let :math:`\X{result}` be the empty sequence.
296-
297-
5. For each :math:`\export_i` in :math:`\export^\ast`, do:
298-
299-
a. Let :math:`\import_j = \edexportimport(\module, \export_i.\EDESC)`.
300-
301-
b. If :math:`\import_j \neq \epsilon`, then:
302-
303-
i. Append the triple :math:`(\export_i.\ENAME, \import_j.\IMODULE, \import_j.\INAME)` to :math:`\X{result}`.
304-
305-
6. Return :math:`\X{result}`.
306-
307-
.. math::
308-
~ \\
309-
\begin{array}{lclll}
310-
\F{module\_indirect\_exports}(m) &=& (\X{ex}.\ENAME, \X{im}.\IMODULE, \X{im}.\INAME)^\ast \\
311-
&& \qquad (\iff \X{ex}^\ast = m.\MEXPORTS \\
312-
&& \qquad\quad \wedge~\X{im} = \edexportimport(m, \X{ex}.\EDESC) \\
313-
&& \qquad\quad \wedge~\X{im} \neq \epsilon \\
314-
&& \qquad\quad \wedge~\vdashmodule m : \externtype^\ast \to {\externtype'}^\ast) \\
315-
\end{array}
316-
317-
318221
.. index:: module, module instance
319222
.. _embed-instance:
320223

document/core/syntax/modules.rst

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@ The |MSTART| component of a module declares the :ref:`function index <syntax-fun
327327
The module and its exports are not accessible externally before this initialization has completed.
328328

329329

330-
.. index:: ! export, direct export, indirect export, re-export, name, index, function index, table index, memory index, global index, function, table, memory, global, instantiation
330+
.. index:: ! export, name, index, function index, table index, memory index, global index, function, table, memory, global, instantiation
331331
pair: abstract syntax; export
332332
single: function; export
333333
single: table; export
@@ -356,30 +356,6 @@ Each export is labeled by a unique :ref:`name <syntax-name>`.
356356
Exportable definitions are :ref:`functions <syntax-func>`, :ref:`tables <syntax-table>`, :ref:`memories <syntax-mem>`, and :ref:`globals <syntax-global>`,
357357
which are referenced through a respective descriptor.
358358

359-
A *direct export* is one where the export references a function, table, memory, or global that is defined within the module itself rather than being imported.
360-
361-
An *indirect export* (or *re-export*) is one where the export references a function, table, memory, or global that the module imports.
362-
363-
For an export :math:`\export` in module :math:`m`, the export is direct when :math:`\edexportimport(m, \export.\EDESC) = \epsilon` and indirect otherwise, where
364-
the import corresponding to an export descriptor :math:`\export.\EDESC` is defined by:
365-
366-
.. math::
367-
\begin{array}{lclll}
368-
\F{exportimport}(m, \exportdesc) &=& m.\MIMPORTS[i] && (\iff \exportdesc = \EDFUNC~\funcidx \\
369-
&&&& \quad \wedge~\exists~i~\colon~\funcidx = |\{j ~|~ j < i \\
370-
&&&& \quad \quad \wedge~m.\MIMPORTS[j].\IDESC = \IDFUNC~\typeidx' \}|) \\
371-
\F{exportimport}(m, \exportdesc) &=& m.\MIMPORTS[i] && (\iff \exportdesc = \EDTABLE~\tableidx \\
372-
&&&& \quad \wedge~\exists~i~\colon~\tableidx = |\{j ~|~ j < i \\
373-
&&&& \quad \quad \wedge~m.\MIMPORTS[j].\IDESC = \IDTABLE~\tabletype' \}|) \\
374-
\F{exportimport}(m, \exportdesc) &=& m.\MIMPORTS[i] && (\iff \exportdesc = \EDMEM~\memidx \\
375-
&&&& \quad \wedge~\exists~i~\colon~\memidx = |\{j ~|~ j < i \\
376-
&&&& \quad \quad \wedge~m.\MIMPORTS[j].\IDESC = \IDMEM~\memtype' \}|) \\
377-
\F{exportimport}(m, \exportdesc) &=& m.\MIMPORTS[i] && (\iff \exportdesc = \EDGLOBAL~\globalidx \\
378-
&&&& \quad \wedge~\exists~i~\colon~\globalidx = |\{j ~|~ j < i \\
379-
&&&& \quad \quad \wedge~m.\MIMPORTS[j].\IDESC = \IDGLOBAL~\globaltype' \}|) \\
380-
\F{exportimport}(m, \exportdesc) &=& \epsilon && (\otherwise) \\
381-
\end{array}
382-
383359

384360
Conventions
385361
...........

document/core/util/macros.def

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,6 @@
346346
.. |edtables| mathdef:: \xref{syntax/modules}{syntax-exportdesc}{\F{tables}}
347347
.. |edmems| mathdef:: \xref{syntax/modules}{syntax-exportdesc}{\F{mems}}
348348
.. |edglobals| mathdef:: \xref{syntax/modules}{syntax-exportdesc}{\F{globals}}
349-
.. |edexportimport| mathdef:: \xref{syntax/modules}{syntax-export}{\F{exportimport}}
350349

351350

352351
.. Instructions, terminals

document/js-api/index.bs

Lines changed: 3 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -123,12 +123,9 @@ urlPrefix: https://webassembly.github.io/spec/core/; spec: WebAssembly; type: df
123123
text: store_init; url: appendix/embedding.html#embed-store-init
124124
text: module_decode; url: appendix/embedding.html#embed-module-decode
125125
text: module_validate; url: appendix/embedding.html#embed-module-validate
126-
text: module_extern_subtype; url: appendix/embedding.html#embed-module-extern-subtype
127126
text: module_instantiate; url: appendix/embedding.html#embed-module-instantiate
128127
text: module_imports; url: appendix/embedding.html#embed-module-imports
129128
text: module_exports; url: appendix/embedding.html#embed-module-exports
130-
text: module_direct_exports; url: appendix/embedding.html#embed-module-direct-exports
131-
text: module_inirect_exports; url: appendix/embedding.html#embed-module-indirect-exports
132129
text: instance_export; url: appendix/embedding.html#embed-instance-export
133130
text: func_alloc; url: appendix/embedding.html#embed-func-alloc
134131
text: func_type; url: appendix/embedding.html#embed-func-type
@@ -1394,8 +1391,6 @@ To <dfn export>parse a WebAssembly module</dfn> given a <a>byte sequence</a> |by
13941391
1. [=list/iterate|For each=] (|moduleName|, <var ignore>name</var>, <var ignore>type</var>) in [=module_imports=](|module|.\[[Module]]),
13951392
1. [=set/Append=] |moduleName| to |requestedModules|.
13961393
1. Let |moduleRecord| be {
1397-
<!-- WebAssembly Module Records -->
1398-
\[[Instance]]: ~empty~,
13991394
<!-- Abstract Module Records -->
14001395
\[[Realm]]: |realm|,
14011396
\[[Environment]]: ~empty~,
@@ -1445,24 +1440,8 @@ WebAssembly Module Records have the following methods:
14451440

14461441
<div algorithm=ResolveExport>
14471442

1448-
<h3 id="resolve-export">ResolveExport ( |exportName|, |resolveSet| ) Concrete Method</h3>
1449-
1. If |resolveSet| is not present, set |resolveSet| to « ».
1443+
<h3 id="resolve-export">ResolveExport ( |exportName|, <var ignore>resolveSet</var> ) Concrete Method</h3>
14501444
1. Let |record| be this WebAssembly Module Record.
1451-
1. Let |module| be |record|.\[[ModuleSource]].\[[Module]].
1452-
1. [=list/iterate|For each=] Record |r| of |resolveSet|,
1453-
1. If |record| and |r|.\[[Module]] are the same Module Record and |exportName| is |r|.\[[ExportName]],
1454-
1. Return null.
1455-
1. Append the record { \[[Module]]: |record|, \[[ExportName]]: |exportName| } to |resolveSet|.
1456-
1. [=list/iterate|For each=] (|name|, |importedModuleName|, |importName|, <var ignore>type</var>) in [=module_indirect_exports=](|module|),
1457-
1. If |name| is equal to |exportName|,
1458-
1. Let |importedModule| be [$GetImportedModule$](|record|, |importedModuleName|).
1459-
1. Let |resolved| be [=?=] |importedModule|.ResolveExport(|importName|, |resolveSet|).
1460-
1. If |resolved| is null or ~AMBIGUOUS~,
1461-
1. Return |resolved|.
1462-
1. If |resolved|.\[[Module]] is a WebAssembly Module Record,
1463-
1. Return |resolved|.
1464-
1. Note: This fall-through case allows indirect exports referencing JS values to be treated as captured direct bindings in the environment record,
1465-
with live bindings unsupported. Only live bindings between Wasm globals are supported for Wasm exports.
14661445
1. If the [=export name list=] of |record| contains |exportName|, return { \[[Module]]: |record|, \[[BindingName]]: |exportName| }.
14671446
1. Otherwise, return null.
14681447

@@ -1481,23 +1460,8 @@ WebAssembly Module Records have the following methods:
14811460
1. Let |record| be this WebAssembly Module Record.
14821461
1. Let |env| be [$NewModuleEnvironment$](null).
14831462
1. Set |record|.\[[Environment]] to |env|.
1484-
1. Let |module| be |record|.\[[ModuleSource]].\[[Module]].
1485-
1. [=list/iterate|For each=] (|importedModuleName|, |name|, <var ignore>type</var>) in [=module_imports=](|module|),
1486-
1. Let |importedModule| be [$GetImportedModule$](|record|, |importedModuleName|).
1487-
1. Let |resolution| be |importedModule|.ResolveExport(|name|).
1488-
1. If |resolution| is null or ~AMBIGUOUS~, throw a {{SyntaxError}} exception.
1489-
1. [=list/iterate|For each=] (|name|, |importedModuleName|, |importName|, <var ignore>type</var>) in [=module_indirect_exports=](|module|),
1490-
1. Let |importedModule| be [$GetImportedModule$](|record|, |importedModuleName|).
1491-
1. Let |resolved| be [=?=] |importedModule|.ResolveExport(|importName|).
1492-
1. Assert |resolved| is not null or ~AMBIGUOUS~.
1493-
1. If |resolved|.\[[Module]] is not a WebAssembly Module Record,
1494-
1. Note: This case corresponds to indirect exports to non-WebAssembly bindings, which are always snapshotted.
1495-
1. Perform [=!=] |env|.CreateImmutableBinding(|name|, true).
1496-
1. [=list/iterate|For each=] (|name|, |externtype|) of [=module_direct_exports=](|module|),
1497-
1. If |externtype| is of the form [=global=] [=var=] <var ignore>valtype</var>,
1498-
1. Perform [=!=] |env|.CreateMutableBinding(|name|, false).
1499-
1. Otherwise,
1500-
1. Perform [=!=] |env|.CreateImmutableBinding(|name|, true).
1463+
1. For each |name| in the [=export name list=] of |record|,
1464+
1. Perform ! |env|.CreateImmutableBinding(|name|, true).
15011465

15021466
</div>
15031467

@@ -1605,8 +1569,6 @@ will always reflect the current mutable global export value as interpreted throu
16051569
1. [=list/iterate|For each=] (|moduleName|, <var ignore>name</var>, <var ignore>type</var>) in [=module_imports=](|module|),
16061570
1. [=set/Append=] |moduleName| to |requestedModules|.
16071571
1. Let |moduleRecord| be {
1608-
<!-- WebAssembly Module Records -->
1609-
\[[Instance]]: ~empty~,
16101572
<!-- Abstract Module Records -->
16111573
\[[Realm]]: |realm|,
16121574
\[[Environment]]: ~empty~,

0 commit comments

Comments
 (0)