[Vm-dev] Re: Performance of primitiveFailFor: and use of primFailCode

Eliot Miranda eliot.miranda at gmail.com
Wed May 25 00:40:57 UTC 2011


On Tue, May 24, 2011 at 5:34 PM, Igor Stasenko <siguctua at gmail.com> wrote:

>
> On 25 May 2011 00:51, Craig Latta <craig at netjam.org> wrote:
> >
> >
> > Hi Igor--
> >
> >> > ...now I'm looking forward to ephemeron conflicts. :)
> >> >
> >>
> >> What conflicts?
> >>
> >> Please elaborate :)
> >
> >     Oh, none yet, I just suspect there will be some with the stuff I
> > wrote to GC stale methods.
>
> Yes. This could be a problem. Consider a following:
>
> MyClass>>someMethod
>  ^ #( 'abc' 'def' )
>
>
> ephemeron := Ephemeron new
>   key: self someMethod first
>   value: somethingElse.
>
> So, we created an ephemeron, whose key are object which came from
> method's literals. And even worse,
> as it shown above, it could be not a direct literal, but nested object.
>
> Now, if you GC this stale #someMethod , it will apparently turn
> ephemeron's value to be weakly referenced,
> and its key will be lost and replaced by nil.
>

Uh, no.  The ephemeron refers to the string 'abc' that happened to be
referenced by the method.  But that string won't be garbage collected until
there are no references to it in the system, including from the ephemeron.
 i.e. the ephemeron will either need to nil its key or itself be collected
before the 'abc' string can be collected.  There is no magic here with
references to objects from methods.  In Smalltalk, methods are just objects.
 [and in the Cog VM there is a little bit of chicanery to preserve the
illusion that there are no machien code methods involved, but that's what it
does; hide the machine code].


>
> To circumvent that, you have to make sure that all literals which kept
> by method are still reachable from roots by other means.
> Another approach is to detect and do something with such problematic
> ephemerons, but as example shows, this could be tricky.
>
> Btw this will happen with other weak refs as well.
>
> array := WeakArray with: self someMethod first.
>
> do you have a solution for that?
>
> Of course it depends on your intents.
>
> --
> Best regards,
> Igor Stasenko AKA sig.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/vm-dev/attachments/20110524/b5c377fc/attachment.htm


More information about the Vm-dev mailing list