I've always wondered how Smalltalk objects are represented in memory but never asked. I assume when objects are created that memory space is reserved for the instance variables and the Smalltalk objects actually point to these memory spaces. I also assume that the methods are stored in memory for the first instance of the object and each instance points to these methods.
For instance, if I have an object Person defined as
- Code: Select all
Object subclass: #Person
instanceVariableNames: 'firstName lastName'
firstName := aString
lastName := aString
^'%1 %2' bindWith: self firstName with: self lastName
I assume the Smalltalk representation of this has pointers to the memory spaces held by firstName and lastName. I also assume the Smalltalk representation has pointers to the method #printName and uses the pointers to firstName and lastName for the actual values.
Does anyone know how the objects are represented in memory when they are created? Or can anyone point me to a document or book that explains how memory is allocated for Smalltalk objects? Again, I've been curious about this for years but have not found anything on the subject.