[Vm-dev] Weird problem when adding a method to StackInterpreter

Eliot Miranda eliot.miranda at gmail.com
Thu Dec 22 00:32:49 UTC 2011


On Wed, Dec 21, 2011 at 2:04 PM, Mariano Martinez Peck <
marianopeck at gmail.com> wrote:

>
> Hi guys. I am migrating some old stuff I have about tracing object usage
> to the latest version of Cog. I have in StackInterpreter a method which
> looks like this:
>
> traceObjectUsage: anOop
>     ((self isIntegerObject: anOop) not and: [hasToTrace])
>         ifTrue: [
>             objectMemory setExperimentalBitOf: anOop to: true.
>             ]
>
> So I have also added #setExperimentalBitOf:to:  to ObjectMemory, and I
> have added the instVar 'hasToTrace' to the StackInterpreter. So now from
> some methods of StackInterpreter, I add sends to this method to trace OOPs.
> This is working fine, but there is one particular method where I cannot do
> it. The method is #lookupInMethodCacheSel:class:  and I am trying to do
> something like:
>
> lookupInMethodCacheSel: selector class: class
>     "This method  ....."
>
>     | hash probe rcvr |
>     <inline: true>
>     <asmLabel: false>
>     self traceObjectUsage: class.
>     rcvr := self internalStackValue: argumentCount.
>     self traceObjectUsage: rcvr.
>     hash := selector bitXor: class.  "shift drops two low-order zeros from
> addresses"
>  .......
>
> In this particular method, the problem is with the two lines:
>     rcvr := self internalStackValue: argumentCount.
>     self traceObjectUsage: rcvr.
>
> If I DO NOT put those two lines, then it compiles perfect. If I put those
> lines, I have a compilation error:
>
> Undefined symbols:
>   "_lookupInMethodCacheSelclass", referenced from:
>       _lookupreceiver in gcc3x-cointerpmt.c.o
>       _handleMNUInMachineCodeToclassForMessage in gcc3x-cointerpmt.c.o
>       _ceSendsupertonumArgs in gcc3x-cointerpmt.c.o
>       _ceSendFromInLineCacheMiss in gcc3x-cointerpmt.c.o
>       _ceSendAborttonumArgs in gcc3x-cointerpmt.c.o
>       _interpret in gcc3x-cointerpmt.c.o
>       _interpret in gcc3x-cointerpmt.c.o
>       _sendInvokeCallbackStackRegistersJmpbuf in gcc3x-cointerpmt.c.o
>       _sendInvokeCallbackContext in gcc3x-cointerpmt.c.o
>   "_findNewMethodInClass", referenced from:
>       _primitivePerform in gcc3x-cointerpmt.c.o
>       _primitiveObjectperformwithArgumentslookedUpIn in
> gcc3x-cointerpmt.c.o
>       _primitiveInvokeObjectAsMethod in gcc3x-cointerpmt.c.o
> ld: symbol(s) not found
> collect2: ld returned 1 exit status
> make[2]: ***
> [/Users/mariano/Pharo/VM/git/cogVMBlessedSSH/blessed/results/CogMTVM.app/Contents/MacOS/CogMTVM]
> Error 1
> make[1]: *** [CMakeFiles/CogMTVM.dir/all] Error 2
> make: *** [all] Error 2
>
>
> 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.
 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 in advance,
>
>
> --
> Mariano
> http://marianopeck.wordpress.com
>
>
>


-- 
best,
Eliot
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/vm-dev/attachments/20111221/d71c1081/attachment.htm


More information about the Vm-dev mailing list