Adding a new imediate type

Hans-Martin Mosner hmm at heeg.de
Tue Jan 3 16:43:43 UTC 2006


Colin Putney wrote:

> What would b really cool though, (and I don't know if Martin's work 
> allows for this) would be user-definable immediates. Adding a tag bit 
> allows for 2 more immediate classes. With the right primitives, one 
> could define a class, designate it as immediate and write methods that 
> manipulate the bits of the object references, much the way 
> SmallInteger does. There would probably have to be some machinery 
> similar to the way compact classes are managed.

That's exactly how my code works. There are 2 tag bits: The SmallInteger 
bit and the Immediate bit. For SmallIntegers, the higher 30 bites are 
the 2's complement value. For non-SmallInteger immediates, 4 more bits 
are used to designate a class, so there are 26 bits of value left. Of 
course, you can designate the same class to different bit patterns in 
that 4 bit index, resulting in wider values for less classes.

Cheers,
Hans-Martin



More information about the Squeak-dev mailing list