64-bit Lisps



On Mon, Mar 25, 2013 at 5:13 AM, Henry Baker <hbaker1 at pipeline.com> wrote:

> It's bizarre how all these Lisps use different tagging regimes!
>

Henry -- The word bizarre may be a little strong here.  The tagging systems
used in the several stock-hardware implementations are usually very
carefully considered and may be designed for different tradeoffs between
speed, error detection, bits-consumed, etc.

One important operation is array referencing.  If the tagging system uses
the same number of bits as needed for the native word size (2 bits on
32-bit hardware, 3 bits on 64-bit hardware) then array reference with a
fixnum index requires no shifting.  A small detail, but it adds up in
benchmarks.  Other details in tagging are intended to optimize type
dispatching -- for example, there is an annoying jumble around the cons,
null, list, and symbol, and making these tests code efficiently can be
really important.  ("Optimal" tagging could be different on different
architectures, although exploiting this adds complexity to maintenance
across multiple platforms.)

One more detail that ought be made clear:  The integer length of fixnums
doesn't quite tell the entire story, as fixnums are required to be signed.
 If an implementation shows integer length of 60 for most-positive-fixnum
(and most-negative-fixnum) then it would be more accurate to say that
fixnums are 61 bits.  These values would be represented as
x7ffffffffffffff8 and x8000000000000000 respectively.  Another way of
looking at this is that the tagging system occupies 4 bits, and positive
and negative fixnums each have separate tags.