Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1188)

Issue 2458773008: [wrapper-tracing] Fix EventTarget with LazyEventListeners (Closed)

Created:
4 years, 1 month ago by Michael Lippautz
Modified:
4 years, 1 month ago
Reviewers:
haraken, Marcel Hlopko
CC:
chromium-reviews, blink-reviews, blink-reviews-bindings_chromium.org
Target Ref:
refs/pending/heads/master
Project:
chromium
Visibility:
Public.

Description

[wrapper-tracing] Fix EventTarget with LazyEventListeners LazyEventListener_s have their listener object set at some later point in time. We need to trace the EventListener objects in any case and add a write barrier for the ScopedPersistent. BUG=chromium:468240 R=haraken@chromium.org,hlopko@chromium.org

Patch Set 1 #

Unified diffs Side-by-side diffs Delta from patch set Stats (+9 lines, -7 lines) Patch
M third_party/WebKit/Source/bindings/core/v8/ScriptWrappableVisitor.h View 1 chunk +6 lines, -0 lines 0 comments Download
M third_party/WebKit/Source/bindings/core/v8/V8AbstractEventListener.cpp View 1 chunk +1 line, -0 lines 0 comments Download
M third_party/WebKit/Source/core/events/EventTarget.cpp View 2 chunks +2 lines, -7 lines 0 comments Download

Messages

Total messages: 13 (1 generated)
Michael Lippautz
4 years, 1 month ago (2016-10-29 14:13:06 UTC) #1
Michael Lippautz
PTAL, needed to get this out of my head. What I think currently happens (which ...
4 years, 1 month ago (2016-10-29 14:14:46 UTC) #2
haraken
Maybe should we introduce TraceWrapperV8Persistent? I'm wondering why it's enough to add write barriers to ...
4 years, 1 month ago (2016-10-29 18:58:26 UTC) #3
Michael Lippautz
On 2016/10/29 18:58:26, haraken wrote: > Maybe should we introduce TraceWrapperV8Persistent? > Possibly, see below. ...
4 years, 1 month ago (2016-10-30 20:55:03 UTC) #4
haraken
On 2016/10/30 20:55:03, Michael Lippautz wrote: > On 2016/10/29 18:58:26, haraken wrote: > > Maybe ...
4 years, 1 month ago (2016-10-31 10:23:36 UTC) #5
Michael Lippautz
On 2016/10/31 10:23:36, haraken wrote: > On 2016/10/30 20:55:03, Michael Lippautz wrote: > > On ...
4 years, 1 month ago (2016-10-31 10:51:00 UTC) #6
Marcel Hlopko
On 2016/10/31 at 10:51:00, mlippautz wrote: > On 2016/10/31 10:23:36, haraken wrote: > > On ...
4 years, 1 month ago (2016-10-31 11:06:30 UTC) #7
haraken
On 2016/10/31 11:06:30, Marcel Hlopko wrote: > On 2016/10/31 at 10:51:00, mlippautz wrote: > > ...
4 years, 1 month ago (2016-10-31 12:29:26 UTC) #8
Michael Lippautz
On 2016/10/31 12:29:26, haraken wrote: > On 2016/10/31 11:06:30, Marcel Hlopko wrote: > > On ...
4 years, 1 month ago (2016-10-31 13:04:14 UTC) #9
Michael Lippautz
On 2016/10/31 12:29:26, haraken wrote: > On 2016/10/31 11:06:30, Marcel Hlopko wrote: > > On ...
4 years, 1 month ago (2016-10-31 13:04:16 UTC) #10
haraken
On 2016/10/31 13:04:16, Michael Lippautz wrote: > On 2016/10/31 12:29:26, haraken wrote: > > On ...
4 years, 1 month ago (2016-11-01 04:28:08 UTC) #11
Michael Lippautz
4 years, 1 month ago (2016-11-01 11:24:29 UTC) #12
On 2016/11/01 04:28:08, haraken wrote:
> On 2016/10/31 13:04:16, Michael Lippautz wrote:
> > On 2016/10/31 12:29:26, haraken wrote:
> > > On 2016/10/31 11:06:30, Marcel Hlopko wrote:
> > > > On 2016/10/31 at 10:51:00, mlippautz wrote:
> > > > > On 2016/10/31 10:23:36, haraken wrote:
> > > > > > On 2016/10/30 20:55:03, Michael Lippautz wrote:
> > > > > > > On 2016/10/29 18:58:26, haraken wrote:
> > > > > > > > Maybe should we introduce TraceWrapperV8Persistent?
> > > > > > > > 
> > > > > > > 
> > > > > > > Possibly, see below.
> > > > > > > 
> > > > > > > > I'm wondering why it's enough to add write barriers to
> > > > > > > V8AbstractEventListener's
> > > > > > > > ScopedPersistent. What about other ScopedPersistents traced by
> > > > > > traceWrapper()?
> > > > > > > 
> > > > > > > As far as I know, in the usual case ScopedPersistent_s on
> > > > ScriptWrappable_s do
> > > > > > > not change and this might be the only case that lazily sets the
> > > reference.
> > > > Not
> > > > > > > sure it's worth to introduce the whole infrastructure (+ back
> pointers
> > > > > > overhead)
> > > > > > > to cover this case. I would only introduce the whole machinery if
> it's
> > > > really
> > > > > > > needed, i.e., we see that many cases actually require it.
> > > > > > > 
> > > > > > > Will check what the other uses of ScopedPersistent do on
Wednesday.
> > > > > > 
> > > > > > We will anyway need a new pointer type for ScopedPersistent, because
> one
> > > of
> > > > the
> > > > > > goals of traceWrapper() is to remove most of the ScopedPersistents
> from
> > > the
> > > > code
> > > > > > base and thus fix memory leaks that cross the Blink <=> V8 boundary.
> So
> > I
> > > > think
> > > > > > it's worth introducing TraceWrapperV8Persistent.
> > > > > > 
> > > > > 
> > > > > Thanks for the explanation, I see that now.
> > > > > 
> > > > > > But I'm confused. How are we handling ScopedPersistents when the
> wrapper
> > > > tracing
> > > > > > is enabled? Is it traced by traceWrapper() but still using
> > > ScopedPersistent?
> > > > > > Then it doesn't make sense because with the wrapper tracing enabled,
> it
> > > > doesn't
> > > > > > need to be a v8::Persistent handle at all (and that's the whole
point
> of
> > > the
> > > > > > wrapper tracing).
> > > > > 
> > > > > - ScopedPersistent is traced, i.e., the reference is registered with
v8.
> 
> > > > > - ScriptWrappable still contains a v8::Persistent which is also traced
> by
> > > > registering it with v8
> > > > > 
> > > > > I guess what we really want is a new type of handle on the V8 side
that
> is
> > > > usually weak, but can be used by wrapper tracing to indicate liveness
and
> > thus
> > > > make it strong.
> > > > 
> > > > LGTM for the logic in this cl.
> > > > 
> > > > There is no simple solution (that doesn't regress memory or performance)
> to
> > > > making progress in the persistent cycles front while object grouping is
> > still
> > > in
> > > > use. Our effort is to ship wrapper tracing, and then solve the cycles
> issue,
> > > > once object grouping is gone. That should be "easy", just like Michael
> said,
> > > by
> > > > introducing new v8 wrapper-tracing handle type, that normally would be
> weak,
> > > but
> > > > wrapper tracing "will turn it into strong" upon reaching. Does it make
> > sense?
> > > 
> > > The shipping plan makes sense.
> > > 
> > > But then why do we need to add a write barrier to ScopedPersistent? It is
> > > already treated as a root set, so we shouldn't need to worry about the
write
> > > barrier, right?
> > 
> > It's in the root set and will be held alive, yes. 
> > 
> > The barrier is needed since we already have the verifier in place that
checks
> > non-inc vs inc wrapper tracing assuming that the references are weak (and
only
> > strong by tracing).
> 
> Ah, got it. So the ScopedPersistent is NOT in the root set (because it's
> weakened).
> 
> If this is really the only place where a ScopedPersistent is updated, this CL
> LGTM.
> 
> However, in general I think that all weak ScopedPersistents should be replaced
> with TraceWrapperV8Persistents. For example, if we have the following
scenario,
> it will miss a write barrier.
> 
> class DOMObject {
>   DOMObject() {  // The ScopedPersistent is assigned in the constructor but...
>     m_persistent.set(...);
>     m_persistent.setPhantom();
>     someV8API();  // if this V8 API triggers a GC...
>     m_persistent2.set(...);  // we need to have a write barrier for
> m_persistent2.
>     m_persistent2.setPhantom();
>   }
>   ScopedPersistent<v8::Value> m_persistent;
>   ScopedPersistent<v8::Value> m_persistent2;
> };

Correct. I will check how many cases of tracing through ScopedPersistent we have
and whether we should add a type to better support this.

Powered by Google App Engine
This is Rietveld 408576698