⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 293757 in webkit


Ignore:
Timestamp:
May 3, 2022, 7:27:25 PM (4 years ago)
Author:
ysuzuki@apple.com
Message:

[JSC] Initialize empty and null AtomString at compile time
​https://bugs.webkit.org/show_bug.cgi?id=240031

Reviewed by Mark Lam.

Because they are initialized from static data, we can just initialize them
at compile time, and we do not need to have AtomString::init.

  • Source/WebKit/WebAuthnProcess/WebAuthnProcess.cpp:

(WebKit::WebAuthnProcess::initializeWebAuthnProcess):

  • Source/WTF/wtf/Threading.cpp:

(WTF::initialize):

  • Source/WTF/wtf/text/AtomString.cpp:

(WTF::AtomString::init): Deleted.

  • Source/WTF/wtf/text/AtomString.h:

(WTF::StaticAtomString::StaticAtomString):
(WTF::nullAtom):
(WTF::emptyAtom):

  • Source/WebCore/dom/make_names.pl:

(printInit):

Canonical link: ​https://commits.webkit.org/250236@main

Location:
trunk/Source
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WTF/ChangeLog

    r293735 r293757  
     12022-05-03  Yusuke Suzuki  <ysuzuki@apple.com>
     2
     3        [JSC] Initialize empty and null AtomString at compile time
     4        https://bugs.webkit.org/show_bug.cgi?id=240031
     5
     6        Reviewed by Mark Lam.
     7
     8        Because they are initialized from static data, we can just initialize them
     9        at compile time, and we do not need to have `AtomString::init`.
     10
     11        * wtf/Threading.cpp:
     12        (WTF::initialize):
     13        * wtf/text/AtomString.cpp:
     14        (WTF::AtomString::init): Deleted.
     15        * wtf/text/AtomString.h:
     16        (WTF::StaticAtomString::StaticAtomString):
     17        (WTF::nullAtom):
     18        (WTF::emptyAtom):
     19
    1202022-05-03  Chris Dumez  <cdumez@apple.com>
    221
  • trunk/Source/WTF/wtf/Threading.cpp

    r293735 r293757  
    476476        SignalHandlers::initialize();
    477477#endif
    478         AtomString::init();
    479478    });
    480479}
  • trunk/Source/WTF/wtf/text/AtomString.cpp

    r293735 r293757  
    3232
    3333namespace WTF {
     34
     35WTF_EXPORT_PRIVATE const StaticAtomString nullAtomData { nullptr };
     36WTF_EXPORT_PRIVATE const StaticAtomString emptyAtomData { &StringImpl::s_emptyAtomString };
    3437
    3538template<AtomString::CaseConvertType type>
    … …  
    135138#endif
    136139
    137 WTF_EXPORT_PRIVATE LazyNeverDestroyed<const AtomString> nullAtomData;
    138 WTF_EXPORT_PRIVATE LazyNeverDestroyed<const AtomString> emptyAtomData;
    139 
    140 void AtomString::init()
    141 {
    142     static std::once_flag initializeKey;
    143     std::call_once(initializeKey, [] {
    144         nullAtomData.construct();
    145         emptyAtomData.construct(AtomString::fromLatin1(""));
    146     });
    147 }
    148 
    149140static inline StringBuilder replaceUnpairedSurrogatesWithReplacementCharacterInternal(StringView view)
    150141{
  • trunk/Source/WTF/wtf/text/AtomString.h

    r293703 r293757  
    3636    WTF_MAKE_FAST_ALLOCATED;
    3737public:
    38     WTF_EXPORT_PRIVATE static void init();
    39 
    4038    AtomString();
    4139    AtomString(const LChar*, unsigned length);
    … …  
    280278#endif
    281279
    282 // nullAtom and emptyAtom are special AtomString. They can be used from any threads since their StringImpls are not actually registered into AtomStringTable.
    283 extern WTF_EXPORT_PRIVATE LazyNeverDestroyed<const AtomString> nullAtomData;
    284 extern WTF_EXPORT_PRIVATE LazyNeverDestroyed<const AtomString> emptyAtomData;
    285 
    286 inline const AtomString& nullAtom() { return nullAtomData.get(); }
    287 inline const AtomString& emptyAtom() { return emptyAtomData.get(); }
     280struct StaticAtomString {
     281    constexpr StaticAtomString(StringImpl::StaticStringImpl* pointer)
     282        : m_pointer(pointer)
     283    {
     284    }
     285
     286    StringImpl::StaticStringImpl* m_pointer;
     287};
     288static_assert(sizeof(AtomString) == sizeof(StaticAtomString), "AtomString and StaticAtomString must be the same size!");
     289extern WTF_EXPORT_PRIVATE const StaticAtomString nullAtomData;
     290extern WTF_EXPORT_PRIVATE const StaticAtomString emptyAtomData;
     291
     292inline const AtomString& nullAtom() { return *reinterpret_cast<const AtomString*>(&nullAtomData); }
     293inline const AtomString& emptyAtom() { return *reinterpret_cast<const AtomString*>(&emptyAtomData); }
    288294
    289295inline AtomString::AtomString(ASCIILiteral literal)
  • trunk/Source/WebCore/ChangeLog

    r293736 r293757  
     12022-05-03  Yusuke Suzuki  <ysuzuki@apple.com>
     2
     3        [JSC] Initialize empty and null AtomString at compile time
     4        https://bugs.webkit.org/show_bug.cgi?id=240031
     5
     6        Reviewed by Mark Lam.
     7
     8        * dom/QualifiedName.cpp:
     9        (WebCore::QualifiedName::init):
     10        * dom/make_names.pl:
     11        (printInit):
     12
    1132022-05-03  Sihui Liu  <sihui_liu@apple.com>
    214
  • trunk/Source/WebCore/dom/QualifiedName.cpp

    r293701 r293757  
    5050        return;
    5151
    52     ASSERT_WITH_MESSAGE(WTF::nullAtomData.isConstructed(), "AtomString::init should have been called");
    5352    anyName.construct(nullAtom(), starAtom(), starAtom());
    5453    initialized = true;
  • trunk/Source/WebCore/dom/make_names.pl

    r293548 r293757  
    603603
    604604    // Use placement new to initialize the globals.
    605 
    606     AtomString::init();
    607605";
    608606}
  • trunk/Source/WebKit/ChangeLog

    r293744 r293757  
     12022-05-03  Yusuke Suzuki  <ysuzuki@apple.com>
     2
     3        [JSC] Initialize empty and null AtomString at compile time
     4        https://bugs.webkit.org/show_bug.cgi?id=240031
     5
     6        Reviewed by Mark Lam.
     7
     8        * WebAuthnProcess/WebAuthnProcess.cpp:
     9        (WebKit::WebAuthnProcess::initializeWebAuthnProcess):
     10
    1112022-05-03  Commit Queue  <commit-queue@webkit.org>
    212
  • trunk/Source/WebKit/WebAuthnProcess/WebAuthnProcess.cpp

    r293266 r293757  
    9595    applyProcessCreationParameters(parameters.auxiliaryProcessParameters);
    9696    WTF::Thread::setCurrentThreadIsUserInitiated();
    97     AtomString::init();
    9897}
    9998
Note: See TracChangeset for help on using the changeset viewer.