How to change your Squeak to 2 tag bits and more immediate classes
Hans-Martin Mosner
<hmm@heeg.de> (at work),
March 20, 1997
To do this, you need to be able to re-create your Squeak VM from the Smalltalk
sources in Squeak. I've tried to make the process as easy as possible, and
the changes to the VM should applicable even if you have modified it with
your own primitives.
There are 4 files:
- VM-2TagBits.cs
This changes your VM. You should file it into the image in which you
generate your VM, and then build a new VM. Be sure to backup everything,
as this change is radical!
The new VM will have an image format version of 6503 as opposed to 6502,
so you won't be able to run images saved by this VM with any older VM.
The new VM will be able to read old images, but the images won't run
correctly unless SmallInt-2TagBits.cs has been filed in first.
The reason for this is that the old SmallIntegers are converted to the
new format by simply shifting them 1 bit to the left. If they are not
in the appropriate range, their value will change.
In the new VM, primitives 126 and 127 are defined to support more immediate
classes. They are used by MoreImmediateClasses.cs.
- SmallInt-2TagBits.cs
This scans the image for SmallIntegers that would not fit into the range
that SmallInts will have after the 2-tag-bit conversion. These SmallIntegers
are converted into LargeIntegers. The file-in also changes the SmallInteger
minVal and maxVal methods to check for the actual range ofSmallIntegers
on image startup. An image prepared with these changes will still be
ok to use with an older VM, but when you want to save it for conversion
by a 2-tag-bit VM, you should execute "SmallInteger prepareFor2BitTags"
before saving to make certain that no SmallIntegers will be incorrectly
converted.
- MoreImmediateClasses.cs
The code in this file-in supports the creation of more immediate objects.
Currently it consists of 2 primitives that are used to convert between
SmallIntegers and other immediate values, plus somecode to register Immediate
classes with the CompactClasses Array (which will be extended from 31
to 47 entries for this purpose).
- SmallPoint.cs
This is an example of how the mechanism can be used. It modifies the
methods in class Point so that only the getters and setters for x and
y access the instance variables directly. Then a new subclass SmallPoint
is defined. You can use instances of the class just like normal points,
but the VM is not yet aware of them. Be warned that this has not been
fully tested!
SmallCharacters and other funny and useful things are left as an exercise
for the reader...
Have fun with this. I hope it will make it into the next Squeak release.
Hans-Martin