alexcrichton opened PR #11271 from alexcrichton:x64-jmp-short to bytecodealliance:main:
Cranelift does not currently implement any form of "relaxation" of instructions where, for example, a 32-bit jump is shrunk to an 8-bit jump if the destination actually fits. In lieu of this Cranelift pessimistically emits 32-bit jumps on x64, for example, for all jumps between basic blocks. This is a difficult problem to solve in general but for pseudo-instructions it's a much more targeted problem which should be easier to solve.
This commit updates all pseudo-instructions in the x64 backend to use 8-bit jumps instead of full 32-bit jumps within their code bodies. It's statically known that the instructions bodies being generate are all small enough to fit in 8 bits. This helps shrink the generated code for a number of instructions whenever a pseudo-inst is used instead of basic blocks.
Optimizing jumps between basic blocks is left as a future optimization as it's likely to be much more difficult to implement than this.
<!--
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 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 #11271.
alexcrichton requested wasmtime-core-reviewers for a review on PR #11271.
alexcrichton requested wasmtime-compiler-reviewers for a review on PR #11271.
alexcrichton updated PR #11271.
abrown submitted PR review:
Looks like smaller code for all these sequences; :+1:
abrown merged PR #11271.
Last updated: Dec 06 2025 at 06:05 UTC