Re:Architecture of Lisp Machines (2008) [pdf]
by pfdietz on Friday July 02, 2021 @06:29PM
(#27717714)
The single most important trick I remember for Lisp on stock hardware was implementing pointers to cons cells as pointers to the next byte, and doing car/cdr by -1(reg) and 3(reg) (or 7(reg) on a 64 bit machine). This automatically traps on non-conses without any extra cost.
[ Parent
| on HN ]
Re:Architecture of Lisp Machines (2008) [pdf]
by rjsw on Saturday July 03, 2021 @08:36AM
(#27721206)
The original SPARC CPU is designed to use this tag encoding scheme, section D.4 of the V8 Architecture Manual describes how to use it.
Re:Architecture of Lisp Machines (2008) [pdf]
by pfdietz on Saturday July 03, 2021 @10:46AM
(#27721924)
Yes, that gives you flagging/trapping on arithmetic if any args are not fixnums. Aside from that, the idea works on other architectures as well.
Re:Architecture of Lisp Machines (2008) [pdf]
by bitwize on Saturday July 03, 2021 @01:42AM
(#27719642)
Oooooh, that is "square root magic constant" levels of dirty.
Re:Architecture of Lisp Machines (2008) [pdf]
by pfdietz on Saturday July 03, 2021 @06:04AM
(#27720541)
Also, it lets you implement fixnums with zero low order bits. That is, fixnum x is implemented as x << 2 (on 32 bit machines) or x << 3 (on 64 bit machines). With this encoding, addition and subtraction that is known to produce another fixnum can be done with ordinary add/sub instructions.