Stream: git-wasmtime

Topic: wasmtime / PR #9859 pulley: Add add/sub-with immediate op...


view this post on Zulip Wasmtime GitHub notifications bot (Dec 18 2024 at 21:56):

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 on xconstN 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 for xconst8 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 extend BinaryOperands 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:

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 (Dec 18 2024 at 21:56):

alexcrichton requested cfallin for a review on PR #9859.

view this post on Zulip Wasmtime GitHub notifications bot (Dec 18 2024 at 21:56):

alexcrichton requested wasmtime-compiler-reviewers for a review on PR #9859.

view this post on Zulip Wasmtime GitHub notifications bot (Dec 18 2024 at 21:56):

alexcrichton requested dicej for a review on PR #9859.

view this post on Zulip Wasmtime GitHub notifications bot (Dec 18 2024 at 21:56):

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

view this post on Zulip Wasmtime GitHub notifications bot (Dec 18 2024 at 21:56):

alexcrichton requested wasmtime-default-reviewers for a review on PR #9859.

view this post on Zulip Wasmtime GitHub notifications bot (Dec 18 2024 at 22:24):

cfallin submitted PR review:

Nice!

view this post on Zulip Wasmtime GitHub notifications bot (Dec 18 2024 at 22:42):

cfallin merged PR #9859.


Last updated: Dec 23 2024 at 12:05 UTC