Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 33bf00e7fc8ce2293431540c62b0f7fd08b89221
      
https://github.com/WebKit/WebKit/commit/33bf00e7fc8ce2293431540c62b0f7fd08b89221
  Author: Chris Dumez <[email protected]>
  Date:   2026-04-29 (Wed, 29 Apr 2026)

  Changed paths:
    M Source/WTF/wtf/text/AtomStringImpl.cpp
    M Source/WTF/wtf/text/AtomStringTable.cpp
    M Source/WTF/wtf/text/StringImpl.h
    M Source/WebCore/dom/make-event-names.py

  Log Message:
  -----------
  Use StaticStringImpl for EventNames to avoid per-thread heap allocations
https://bugs.webkit.org/show_bug.cgi?id=313178

Reviewed by Ryosuke Niwa and Yusuke Suzuki.

Previously, each thread's EventNames constructor initialized ~335 AtomString
members from ASCIILiteral. Each one heap-allocated a StringImpl via
`createWithoutCopying()` and computed the string hash at runtime.

Now, event names are declared as `static constexpr StaticStringImpl` with the
StringAtom flag, and `addStatic()` stores them directly in the atom table
without heap-allocating a copy. This means:
- ~335 heap allocations eliminated per thread
- String hashes are computed at compile time (constexpr)
- All threads share the same StringImpl* pointers for event names

The StringAtom flag (same mechanism used by `emptyAtom()`) ensures the
StaticStringImpl is recognized as a valid atom, enabling the
`dynamicDowncast<AtomStringImpl>` fast path in `add(StringImpl&)`.

* Source/WTF/wtf/text/AtomStringImpl.cpp:
(WTF::StaticStringAtomTranslator::hash):
(WTF::StaticStringAtomTranslator::equal):
(WTF::StaticStringAtomTranslator::translate):
(WTF::addStatic):
* Source/WTF/wtf/text/AtomStringTable.cpp:
(WTF::AtomStringTable::~AtomStringTable):
* Source/WTF/wtf/text/StringImpl.h:
* Source/WebCore/dom/make-event-names.py:

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



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

Reply via email to