Bug 70468 - DFG call optimization handling will fail if the call had been unlinked due to the callee being optimized
Summary: DFG call optimization handling will fail if the call had been unlinked due to...
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: 69996
  Show dependency treegraph
 
Reported: 2011-10-19 19:51 PDT by Filip Pizlo
Modified: 2011-10-20 22:14 PDT (History)
1 user (show)

See Also:


Attachments
the patch (4.70 KB, patch)
2011-10-19 20:43 PDT, Filip Pizlo
oliver: review-
Details | Formatted Diff | Diff
the patch (5.61 KB, patch)
2011-10-20 21:33 PDT, Filip Pizlo
ggaren: 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-10-19 19:51:57 PDT
Since the optimization trigger is likely to fire at roughly the same time for multiple code blocks, this leads to an unfortunate outcome where the optimization of one code block leads the others to forget about its existence.
Comment 1 Filip Pizlo 2011-10-19 20:43:47 PDT
Created attachment 111720 [details]
the patch
Comment 2 Oliver Hunt 2011-10-19 20:51:12 PDT
Comment on attachment 111720 [details]
the patch

lastSeenCallee isn't marked so this isn't safe, but also this may result in dead functions being kept alive longer than is strictly necessary.  I would almost consider going with a Weak<> ref rather than WriteBarrier<JSFunction> if we can get do it without a perf impact
Comment 3 Filip Pizlo 2011-10-19 20:53:01 PDT
(In reply to comment #2)
> (From update of attachment 111720 [details])
> lastSeenCallee isn't marked so this isn't safe, but also this may result in dead functions being kept alive longer than is strictly necessary.  I would almost consider going with a Weak<> ref rather than WriteBarrier<JSFunction> if we can get do it without a perf impact

I'll change it to use the WeakReferenceHarvester approach.
Comment 4 Oliver Hunt 2011-10-19 21:20:04 PDT
(In reply to comment #3)
> (In reply to comment #2)
> > (From update of attachment 111720 [details] [details])
> > lastSeenCallee isn't marked so this isn't safe, but also this may result in dead functions being kept alive longer than is strictly necessary.  I would almost consider going with a Weak<> ref rather than WriteBarrier<JSFunction> if we can get do it without a perf impact
> 
> I'll change it to use the WeakReferenceHarvester approach.

Righto
Comment 5 Filip Pizlo 2011-10-20 21:29:14 PDT
(In reply to comment #3)
> (In reply to comment #2)
> > (From update of attachment 111720 [details] [details])
> > lastSeenCallee isn't marked so this isn't safe, but also this may result in dead functions being kept alive longer than is strictly necessary.  I would almost consider going with a Weak<> ref rather than WriteBarrier<JSFunction> if we can get do it without a perf impact
> 
> I'll change it to use the WeakReferenceHarvester approach.

Changed my mind.  As per earlier discussions, using a strong reference would not be a regression.  We currently unlink calls when we blow away all code.  If we blow away all code, then this reference (lastSeenCallee) would disappear from the GC trace since its owned by CodeBlock.

It's definitely worthwhile to make all stubs into weak references, and when they go stale, blow away the stubs.  Or in the case of DFG optimized code, trigger recompilation.
Comment 6 Filip Pizlo 2011-10-20 21:33:34 PDT
Created attachment 111899 [details]
the patch
Comment 7 Geoffrey Garen 2011-10-20 21:48:56 PDT
Comment on attachment 111899 [details]
the patch

r=me

Can we remove the callee field entirely now? It seems like it's a strict subset of lastSeenCallee.
Comment 8 Filip Pizlo 2011-10-20 22:13:32 PDT
Landed in http://trac.webkit.org/changeset/98065
Comment 9 Filip Pizlo 2011-10-20 22:14:20 PDT
(In reply to comment #7)
> (From update of attachment 111899 [details])
> r=me
> 
> Can we remove the callee field entirely now? It seems like it's a strict subset of lastSeenCallee.

callee is a magic field - it's really just a pointer to the machine code containing the callee immediate.  We don't want to remove that since then we wouldn't be able to do linking/unlinking.