Here is the breakdown of why using existing libraries as-is failed and required building our custom-patched JIT runtime:
- Rosetta 2 by default emulates x87 with native ARM64 NEON scalar floats (IEEE-754 64-bit
double):- Real x86 CPUs execute x87 code on 80-bit extended-precision hardware registers and strictly adhere to the precision control field in the x87 Control Word (
CW.PC). - In Supreme Commander: Forged Alliance, the physics and simulation loop switches
CW.PCto 24-bit single-precision mode (0x007F). - Stock Rosetta 2 ignores
CW.PCcompletely and computes intermediate operations at 53-bitdoubleprecision.
- Real x86 CPUs execute x87 code on 80-bit extended-precision hardware registers and strictly adhere to the precision control field in the x87 Control Word (
- Rosetta also aggressively fuses multiply-add operations into ARM64 FMA (
fmadd/fmsub), which rounds only once at the end instead of twice (real x87 multiplies, rounds, adds, and rounds again).