Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
wasm-smith: restrict which kinds of instructions can be generated
In looking into bytecodealliance/wasmtime#3251, I created a mechanism for restricting what kinds of instructions wasm-smith can generate. The [WebAssembly specification](https://webassembly.github.io/spec/core/syntax/instructions.html) organizes its instructions into several categories (e.g., numeric, vector, reference, control, etc.) and this change allows the user to configure the module generation based on these categories: ``` head -c 10000 /dev/urandom | cargo run --bin wasm-smith -- --allowed-instructions memory,parametric -o test.wasm && wasm2wat test.wasm ``` There is some related configuration in wasm-smith to restrict what instructions are available. Currently, the wasm-smith configuration is organized around "proposals," which can be enabled or disabled. In theory, a user could be confused if the proposal was disabled and they explicitly enabled an instruction kind (e.g. reference)--"why aren't reference instructions being generated?" But this accident seems unlikely: `--allowed-instructions` defaults to enabling all kinds, so the user would have to explicitly filter out some kind, deliberately shooting themselves in the foot. Despite some risk of confusion (mitigated by the documentation in this PR), this filtering of instructions kinds ends up being useful in a general way: not only is it a start at fixing the issue above, it is useful for work I am doing to generate fuzz only parts of the spec.
- Loading branch information