Implementation Limitations¶
Implementations typically impose additional restrictions on a number of aspects of a WebAssembly module or execution.These may stem from:
physical resource limits,
constraints imposed by the embedder or its environment,
limitations of selected implementation strategies.
This section lists allowed limitations.Where restrictions take the form of numeric limits, no minimum requirements are given,nor are the limits assumed to be concrete, fixed numbers.However, it is expected that all implementations have “reasonably” large limits to enable common applications.
Note
A conforming implementation is not allowed to leave out individualfeatures.However, designated subsets of WebAssembly may be specified in the future.
Syntactic Limits¶
Structure¶
An implementation may impose restrictions on the following dimensions of a module:
the number ofelement segments in amodule
the number ofdata segments in amodule
the number ofsub types in arecursive type
the subtyping depth of asub type
the number of fields in astructure type
the number of parameters in afunction type
the number of results in afunction type
the number of parameters in ablock type
the number of results in ablock type
the number ofinstructions in afunction body
the number ofinstructions in astructured control instruction
the number ofstructured control instructions in afunction
the nesting depth ofstructured control instructions
the number oflabel indices in a\(\href{../syntax/instructions.html#syntax-instr-control}{\mathsf{br\_table}}\) instruction
the number of instructions in aconstantexpression
the length of the array in a\(\href{../syntax/instructions.html#syntax-instr-array}{\mathsf{array{.}new\_fixed}}\) instruction
the length of anelement segment
the length of adata segment
the length of aname
the range ofcharacters in aname
If the limits of an implementation are exceeded for a given module,then the implementation may reject thevalidation, compilation, orinstantiation of that module with an embedder-specific error.
Binary Format¶
For a module given inbinary format, additional limitations may be imposed on the following dimensions:
the size of amodule
the size of anysection
the size of astructured control instruction
the size of an individualconstantexpression’s instruction sequence
the number ofsections
Text Format¶
For a module given intext format, additional limitations may be imposed on the following dimensions:
the size of thesource text
the size of any syntactic element
the size of an individualtoken
the nesting depth offolded instructions
the length of symbolicidentifiers
the range of literalcharacters allowed in thesource text
Validation¶
An implementation may defervalidation of individualfunctions until they are firstinvoked.
If a function turns out to be invalid, then the invocation, and every consecutive call to the same function, results in atrap.
Note
This is to allow implementations to use interpretation or just-in-time compilation for functions.The function must still be fully validated before execution of its body begins.
Execution¶
Restrictions on the following dimensions may be imposed duringexecution of a WebAssembly program:
the number of allocatedmodule instances
the number of allocatedfunction instances
the number of allocatedtable instances
the number of allocatedmemory instances
the number of allocatedglobal instances
the number of allocatedtag instances
the number of allocatedstructure instances
the number of allocatedarray instances
the number of allocatedexception instances
the size of atable instance
the size of amemory instance
the size of anarray instance
If the runtime limits of an implementation are exceeded during execution of a computation,then it may terminate that computation and report an embedder-specific error to the invoking code.
Some of the above limits may already be verified during instantiation, in which case an implementation may report exceedance in the same manner as forsyntactic limits.
Note
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.
