Bug 29825

Summary: [V8] Refactored V8 event listeners.
Product: WebKit Reporter: Vitaly Repeshko <vitalyr>
Component: WebCore Misc.Assignee: Nobody <webkit-unassigned>
Status: RESOLVED FIXED    
Severity: Normal CC: commit-queue, dglazkov, eric, ojan, sam
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: All   
OS: All   
Attachments:
Description Flags
patch: WIP
none
updated patch
dglazkov: review-
updated patch v2 none

Description Vitaly Repeshko 2009-09-28 14:09:26 PDT
[V8] Refactored V8 event listeners.
Comment 1 Vitaly Repeshko 2009-09-28 14:29:18 PDT
Created attachment 40260 [details]
patch: WIP

Dimitri, please have a look. This is still WIP (testing lazy listeners) and depends on http://code.google.com/p/v8/source/detail?r=2980 (should be in V8 trunk this week), but I think it's almost done.
Comment 2 Ojan Vafai 2009-09-28 14:36:52 PDT
drive-by comment: Is there any way to test for leaks so this doesn't regress?
Comment 3 Sam Weinig 2009-09-28 14:38:06 PDT
If this is still a WIP, this should not be marked for review.  One question though, why are the attribute event listeners marked as OnProto?  This does not match the JSC bindings.  Are there tests that indicate it should be this way?
Comment 4 Vitaly Repeshko 2009-09-28 14:40:03 PDT
(In reply to comment #2)
> drive-by comment: Is there any way to test for leaks so this doesn't regress?

Yes, for fixed leaks I'll extend src/webkit/tools/test_shell/listener_leak_test.cc.
Comment 5 Vitaly Repeshko 2009-09-28 14:46:37 PDT
(In reply to comment #3)
> If this is still a WIP, this should not be marked for review.  One question
> though, why are the attribute event listeners marked as OnProto?  This does not
> match the JSC bindings.  Are there tests that indicate it should be this way?

They are marked with v8onproto attribute because old custom V8 code used to look up the holder of the property in prototype chain. I tried to copy the old behavior. I'll double-check if this is in fact needed. If JSC doesn't need this, chances are V8 doesn't need either.
Comment 6 Dimitri Glazkov (Google) 2009-09-28 20:00:13 PDT
Comment on attachment 40260 [details]
patch: WIP

+1 on investigating v8onproto.
Comment 7 Vitaly Repeshko 2009-09-30 04:43:11 PDT
Created attachment 40360 [details]
updated patch

Notification does not require v8onproto. Removed.

Remaining memory leaks in lazy listeners are unrelated to handles and are caused by Function cache for functions created by FunctionTemplate. I'm going to fix usages of FunctionTemplate in V8 bindings in a separate patch.
Comment 8 Dimitri Glazkov (Google) 2009-09-30 10:26:50 PDT
Comment on attachment 40360 [details]
updated patch

This is super-awesome. I only have style nits.

I would really like to use enums for isAttribute params in getEventListener. That should clarify the call sites.

> +    V8Proxy* proxy = V8Proxy::retrieve(worker->scriptExecutionContext());
> +    if (proxy) {
> +        return findOnly ? V8EventListenerList::findWrapper(value, isAttribute) : V8EventListenerList::findOrCreateWrapper<V8EventListener>(proxy->frame(), value, isAttribute);
> +    }

Don't need braces here.

> +    if (proxy) {
> +        return findOnly ? V8EventListenerList::findWrapper(value, isAttribute) : V8EventListenerList::findOrCreateWrapper<V8EventListener>(proxy->frame(), value, isAttribute);
> +    }

Ditto.

> +v8::Handle<v8::String> V8HiddenPropertyName::listener()
> +{
> +    static v8::Persistent<v8::String>* string = createString("WebCore::V8HiddenPropertyName::listener");
> +

no line break here.

> +    return *string;
> +}
> +
> +v8::Handle<v8::String> V8HiddenPropertyName::attributeListener()
> +{
> +    static v8::Persistent<v8::String>* string = createString("WebCore::V8HiddenPropertyName::attributeListener");

Ditto.

> +void V8Proxy::disconnectEventListeners()
> +{
> +}
> +

Why is this here? Can we just get rid of it?
Comment 9 Vitaly Repeshko 2009-09-30 11:41:54 PDT
Created attachment 40386 [details]
updated patch v2
Comment 10 Dimitri Glazkov (Google) 2009-10-01 09:44:25 PDT
Comment on attachment 40386 [details]
updated patch v2

r=me.
Comment 11 WebKit Commit Bot 2009-10-01 10:02:02 PDT
Comment on attachment 40386 [details]
updated patch v2

Clearing flags on attachment: 40386

Committed r48978: <http://trac.webkit.org/changeset/48978>
Comment 12 WebKit Commit Bot 2009-10-01 10:02:06 PDT
All reviewed patches have been landed.  Closing bug.
Comment 13 Eric Seidel (no email) 2009-10-01 18:01:49 PDT
See http://code.google.com/p/chromium/issues/detail?id=23597 I guess this caused some sort of regression.  I'm happy to roll this out if that's what's desired.

bugzilla-tool rollout 48978

will prepare the rollout.

bugzilla-tool rollout 48978 --complete-rollout --force-clean

would do the full rollout including testing to make sure it builds/passes tests and updating the bug.
Comment 14 Dimitri Glazkov (Google) 2009-10-01 20:28:24 PDT
Let's give vitalyr a chance to fix this. Sadness that it broke.
Comment 15 Vitaly Repeshko 2009-10-02 06:43:14 PDT
(In reply to comment #14)
> Let's give vitalyr a chance to fix this. Sadness that it broke.

Reverting this patch doesn't fix the breakage. Please see discussion in http://code.google.com/p/chromium/issues/detail?id=23597.