[Vm-dev] Problem with the method lookup sending a message twice

Mariano Martinez Peck marianopeck at gmail.com
Thu Mar 17 09:16:34 UTC 2011


Hi folks. I have a problem and I am completely clueless. I did one simple
modification to the method lookup: I want to check whether the class of the
receiver is a proxy and if true, send an special message. So I just modify
the first lines of:

lookupMethodInClass: class
    | currentClass dictionary found |
    <inline: false>
    self assert: class ~~ objectMemory nilObject.
    currentClass := class.
    [currentClass ~= objectMemory nilObject]
        whileTrue:
        [dictionary := objectMemory fetchPointer: MethodDictionaryIndex
ofObject: currentClass.


        "  THIS IS MY CHANGE "
        (currentClass = (objectMemory splObj: ProxyClass)) ifTrue: [
            self createActualMessageTo: currentClass.
            messageSelector := objectMemory splObj:
SelectorHandleProxyInvocation.
            self sendBreak: messageSelector + BaseHeaderSize
                point: (objectMemory lengthOf: messageSelector)
                receiver: nil.
            ^self lookupMethodInClass: (self superclassOf: currentClass)
        ].
        "  HERE FINISH MY CHANGE "

        dictionary = objectMemory nilObject ifTrue:
            ["MethodDict pointer is nil (hopefully due a swapped out stub)
                -- raise exception #cannotInterpret:."
            self createActualMessageTo: class.
            messageSelector := objectMemory splObj: SelectorCannotInterpret.
            self sendBreak: messageSelector + BaseHeaderSize
                point: (objectMemory lengthOf: messageSelector)
                receiver: nil.
            ^self lookupMethodInClass: (self superclassOf: currentClass)].
        found := self lookupMethodInDictionary: dictionary.
        found ifTrue: [^currentClass].
        currentClass := self superclassOf: currentClass].

    "Could not find #doesNotUnderstand: -- unrecoverable error."
    messageSelector = (objectMemory splObj: SelectorDoesNotUnderstand)
ifTrue:
        [self error: 'Recursive not understood error encountered'].

    "Cound not find a normal message -- raise exception #doesNotUnderstand:"
    self createActualMessageTo: class.
    messageSelector := objectMemory splObj: SelectorDoesNotUnderstand.
    self sendBreak: messageSelector + BaseHeaderSize
        point: (objectMemory lengthOf: messageSelector)
        receiver: nil.
    ^self lookupMethodInClass: class



Now, from the image side, I added ProxyClass and
SelectorHandleProxyInvocation  and:

ClassProxy>> handleProxyInvocation: aMessage
    Transcript show: 'a message: '; aMessage selector, 'was sent'; cr.


If I do ClassProxy new foo.  I see TWO times the message in the Transcript.
I mean, handleProxyInvocation:  is being invoke twice per message.

Thanks in advance for any help.

Mariano
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/vm-dev/attachments/20110317/577f72da/attachment.htm


More information about the Vm-dev mailing list