[Vm-dev] Re: #flushCache with MethoWrappers in CogVM

Mariano Martinez Peck marianopeck at gmail.com
Sun Mar 20 13:47:41 UTC 2011


Anyone? I am having Cog crashed and I think it is related to this...



On Wed, Mar 16, 2011 at 11:20 AM, Mariano Martinez Peck <
marianopeck at gmail.com> wrote:

> Hi Eliot. I am implementing some kind of MethodWrappes/ObjectsAsMethod,
> whihc basically use the #run:with:in trick.
> My question is that I am not sure how to implement #flushCache in my
> wrappers. This method is called by MethodDictionary>>#at:put:  when I want
> to put back the original CompiledMethod.
>
> MyClass methodDict at: #foo put: MyWrapper withMethod: (MyClass>>#foo).
> ...
> MyClass methodDict at: #foo put:  wrapper wrappedMethod
> ->  here it sends #flushCache to my wrapper instance.
>
> In the StandardVM, I realised that at that moment, there is an entry in the
> cache that has selector: #foo, method:  my wrapped instance, class: MyClass,
> etc...
>
> So, to flush this, I have to options:
>
> MyWrappers>>flushCache
> self wrappedMethod selector flushCache
>
> or....
>
> MyWrappers>>flushCache
>   <primitive: 116>
>
> this is because "self" will be found in the entry as "method" in the cache
> table...
>
> So, first, are my assumptions correct?
>
> Now, in cog I am not sure if both solutions are still valid. If I see
> CoInterpreterPrimitives>> primitiveFlushCacheByMethod
>
> you do at the end:
>
> (self methodHasCogMethod: oldMethod) ifTrue:
>         [cogit unlinkSendsTo: (self cogMethodOf: oldMethod)]
>
> and
>
> methodHasCogMethod: aMethodOop
>     <api>
>     self assert: (objectMemory isNonIntegerObject: aMethodOop).
>     ^self isCogMethodReference: (self rawHeaderOf: aMethodOop)
>
>
> So, it is not safe if the method is something different than a compiled
> method.
>
> Is that correct? should I flush the cache entering by selector instead?
> which is the safe way to clean the cache in this case?
>
> thanks
>
> Mariano
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/vm-dev/attachments/20110320/97d4fd80/attachment.htm


More information about the Vm-dev mailing list