Template site objects and WeakMap
Mark S. Miller
erights at google.com
Wed Jun 17 02:31:37 UTC 2015
Hi Yusuke, I am not sure I understood your message. Could you show some
example code that would observe the observable difference you have in mind?
On Tue, Jun 16, 2015 at 7:25 PM, Yusuke SUZUKI <utatane.tea at gmail.com>
> Hi forks,
> In ES6 spec, template site objects are strongly referenced by the
> So naive implementation leaks memory because it keeps all the site objects
> in the realm.
> However, we can alleviate this situation.
> Because template site objects are frozen completely, it behaves as if it's
> a primitive value.
> It enables the implementation to reference it from the realm weakly. When
> all disclosed site objects are not referenced, we can GC them because
> nobody knows the given site object is once collected (& re-generated).
> But, even if the object is frozen, we can bind the property with it
> indirectly by using WeakMap.
> As a result, if the site objects are referenced by the realm weakly, users
> can observe it by using WeakMap.
> To avoid this situation, we need to specially handle template site objects
> in WeakMap; WeakMap refers template site objects strongly (if we choose the
> weak reference implementation for realm.[[templateMap]]).
> But this may complicate the implementation and it may prevent implementing
> WeakMap as per-object table (it can be done, but it is no longer simple
> private symbols).
> Is it intentional semantics? I'd like to hear about this.
> (And please point it if I misunderstood)
> Best Regards,
> Yusuke Suzuki
> es-discuss mailing list
> es-discuss at mozilla.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the es-discuss