[virtmach] VM with garbage collection

David Rush virtmach@iecc.com
11 Jan 2002 11:43:18 +0000

"Stephan H.M.J. Houben" <stephanh@win.tue.nl> writes:
> Some approaches I have considered:
> 1. Since I am planning to represent small integers as tagged
>    words, I could represent every bytecode by such a tagged small
>    integer.
>    However, it seems somewhat wasteful of space.

So what? Memory is cheap, unless you're embedded. This is a
quick-but-not-very dirty solution with a lot to recommend it.

> 2. Apparently, the Smalltalk 80 VM splits a code vector in 2 parts:

There's a number of reasons for that beyond GC'ing immediate object
references (primarily reification and introspection). If you don't
have them I don't know that this would buy you all that much.

> 3. One could also directly embed the pointers in the instruction stream
>    and have a separate table that gives the offsets of all pointers, for
>    use by the GC. This is more complex and may lead to pointers not being
>    put on aligned addresses.

Alignment is one of the things that NOOPs are all about. Actually, I
think that this is a fairly common approach, if for no other reason
than that the constant vector is effectively the same as the closed
environment for a function.

> 4. As in 3., but observe that if the GC understands the instruction format,
>    it doesn't need the table but can find the pointers itself. This is very complex.

This is really a just refinement of 1. It loses to 3 because for 3 you
don't have to change the GC to accomadate new instructions or native

> I am leaning towards method 1. Any ideas if I'm going to lose big on space or time
> efficiency?

I'd go with 1 or 3. Actually, I'd probably go with 3 because it has a
nice correspondence to the way code is actually structured, but I
think I could implement 1 more quickly.

david rush
>From the start, when it was the instrument of the wood-god Pan, the
flute has been associated with pure (some might say impure)
energy. Its sound releases something naturally untamed, as if a
squirrel were let loose in a church." --Seamus Heaney