Skip to content

Commit 6d6648b

Browse files
authored
[spec] Implementation restrictions (#483)
Includes [spec] Allow impls to limit code point range (#488).
1 parent c4774b4 commit 6d6648b

File tree

8 files changed

+166
-17
lines changed

8 files changed

+166
-17
lines changed

document/appendix-names/index.rst

Lines changed: 0 additions & 6 deletions
This file was deleted.

document/appendix-properties/index.rst

Lines changed: 0 additions & 6 deletions
This file was deleted.

document/appendix-algorithm/index.rst renamed to document/appendix/algorithm.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
Appendix: Validation Algorithm
2-
------------------------------
1+
Validation Algorithm
2+
--------------------
33

44
.. todo::
55

document/appendix/implementation.rst

Lines changed: 137 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
1+
.. _impl:
2+
.. index:: ! implementation limitations, implementation
3+
4+
Implementation Limitations
5+
--------------------------
6+
7+
Implementations typically impose additional restrictions on a number of aspects of a WebAssembly module or execution.
8+
These may stem from:
9+
10+
* physical resource limits,
11+
* constraints imposed by the embedder or its environment,
12+
* limitations of selected implementation strategies.
13+
14+
This section lists allowed limitations.
15+
Where restrictions take the form of numeric limits, no minimum requirements are given,
16+
nor are the limits assumed to be concrete, fixed numbers.
17+
However, it is expected that all implementations have "reasonably" large limits to enable common applications.
18+
19+
.. note::
20+
A conforming implementation is not allowed to leave out individual *features*.
21+
However, designated subsets of WebAssembly may be specified in the future.
22+
23+
24+
Syntactic Limits
25+
~~~~~~~~~~~~~~~~
26+
27+
.. _impl-syntax:
28+
.. index:: abstract syntax, module, type, function, table, memory, global, element, data, import, export, parameter, result, local, structured control instruction, instruction, name, Unicode, code point
29+
30+
Structure
31+
.........
32+
33+
An implementation may impose restrictions on the following dimensions of a module:
34+
35+
* the number of :ref:`types <syntax-type>` in a :ref:`module <syntax-module>`
36+
* the number of :ref:`functions <syntax-func>` in a :ref:`module <syntax-module>`, including imports
37+
* the number of :ref:`tables <syntax-table>` in a :ref:`module <syntax-module>`, including imports
38+
* the number of :ref:`memories <syntax-mem>` in a :ref:`module <syntax-module>`, including imports
39+
* the number of :ref:`globals <syntax-global>` in a :ref:`module <syntax-module>`, including imports
40+
* the number of :ref:`element segments <syntax-elem>` in a :ref:`module <syntax-module>`
41+
* the number of :ref:`data segments <syntax-data>` in a :ref:`module <syntax-module>`
42+
* the number of :ref:`imports <syntax-import>` to a :ref:`module <syntax-module>`
43+
* the number of :ref:`exports <syntax-export>` form a :ref:`module <syntax-module>`
44+
* the number of parameters in a :ref:`function type <syntax-functype>`
45+
* the number of results in a :ref:`function type <syntax-functype>`
46+
* the number of :ref:`locals <syntax-local>` in a :ref:`function <syntax-func>`
47+
* the size of a :ref:`function <syntax-func>` body
48+
* the size of a :ref:`structured control instruction <syntax-instr-control>`
49+
* the number of :ref:`structured control instructions <syntax-instr-control>` in a :ref:`function <syntax-func>`
50+
* the nesting depth of :ref:`structured control instructions <syntax-instr-control>`
51+
* the number of :ref:`label indices <syntax-labelidx>` in a |brtable| instruction
52+
* the length of an :ref:`element segment <syntax-elem>`
53+
* the length of a :ref:`data segment <syntax-data>`
54+
* the length of a :ref:`name <syntax-name>`
55+
* the range of :ref:`code points <syntax-codepoint>` in a :ref:`name <syntax-name>`
56+
57+
If the limits of an implementation are exceeded for a given module,
58+
then the implementation may reject the :ref:`validation <valid>`, compilation, or :ref:`instantiation <exec-instantiate>` of that module with an embedder-specific error.
59+
60+
.. note::
61+
The last item allows embedders that operate in limited environments without support for
62+
`Unicode <http://www.unicode.org/versions/latest/>`_ to limit the
63+
names of :ref:`imports <syntax-import>` and :ref:`exports <syntax-export>`
64+
to common subsets like `ASCII <http://webstore.ansi.org/RecordDetail.aspx?sku=INCITS+4-1986%5bR2012%5d>`_.
65+
66+
67+
.. _impl-binary:
68+
.. index:: binary format, module, section, function, code
69+
70+
Binary Format
71+
.............
72+
73+
For a module given in :ref:`binary format <binary>`, additional limitations may be imposed on the following dimensions:
74+
75+
* the size of a :ref:`module <binary-module>`
76+
* the size of any :ref:`section <binary-section>`
77+
* the size of an individual :ref:`function's code <binary-func>`
78+
* the number of :ref:`sections <binary-section>`
79+
80+
81+
.. _impl-text:
82+
.. index:: text format, source text, token, identifier, character, unicode
83+
84+
Text Format
85+
...........
86+
87+
For a module given in :ref:`text format <text>`, additional limitations may be imposed on the following dimensions:
88+
89+
* the size of the :ref:`source text <source>`
90+
* the size of any syntactic element
91+
* the size of an individual :ref:`token <text-token>`
92+
* the nesting depth of :ref:`folded instructions <text-foldedinstr>`
93+
* the length of symbolic :ref:`identifiers <text-id>`
94+
* the range of literal :ref:`characters <text-char>` (code points) allowed in the :ref:`source text <source>`
95+
96+
97+
.. _impl-valid:
98+
.. index:: validation, function
99+
100+
Validation
101+
~~~~~~~~~~
102+
103+
An implementation may defer :ref:`validation <valid>` of individual :ref:`functions <syntax-func>` until they are first :ref:`invoked <exec-invoke>`.
104+
105+
If a function turns out to be invalid, then the invocation, and every consecutive call to the same function, results in a :ref:`trap <trap>`.
106+
107+
.. note::
108+
This is to allow implementations to use interpretation or just-in-time compilation for functions.
109+
The function must still be fully validated before execution of its body begins.
110+
111+
112+
.. _impl-exec:
113+
.. index:: execution, module instance, function instance, table instance, memory instance, global instance, allocation, frame, label, value
114+
115+
Execution
116+
~~~~~~~~~
117+
118+
Restrictions on the following dimensions may be imposed during :ref:`execution <exec>` of a WebAssembly program:
119+
120+
* the number of allocated :ref:`module instances <syntax-moduleinst>`
121+
* the number of allocated :ref:`function instances <syntax-funcinst>`
122+
* the number of allocated :ref:`table instances <syntax-tableinst>`
123+
* the number of allocated :ref:`memory instances <syntax-meminst>`
124+
* the number of allocated :ref:`global instances <syntax-globalinst>`
125+
* the size of a :ref:`table instance <syntax-tableinst>`
126+
* the size of a :ref:`memory instance <syntax-meminst>`
127+
* the number of :ref:`frames <syntax-frame>` on the :ref:`stack <syntax-stack>`
128+
* the number of :ref:`labels <syntax-label>` on the :ref:`stack <syntax-stack>`
129+
* the number of :ref:`values <syntax-val>` on the :ref:`stack <syntax-stack>`
130+
131+
If the runtime limits of an implementation are exceeded during execution of a computation,
132+
then it may terminate that computation and report an embedder-specific error to the invoking code.
133+
134+
Some of the above limits may already be verified during instantiation, in which case an implementation may report exceedance in the same manner as for :ref:`syntactic limits <impl-syntax>`.
135+
136+
.. note::
137+
Concrete limits are usually not fixed but may be dependent on specifics, interdependent, vary over time, or depend on other implementation- or embedder-specific situations or events.

document/appendix/index.rst

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
.. _appendix:
2+
3+
Appendix
4+
========
5+
6+
.. toctree::
7+
:maxdepth: 2
8+
9+
implementation
10+
names
11+
properties
12+
algorithm

document/appendix/names.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Name Section
2+
------------
3+
4+
.. todo::
5+
6+
Describe

document/appendix/properties.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
Formal Properties
2+
-----------------
3+
4+
.. todo::
5+
6+
* representation (bijection between abstract and binary)
7+
* validation (progress, preservation)
8+
* ...

document/index.rst

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,7 @@ WebAssembly Specification
1414
execution/index
1515
binary/index
1616
text/index
17-
appendix-properties/index
18-
appendix-algorithm/index
19-
appendix-names/index
17+
appendix/index
2018

2119
.. only:: latex
2220

0 commit comments

Comments
 (0)