Changeset 243075 in webkit
- Timestamp:
- Mar 18, 2019 10:05:54 AM (5 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r243072 r243075 1 2019-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 1 14 2019-03-18 Eric Carlson <eric.carlson@apple.com> 2 15 -
trunk/Source/WebCore/dom/Document.cpp
r243037 r243075 670 670 ASSERT(!m_deletionHasBegun); 671 671 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 676 672 // If removing a child removes the last node reference, we don't want the scope to be destroyed 677 673 // until after removeDetachedChildren returns, so we protect ourselves. … … 723 719 m_deletionHasBegun = true; 724 720 #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.) 725 722 delete this; 726 723 } -
trunk/Source/WebCore/dom/Document.h
r243037 r243075 377 377 m_deletionHasBegun = true; 378 378 #endif 379 m_refCount AndParentBit = 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.) 380 380 delete this; 381 381 } -
trunk/Source/WebCore/dom/Node.cpp
r243037 r243075 317 317 318 318 Node::Node(Document& document, ConstructionType type) 319 : m_nodeFlags(type) 319 : m_refCount(1) 320 , m_nodeFlags(type) 320 321 , m_treeScope(&document) 321 322 { … … 332 333 { 333 334 ASSERT(isMainThread()); 334 // We set m_refCount to 2before 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>. 335 336 // This is a security mitigation in case of programmer errorm (caught by a debug assertion). 336 ASSERT(m_refCount AndParentBit == s_refCountIncrement);337 ASSERT(m_refCount == 1); 337 338 ASSERT(m_deletionHasBegun); 338 339 ASSERT(!m_adoptionIsRequired); … … 2523 2524 void Node::removedLastRef() 2524 2525 { 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 2529 2526 // An explicit check for Document here is better than a virtual function since it is 2530 2527 // faster for non-Document nodes, and because the call to removedLastRef that is inlined … … 2538 2535 m_deletionHasBegun = true; 2539 2536 #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.) 2540 2538 delete this; 2541 2539 } -
trunk/Source/WebCore/dom/Node.h
r243037 r243075 501 501 void deref(); 502 502 bool hasOneRef() const; 503 unsignedrefCount() const;503 int refCount() const; 504 504 505 505 #ifndef NDEBUG … … 619 619 Node(Document&, ConstructionType); 620 620 621 static constexpr uint32_t s_refCountIncrement = 2;622 static constexpr uint32_t s_refCountMask = ~0x1;623 624 621 virtual void addSubresourceAttributeURLs(ListHashSet<URL>&) const { } 625 622 … … 668 665 void moveNodeToNewDocument(Document& oldDocument, Document& newDocument); 669 666 670 uint32_t m_refCountAndParentBit { s_refCountIncrement };667 int m_refCount; 671 668 mutable uint32_t m_nodeFlags; 672 669 … … 699 696 ASSERT(!m_inRemovedLastRefFunction); 700 697 ASSERT(!m_adoptionIsRequired); 701 m_refCountAndParentBit += s_refCountIncrement;698 ++m_refCount; 702 699 } 703 700 … … 705 702 { 706 703 ASSERT(isMainThread()); 707 ASSERT( refCount());704 ASSERT(m_refCount >= 0); 708 705 ASSERT(!m_deletionHasBegun); 709 706 ASSERT(!m_inRemovedLastRefFunction); 710 707 ASSERT(!m_adoptionIsRequired); 711 auto tempRefCount = m_refCountAndParentBit - s_refCountIncrement; 712 if (!tempRefCount) { 708 if (--m_refCount <= 0 && !parentNode()) { 713 709 #ifndef NDEBUG 714 710 m_inRemovedLastRefFunction = true; 715 711 #endif 716 712 removedLastRef(); 717 return;718 713 } 719 m_refCountAndParentBit = tempRefCount;720 714 } 721 715 … … 724 718 ASSERT(!m_deletionHasBegun); 725 719 ASSERT(!m_inRemovedLastRefFunction); 726 return refCount()== 1;727 } 728 729 ALWAYS_INLINE unsignedNode::refCount() const730 { 731 return m_refCount AndParentBit / s_refCountIncrement;720 return m_refCount == 1; 721 } 722 723 ALWAYS_INLINE int Node::refCount() const 724 { 725 return m_refCount; 732 726 } 733 727 … … 743 737 ASSERT(isMainThread()); 744 738 m_parentNode = parent; 745 auto refCountWithoutParentBit = m_refCountAndParentBit & s_refCountMask;746 m_refCountAndParentBit = refCountWithoutParentBit | !!parent;747 739 } 748 740
Note: See TracChangeset
for help on using the changeset viewer.