mirror of
https://github.com/HeyPuter/gex.git
synced 2026-11-13 20:12:43 -10:00
Stmt::X87 lowers to inline wasm for the common operands and, for the rest, a call to the new gex.x87 import, which computes the operation with gex_f80 -- the same algorithm, so either way the bits are the hardware's. The import is pure (it neither reads nor writes cached guest state), so the block does not flush or invalidate around it: it returns the result and leaves the status-word bits at ctx::X87_TMP + 12. Fast paths, under every rounding mode: - Narrow (fst m32/m64): J set and an exponent whose result is normal and stays finite even if rounding carries; about twenty instructions. - ToInt (fist/fisttp): zero, and 1 <= |v| < 2^(bits-1), rounded by RC or truncated, the indefinite with IE when rounding takes it out of range. The import is wired through gex-abi (X87, with its signature), the module's import section, both shims (native: a host function; browser: gex_x87, and gex.mjs's import objects) and the cross-engine harness, which declines it. X87Op::code for ToInt is now 0x100 | bits << 1 | trunc (0x10 collided with the bit width on decoding). shims/native/tests/x87.rs checks every operation lowers to a valid module in a plain block and in a fused loop. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01FFqjijkLKTTuaQutt3168C