Skip to content

Stop passing around &WasmFeatures #2121

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

alexcrichton
Copy link
Member

This commit updates the validation phase of wasmparser to avoid passing around &WasmFeatures all over the place. Instead it's now stored within module/component state in addition to the validator itself to store a duplicate copy. This should be reasonable to do as WasmFeatures is cheap to clone/copy.

The main motivation for this is that it's a big pain to pass around these features. Existing code paths often start getting it as a new argument when new wasm proposals are implemented and it's quite a lot of threading around to do. There's not really much reason to avoid copies when everything is a single source of truth from the validator anyway and the features never change afterwards, so reduce the cognitive complexity by just storing copies in module/component states.

This commit updates the validation phase of wasmparser to avoid passing
around `&WasmFeatures` all over the place. Instead it's now stored
within module/component state in addition to the validator itself to
store a duplicate copy. This should be reasonable to do as
`WasmFeatures` is cheap to clone/copy.

The main motivation for this is that it's a big pain to pass around
these features. Existing code paths often start getting it as a new
argument when new wasm proposals are implemented and it's quite a lot of
threading around to do. There's not really much reason to avoid copies
when everything is a single source of truth from the validator anyway
and the features never change afterwards, so reduce the cognitive
complexity by just storing copies in module/component states.
@alexcrichton alexcrichton marked this pull request as ready for review April 1, 2025 19:12
@alexcrichton alexcrichton added this pull request to the merge queue Apr 1, 2025
Merged via the queue into bytecodealliance:main with commit 2c0c3fd Apr 1, 2025
32 checks passed
@alexcrichton alexcrichton deleted the less-feature-arguments branch April 1, 2025 21:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants