Bug 61134 - Make Executables release their JIT code as soon as they become dead
Summary: Make Executables release their JIT code as soon as they become dead
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: New Bugs (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Oliver Hunt
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-05-19 12:13 PDT by Oliver Hunt
Modified: 2011-05-19 13:19 PDT (History)
1 user (show)

See Also:


Attachments
Patch (4.72 KB, patch)
2011-05-19 12:15 PDT, Oliver Hunt
no flags Details | Formatted Diff | Diff
Patch (4.69 KB, patch)
2011-05-19 13:01 PDT, Oliver Hunt
ggaren: review+
webkit-ews: commit-queue-
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Oliver Hunt 2011-05-19 12:13:22 PDT
Make Executable's release their JIT code as soon as they become dead
Comment 1 Oliver Hunt 2011-05-19 12:15:32 PDT
Created attachment 94099 [details]
Patch
Comment 2 Geoffrey Garen 2011-05-19 12:41:00 PDT
Comment on attachment 94099 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=94099&action=review

r- because I think you're missing an implementation of executableFinalizer().

> Source/JavaScriptCore/runtime/Executable.cpp:58
> +WeakHandleOwner* ExecutableBase::executableFinalizer()
> +{
> +    return 0;
> +}

This seems wrong. Who actually provides the executable finalizer?

> Source/JavaScriptCore/runtime/Executable.h:65
> +#if ENABLE(JIT)
> +            HandleSlot slot = globalData.heap.allocateGlobalHandle();
> +            HandleHeap* handleHeap = HandleHeap::heapFor(slot);
> +            handleHeap->makeWeak(slot, executableFinalizer());
> +            handleHeap->writeBarrier(slot, this);
> +            *slot = this;

It's a shame that clients have to duplicate all this error-prone code. The Weak<T> class was an attempt to reduce error-prone duplication. I think it could be adapted to this purpose if you added leak() and adopt() features to Weak<T>.
Comment 3 Oliver Hunt 2011-05-19 12:54:39 PDT
(In reply to comment #2)
> (From update of attachment 94099 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=94099&action=review
> 
> r- because I think you're missing an implementation of executableFinalizer().
> 
> > Source/JavaScriptCore/runtime/Executable.cpp:58
> > +WeakHandleOwner* ExecutableBase::executableFinalizer()
> > +{
> > +    return 0;
> > +}
> 
> This seems wrong. Who actually provides the executable finalizer?

The patch was meant to, i suspect i posted an incomplete patch but i'm redoing perf numbers to be sure.

> 
> > Source/JavaScriptCore/runtime/Executable.h:65
> > +#if ENABLE(JIT)
> > +            HandleSlot slot = globalData.heap.allocateGlobalHandle();
> > +            HandleHeap* handleHeap = HandleHeap::heapFor(slot);
> > +            handleHeap->makeWeak(slot, executableFinalizer());
> > +            handleHeap->writeBarrier(slot, this);
> > +            *slot = this;
> 
> It's a shame that clients have to duplicate all this error-prone code. The Weak<T> class was an attempt to reduce error-prone duplication. I think it could be adapted to this purpose if you added leak() and adopt() features to Weak<T>.

agreed.
Comment 4 Oliver Hunt 2011-05-19 13:01:47 PDT
Created attachment 94104 [details]
Patch
Comment 5 Geoffrey Garen 2011-05-19 13:05:05 PDT
Comment on attachment 94104 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=94104&action=review

r=me

> Source/JavaScriptCore/heap/Weak.h:133
> +        setSlot(0);

Might as well assert that you have a finalizer here. It's not a guarantee that you won't leak, but not having a finalizer is a guarantee that you will leak.

> Source/JavaScriptCore/runtime/Executable.cpp:56
> +    static ExecutableFinalizer* finalizer = new ExecutableFinalizer;

Please use DEFINE_STATIC_LOCAL, in accord with our style.
Comment 6 Early Warning System Bot 2011-05-19 13:13:58 PDT
Comment on attachment 94104 [details]
Patch

Attachment 94104 [details] did not pass qt-ews (qt):
Output: http://queues.webkit.org/results/8718269
Comment 7 Oliver Hunt 2011-05-19 13:19:54 PDT
Committed r86883: <http://trac.webkit.org/changeset/86883>