Ignore:
Timestamp:
Mar 1, 2022, 3:51:26 PM (3 years ago)
Author:
Fujii Hironori
Message:

WTF::SentinelLinkedList::iterator should have operator++ for range-for loop
https://bugs.webkit.org/show_bug.cgi?id=237265

Reviewed by Yusuke Suzuki.

Source/JavaScriptCore:

SentinelLinkedList::iterator isn't a pointer of node now, it
should be deferenced before comparing with a pointer.

  • bytecode/Watchpoint.cpp:

(JSC::WatchpointSet::fireAllWatchpoints):

  • heap/HandleSet.cpp:

(JSC::HandleSet::visitStrongHandles):
(JSC::HandleSet::protectedGlobalObjectCount):

  • heap/HandleSet.h:

(JSC::HandleSet::forEachStrongHandle):

  • heap/IsoSubspace.cpp:

(JSC::IsoSubspace::tryAllocateFromLowerTier):

  • heap/SubspaceInlines.h:

(JSC::Subspace::forEachPreciseAllocation):

  • jsc.cpp:

(Workers::broadcast):

Source/WTF:

SentinelLinkedList had three problems.

  1. Even though it has begin() and end(), using SentinelLinkedList with range-for loop resulted in a broken node because iterator::operator++ didn't work as expected.
  2. If I used a SentinelLinkedList in a movable type, the sentinel pointer gets stale after moving the object. move-ctor should be deleted.
  3. It didn't have const_iterator.
  • wtf/OrderMaker.h:

(WTF::OrderMaker::iterator::iterator):
(WTF::OrderMaker::iterator::operator*):
(WTF::OrderMaker::iterator::operator++):
(WTF::OrderMaker::iterator::operator== const):

  • wtf/SentinelLinkedList.h:

(WTF::BasicRawSentinelNode::prev const):
(WTF::BasicRawSentinelNode::next const):
(WTF::SentinelLinkedList::BaseIterator::BaseIterator):
(WTF::SentinelLinkedList::BaseIterator::operator* const):
(WTF::SentinelLinkedList::BaseIterator::operator-> const):
(WTF::SentinelLinkedList::BaseIterator::operator++):
(WTF::SentinelLinkedList::BaseIterator::operator--):
(WTF::SentinelLinkedList::BaseIterator::operator== const):
(WTF::SentinelLinkedList::BaseIterator::operator!= const):
(WTF::SentinelLinkedList::forEach):
(WTF::RawNode>::begin):
(WTF::RawNode>::end):
(WTF::RawNode>::begin const):
(WTF::RawNode>::end const):
(WTF::BasicRawSentinelNode::prev): Deleted.
(WTF::BasicRawSentinelNode::next): Deleted.

Tools:

  • TestWebKitAPI/Tests/WTF/SentinelLinkedList.cpp:

(TestWebKitAPI::TEST):

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/heap/HandleSet.h

    r273138 r290705  
    182182template<typename Functor> void HandleSet::forEachStrongHandle(const Functor& functor, const HashCountedSet<JSCell*>& skipSet)
    183183{
    184     HandleSet::Node* end = m_strongList.end();
    185     for (HandleSet::Node* node = m_strongList.begin(); node != end; node = node->next()) {
    186         JSValue value = *node->slot();
     184    for (Node& node : m_strongList) {
     185        JSValue value = *node.slot();
    187186        if (!value || !value.isCell())
    188187            continue;
Note: See TracChangeset for help on using the changeset viewer.