Changeset 243686 in webkit
- Timestamp:
- Mar 31, 2019, 7:03:14 PM (7 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 4 edited
-
ChangeLog (modified) (1 diff)
-
dom/Document.cpp (modified) (1 diff)
-
dom/Node.cpp (modified) (2 diffs)
-
dom/Node.h (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r243683 r243686 1 2019-03-31 Ryosuke Niwa <rniwa@webkit.org> 2 3 Reduce the size of Node::deref by eliminating an explicit parentNode check 4 https://bugs.webkit.org/show_bug.cgi?id=195776 5 6 Reviewed by Darin Adler. 7 8 Address post-commit review comments. 9 10 * dom/Document.cpp: 11 (WebCore::Document::removedLastRef): 12 * dom/Node.cpp: 13 (WebCore::Node::~Node): 14 (WebCore::Node::removedLastRef): 15 * dom/Node.h: 16 (WebCore::Node::deref): 17 (WebCore::Node::setParentNode): 18 1 19 2019-03-31 Sam Weinig <weinig@apple.com> 2 20 -
trunk/Source/WebCore/dom/Document.cpp
r243666 r243686 669 669 if (m_referencingNodeCount) { 670 670 // Node::removedLastRef doesn't set refCount() to zero because it's not observable. 671 // But we need to remember that our refCount reached zero in subsequent calls to decrementReferencingNodeCount() 671 // But we need to remember that our refCount reached zero in subsequent calls to decrementReferencingNodeCount(). 672 672 m_refCountAndParentBit = 0; 673 673 -
trunk/Source/WebCore/dom/Node.cpp
r243249 r243686 333 333 { 334 334 ASSERT(isMainThread()); 335 // We set m_refCount to 2 before calling delete to avoid double destruction through use of Ref<T>/RefPtr<T>.336 // This is a security mitigation in case of programmer errorm (caught by a debug assertion).337 335 ASSERT(m_refCountAndParentBit == s_refCountIncrement); 338 336 ASSERT(m_deletionHasBegun); … … 2515 2513 void Node::removedLastRef() 2516 2514 { 2517 // This avoids double destruction even when there is a programming error to use Ref<T> / RefPtr<T> on this node.2518 // There are debug assertions in Node::ref() / Node::deref() to catch such a programming error.2519 2515 ASSERT(m_refCountAndParentBit == s_refCountIncrement); 2520 2516 -
trunk/Source/WebCore/dom/Node.h
r243233 r243686 619 619 620 620 static constexpr uint32_t s_refCountIncrement = 2; 621 static constexpr uint32_t s_refCountMask = ~static_cast<uint32_t>( 0x1);621 static constexpr uint32_t s_refCountMask = ~static_cast<uint32_t>(1); 622 622 623 623 virtual void addSubresourceAttributeURLs(ListHashSet<URL>&) const { } … … 708 708 ASSERT(!m_inRemovedLastRefFunction); 709 709 ASSERT(!m_adoptionIsRequired); 710 auto tempRefCount = m_refCountAndParentBit - s_refCountIncrement; 711 if (!tempRefCount) { 710 auto updatedRefCount = m_refCountAndParentBit - s_refCountIncrement; 711 if (!updatedRefCount) { 712 // Don't update m_refCountAndParentBit to avoid double destruction through use of Ref<T>/RefPtr<T>. 713 // (This is a security mitigation in case of programmer error. It will ASSERT in debug builds.) 712 714 #ifndef NDEBUG 713 715 m_inRemovedLastRefFunction = true; … … 716 718 return; 717 719 } 718 m_refCountAndParentBit = tempRefCount;720 m_refCountAndParentBit = updatedRefCount; 719 721 } 720 722 … … 742 744 ASSERT(isMainThread()); 743 745 m_parentNode = parent; 744 auto refCountWithoutParentBit = m_refCountAndParentBit & s_refCountMask; 745 m_refCountAndParentBit = refCountWithoutParentBit | !!parent; 746 m_refCountAndParentBit = (m_refCountAndParentBit & s_refCountMask) | !!parent; 746 747 } 747 748
Note:
See TracChangeset
for help on using the changeset viewer.