Next: layout bitfid immediate, Up: layout bitfid [Contents][Index]
We’ve learned how CHICKEN distinguishes between pointers to (block) objects and immediate values. Now we will look into the nitty–gritty details of the object representation.
We can make the following breakdown of bit patterns (assuming a 32-bit platform):
XXXXXXXX XXXXXXXX XXXXXXXX XXXXXX00 Pointer to block object XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXX1 Fixnum (small integer) XXXXXXXX XXXXXXXX XXXXXXXX XXXXYY10 Other immediate object
This shows that the lower two bits can be used to distinguish between block objects (zero) and immediate objects (nonzero). For immediate objects, the low bit can be used to distinguish between fixnum objects and other kinds of immediate objects. Notice that for non–fixnum immediate objects: the 4 least significant bits ‘YY10’ are used for tagging the value as object of a specific kind.
Fixnums are distinguished from “other immediate” values because fixnums are so incredibly common: they are used for indexing into strings, loop counters and many calculations. These have to be represented as efficiently as possible while storing the widest possible range of values. Run time type checking for fixnums should use as few CPU instructions as possible.
The “other immediate” types are further differentiated through the top two bits of the lower nibble:
XXXXXXXX XXXXXXXX XXXXXXXX XXXX0110 Boolean XXXXXXXX XXXXXXXX XXXXXXXX XXXX1010 Character XXXXXXXX XXXXXXXX XXXXXXXX XXXX1110 Special object
The unused “other immediate” type of 0010
is reserved for future use. To get a good feel
for the representation of immediates, let us look at a few example bit patterns. We’ll also see how
to construct them in C.
Next: layout bitfid immediate, Up: layout bitfid [Contents][Index]