Stream: git-wasmtime

Topic: wasmtime / PR #11595 Manually register-allocate in inline...


view this post on Zulip Wasmtime GitHub notifications bot (Sep 02 2025 at 23:03):

alexcrichton opened PR #11595 from alexcrichton:update-inline-asm to bytecodealliance:main:

This commit fixes a mistake with our inline assembly for resumption of an exception on various platforms. This was detected during the development of #11592 for riscv64 but I believe this affects other platforms too. The basic issue is that our inline assembly blocks are all clobbering the frame pointer because that's what wasm uses but we have no constraint against preventing any input to these inline assembly blocks from being allocated into the frame pointer. This means that if the destination to jump to is allocated to the frame pointer register then we'll jump to wasm's old frame pointer, no the actual destination, because the frame pointer register is clobbered before jumping. An example of this for riscv64 is on [godbolt] where the s0 register, the frame pointer on riscv64, is clobbered and then jumped to.

The fix in this PR is to manually allocate all registers. All input operands are allocated to explicit registers rather than letting the compiler pick which register they're in. This ensures no overlap with the frame pointer and fixes the test in question. Note that s390x isn't updated here as it doesn't have a frame pointer.

[godbolt]: https://godbolt.org/z/E9vWb9coq

<!--
Please make sure you include the following information:

Our development process is documented in the Wasmtime book:
https://docs.wasmtime.dev/contributing-development-process.html

Please ensure all communication follows the code of conduct:
https://github.com/bytecodealliance/wasmtime/blob/main/CODE_OF_CONDUCT.md
-->

view this post on Zulip Wasmtime GitHub notifications bot (Sep 02 2025 at 23:03):

alexcrichton requested fitzgen for a review on PR #11595.

view this post on Zulip Wasmtime GitHub notifications bot (Sep 02 2025 at 23:03):

alexcrichton requested wasmtime-core-reviewers for a review on PR #11595.

view this post on Zulip Wasmtime GitHub notifications bot (Sep 02 2025 at 23:37):

cfallin submitted PR review:

Yikes, sorry about that! For all of our caution around regalloc constraints in Cranelift I should have known better with asm!!

view this post on Zulip Wasmtime GitHub notifications bot (Sep 03 2025 at 00:14):

cfallin merged PR #11595.

view this post on Zulip Wasmtime GitHub notifications bot (Sep 03 2025 at 17:22):

alexcrichton commented on PR #11595:

Oh no worries I also had no idea this was possible until riscv64 crashed on #11592... The main thing I found odd was that there was no regalloc constraint for "don't put things in the frame pointer register" or at least not that I could find


Last updated: Jan 09 2026 at 13:15 UTC