[Mono-list] Making a ruby.net compiler

Miguel de Icaza miguel@ximian.com
10 May 2003 20:47:20 -0400


Hello,

    I pretty much agree with Paolo's analysis.  I want to add a few
comments for the general readership.

> So, you see that while the register machine design reduces the dispatch
> overhead vs a stack machine _interpreter_, the actual implementation has

    An interesting point of the design of the CLI is that it is an
encoding system for an intermediate language.  In the "real" language,
you have operations like:

	temp = b + c
	store temp, local

    Which corresponds roughly to:

	ldloc b
	ldloc c
	add
	stloc local

    That language maps into a stack machine easily, as you have pointed
out in your message.   But the bigger mistake is assuming that the
optimal way of executing the above is to interpret "push-local b",
"push-local c", "add two operands on stack", "store stack to local".

    The CIL stream should be decoded, not only from its bytecode
representation, but into its higher level meaning, so that the
interpreter does not cope with that, but with the higher order
constructs, as the ones illustrated before.

    For instance, Mono and goes through a process of recreating this
meaning in the method_to_ir() process.   At some point Dietmar wrote a
set of BURG rules for the *interpreter*.  Our interpreter was quite a
bit faster with this support, as it did not have to emulate a stack
machine, but rather had a list of higher-level instructions to execute. 
    Such an approach could be used by another virtual machine.

Miguel