Adds the i64 value type to the compiler: params/results/locals/globals/block types, i64.const, comparisons, add/sub/mul/div/rem, bitwise ops, shifts/rotates, i32.wrap_i64 / i64.extend_i32_{s,u}, sign-extension ops, and all i64 loads/stores (including narrow forms). Globals can be initialised with i64.const.
Why
The compiler was i32-only, so any module using i64 was rejected. The value stack, locals and globals were already 8 bytes wide, so supporting i64 mostly meant emitting REX.W variants of the existing instructions.
Details
Division traps on a zero divisor and on INT64_MIN / -1; INT64_MIN % -1 returns 0.
global.get/set now move 64 bits (works for i32 globals too).
Memory-access code was reworked around a per-opcode size/encoding table.
Not included: clz/ctz/popcnt (missing for i32 as well), floats.
Testing
New examples/i64.wat self-checks 22 cases (fib(40), div/rem edge cases, signed vs unsigned compares, shifts/rotates, conversions, memory, globals) and exits 0 on success; it does.
Existing examples produce the same exit codes/traps as before.
wasm-tools wasn't available in my environment, so I assembled the .wat files with the npm wabt package; moon test and just examples were not run.
## What
Adds the i64 value type to the compiler: params/results/locals/globals/block types, `i64.const`, comparisons, add/sub/mul/div/rem, bitwise ops, shifts/rotates, `i32.wrap_i64` / `i64.extend_i32_{s,u}`, sign-extension ops, and all i64 loads/stores (including narrow forms). Globals can be initialised with `i64.const`.
## Why
The compiler was i32-only, so any module using i64 was rejected. The value stack, locals and globals were already 8 bytes wide, so supporting i64 mostly meant emitting REX.W variants of the existing instructions.
## Details
- Division traps on a zero divisor and on `INT64_MIN / -1`; `INT64_MIN % -1` returns 0.
- `global.get/set` now move 64 bits (works for i32 globals too).
- Memory-access code was reworked around a per-opcode size/encoding table.
- Not included: clz/ctz/popcnt (missing for i32 as well), floats.
## Testing
- New `examples/i64.wat` self-checks 22 cases (fib(40), div/rem edge cases, signed vs unsigned compares, shifts/rotates, conversions, memory, globals) and exits 0 on success; it does.
- Existing examples produce the same exit codes/traps as before.
- `wasm-tools` wasn't available in my environment, so I assembled the `.wat` files with the npm `wabt` package; `moon test` and `just examples` were not run.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Stack slots, locals and globals were already 8 bytes wide, so i64 is mostly
64-bit encodings of the existing i32 ops: constants, comparisons, arithmetic,
bitwise, shifts/rotates, div/rem (with zero and overflow traps), wrap/extend,
sign-extension ops, i64 loads/stores (incl. narrow forms) and 64-bit globals.
Adds examples/i64.wat, which self-checks and exits 0 on success.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
What
Adds the i64 value type to the compiler: params/results/locals/globals/block types,
i64.const, comparisons, add/sub/mul/div/rem, bitwise ops, shifts/rotates,i32.wrap_i64/i64.extend_i32_{s,u}, sign-extension ops, and all i64 loads/stores (including narrow forms). Globals can be initialised withi64.const.Why
The compiler was i32-only, so any module using i64 was rejected. The value stack, locals and globals were already 8 bytes wide, so supporting i64 mostly meant emitting REX.W variants of the existing instructions.
Details
INT64_MIN / -1;INT64_MIN % -1returns 0.global.get/setnow move 64 bits (works for i32 globals too).Testing
examples/i64.watself-checks 22 cases (fib(40), div/rem edge cases, signed vs unsigned compares, shifts/rotates, conversions, memory, globals) and exits 0 on success; it does.wasm-toolswasn't available in my environment, so I assembled the.watfiles with the npmwabtpackage;moon testandjust exampleswere not run.🤖 Generated with Claude Code