mirror of
https://github.com/vercel-labs/scriptc.git
synced 2026-11-10 01:56:15 +08:00
A sum or product of exact integers whose result range is not proven, such as `child + 1` of a speculated loop counter, computes its double and, beside it, an i64 wide view (`wideArithmetic`). Array indexes already used that view, but number compares and typed-array indexes did not: `child + 1 < end` compared doubles, and `a[child + 1]` converted the double back to an integer and tested the round trip before its bounds compare. `alwaysExactInteger` gives a value's exact integer, or its wide view when the view's magnitude bound is within the magnitude below which the view equals the double. A number compare whose two operands both have one compares the i64s, and a typed-array index uses it directly. Views that may differ from their double, such as `2 * root + 1` of a counter that may reach 2^53, keep the double compare.