Squeak: Round About Squeaky Object

Squeak!
Updated: Nov 19, 1998.

An brief description of difference of Squeak and Smalltalk-80.


source code is here.
  1. Rupa Investigator WMC(Weighted Methods per Class) Goodies for Squeak.
  2. Rupa Investigator WMC(Weighted Methods per Class) Goodies for Squeak.

How to get the byte size of any object?

For Squeak, Basic concept is:

byteSize := total of
            bytes in Object Table Entry + 
            byte size of object header + 
            byte size of instance variables field + 
            byte size of indexable field

For VisualWorks the concept is:

byteSize := total of
            bytes in Object Table Entry + 
            byte size of instance variables field + 
            byte size of indexable field
See below:

Squeak does not have an object table

So bytes in Object Table Entry = 0 in Squeak.

byteSize := total of
            byte size of object header + 
            byte size of instance variables field + 
            byte size of indexable field
see direct pointer from OOPSLA paper ("Back to the Future")

Mr. OHSHIMA Yoshiki (The author of Squeak for the Sharp Zaurus) said:

an oop doesn't point at Object Table but object itself directly.

Size of object header is variable

Object headers can be 1, 2, or 3 words (4, 8, or 12 bytes). see The Object Memory from OOPSLA paper ("Back to the Future")

How to get the byte size of any method?

The response to size is the method size in bytes, including the method header, the literal frame, the bytecodes and the 4-byte sourcecode pointer at the end. Just add 4 for the object header.

Of course, you must consider "4 bytes boundary". Look at the expression for inc (the increment due to indexable bytes)

inc := (size + 3) bitAnd: 16r1FFFFFFC.
in the method ObjectMemory>>instantiateClass:indexableSize:, which might help you to understand exactly what gets allocated by the Squeak engine.

And other points

How to get the byte size of any BlockContext?

The home method context is a different object. Contexts and BlockContexts point to the home method rather than copying it. Need not add the size of aBlockContext home method.

SmallIntegers and Characters

SmallIntegers are immediate. Characters are not, but there are only 256 of them which are shared, so their space is effectively 0.

Small integers are immediate. Characters are shared references to one of a set of 256 Character objects. String elements are, of course, a single byte, which is used as an index into the 256 Character table.


Special thanks to

With helps, advices and encouragements by Smalltalkers Giants as Dan Ingalls, John Maloney, OHSHIMA Yoshiki and of course AOKI Atsushi. And Squeak mailing-list, SML (Smalltalkers' Salon -> Smalltalkers mailing-list in Japan).


Created: Nov 19, 1998.