[webkit-changes] [WebKit/WebKit] 7c0d59: Prepare StringImpl for concurrent sweeping

Keith Miller noreply at github.com
Sat Jun 15 08:17:06 PDT 2024


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 7c0d5979a6587fa13e06e093df7cd8be6bb7b4fd
      https://github.com/WebKit/WebKit/commit/7c0d5979a6587fa13e06e093df7cd8be6bb7b4fd
  Author: Keith Miller <keith_miller at apple.com>
  Date:   2024-06-15 (Sat, 15 Jun 2024)

  Changed paths:
    M Source/WTF/wtf/Atomics.h
    M Source/WTF/wtf/text/ExternalStringImpl.cpp
    M Source/WTF/wtf/text/StringImpl.cpp
    M Source/WTF/wtf/text/StringImpl.h

  Log Message:
  -----------
  Prepare StringImpl for concurrent sweeping
https://bugs.webkit.org/show_bug.cgi?id=275036
rdar://129139374

Reviewed by Yusuke Suzuki.

This patch adds the parts needed for concurrent sweeping of JSStrings.
For CPUs where relaxed atomic ref counting is essetially free this patch makes
ref/deref of strings atomic. This enables derefing JSString's underlying
StringImpl from the sweeping thread. For other CPUs, it sets up the necessary
bits to allow detecting of a String needs deref on the main thread or destruction
from the sweeper thread.

To make this work StringImpl's m_hashAndFlags is now Atomic. It's mostly write once
so the impact should be negligible. It's possible that lazily computing the hash for
StaticStrings now would be profitable but this patch doesn't make that change.

This patch also adds the implementation of StringImpl::tryDerefConcurrently() which
will eventually be used by the concurrent sweeper.

* Source/WTF/wtf/Atomics.h:
(WTF::NonAtomic::NonAtomic):
(WTF::NonAtomic::load const):
(WTF::NonAtomic::loadRelaxed const):
(WTF::NonAtomic::store):
(WTF::NonAtomic::storeRelaxed):
(WTF::NonAtomic::exchangeAdd):
(WTF::NonAtomic::exchangeSub):
(WTF::NonAtomic::exchangeOr):
(WTF::NonAtomic::exchangeAnd):
* Source/WTF/wtf/text/ExternalStringImpl.cpp:
(WTF::ExternalStringImpl::ExternalStringImpl):
* Source/WTF/wtf/text/StringImpl.cpp:
(WTF::StringImpl::createStaticStringImpl):
* Source/WTF/wtf/text/StringImpl.h:
(WTF::StringImpl::maskIsUniqued):
(WTF::StringImpl::is8Bit const):
(WTF::StringImpl::isSymbol const):
(WTF::StringImpl::isAtom const):
(WTF::StringImpl::isUniqued const):
(WTF::StringImpl::rawHash const):
(WTF::StringImpl::isStatic const):
(WTF::StringImpl::refCount const):
(WTF::StringImpl::hasOneRef const):
(WTF::StringImpl::hasAtLeastOneRef const):
(WTF::StringImpl::bufferOwnership const):
(WTF::StringImpl::cost const):
(WTF::StringImpl::setIsAtom):
(WTF::StringImpl::setHash const):
(WTF::StringImpl::ref):
(WTF::StringImpl::deref):
(WTF::StringImpl::tryDerefConcurrently):

Canonical link: https://commits.webkit.org/280050@main



To unsubscribe from these emails, change your notification settings at https://github.com/WebKit/WebKit/settings/notifications


More information about the webkit-changes mailing list