Concerns about weak refs and weak maps.

Brendan Eich brendan at mozilla.com
Fri Oct 29 16:09:37 PDT 2010


On Oct 29, 2010, at 4:01 PM, felix wrote:

> On 10/29/10 15:18, Jim Deville wrote:
>> C# 4.0 has WeakMap's too, and one of the goals was to work around the cyclical reference issue:
>> 
>> http://blogs.msdn.com/b/clrteam/archive/2009/05/18/the-conditional-weak-table-enabling-dynamic-object-properties.aspx
> 
> mono implements ConditionalWeakTable with Ephemeron tables registered with the GC.  The registration does nothing with boehm-gc, but there is special handling for Ephemerons in the experimental sgen-gc, and it looks to me like it's similar to what's described on the ECMAScript wiki for WeakMap: repeatedly scan Ephemeron key,value entries for values that are newly reachable, until no more newly-reachable values are found.
> 
> http://github.com/mono/mono/blob/09ae7f243df64f6928ffcd89eb44ac1f688c689e/mono/metadata/sgen-gc.c
> 
> it's instrumented to count how many times it repeats the Ephemeron scan, so it probably wouldn't be too hard to get practical data on how expensive it is in real usage.


We have a patch in progress for SpiderMonkey, in this bug:

https://bugzilla.mozilla.org/show_bug.cgi?id=547941

It won't be in Firefox 4.

Instrumentation is easy, the hard part (as ever) is workload selection. That would be good to build up, in advance of implementations.

/be


More information about the es-discuss mailing list