Skip to content

Commit 95acd3e

Browse files
committed
Merge branch 'wasm-3.0+relaxed' into wasm-3.0
2 parents a315401 + 8dadd74 commit 95acd3e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+2407
-48
lines changed

.github/workflows/ci-interpreter.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ jobs:
2727
- name: Setup Node.js
2828
uses: actions/setup-node@v2
2929
with:
30-
node-version: 19.x
30+
node-version: 20.x
3131
- name: Build interpreter
3232
run: cd interpreter && opam exec make
3333
- name: Run tests

document/core/appendix/changes.rst

Lines changed: 47 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -518,6 +518,48 @@ Added managed reference types. [#proposal-gc]_
518518
- |EXTERNCONVERTANY|
519519

520520

521+
.. index:: instruction, vector instruction, SIMD
522+
523+
Relaxed Vector Instructions
524+
...........................
525+
526+
Added new *relaxed* vector instructions,
527+
whose behaviour is non-deterministic and implementation-dependent. [#proposal-relaxed]_
528+
529+
* New binary :ref:`vector instruction <syntax-instr-relaxed>`:
530+
531+
- :math:`\K{f}\!N\!\K{x}\!M\!\K{.relaxed\_min}`
532+
- :math:`\K{f}\!N\!\K{x}\!M\!\K{.relaxed\_max}`
533+
- :math:`\K{i16x8.relaxed\_q15mulr\_s}`
534+
- :math:`\K{i16x8.relaxed\_dot\_i8x16\_i7x16\_s}`
535+
536+
* New ternary :ref:`vector instruction <syntax-instr-relaxed>`:
537+
538+
- :math:`\K{f}\!N\!\K{x}\!M\!\K{.relaxed\_madd}`
539+
- :math:`\K{f}\!N\!\K{x}\!M\!\K{.relaxed\_nmadd}`
540+
- :math:`\K{i}\!N\!\K{x}\!M\!\K{.relaxed\_laneselect}`
541+
- :math:`\K{i32x4.relaxed\_dot\_i8x16\_i7x16\_add\_s}`
542+
543+
* New conversion :ref:`vector instructions <syntax-instr-relaxed>`:
544+
545+
- :math:`\K{i32x4.relaxed\_trunc\_f32x4\_}\sx`
546+
- :math:`\K{i32x4.relaxed\_trunc\_f64x2\_}\sx\K{\_zero}`
547+
548+
* New byte reordering :ref:`vector instruction <syntax-instr-relaxed>`:
549+
550+
- :math:`\K{i8x16.relaxed\_swizzle}`
551+
552+
553+
.. index:: determinism, non-determinism, profiles
554+
555+
Profiles
556+
........
557+
558+
Introduced the concept of :ref:`profile <profiles>` for specifying language subsets.
559+
560+
* A new profile defining a :ref:`deterministic <profile-deterministic>` mode of execution.
561+
562+
521563
.. index:: text format, annotation, custom section, identifier, module, type, function, local, structure field
522564

523565
Custom Annotations
@@ -542,7 +584,7 @@ mirroring the role of custom sections in the binary format. [#proposal-annot]_
542584

543585

544586
.. [#proposal-extconst]
545-
https://github.com/WebAssembly/extended-const/blob/main/proposals/extended-const/
587+
https://github.com/WebAssembly/spec/blob/main/proposals/extended-const/
546588
547589
.. [#proposal-tailcall]
548590
https://github.com/WebAssembly/spec/tree/main/proposals/tail-call/
@@ -551,13 +593,16 @@ mirroring the role of custom sections in the binary format. [#proposal-annot]_
551593
https://github.com/WebAssembly/spec/tree/main/proposals/exception-handling/
552594
553595
.. [#proposal-multimem]
554-
https://github.com/WebAssembly/multi-memory/blob/main/proposals/multi-memory/
596+
https://github.com/WebAssembly/spec/blob/main/proposals/multi-memory/
555597
556598
.. [#proposal-typedref]
557599
https://github.com/WebAssembly/spec/tree/main/proposals/function-references/
558600
559601
.. [#proposal-gc]
560602
https://github.com/WebAssembly/spec/tree/main/proposals/gc/
561603
604+
.. [#proposal-relaxed]
605+
https://github.com/WebAssembly/spec/tree/main/proposals/relaxed-simd/
606+
562607
.. [#proposal-annot]
563608
https://github.com/WebAssembly/annotations/tree/main/proposals/annotations/

document/core/appendix/index-instructions.py

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -633,7 +633,26 @@ def Instruction(name, opcode, type=None, validation=None, execution=None, operat
633633
Instruction(r'\I32X4.\VTRUNC\K{\_sat\_f64x2\_u\_zero}', r'\hex{FD}~~\hex{FD}~~\hex{01}', r'[\V128] \to [\V128]', r'valid-vcvtop', r'exec-vcvtop', r'op-trunc_sat_u'),
634634
Instruction(r'\F64X2.\VCONVERT\K{\_low\_i32x4\_s}', r'\hex{FD}~~\hex{FE}~~\hex{01}', r'[\V128] \to [\V128]', r'valid-vcvtop', r'exec-vcvtop', r'op-convert_s'),
635635
Instruction(r'\F64X2.\VCONVERT\K{\_low\_i32x4\_u}', r'\hex{FD}~~\hex{FF}~~\hex{01}', r'[\V128] \to [\V128]', r'valid-vcvtop', r'exec-vcvtop', r'op-convert_u'),
636-
Instruction(None, r'\hex{FD}~\hex{00}~\hex{02} \dots'),
636+
Instruction(r'\I8X16.\RELAXEDSWIZZLE', r'\hex{FD}~~\hex{80}~~\hex{02}', r'[\V128~\V128] \to [\V128]', r'valid-relaxed_swizzle', r'exec-relaxed_swizzle', r'op-irelaxed_swizzle'),
637+
Instruction(r'\I32X4.\RELAXEDTRUNC\K{\_f32x4\_s}', r'\hex{FD}~~\hex{81}~~\hex{02}', r'[\V128] \to [\V128]', r'valid-vcvtop', r'exec-vcvtop', r'op-relaxed_trunc_s'),
638+
Instruction(r'\I32X4.\RELAXEDTRUNC\K{\_f32x4\_u}', r'\hex{FD}~~\hex{82}~~\hex{02}', r'[\V128] \to [\V128]', r'valid-vcvtop', r'exec-vcvtop', r'op-relaxed_trunc_u'),
639+
Instruction(r'\I32X4.\RELAXEDTRUNC\K{\_f64x2\_s}', r'\hex{FD}~~\hex{83}~~\hex{02}', r'[\V128] \to [\V128]', r'valid-vcvtop', r'exec-vcvtop', r'op-relaxed_trunc_s'),
640+
Instruction(r'\I32X4.\RELAXEDTRUNC\K{\_f64x2\_u}', r'\hex{FD}~~\hex{84}~~\hex{02}', r'[\V128] \to [\V128]', r'valid-vcvtop', r'exec-vcvtop', r'op-relaxed_trunc_u'),
641+
Instruction(r'\F32X4.\RELAXEDMADD', r'\hex{FD}~~\hex{85}~~\hex{02}', r'[\V128~\V128~\V128] \to [\V128]', r'valid-vternop', r'exec-vternop', r'op-frelaxed_madd'),
642+
Instruction(r'\F32X4.\RELAXEDNMADD', r'\hex{FD}~~\hex{86}~~\hex{02}', r'[\V128~\V128~\V128] \to [\V128]', r'valid-vternop', r'exec-vternop', r'op-frelaxed_nmadd'),
643+
Instruction(r'\F64X2.\RELAXEDMADD', r'\hex{FD}~~\hex{87}~~\hex{02}', r'[\V128~\V128~\V128] \to [\V128]', r'valid-vternop', r'exec-vternop', r'op-frelaxed_madd'),
644+
Instruction(r'\F64X2.\RELAXEDNMADD', r'\hex{FD}~~\hex{88}~~\hex{02}', r'[\V128~\V128~\V128] \to [\V128]', r'valid-vternop', r'exec-vternop', r'op-frelaxed_nmadd'),
645+
Instruction(r'\I8X16.\RELAXEDLANESELECT', r'\hex{FD}~~\hex{89}~~\hex{02}', r'[\V128~\V128~\V128] \to [\V128]', r'valid-relaxed_laneselect', r'exec-relaxed_laneselect', r'op-irelaxed_laneselect'),
646+
Instruction(r'\I16X8.\RELAXEDLANESELECT', r'\hex{FD}~~\hex{8A}~~\hex{02}', r'[\V128~\V128~\V128] \to [\V128]', r'valid-relaxed_laneselect', r'exec-relaxed_laneselect', r'op-irelaxed_laneselect'),
647+
Instruction(r'\I32X4.\RELAXEDLANESELECT', r'\hex{FD}~~\hex{8B}~~\hex{02}', r'[\V128~\V128~\V128] \to [\V128]', r'valid-relaxed_laneselect', r'exec-relaxed_laneselect', r'op-irelaxed_laneselect'),
648+
Instruction(r'\I64X2.\RELAXEDLANESELECT', r'\hex{FD}~~\hex{8C}~~\hex{02}', r'[\V128~\V128~\V128] \to [\V128]', r'valid-relaxed_laneselect', r'exec-relaxed_laneselect', r'op-irelaxed_laneselect'),
649+
Instruction(r'\F32X4.\RELAXEDMIN', r'\hex{FD}~~\hex{8D}~~\hex{02}', r'[\V128~\V128] \to [\V128]', r'valid-vbinop', r'exec-vbinop', r'op-frelaxed_min'),
650+
Instruction(r'\F32X4.\RELAXEDMAX', r'\hex{FD}~~\hex{8E}~~\hex{02}', r'[\V128~\V128] \to [\V128]', r'valid-vbinop', r'exec-vbinop', r'op-frelaxed_max'),
651+
Instruction(r'\F64X2.\RELAXEDMIN', r'\hex{FD}~~\hex{8F}~~\hex{02}', r'[\V128~\V128] \to [\V128]', r'valid-vbinop', r'exec-vbinop', r'op-frelaxed_min'),
652+
Instruction(r'\F64X2.\RELAXEDMAX', r'\hex{FD}~~\hex{90}~~\hex{02}', r'[\V128~\V128] \to [\V128]', r'valid-vbinop', r'exec-vbinop', r'op-frelaxed_max'),
653+
Instruction(r'\I16X8.\RELAXEDQ15MULRS', r'\hex{FD}~~\hex{91}~~\hex{02}', r'[\V128~\V128] \to [\V128]', r'valid-vbinop', r'exec-vbinop', r'op-irelaxed_q15mulr_s'),
654+
Instruction(r'\I16X8.\RELAXEDDOT\K{\_i8x16\_i7x16\_s}', r'\hex{FD}~~\hex{92}~~\hex{02}', r'[\V128~\V128] \to [\V128]', r'valid-relaxed_dot', r'exec-relaxed_dot'),
655+
Instruction(r'\I32X4.\RELAXEDDOT\K{\_i8x16\_i7x16\_add\_s}', r'\hex{FD}~~\hex{93}~~\hex{02}', r'[\V128~\V128~\V128] \to [\V128]', r'valid-relaxed_dot', r'exec-relaxed_dot'),
637656
Instruction(None, r'\hex{FE}'),
638657
Instruction(None, r'\hex{FF}'),
639658
]

document/core/appendix/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ Appendix
77
:maxdepth: 2
88

99
embedding
10+
profiles
1011
implementation
1112
properties
1213
algorithm

document/core/appendix/profiles.rst

Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
.. index:: ! profile, abstract syntax, validation, execution, binary format, text format
2+
.. _profiles:
3+
4+
Profiles
5+
--------
6+
7+
To enable the use of WebAssembly in as many environments as possible, *profiles* specify coherent language subsets that fit constraints imposed by common classes of host environments.
8+
A host platform can thereby decide to support the language only under a restricted profile, or even the intersection of multiple profiles.
9+
10+
11+
Conventions
12+
~~~~~~~~~~~
13+
14+
A profile modification is specified by decorating selected rules in the main body of this specification with a *profile annotation* that defines them as conditional on the choice of profile.
15+
16+
For that purpose, every profile defines a *profile marker*, an alphanumeric short-hand like :math:`\profilename{ABC}`.
17+
A profile annotation of the form :math:`\exprofiles{\profile{ABC}~\profile{XYZ}}` on a rule indicates that this rule is *excluded* for either of the profiles whose marker is :math:`\profilename{ABC}` or :math:`\profilename{XYZ}`.
18+
19+
There are two ways of subsetting the language in a profile:
20+
21+
* *Syntactic*, by *omitting* a feature, in which case certain constructs are removed from the syntax altogether.
22+
23+
* *Semantic*, by *restricting* a feature, in which case certain constructs are still present but some behaviours are ruled out.
24+
25+
26+
Syntax Annotations
27+
..................
28+
29+
To omit a construct from a profile syntactically, respective productions in the grammar of the :ref:`abstract syntax <syntax>` are annotated with an associated profile marker.
30+
This is defined to have the following implications:
31+
32+
1. Any production in the :ref:`binary <binary>` or :ref:`textual <text>` syntax that produces abstract syntax with a marked construct is omitted by extension.
33+
34+
2. Any :ref:`validation <valid>` or :ref:`execution <exec>` rule that handles a marked construct is omitted by extension.
35+
36+
The overall effect is that the respective construct is no longer part of the language under a respective profile.
37+
38+
.. note::
39+
For example, a "busy" profile marked :math:`\profilename{BUSY}` could rule out the |NOP| instruction by marking the production for it in the abstract syntax as follows:
40+
41+
.. math::
42+
\begin{array}{llcl}
43+
\production{instruction} & \instr &::=&
44+
\dots \\
45+
& \exprofiles{\profile{BUSY}} &|& \NOP \\
46+
& &|& \UNREACHABLE \\
47+
\end{array}
48+
49+
A rule may be annotated by multiple markers, which could be the case if a construct is in the intersection of multiple features.
50+
51+
52+
Semantics Annotations
53+
.....................
54+
55+
To restrict certain behaviours in a profile, individual :ref:`validation <valid>` or :ref:`reduction <exec>` rules or auxiliary definitions are annotated with an associated marker.
56+
57+
This has the consequence that the respective rule is no longer applicable under the given profile.
58+
59+
.. note::
60+
For example, an "infinite" profile marked :math:`\profilename{INF}` could define that growing memory never fails:
61+
62+
.. math::
63+
\begin{array}{llcl@{\qquad}l}
64+
& S; F; (\I32.\CONST~n)~\MEMORYGROW~x &\stepto& S'; F; (\I32.\CONST~\X{sz})
65+
\\&&&
66+
\begin{array}[t]{@{}r@{~}l@{}}
67+
(\iff & F.\AMODULE.\MIMEMS[x] = a \\
68+
\wedge & \X{sz} = |S.\SMEMS[a].\MIDATA|/64\,\F{Ki} \\
69+
\wedge & S' = S \with \SMEMS[a] = \growmem(S.\SMEMS[a], n)) \\[1ex]
70+
\end{array}
71+
\\[1ex]
72+
\exprofiles{\profile{INF}} & S; F; (\I32.\CONST~n)~\MEMORYGROW~x &\stepto& S; F; (\I32.\CONST~\signed_{32}^{-1}(-1))
73+
\end{array}
74+
75+
76+
Properties
77+
..........
78+
79+
All profiles are defined such that the following properties are preserved:
80+
81+
* All profiles represent syntactic and semantic subsets of the :ref:`full profile <profile-full>`, i.e., they do not *add* syntax or *alter* behaviour.
82+
83+
* All profiles are mutually compatible, i.e., no two profiles subset semantic behaviour in inconsistent or ambiguous ways, and any intersection of profiles preserves the properties described here.
84+
85+
* Profiles do not violate :ref:`soundness <soundness>`, i.e., all :ref:`configurations <syntax-config>` valid under that profile still have well-defined execution behaviour.
86+
87+
.. note::
88+
Tools are generally expected to handle and produce code for the full profile by default.
89+
In particular, producers should not generate code that *depends* on specific profiles. Instead, all code should preserve correctness when executed under the full profile.
90+
91+
Moreover, profiles should be considered static and fixed for a given platform or ecosystem. Runtime conditioning on the "current" profile is not intended and should be avoided.
92+
93+
94+
95+
Defined Profiles
96+
~~~~~~~~~~~~~~~~
97+
98+
.. note::
99+
The number of defined profiles is expected to remain small in the future. Profiles are intended for broad and permanent use cases only. In particular, profiles are not intended for language versioning.
100+
101+
102+
.. index:: full profile
103+
single: profile; full
104+
.. _profile-full:
105+
106+
Full Profile (:math:`{\small{\mathrm{FUL}}}`)
107+
.............................................
108+
109+
The *full* profile contains the complete language and all possible behaviours.
110+
It imposes no restrictions, i.e., all rules and definitions are active.
111+
All other profiles define sub-languages of this profile.
112+
113+
114+
.. index:: determinism, non-determinism, deterministic profile
115+
single: profile; deterministic
116+
.. _profile-deterministic:
117+
118+
Deterministic Profile (:math:`{\small{\mathrm{DET}}}`)
119+
......................................................
120+
121+
The *deterministic* profile excludes all rules marked :math:`\exprofiles{\PROFDET}`.
122+
It defines a sub-language that does not exhibit any incidental non-deterministic behaviour:
123+
124+
* All :ref:`NaN <syntax-nan>` values :ref:`generated <aux-nans>` by :ref:`floating-point instructions <syntax-instr-numeric>` are canonical and positive.
125+
126+
* All :ref:`relaxed vector instructions <syntax-instr-relaxed>` have a fixed behaviour that does not depend on the implementation.
127+
128+
Even under this profile, the |MEMORYGROW| and |TABLEGROW| instructions technically remain :ref:`non-deterministic <exec-memory.grow>`, in order to be able to indicate resource exhaustion.
129+
130+
.. note::
131+
In future versions of WebAssembly, new non-deterministic behaviour may be added to the language, such that the deterministic profile will induce additional restrictions.

document/core/binary/instructions.rst

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -931,6 +931,31 @@ All other vector instructions are plain opcodes without any immediates.
931931
\hex{FD}~~95{:}\Bu32 &\Rightarrow& \F64X2.\VPROMOTE\K{\_low\_f32x4}\\
932932
\end{array}
933933
934+
.. math::
935+
\begin{array}{llclll}
936+
\phantom{\production{instruction}} & \phantom{\Binstr} &\phantom{::=}& \phantom{\dots} && \phantom{vechaslongerinstructionnames} \\[-2ex] &&|&
937+
\hex{FD}~~256{:}\Bu32 &\Rightarrow& \I16X8.\RELAXEDSWIZZLE \\ &&|&
938+
\hex{FD}~~257{:}\Bu32 &\Rightarrow& \I32X4.\RELAXEDTRUNC\K{\_f32x4\_s} \\ &&|&
939+
\hex{FD}~~258{:}\Bu32 &\Rightarrow& \I32X4.\RELAXEDTRUNC\K{\_f32x4\_u} \\ &&|&
940+
\hex{FD}~~259{:}\Bu32 &\Rightarrow& \I32X4.\RELAXEDTRUNC\K{\_f32x4\_s\_zero} \\ &&|&
941+
\hex{FD}~~260{:}\Bu32 &\Rightarrow& \I32X4.\RELAXEDTRUNC\K{\_f32x4\_u\_zero} \\ &&|&
942+
\hex{FD}~~261{:}\Bu32 &\Rightarrow& \F32X4.\RELAXEDMADD \\ &&|&
943+
\hex{FD}~~262{:}\Bu32 &\Rightarrow& \F32X4.\RELAXEDNMADD \\ &&|&
944+
\hex{FD}~~263{:}\Bu32 &\Rightarrow& \F64X2.\RELAXEDMADD \\ &&|&
945+
\hex{FD}~~264{:}\Bu32 &\Rightarrow& \F64X2.\RELAXEDNMADD \\ &&|&
946+
\hex{FD}~~265{:}\Bu32 &\Rightarrow& \I8X16.\RELAXEDLANESELECT \\ &&|&
947+
\hex{FD}~~266{:}\Bu32 &\Rightarrow& \I16X8.\RELAXEDLANESELECT \\ &&|&
948+
\hex{FD}~~267{:}\Bu32 &\Rightarrow& \I32X4.\RELAXEDLANESELECT \\ &&|&
949+
\hex{FD}~~268{:}\Bu32 &\Rightarrow& \I64X2.\RELAXEDLANESELECT \\ &&|&
950+
\hex{FD}~~269{:}\Bu32 &\Rightarrow& \F32X4.\RELAXEDMIN \\ &&|&
951+
\hex{FD}~~270{:}\Bu32 &\Rightarrow& \F32X4.\RELAXEDMAX \\ &&|&
952+
\hex{FD}~~271{:}\Bu32 &\Rightarrow& \F64X2.\RELAXEDMIN \\ &&|&
953+
\hex{FD}~~272{:}\Bu32 &\Rightarrow& \F64X2.\RELAXEDMAX \\ &&|&
954+
\hex{FD}~~273{:}\Bu32 &\Rightarrow& \I16X8.\RELAXEDQ15MULRS \\ &&|&
955+
\hex{FD}~~274{:}\Bu32 &\Rightarrow& \I16X8.\RELAXEDDOT\K{\_i8x16\_i7x16\_s} \\ &&|&
956+
\hex{FD}~~275{:}\Bu32 &\Rightarrow& \I16X8.\RELAXEDDOT\K{\_i8x16\_i7x16\_add\_s} \\
957+
\end{array}
958+
934959
935960
.. index:: expression
936961
pair: binary format; expression

0 commit comments

Comments
 (0)