[virtmach] Virtual Machines and Code Representation

Reuben Thomas Reuben.Thomas@cl.cam.ac.uk
Mon, 24 Jul 2000 19:07:33 +0100 (BST)


On Mon, 24 Jul 2000, John R Levine wrote:

> > I've not been impressed with what I've seen of ANDF.  It doesn't seem to me
> > to exploit the structure of abstract tree code very well.
> 
> Me neither.  Despite claims to the contrary by some of its authors, it's yet
> another attempt at an UNCOL, a universal intermediate language, and it's
> failed for the same reasons that every other UNCOL project has failed since
> the original one in the 1950s, basically that we can't abstract either
> language semantics or machine architecture well enough to avoid an impossible
> morass of special case hacks in such a language. 

I don't think this is quite true. Provided you limit your aims, and stay
really low level, the right combination of care and brutality can be
found. My own attempt at this, Mite (see my home page, URL below), is
certainly flawed, but illustrates, I think, that it is possible to design
a low-level VM that gives binary portable code for a wide range of
languages.

Mite is tailored to a C-like world, but that's not a problem, as many
modern high-level languages are compiled into C or via a C-like
intermediate language. This simply acknowledges the fact that most system
calling conventions are built on C. You wouldn't want to compile ML or APL
directly to Mite, for example, but it's designed for languages that would
otherwise be compiled directly to machine code.

Mite's biggest strength, in my view, is that it leaves many of the
tradeoffs between portability, speed, and simplicity in the hands of the
compiler writer, rather than requiring magically good JITs for decent
performance (VM authors often seem to resort to the "but of course it'd be
fine with a properly optimising JIT" argument).

However, though it's a small beast, it's still quite complex (considering
that it has nothing to say about security, libraries, or even floating
point), and there are many subtleties involved in implementing it
correctly and efficiently (they are, unsurprisingly, much the same
problems that one has with writing C compilers).

I've also been working on a simpler version on a par with GNU Lightning in
terms of expected performance. Unsurprisingly, dropping this single
criterion makes life much easier!

-- 
http://sc3d.org/rrt/ | Si hoc legere scis nimium eruditionis habes.