[Vm-dev] Immediates

Jecel Assumpcao Jr jecel at merlintec.com
Fri May 8 21:26:49 UTC 2009

Sorry about the wrong attribution - Celeste makes a big mess of all of
Eliot's emails and most replies to those emails. Unfortunately, fixing
this is not currently near the top of my "to do" list so I'll just have
to deal with this for a few more months.

I totally agree about the value of immediates being to speed up
computations by avoiding allocations. My idea for symbols was not to
avoid the costly mapping of strings to new instances but rather speed up
class lookup a little bit. This wouldn't help us now, but for a future
modular Squeak that would be loading and unloading object graphs all the
time, this could make a difference.

Like VisualWorks, Self uses 30 bit integers with a 00 tag (which makes
detagging/retagging unnecessary for addition, subtraction and bitwise
logical operations). The other tag values represent 30 bit floats,
object pointers (you always use a constant offset with these anyway, so
the detagging can be built into that constant) and object headers. The
memory is divided into segments (generations) and each segment stores
tagged data from the bottom and binary data from the top. ByteVectors
are normal tagged objects with a SmallInteger pointing to the actual

The idea of a tag pattern for object headers is that you can "flatten"
the memory scanning operations. You just scan from top to the limit
until you found what you were looking for and then back up to the
previous header to see what object contains that oop. This can be many
times faster than a objects do: [ :obj | obj fieldsDo: [ :oop | ....]]
nested loop.

For my old RISC42 design I came up with the idea of having the top two
bits the same to indicate SmallIntegers. This is hard to check in
software, but in hardware is just a two input XOR gate. This allows you
to avoid detagging not only for the operations I mentioned above, but
also for multiplies, divides, left shift and signed right shift too. A
few weeks ago I found out that the old Swamp Smalltalk computer from
1986 used exactly the same scheme (the two patterns where the top two
bits were different were used for oops and for pointers to context

-- Jecel

More information about the Vm-dev mailing list