On Mon, Apr 1, 2013 at 2:56 PM, Brendan Eich <bren...@mozilla.com> wrote:

> Hudson, Rick wrote:
>
>>
>> This brings up another interesting point. Do WeakRefs change a compiler’s
>> liveness analysis?
>>
>>
> Yes, of course.
>
>
>  This could complicate some apparently useful optimizations.
>>
>> {
>>
>> var x = new Something();
>>
>> someWeakRef.set(x);
>>
>> // Is x dead? (yes) Is x required to contribute to the root set? (I hope
>> not.)
>>
>>
> You dind't kill x yet. Did you forget
>
> x = null;
>
> here?
>
>
>  gc();
>>
>> someWeakRef.get() // null or foo?
>>
>>
> If x = null; happened before gc() then null else the original ref.


Not necessarily. For example, a conservative gc might not be able to see
that foo is no longer actually reachable. <
http://wiki.ecmascript.org/doku.php?id=strawman:gc_semantics> explains that
this is why it states such matters as SHOULDs rather than MUSTs.

Of course, if we imagine a gc() function with a stronger contract, then the
above would follow. I am skeptical that we could ever state such a stronger
contract that all JS implementors could agree to.

-- 
    Cheers,
    --MarkM
_______________________________________________
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to