mirror of
https://github.com/vercel-labs/scriptc.git
synced 2026-11-09 09:09:47 +08:00
The slow path of ToUint32 (NaN, the infinities and magnitudes above 2^53) reduced the value with `frem`, which lowers to an `fmod` call. The call is pure, so LLVM sometimes hoisted it above the range test onto the fast path (65,865 calls in one tsc-ts parse). A finite double above 2^53 is its integer mantissa shifted left by exponent - 1075 >= 1, so its low 32 bits are the shifted mantissa's (none once the shift reaches 64), negated for a negative value. NaN and the infinities have the maximum exponent and give 0. The slow path is now integer arithmetic on the double's bits with no branches.