4 ms·
Also, NaN boxing. Which is (was?) used by JavaScript Core (Safari’s JS engine). All values are stored as a double; true, false, null, undefined have different
by hinoki 5y ago
Also, NaN boxing. Which is (was?) used by JavaScript Core (Safari’s JS engine).
All values are stored as a double; true, false, null, undefined have different NaN values. NaN even has enough spare bits to store Object pointers. Short strings are also stored packed into NaN bits.
- cormacrelf 5y agoHopefully not as an actual double, right? Not that many floating point registers compared to integer on most archs.
- hinoki 5y agoI think you can use general purpose registers so long as you don’t actually need to do IEEE 754 math. I’m not clear on the details of how the byte code/JIT deals with it, my only experience is with hire values are stored in the heap.
- saagarjha 5y agoYes, they’re stored in a union and passed around as whatever is convenient.
- Tuna-Fish 5y agoThere are an equal amount of vector (also used for FP) regs as there are gprs on x86_64 and on Aarch64. Since those registers are rarely used in normal general purpose code, moving some values over there in principle saves register space. (x87 fp is obsolete and should never be used for anything.)
- KMag 5y agoI'm not sure the latency on moving data between SSE and GP registers on modern x86 processors. If I remember correctly, late 1990s x86 was notoriously slow at moving data between GP registers and the x87 fp stack. I could certainly believe that on some architectures, moving data between vector registers and GP registers is slower than an L1 cache access.
- saagarjha 5y agoIt’s still in use, plus Mozilla uses it too.