Profiles¶
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. A host platform can thereby decide to support the language only under a restricted profile, or even the intersection of multiple profiles.
Conventions¶
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.
For that purpose, every profile defines a profile marker, an alphanumeric short-hand like \(\def\mathdef1534#1{{\small{\mathrm{#1}}}}\mathdef1534{ABC}\). A profile annotation of the form \(\def\mathdef1535#1{{^{\small{[!#1]}}}}\mathdef1535{\mathrm{ABC}~\mathrm{XYZ}}\) on a rule indicates that this rule is excluded for either of the profiles whose marker is \(\def\mathdef1536#1{{\small{\mathrm{#1}}}}\mathdef1536{ABC}\) or \(\def\mathdef1537#1{{\small{\mathrm{#1}}}}\mathdef1537{XYZ}\).
There are two ways of subsetting the language in a profile:
Syntactic, by omitting a feature, in which case certain constructs are removed from the syntax altogether.
Semantic, by restricting a feature, in which case certain constructs are still present but some behaviours are ruled out.
Syntax Annotations¶
To omit a construct from a profile syntactically, respective productions in the grammar of the abstract syntax are annotated with an associated profile marker. This is defined to have the following implications:
Any production in the binary or textual syntax that produces abstract syntax with a marked construct is omitted by extension.
Any validation or execution rule that handles a marked construct is omitted by extension.
The overall effect is that the respective construct is no longer part of the language under a respective profile.
Note
For example, a “busy” profile marked \(\def\mathdef1538#1{{\small{\mathrm{#1}}}}\mathdef1538{BUSY}\) could rule out the \(\href{../syntax/instructions.html#syntax-instr-control}{\mathsf{nop}}\) instruction by marking the production for it in the abstract syntax as follows:
A rule may be annotated by multiple markers, which could be the case if a construct is in the intersection of multiple features.
Semantics Annotations¶
To restrict certain behaviours in a profile, individual validation or reduction rules or auxiliary definitions are annotated with an associated marker.
This has the consequence that the respective rule is no longer applicable under the given profile.
Note
For example, an “infinite” profile marked \(\def\mathdef1540#1{{\small{\mathrm{#1}}}}\mathdef1540{INF}\) could define that growing memory never fails:
Properties¶
All profiles are defined such that the following properties are preserved:
All profiles represent syntactic and semantic subsets of the full profile, i.e., they do not add syntax or alter behaviour.
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.
Profiles do not violate soundness, i.e., all configurations valid under that profile still have well-defined execution behaviour.
Note
Tools are generally expected to handle and produce code for the full profile by default. In particular, producers should not generate code that depends on specific profiles. Instead, all code should preserve correctness when executed under the full profile.
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.
Defined Profiles¶
Note
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.
Full Profile (\({\small{\mathrm{FUL}}}\))¶
The full profile contains the complete language and all possible behaviours. It imposes no restrictions, i.e., all rules and definitions are active. All other profiles define sub-languages of this profile.
Deterministic Profile (\({\small{\mathrm{DET}}}\))¶
The deterministic profile excludes all rules marked \(\def\mathdef1542#1{{^{\small{[!#1]}}}}\mathdef1542{\href{../appendix/profiles.html#profile-deterministic}{\mathrm{DET}}}\). It defines a sub-language that does not exhibit any incidental non-deterministic behaviour:
All NaN values generated by floating-point instructions are canonical and positive.
All relaxed vector instructions have a fixed behaviour that does not depend on the implementation.
Even under this profile, the \(\href{../syntax/instructions.html#syntax-instr-memory}{\mathsf{memory.grow}}\) and \(\href{../syntax/instructions.html#syntax-instr-table}{\mathsf{table.grow}}\) instructions technically remain non-deterministic, in order to be able to indicate resource exhaustion.
Note
In future versions of WebAssembly, new non-deterministic behaviour may be added to the language, such that the deterministic profile will induce additional restrictions.