[Vm-dev] Squeak Object Engine Message Sending clarification
gettimothy at zoho.com
Sun Dec 8 17:28:10 UTC 2013
I am very glad I asked. (:
I have cut-n-paste your reply into my study plans.
thank you very much.
---- On Sun, 08 Dec 2013 09:12:08 -0800 David T. Lewis<lewis at mail.msen.com> wrote ----
On Sun, Dec 08, 2013 at 08:19:59AM -0800, gettimothy wrote:
> No need to go into details as I am just attempting to avoid a misconception.
> On page 5 of 28 on Tim Rowledge's (very useful and enjoyable, btw) A Tour of the Squeak Object Engine
> I am unclear as to what object's header' refers to in step I.
> To send a message to a receiver, the VM has to:-
> I. find the class of the receiver by examining the object's header.
> II. lookup the message in the list of messages understood by that class
> (the class's MethodDictionary)
> It seems 'obvious' to me that it has to be something in the current MethodContext, and that 'object' does not refer to something out in ObjectMemory
Actually it does refer to something out in the ObjectMemory. There is
an excellent summary in the class comment of ObjectMemory, so read that
for an overview (it's short, but be prepared to read it several times
slowly to wrap your head around it).
Each object in the object memory can be referenced by an object pointer.
This is not a pointer in the C sense of the word, so the various references
to "pointers" throughout the VM code may be confusing in that regard.
The object pointer identifies the current location of the object in
the object memory. It points to the location of the object header, which
is described in detail in the ObjectMemory class comment. The header
may be one or more words in length, and you can think of the header
words as extending to the left (memory locations 0, -1, -2) of the first
object header word. Any data required to represent the object then
extends to the right (1, 2, 3, ...) of the object header location.
Object headers contain enough information to identify the class of
the object, and that is what Tim means by "find the class of the receiver
by examining the object's header". Tim and Eliot can explain the rest
better than I can, but hopefully this clarifies some of it.
Note that the 64-bit object format described in ObjectMemory is not
the same thing as the newer format that you will be working on with
Eliot (it is a simple extension of the current 32-bit object format),
but understanding that format may also be helpful in understanding
the work that Eliot is doing now.
On Sun, Dec 08, 2013 at 11:54:46AM -0500, Bob Arning wrote:
> "object" in this case is something on the stack. Sending a message
> involves pushing the receiver ("object") and arguments onto the stack
> and then sending the message (some variant of send bytecode) which
> causes the vm to look on the stack for the receiver and then follow the
> receiver's class chain to find the suitable method.
And to relate this what I was was saying, the object on the stack is
an object pointer, which gives the VM enough information to locate
the object header out there in the object memory.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Vm-dev