Bug 143942 - Merge TreeShared into Node.
Summary: Merge TreeShared into Node.
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebCore Misc. (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Andreas Kling
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-04-19 22:39 PDT by Andreas Kling
Modified: 2015-04-23 09:33 PDT (History)
6 users (show)

See Also:


Attachments
Patch (13.36 KB, patch)
2015-04-19 22:49 PDT, Andreas Kling
darin: review+
Details | Formatted Diff | Diff
Patch for landing (13.49 KB, patch)
2015-04-20 01:23 PDT, Andreas Kling
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Andreas Kling 2015-04-19 22:39:09 PDT
Node is the only remaining subclass of TreeShared. Let's just fold TreeShared into Node.
Comment 1 Andreas Kling 2015-04-19 22:49:57 PDT
Created attachment 251143 [details]
Patch
Comment 2 Darin Adler 2015-04-19 23:19:39 PDT
Comment on attachment 251143 [details]
Patch

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

> Source/WebCore/dom/Node.h:545
> +    void ref()
> +    {
> +        ASSERT(isMainThread());
> +        ASSERT(!m_deletionHasBegun);
> +        ASSERT(!m_inRemovedLastRefFunction);
> +        ASSERT(!m_adoptionIsRequired);
> +        ++m_refCount;
> +    }

These function bodies are kind of big. I’d rather see them at the end of the file, outside the class definition. Some day we have a chance of being able to read the class definition.

> Source/WebCore/dom/Node.h:560
> +    void deref()
> +    {
> +        ASSERT(isMainThread());
> +        ASSERT(m_refCount >= 0);
> +        ASSERT(!m_deletionHasBegun);
> +        ASSERT(!m_inRemovedLastRefFunction);
> +        ASSERT(!m_adoptionIsRequired);
> +        if (--m_refCount <= 0 && !parentNode()) {
> +#ifndef NDEBUG
> +            m_inRemovedLastRefFunction = true;
> +#endif
> +            removedLastRef();
> +        }
> +    }

This one too.

> Source/WebCore/dom/Node.h:567
> +    bool hasOneRef() const
> +    {
> +        ASSERT(!m_deletionHasBegun);
> +        ASSERT(!m_inRemovedLastRefFunction);
> +        return m_refCount == 1;
> +    }

Maybe even this one.

> Source/WebCore/dom/Node.h:572
> +    int refCount() const
> +    {
> +        return m_refCount;
> +    }

Not sure about this one. Not sure why we even have it!

> Source/WebCore/dom/Node.h:578
> +#ifndef NDEBUG
> +    bool m_deletionHasBegun { false };
> +    bool m_inRemovedLastRefFunction { false };
> +    bool m_adoptionIsRequired { true };
> +#endif

Lame that these are public, but I guess that’s how we do it.

> Source/WebCore/dom/Node.h:721
> +    int m_refCount;

How did you decide whether to put this before or after m_nodeFlags?
Comment 3 Andreas Kling 2015-04-20 01:22:44 PDT
(In reply to comment #2)
> Comment on attachment 251143 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=251143&action=review
> 
> > Source/WebCore/dom/Node.h:545
> > +    void ref()
> > +    {
> > +        ASSERT(isMainThread());
> > +        ASSERT(!m_deletionHasBegun);
> > +        ASSERT(!m_inRemovedLastRefFunction);
> > +        ASSERT(!m_adoptionIsRequired);
> > +        ++m_refCount;
> > +    }
> 
> These function bodies are kind of big. I’d rather see them at the end of the
> file, outside the class definition. Some day we have a chance of being able
> to read the class definition.

Sure thing, I'll pop them all out.

> > Source/WebCore/dom/Node.h:721
> > +    int m_refCount;
> 
> How did you decide whether to put this before or after m_nodeFlags?

I didn't think enough about this. I'll move it to before so the object layout matches what we had before the change.
Comment 4 Andreas Kling 2015-04-20 01:23:47 PDT
Created attachment 251153 [details]
Patch for landing
Comment 5 WebKit Commit Bot 2015-04-20 02:19:32 PDT
Comment on attachment 251153 [details]
Patch for landing

Clearing flags on attachment: 251153

Committed r183009: <http://trac.webkit.org/changeset/183009>
Comment 6 WebKit Commit Bot 2015-04-20 02:19:36 PDT
All reviewed patches have been landed.  Closing bug.
Comment 8 Darin Adler 2015-04-21 15:11:49 PDT
Really!? I wonder what happened.
Comment 9 Andreas Kling 2015-04-21 15:19:28 PDT
(In reply to comment #8)
> Really!? I wonder what happened.

I'll try to reproduce locally, but if there's indeed a problem, my guess would be failure to inline Node::ref() or Node::deref().
Comment 10 Andreas Kling 2015-04-23 02:08:36 PDT
The bug was that DOM nodes were no longer getting WTF_MAKE_FAST_ALLOCATED :|

Fixed in <https://trac.webkit.org/r183183>
Comment 11 Darin Adler 2015-04-23 08:01:36 PDT
Wow, how did we miss that!? Did we also forget to make Node noncopyable, or was that handled some other way?
Comment 12 Chris Dumez 2015-04-23 09:33:49 PDT
(In reply to comment #10)
> The bug was that DOM nodes were no longer getting WTF_MAKE_FAST_ALLOCATED :|
> 
> Fixed in <https://trac.webkit.org/r183183>

oh boy I'm glad the bots caught this :)