alexcrichton opened PR #9859 from alexcrichton:pulley-add-imm
to bytecodealliance:main
:
This commit extends the pulley opcode space with integer addition/subtraction where
src2
is an immediate. The goal here is to be a "sort of macro instruction" despite it not being too too macro here. This cuts down onxconstN
instructions which both saves space in the final binary and should be slightly more optimal perf-wise due to only one dispatch being needed.In this commit the
xadd32
instruction is previously 3 bytes: one for an opcode and 2 bytes for the dst/src1/src2 binary operands. Adding a small constant to a register previously took 5 bytes where 2 bytes were needed forxconst8 N
then 3 for the addition. Here the encoding size of the new instruction is 4 bytes: 1 for the opcode, 2 for dst/src1, and one for the immediate. This is currently chosen to mostly optimize dispatch in the interpreter loop as opposed to code size (as only a single byte is saved). In the future thought it would be possible to extendBinaryOperands
to one operand being a 6-bit immediate to preserve the same code size.This also notably adds, for addition/subtraction, only unsigned immediates. With addition/subtraction being inverses of one another supporting signed immediates isn't necessary and helps free up another bit for packing numbers into these opcodes.
This change reduces the size of
spidermonkey.cwasm
from 31M to 29M locally.<!--
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 cfallin for a review on PR #9859.
alexcrichton requested wasmtime-compiler-reviewers for a review on PR #9859.
alexcrichton requested dicej for a review on PR #9859.
alexcrichton requested wasmtime-core-reviewers for a review on PR #9859.
alexcrichton requested wasmtime-default-reviewers for a review on PR #9859.
cfallin submitted PR review:
Nice!
cfallin merged PR #9859.
Last updated: Dec 23 2024 at 12:05 UTC