Object Format

Ian Piumarta ian.piumarta at inria.fr
Sun Oct 13 20:47:24 UTC 2002


On Sun, 13 Oct 2002, PhiHo Hoang wrote:
> - 4 bits object format
> 
> What is this 4-bit 'object format' field.

It tells you about what the instance contains.

The top bit (bit 3) is 1 for byte objects, 0 for word/pointer objects.

If the top bit is zero (words/pointers) then:
Bit 2 is 0 for pointer objects, 1 for words.
Bit 1 is set if there are indexable fields, 0 if there are none.
Bit 0 is set if there are fixed fields (named inst vars), otherwise 0.

A "word" object (bit 2 set) that has neither indexable nor fixed fields
(bits 1 and 0 clear) contains weak references and may have both fixed and
indexable fields.  (Unless the object contains only fixed fields then you
have to follow the class pointer and look in the class's "instanceSize"
field to find out how many fixed fields are in it.)

If bit 3 is set (byte object) then bit 2 tells you whether it's a compiled
method (set means it's compiled method).  Methods start with an extra
header word (look in class CompiledMethod to see what it contains)
followed by zero or more real pointers (the literals of the method).  
After the pointers they turn into byte objects again.  Bits 1 and 0 (of
any byte object) are the number of bytes by which the size header (or size
field in the base header) is too large (since a bytes object might be 0,
1, 2 or 3 bytes short of an integral number of words long).

To summarise, if we consider the format as an integer from 0 to 15, we
get:

0     0000 no fields
1     0001 fixed fields only (all containing pointers)
2     0010 indexable fields only (all containing pointers)
3     0011 both fixed and indexable fields (all containing pointers)
4     0100 both fixed and indexable weak fields (all containing pointers).
5     0101 unused
6     0110 indexable word fields only (no pointers)
7     0111 unused
8-11  10xx indexable byte fields only (no pointers)
12-15 11xx compiled methods: # of literal oops specified in method header

> Where can I find further detailed information about this 'object format'.

Browse class ObjectMemory in the image, and the object access primitives
in class Interpreter.

You might also find the following useful:

  http://www-sor.inria.fr/~piumarta/esug98/slides.ps.gz

starting around page 33.

Regards,
Ian







More information about the Squeak-dev mailing list