libera/#sicl - IRC Chatlog
Search
14:35:30
jcowan
Well, I keep pointing out the advantages of NaN-boxing, which gives you double floats for free.
14:42:42
beach
So I think we have already taken into account the advantages of NaN-boxing when we made a decision to do something else.
17:25:27
jcowan
beach: Not that I wish to waste your time, but can someone explain how there are costs for fixnum arithmetic other than a limitation on range (which is already the case with the present scheme, IIRC)?
17:30:00
pjb
jcowan: in the usual scheme, fixnum + is native + ; fixnum - is native - ; fixnum * is native * and shift ; fixnum / is a shift and native /.
17:30:22
pjb
jcowan: when you encode fixnums in NAN, you will have to mask out the NAN byte, and then mask it back in for each operation.
17:31:43
pjb
jcowan: on the other hand, compilation-time analysis let floating point expressions be compiled to purely floating point operations, with the unboxing/boxing done only once per function. (even less, when inline is used).
17:35:58
moon-child
beyond that, I will say that compile-time analysis can also let integer operations be done unboxed. It is purely a matter of which you prioritise: int math, or float math
17:36:34
moon-child
especially across abstraction boundaries--where float performance matters is more likely to be in tight loops where analysis can make it go away
17:39:06
jcowan
pjb: In JS-style NaN-boxing you'd be right, because double floats are the main type. But for Lisp purposes, you'd do it the other way: the doubles are rotated, the pointers+ints+chars+specials look normal.
17:40:05
jcowan
So double arithmetic is a little slow because of the rotation, but not nearly as slow as if it were boxed.
17:40:56
moon-child
I think in the past I suggested to steal a couple of exponent bits for that purpose
17:42:15
moon-child
I don't think you can make ints look normal, because nan means an all-ones exponent
18:28:40
jcowan
Bit-stealing means you have to do rounding in software unless you can prove that it's not necessary, so it's been abandoned. But you aren't following me about rotation.
18:34:11
moon-child
with bit-stealing, I imagined you would box in the rare case (very low or high magnitude float) that you can't fit in an immediate. Just the same as with integers