Kernel LISP - how low down can it go?

Dave Hudson
Wed, 21 May 1997 17:23:03 +0100 (BST)

I'm interested in the idea of implementing an OS kernel in a Lispy 
language (have been for about a year or so in fact), having previously 
done quite a lot of OS work in C.  The thing I'm not sure about is how 
low-level it's possible to get with something like Lisp before it's 
necessary to hit some sort of assembler code?

As an example, with C on a 386 I can use the full 32 bits of a register to
store value information since everything is statically typed.  This lets
me do interesting things with say virtual memory and exception handling
(e.g. I can get the address of a faulting instruction).  If I now move to
a dynamically typed language such as Scheme (I appologise now for my lack
of knowledge of CL) I either need to create a new primitive type that can
give me 32 bits still whilst still providing a type tag or I need to use
some sort of language dialect that uses type inference (something like
Infer say).

Clearly in the first case I end up with something that's inherently more
expensive to use (than I'd get with C) whilst the second doesn't really
give me the language I want (I obviously want dynamic typing).  A third
alternative might be to do most of the exception handling in some sort
of assembler micro-kernel and then pass the details back out to the Lisp
code in a different way.

Is there a fourth alternative that I don't know of (or didn't think of)?

Along a similar line, someone on this list (I think it was Henry Baker) 
commented that they'd like to implement some of the GC in Lisp - wouldn't 
this run into the same sort of problems (i.e. the dynamically-typed Lisp 
code would inherently run much slower than an assembler version would do)?

I would think that a similar argument must be true for the idea of making 
bignums out of fixnums?

If I understand it correctly, this sort of thing wasn't so much of an
issue with the original Lisp machines because they had hardware support
for type tagging.

Does anyone know of any tricks that allow me to hit the sort of C
performance levels, or anywhere where I might be able to find such
information?  Alternatively, if the answer is to resort to a core
assembler runtime system, does anyone have any ideas on what it ought to

BTW please don't think I'm knocking Lisp here (vs C) - if the answer is 
that I need to live with the performance losses then fine, but I'd like 
to try and understand the size of any losses sooner rather than later.