[Vm-dev] Weird problem when adding a method to StackInterpreter
Eliot Miranda
eliot.miranda at gmail.com
Thu Dec 22 20:02:36 UTC 2011
Hi Mariano,
On Thu, Dec 22, 2011 at 1:12 AM, Mariano Martinez Peck <
marianopeck at gmail.com> wrote:
>
>
>
>>>
>>> Moreover, when I ADD those lines, apart from the make error, when
>>> translating from SLANG to C, if I open a Transcript I see these
>>> "suspicious" lines:
>>>
>>> Removed findNewMethodInClass: because it refers to the local variable
>>> localSP of interpret.
>>> But it is either used outside of interpret or exported!!
>>> Removed lookupInMethodCacheSel:class: because it refers to the local
>>> variable localSP of interpret.
>>> But it is either used outside of interpret or exported!!
>>>
>>> BUT, none of those methods access localSP.
>>>
>>> Any idea of what can be wrong?
>>>
>>
>> For some reason lookupInMethodCacheSel:class: is not being inlined.
>> Since it uses localSP via internalStackValue: it must be always inlined
>> into the body of interpret. What I don't know is why adding a send of
>> traceObjectusage: after internalStackValue: causes inlining to fail.
>>
>
>
> Hi Eliot. I did some more tests and it even fails WITHOUT using
> #traceObjectUsage: . Just adding the line "rcvr := self
> internalStackValue: argumentCount." at the beginning of
> #lookupInMethodCacheSel:class: will cause the problem. So, the following
> even fails:
>
> lookupInMethodCacheSel: selector class: class
> "This method....."
>
> | hash probe rcvr |
> <inline: true>
> <asmLabel: false>
> rcvr := self internalStackValue: argumentCount.
> hash := selector bitXor: class. "shift drops two low-order zeros from
> addresses"
> ......
>
>
> Weird ehh, because you use #internalStackValue: along StackInterpreter in
> a lot of other places and you don't have problems there.
>
Turns out it's not weird at all. Since lookupInMethodCacheSel:class: is
used outside of interpret in findNewMethodInClass: and in callback lookup
it can't be inlined and hence can't access localSP. If you want to get the
receiver you'll need to use stackValue: *and* you'll need to ensure that
stackPointer is updated when calling lookupInMethodCacheSel:class: from
internalFindNewMethod (see externalizeFPandSP), which may slow down the
interpreter slightly.
>
>
>> You're going to have to delve into the inliner in Slang. This is, um,
>> not fun. I liken it to getting hit on the head with a stick by your guru,
>> except that no enlightenment results. Good luck.
>>
>>
> :( thanks.
>
>
>
>>
>>> Thanks in advance,
>>>
>>>
>>> --
>>> Mariano
>>> http://marianopeck.wordpress.com
>>>
>>>
>>>
>>
>>
>> --
>> best,
>> Eliot
>>
>>
>>
>
>
> --
> Mariano
> http://marianopeck.wordpress.com
>
>
>
--
best,
Eliot
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/vm-dev/attachments/20111222/38d252ed/attachment.htm
More information about the Vm-dev
mailing list