Chasing pointers...

Tim Rowledge tim at sumeru.stanford.edu
Fri Apr 2 04:33:02 UTC 2004


Alan Grimes <alangrimes at starpower.net> wrote:

> I noticed that the object format appears to be a 1 word header with 
> about 33 fields packed into 32 bits followed by the text of the object...
Well, as it says in section 5.1 Object Format of my chapter in the
nublu book :-

One word - all objects have this header. 
3 bits reserved for GC state machine (mark, old, dirty) 
12 bits object hash (for hashed Set usage) 
5 bits compact class index, non-zero if the class is in a group of classes known as 'Compact Classes' 
4 bits object format 
6 bits object size, in 32-bit words 
2 bits header type (0: 3-word, 1: 2-word, 2: free chunk of memory, not an object at all, 3: 1-word)
Two word - objects that are instances of classes not in the compact classes list. This second word sits in front of the header shown above. 
30 bits oop of the class 
2 bits header type as above
Three word - objects that are too big for the size to be encoded in the one-word header, i.e. more than 255 bytes. This third word sits in front of the two shown above.
30 bits of size
2 bits header type as above

I think this is still the case. 

> 
> I know it is common CS practice to point to the beginning of any given 
> data object...
> 
> Since, I presume, the most interesting computations involve the text of 
> the object, wouldn't it, on balance, be better to point to the _middle_ 
> of the object and skip adding BaseHeaderSize to everything?
Actually, I suspect that the header is accessed a great deal since it
is involved in message sending, anything requiring knowledge of the size
and format, all that sort of stuff.
 
> 
> By the way, Is there anything screwy going on with small integers that 
> causes negative values to be a different object type or something? It 
> would be damn convenient if I could just ignore the sign bit when it 
> suits my purpose..
Uh? Negative SmallIntegers are the same class, same type object as
positive ones. Oops have the bottom two bits zero (because they're jst
word aligned memory pointers) and SmallInts have a set bit at the
bottom with the rest of the bits being an otherwise normal 2s
complement value. What are you seeing to be thinking of anything
stranger than that? If you're seeing = & - SmallInts as separate
classes I think maybe your memory is messed up a bit.  The sign bit is
nothing to do with object class or format.

You'll need to tell us more, I think.


tim
--
Tim Rowledge, tim at sumeru.stanford.edu, http://sumeru.stanford.edu/tim
Oxymorons: Twelve-ounce pound cake



More information about the Squeak-dev mailing list