[Vm-dev] Copy Down to avoid Looking Up

Jecel Assumpcao Jr jecel at merlintec.com
Wed Mar 17 20:08:21 UTC 2021


I presented a similar design at OOPSLA 2003. It was for a unique
hardware (a low cost terminal for truck drivers) and had several
features I would not have normally put in a VM. The main memory was 4MB
of SDRAM since that was the lowest cost option at the time while it only
had 512KB of Flash. Even after expanding the compressed image from the
Flash to the SDRAM there was a lot of memory left over.

This was a 16 bit VM with 32K SmallIntegers and only 32K object
pointers. I made SmallIntegers do double duty as Symbols. So the number
3 and the symbol #between:and: might be the exact same object. You could
use it as one or the other by sending different messages as there is
very little overlap. You can find the "symbol string" associated with 3
by looking at the third entry in SymbolTable.

The equivalent of Class was the CodeObject. It includes all of the
compiled code for the class, both local and inhericated (copied down, as
you said). The processor had a bytecode style machine language so the
source texts from the compressed image was translated to that when
copied to the CodeObject.

The code objects had two parts: an initial set of entries with one entry
for every possible symbol and one huge chunk of code. Each entry had
enough room for 4 instructions, which is enough to implement most
methods. For those that need more space you just include a jump to
somewhere in the second part of the code object. The point was to
eliminate every extra clock cycle possible from a message send. Given a
pointer to some object, you could get its corresponding code object by
just zeroing the bottom few bits of the pointer (no memory access to get
the class from the oop). So if you are trying to send message 3 to oop
you just jump to:

call (oop & CodeObjectMask) + 3 * EntrySizeInBytes

Single clock cycle message sends for both local and inherited methods,
at a rather absurd cost in memory. If it were a 32 bit VM the wasted
memory would just be too silly.

A nice overview of the different ways to compress the class vs selector
tables can be found in the ECOOP 95 paper "Message Dispatch on Pipelined
Processors" by Karel Driesen, Urs Hölzle and Jan Vitek:

> https://www.researchgate.net/publication/221496253_Message_Dispatch_on_Pipelined_Processors

-- Jecel

More information about the Vm-dev mailing list