Bug 72346 - Weak reference harvesters should run to fixpoint
Summary: Weak reference harvesters should run to fixpoint
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: JavaScriptCore (show other bugs)
Version: 528+ (Nightly build)
Hardware: All All
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks: 72312
  Show dependency treegraph
 
Reported: 2011-11-14 19:27 PST by Filip Pizlo
Modified: 2011-11-15 12:10 PST (History)
1 user (show)

See Also:


Attachments
the patch (4.74 KB, patch)
2011-11-14 19:43 PST, Filip Pizlo
oliver: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Filip Pizlo 2011-11-14 19:27:12 PST
The weak reference harvester infrastructure is intended for use with inline caches and DFG optimized code that makes weak references to objects in the JavaScript heap.  But there is a special car that requires special treatment: a put_by_id transition refers to two structures, previous and next, and has the semantics of installing the 'next' structure if the previous structure was 'previous'.  Consider a sequence of put_by_id transitions as follows:

put_by_id empty -> a
put_by_id a -> b
put_by_id b -> c

It may be that this is the only code that refers to structures a and b.  'empty' refers to the global empty structure.  Hence, a and b are almost certainly dead during any GC, while empty and c are alive.  What we want the weak reference harvester to do is keep a alive so long as empty is alive, and then keep b alive so long as a is alive.  The best way to do this is to allow weak reference harvesters to mark objects, and to run them to fix point.
Comment 1 Filip Pizlo 2011-11-14 19:43:26 PST
Created attachment 115087 [details]
the patch
Comment 2 Filip Pizlo 2011-11-14 23:01:30 PST
Landed in http://trac.webkit.org/changeset/100242
Comment 3 Andy Wingo 2011-11-15 03:19:07 PST
You have probably already seen it, but this could be tangentially relative to ES.next weak maps:

http://wiki.ecmascript.org/doku.php?id=harmony:weak_maps

They propose an ephemeron-table weak map implementation, that avoids marking the values until a key is known to be alive.
Comment 4 Filip Pizlo 2011-11-15 12:10:22 PST
(In reply to comment #3)
> You have probably already seen it, but this could be tangentially relative to ES.next weak maps:
> 
> http://wiki.ecmascript.org/doku.php?id=harmony:weak_maps
> 
> They propose an ephemeron-table weak map implementation, that avoids marking the values until a key is known to be alive.

It is related. :-)  The big question for me is whether or not it would be wise to expose the O(n^2) implementation in this patch to the wild wild web.  My code should work great mainly because its uses will be limited to optimized JIT code, which constitutes a tiny fraction of the heap.  Not sure what will happen with these weak map thingies.