Changeset 243075 in webkit


Ignore:
Timestamp:
Mar 18, 2019 10:05:54 AM (5 years ago)
Author:
Ryan Haddad
Message:

Unreviewed, rolling out r243037.

Broke the Windows build

Reverted changeset:

"Reduce the size of Node::deref by eliminating an explicit
parentNode check"
https://bugs.webkit.org/show_bug.cgi?id=195776
https://trac.webkit.org/changeset/243037

Location:
trunk/Source/WebCore
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r243072 r243075  
     12019-03-18  Ryan Haddad  <ryanhaddad@apple.com>
     2
     3        Unreviewed, rolling out r243037.
     4
     5        Broke the Windows build
     6
     7        Reverted changeset:
     8
     9        "Reduce the size of Node::deref by eliminating an explicit
     10        parentNode check"
     11        https://bugs.webkit.org/show_bug.cgi?id=195776
     12        https://trac.webkit.org/changeset/243037
     13
    1142019-03-18  Eric Carlson  <eric.carlson@apple.com>
    215
  • trunk/Source/WebCore/dom/Document.cpp

    r243037 r243075  
    670670    ASSERT(!m_deletionHasBegun);
    671671    if (m_referencingNodeCount) {
    672         // Node::removedLastRef doesn't set refCount() to zero because it's not observable.
    673         // But we need to remember that our refCount reached zero in subsequent calls to decrementReferencingNodeCount()
    674         m_refCountAndParentBit = 0;
    675 
    676672        // If removing a child removes the last node reference, we don't want the scope to be destroyed
    677673        // until after removeDetachedChildren returns, so we protect ourselves.
     
    723719        m_deletionHasBegun = true;
    724720#endif
     721        m_refCount = 1; // Avoid double destruction through use of RefPtr<T>. (This is a security mitigation in case of programmer error. It will ASSERT in debug builds.)
    725722        delete this;
    726723    }
  • trunk/Source/WebCore/dom/Document.h

    r243037 r243075  
    377377            m_deletionHasBegun = true;
    378378#endif
    379             m_refCountAndParentBit = s_refCountIncrement; // Avoid double destruction through use of Ref<T>/RefPtr<T>. (This is a security mitigation in case of programmer error. It will ASSERT in debug builds.)
     379            m_refCount = 1; // Avoid double destruction through use of RefPtr<T>. (This is a security mitigation in case of programmer error. It will ASSERT in debug builds.)
    380380            delete this;
    381381        }
  • trunk/Source/WebCore/dom/Node.cpp

    r243037 r243075  
    317317
    318318Node::Node(Document& document, ConstructionType type)
    319     : m_nodeFlags(type)
     319    : m_refCount(1)
     320    , m_nodeFlags(type)
    320321    , m_treeScope(&document)
    321322{
     
    332333{
    333334    ASSERT(isMainThread());
    334     // We set m_refCount to 2 before calling delete to avoid double destruction through use of Ref<T>/RefPtr<T>.
     335    // We set m_refCount to 1 before calling delete to avoid double destruction through use of Ref<T>/RefPtr<T>.
    335336    // This is a security mitigation in case of programmer errorm (caught by a debug assertion).
    336     ASSERT(m_refCountAndParentBit == s_refCountIncrement);
     337    ASSERT(m_refCount == 1);
    337338    ASSERT(m_deletionHasBegun);
    338339    ASSERT(!m_adoptionIsRequired);
     
    25232524void Node::removedLastRef()
    25242525{
    2525     // This avoids double destruction even when there is a programming error to use Ref<T> / RefPtr<T> on this node.
    2526     // There are debug assertions in Node::ref() / Node::deref() to catch such a programming error.
    2527     ASSERT(m_refCountAndParentBit == s_refCountIncrement);
    2528 
    25292526    // An explicit check for Document here is better than a virtual function since it is
    25302527    // faster for non-Document nodes, and because the call to removedLastRef that is inlined
     
    25382535    m_deletionHasBegun = true;
    25392536#endif
     2537    m_refCount = 1; // Avoid double destruction through use of RefPtr<T>. (This is a security mitigation in case of programmer error. It will ASSERT in debug builds.)
    25402538    delete this;
    25412539}
  • trunk/Source/WebCore/dom/Node.h

    r243037 r243075  
    501501    void deref();
    502502    bool hasOneRef() const;
    503     unsigned refCount() const;
     503    int refCount() const;
    504504
    505505#ifndef NDEBUG
     
    619619    Node(Document&, ConstructionType);
    620620
    621     static constexpr uint32_t s_refCountIncrement = 2;
    622     static constexpr uint32_t s_refCountMask = ~0x1;
    623 
    624621    virtual void addSubresourceAttributeURLs(ListHashSet<URL>&) const { }
    625622
     
    668665    void moveNodeToNewDocument(Document& oldDocument, Document& newDocument);
    669666
    670     uint32_t m_refCountAndParentBit { s_refCountIncrement };
     667    int m_refCount;
    671668    mutable uint32_t m_nodeFlags;
    672669
     
    699696    ASSERT(!m_inRemovedLastRefFunction);
    700697    ASSERT(!m_adoptionIsRequired);
    701     m_refCountAndParentBit += s_refCountIncrement;
     698    ++m_refCount;
    702699}
    703700
     
    705702{
    706703    ASSERT(isMainThread());
    707     ASSERT(refCount());
     704    ASSERT(m_refCount >= 0);
    708705    ASSERT(!m_deletionHasBegun);
    709706    ASSERT(!m_inRemovedLastRefFunction);
    710707    ASSERT(!m_adoptionIsRequired);
    711     auto tempRefCount = m_refCountAndParentBit - s_refCountIncrement;
    712     if (!tempRefCount) {
     708    if (--m_refCount <= 0 && !parentNode()) {
    713709#ifndef NDEBUG
    714710        m_inRemovedLastRefFunction = true;
    715711#endif
    716712        removedLastRef();
    717         return;
    718713    }
    719     m_refCountAndParentBit = tempRefCount;
    720714}
    721715
     
    724718    ASSERT(!m_deletionHasBegun);
    725719    ASSERT(!m_inRemovedLastRefFunction);
    726     return refCount() == 1;
    727 }
    728 
    729 ALWAYS_INLINE unsigned Node::refCount() const
    730 {
    731     return m_refCountAndParentBit / s_refCountIncrement;
     720    return m_refCount == 1;
     721}
     722
     723ALWAYS_INLINE int Node::refCount() const
     724{
     725    return m_refCount;
    732726}
    733727
     
    743737    ASSERT(isMainThread());
    744738    m_parentNode = parent;
    745     auto refCountWithoutParentBit = m_refCountAndParentBit & s_refCountMask;
    746     m_refCountAndParentBit = refCountWithoutParentBit | !!parent;
    747739}
    748740
Note: See TracChangeset for help on using the changeset viewer.