LispmFPGA: the goal of this project is to create a small Lisp-Machine in an FPGA
22 points by lproven
22 points by lproven
I’ve always been interested in what kind of fundamental things a lisp machine could do at a hardware level that would be helpful.
I know about the car/cdr thing but is that enough?
I haven’t used those neurons in years, but the two things I can remember are tagged values and various kinds of GC assistance. The following is a made up example, because I can’t remember any actual details…
Your processor has a 32-bit ALU, but a 36-bit word. The extra four bits encode the type of the value. If you use the ADD instruction on two words tagged as integers, they just add, otherwise there’s a “trap” (sort of a super lightweight interrupt — really just a CALL) that jumps to a handler that figures out if you’re trying to add bignums or arrays or what. Tags are also used to make it easier for GC to scan the heap. Object headers, pointers, and scalar values are distinguishable without need for type maps because each value knows what it is.
Other GC support might include hardware read/write barriers, where transferring a pointer (known to be a pointer, because of the tag) across a GC boundary causes a trap or automatically adds a tag bit. This lets you do some concurrent GC algorithms “in the background” without cluttering up the code.
You can see vestiges of this in later general-purpose CPUs, like (I think) SPARC and ARMv6 have tagged arithmetic that can trap based on the low bits.
Most of this became not worth the trouble as CPUs became suoerscalar, deeply pipelined, out of order, and massively cached. There’s enough wiggle room in the pipeline on modern processors to do things like tag checks and write barriers inline without costing much. Not to mention Intel spent a trillion dollars making the CPU just plain fast, and nobody invested anything like that in Lisp machines. The side effect is you get weird stuff like 30-bit integers because you have to steal the tags from the working bits.
I am really not sure, given the low-level expertise of some Lobsters folk, that I know enough to be a good person to answer this – but then again, very few people in the industry today seem to be interested in Lisp Machines, so maybe I’m the best available.
What sort of thing do you have in mind?
I can dig up some references, certainly, but there are also things I read that I’ve not been able to uncover again. For instance, there were at one point hard numbers and benchmarks, normalised for CPU performance, demonstrating that a lispm’s garbage collection performance could be so much better under load that it could outdo pure-software GC and non-GC code. But I couldn’t find that again last time I needed it…
Excellent project idea! I started writing a CPU to run WASM directly, also in an FPGA. It’s fun, even if there is no practical use-case