On Fri, Nov 28, 2014 at 4:21 AM, Andreas Rossberg <[email protected]> wrote:
[...]
> With a normal ephemeral weak map implementation, like the one in V8,
> the value in a (map,key,value) triple can be reclaimed _immediately_
> (in the same cycle) when _either_ the map _or_ the key dies.
Hi Andreas, it is at this claim that I get confused. This is certainly
not true for a normal *ephemeron* map implementation, and is not true
for any ephemeron implementation I've read about, including years of
prior postings here on es-discuss. If this is true for v8, great!
Please walk me through what the v8 implementation does under the
following scenario:
m = new WeakMap();
non_garbage_var = m;
//... stuff not changing whether m is garbage
//... scavenge
{
const k = {};
const v = [k, m];
m.set(k, v);
}
//...assume that variables k and v are no longer reachable.
//...scavenge
// m has remained non-garbage the whole time.
// Immediately after the scavenge above, have k and/or v been either
collected or promoted?
I am also interested in the transposed scenario:
k = {};
non_garbage_var = k;
//... stuff not changing whether k is garbage
//... scavenge
{
const m = new WeakMap();
const v = [k, m];
m.set(k, v);
}
//...assume that variables m and v are no longer reachable.
//...scavenge
// k has remained non-garbage the whole time.
// Immediately after the scavenge above, have m and/or v been either
collected or promoted?
If the existing v8 implementation efficiently collects v as of the
second scavenge in both scenarios, or even if there is any known way
of doing so efficiently (that also deals with the general ephemeron
issue), I would be pleasantly astonished. My assumptions would indeed
be wrong, and I would indeed need to revisit all conclusions that
followed from these assumptions.
Do we have such good news?
Just to be explicit, my assumptions are:
Scavenging, in order to be as super efficient as it needs to be,
avoids any ephemeron collection algorithm during the scavenge itself.
A normal non-transposed ephemeron map implementation will promote k
and v as of the second scavenge in the first scenario, which is the
only safe option that postpones the ephemeron part of the gc
algorithm.
A normal non-transposed ephemeron map implementation will collect m
and v as of the second scavenge in the second scenario, since these
are collected merely by the classic scavenge without awareness of
ephemeron issues.
A transposed ephemeron map implementation will collect k and v as of
the second scavenge in the first scenario, since these are collected
merely by the classic scavenge without awareness of ephemeron issues.
A transposed ephemeron map implementation will promote m and v as of
the second scavenge in the second scenario, which is the only safe
option that postpones the ephemeron part of the gc algorithm for
transposed map representations.
--
Cheers,
--MarkM
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss