Skip to content

wasmparser: avoid skipping locals to get OperatorsReader for a function body #2204

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
merged 1 commit into from
May 23, 2025

Conversation

keithw
Copy link
Contributor

@keithw keithw commented May 23, 2025

This PR lets users turn a finished LocalsReader into an OperatorsReader, avoiding a need to ask the FunctionBody to skip through the locals again (as suggested at #2180 (comment) -- @alexcrichton if you prefer a different/better way to do this please feel free to ignore this one!).

This seems to yield roughly a 3-4.5% improvement in the parse/tests, parse/bz2, parse/spidermonkey, etc. benchmarks.

The validator was already doing this (https://github.com/bytecodealliance/wasm-tools/blob/main/crates/wasmparser/src/validator/func.rs#L82-L87) and is unchanged by this PR, so I didn't expect this to affect validation time -- although I am seeing a ~1.5-2% slowdown in the validate tests for reasons unknown (hopefully just random variation from how this is being compiled).

@alexcrichton alexcrichton added this pull request to the merge queue May 23, 2025
@alexcrichton
Copy link
Member

Nah yeah this all looks reasonable to me, thanks!

Merged via the queue into bytecodealliance:main with commit 03b0d14 May 23, 2025
32 checks passed
@keithw keithw deleted the avoid-skip branch May 26, 2025 22:27
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