alexcrichton opened PR #14782 from alexcrichton:refactor-globals to bytecodealliance:main:
This commit refactors the representation of
VMGlobalDefinitionwhich for the longest time has been[u8; 16]and IIRC predates the addition ofunionto Rust. The previous implementation had a bug wherefuncreffields were loaded/stored as*mut VMFuncRefbut this is not compatible with provenance and Pulley. Instead globals needed to useOption<VmPtr<VMFuncRef>>, and instead of just fixing this one case for globals I've refactored globals to use aunion.The change here reflects the internal representation of wasm globals and how Cranelift accesses them. Documentation is additionally added indicating that some fields are little-endian and some are native-endian. The field type for
funcrefisOption<VmPtr<_>>to resolve the provenance issue as well.<!--
Please make sure you include the following information:
If this work has been discussed elsewhere, please include a link to that
conversation. If it was discussed in an issue, just mention "issue #...".Explain why this change is needed. If the details are in an issue already,
this can be brief.Our development process is documented in the Wasmtime book:
https://docs.wasmtime.dev/contributing-development-process.htmlPlease review the Bytecode Alliance's AI tool usage policy at
https://github.com/bytecodealliance/governance/blob/main/AI_TOOL_POLICY.mdPlease ensure all communication follows the code of conduct:
https://github.com/bytecodealliance/wasmtime/blob/main/CODE_OF_CONDUCT.md
-->
alexcrichton requested fitzgen for a review on PR #14782.
alexcrichton requested wasmtime-core-reviewers for a review on PR #14782.
alexcrichton requested wasmtime-compiler-reviewers for a review on PR #14782.
alexcrichton updated PR #14782.
github-actions[bot] added the label wasmtime:api on PR #14782.
:thumbs_up: fitzgen submitted PR review:
Thanks!
:speech_balloon: fitzgen created PR review comment:
I couldn't find a pre-existing issue on file for this TODO, mind creating one so it doesn't get lost?
:speech_balloon: fitzgen created PR review comment:
Ah, nevermind, I see the TODO didn't get lost
fitzgen added PR #14782 Represent globals as a proper union, fix provenance to the merge queue.
:check: fitzgen merged PR #14782.
fitzgen removed PR #14782 Represent globals as a proper union, fix provenance from the merge queue.
Last updated: Oct 31 2026 at 23:03 UTC