[webkit-changes] [WebKit/WebKit] 39a1ff: Remove static strings and symbols

Justin Michaud noreply at github.com
Fri May 19 10:42:16 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 39a1ff098a4ebfd7b753243ba2d609fc5ef763eb
      https://github.com/WebKit/WebKit/commit/39a1ff098a4ebfd7b753243ba2d609fc5ef763eb
  Author: Justin Michaud <justin at justinmichaud.com>
  Date:   2023-05-19 (Fri, 19 May 2023)

  Changed paths:
    M Source/JavaScriptCore/builtins/BuiltinExecutables.cpp
    M Source/JavaScriptCore/builtins/BuiltinExecutables.h
    M Source/JavaScriptCore/builtins/BuiltinNames.cpp
    M Source/JavaScriptCore/builtins/BuiltinNames.h
    M Source/JavaScriptCore/runtime/InitializeThreading.cpp
    M Source/JavaScriptCore/runtime/JSString.h
    M Source/JavaScriptCore/runtime/SmallStrings.cpp
    M Source/JavaScriptCore/runtime/SmallStrings.h
    M Source/JavaScriptCore/runtime/VM.cpp
    M Source/WTF/wtf/CompactPtr.h
    M Source/WTF/wtf/Threading.cpp
    M Source/WTF/wtf/URL.cpp
    M Source/WTF/wtf/spi/cocoa/MachVMSPI.h
    M Source/WTF/wtf/text/AtomString.cpp
    M Source/WTF/wtf/text/AtomString.h
    M Source/WTF/wtf/text/AtomStringImpl.cpp
    M Source/WTF/wtf/text/AtomStringImpl.h
    M Source/WTF/wtf/text/StringImpl.cpp
    M Source/WTF/wtf/text/StringImpl.h
    M Source/WTF/wtf/text/SymbolImpl.cpp
    M Source/WTF/wtf/text/SymbolImpl.h
    M Source/WTF/wtf/text/UniquedStringImpl.h
    M Source/WTF/wtf/text/WTFString.cpp
    M Source/WTF/wtf/text/WTFString.h
    M Source/WebCore/bindings/scripts/StaticString.pm
    M Source/WebCore/css/CSSFontFaceSet.cpp
    M Source/WebCore/css/CSSFontSelector.cpp
    M Source/WebCore/dom/Document.cpp
    M Source/WebCore/dom/Document.h
    M Source/WebCore/dom/Element.cpp
    M Source/WebCore/dom/make_names.pl
    M Source/WebCore/platform/graphics/FontCascadeFonts.cpp
    M Source/WebCore/style/StyleResolveForFontRaw.cpp
    M Source/WebKit/Shared/EntryPointUtilities/Cocoa/XPCService/XPCServiceMain.mm
    M Source/WebKit/UIProcess/API/Cocoa/WKPreferences.mm
    M Tools/TestWebKitAPI/Tests/WTF/JSONValue.cpp
    M Tools/TestWebKitAPI/Tests/WTF/StringImpl.cpp
    M Tools/TestWebKitAPI/Tests/WebCore/FileMonitor.cpp
    M Tools/TestWebKitAPI/Tests/WebCore/PrivateClickMeasurement.cpp
    M Tools/TestWebKitAPI/Tests/WebKitCocoa/_WKWebAuthenticationPanel.mm

  Log Message:
  -----------
  Remove static strings and symbols
https://bugs.webkit.org/show_bug.cgi?id=256744
rdar://109287900

Reviewed by Yusuke Suzuki.

We would like to make StringImpl*, JSString* and JSRopeString* fit into
32 bits.

Why?
- This has the potential to save memory and improve cache locallity.
- Previously, when Yusuke made JSRopeString smaller by squishing the ropes
    together, it was a 1% Speedometer regression. This will let us undo
    that change while keeping the size of JSRopeString small.

We need to:
1) Forbid precice allocation
2) Ensure 16-byte alignment

This patch does both of these things, and should be sufficient to enable
CompactPtr<StringImpl> to work on iOS (although this patch doesn't do that).

On macOS, pointers are 48-bit instead of 36-bit, so we have more work to do:
1) Make sure that all strings are allocated out of the same malloc region
2) Allocate a chunk of va space for them, and plumb the base pointer around

This patch does the first thing.

Isn't removing static strings going to be a memory regression?

Well, hopefully not. Today we still increment the ref count of static strings,
so the memory is dirtied. After applying this patch, the character data will
still be static, but the StringImpl itself (which remember, was always dirty)
will be placed next to its bretheren.

This patch might introduce some concurrency bugs though. By inspection I
have tried to match the existing invariants, but I don't know if I have
spotted everything.

* Source/JavaScriptCore/builtins/BuiltinExecutables.cpp:
(JSC::BuiltinExecutables::defaultConstructorSourceCode):
* Source/JavaScriptCore/builtins/BuiltinExecutables.h:
* Source/JavaScriptCore/builtins/BuiltinNames.cpp:
(JSC::Symbols::initializeStaticSymbols):
(JSC::BuiltinNames::BuiltinNames):
(): Deleted.
* Source/JavaScriptCore/builtins/BuiltinNames.h:
* Source/JavaScriptCore/runtime/InitializeThreading.cpp:
(JSC::initialize):
* Source/JavaScriptCore/runtime/JSString.h:
(JSC::JSString::destroy): Deleted.
(JSC::JSString::subspaceFor): Deleted.
(JSC::JSString::uninitializedValueInternal const): Deleted.
(JSC::JSString::valueInternal const): Deleted.
(JSC::JSString::JSString): Deleted.
(JSC::JSString::finishCreation): Deleted.
(JSC::JSString::create): Deleted.
(JSC::JSString::createHasOtherOwner): Deleted.
(JSC::JSString::toBoolean const): Deleted.
(JSC::JSString::canGetIndex): Deleted.
(JSC::JSString::offsetOfValue): Deleted.
(JSC::JSString::isRope const): Deleted.
(JSC::JSString::fiberConcurrently const): Deleted.
* Source/JavaScriptCore/runtime/SmallStrings.cpp:
* Source/JavaScriptCore/runtime/SmallStrings.h:
(JSC::SmallString::initializeJSStaticStrings):
* Source/JavaScriptCore/runtime/VM.cpp:
(JSC::VM::ensureTerminationException):
(): Deleted.
* Source/WTF/wtf/CompactPtr.h:
(WTF::CompactPtr::operator!=):
(WTF::CompactPtr::storage const):
(WTF::CompactPtr::storage):
* Source/WTF/wtf/Threading.cpp:
(WTF::initialize):
* Source/WTF/wtf/URL.cpp:
(WTF::aboutBlankURL):
(WTF::aboutSrcDocURL):
(): Deleted.
* Source/WTF/wtf/text/AtomString.cpp:
(WTF::nullAtom):
(WTF::emptyAtom):
(WTF::AtomString::initializeStrings):
(): Deleted.
* Source/WTF/wtf/text/AtomString.h:
(WTF::StaticAtomString::StaticAtomString): Deleted.
(WTF::nullAtom): Deleted.
(WTF::emptyAtom): Deleted.
* Source/WTF/wtf/text/AtomStringImpl.cpp:
* Source/WTF/wtf/text/AtomStringImpl.h:
(WTF::ValueCheck<AtomStringImpl::checkConsistency): Deleted.
* Source/WTF/wtf/text/StringImpl.cpp:
(WTF::StringImpl::createStaticStringImplWithoutCopying):
(WTF::StringImpl::createStaticStringImpl):
* Source/WTF/wtf/text/StringImpl.h:
(WTF::StringImpl::createStaticStringImplWithoutCopying):
(WTF::StringImpl::empty):
(WTF::StringImpl::initializeEmptyString):
(WTF::StringImpl::StringImpl):
(WTF::StringImpl::cost const):
(WTF::ValueCheck<StringImpl::checkConsistency): Deleted.
(WTF::StringImpl::StaticStringImpl::StaticStringImpl): Deleted.
(WTF::StringImpl::StaticStringImpl::operator StringImpl&): Deleted.
* Source/WTF/wtf/text/SymbolImpl.cpp:
(WTF::SymbolImpl::createStatic):
(WTF::PrivateSymbolImpl::createStatic):
* Source/WTF/wtf/text/SymbolImpl.h:
(WTF::SymbolImpl::create):
(WTF::SymbolImpl::createStatic):
(WTF::ValueCheck<SymbolImpl::checkConsistency): Deleted.
* Source/WTF/wtf/text/UniquedStringImpl.h:
(WTF::ValueCheck<UniquedStringImpl::checkConsistency): Deleted.
(): Deleted.
* Source/WTF/wtf/text/WTFString.cpp:
(WTF::nullString):
(WTF::emptyString):
(WTF::String::initializeStrings):
* Source/WTF/wtf/text/WTFString.h:
(WTF::StaticString::StaticString): Deleted.
(WTF::nullString): Deleted.
(WTF::emptyString): Deleted.
* Source/WebCore/bindings/scripts/StaticString.pm:
(GenerateStrings):
(GenerateStringAsserts):
* Source/WebCore/css/CSSFontFaceSet.cpp:
(WebCore::CSSFontFaceSet::matchingFacesExcludingPreinstalledFonts):
* Source/WebCore/css/CSSFontSelector.cpp:
(WebCore::m_version):
* Source/WebCore/dom/Document.cpp:
(WebCore::Document::maskedURLForBindings):
(WebCore::Document::maskedURLStringForBindings): Deleted.
* Source/WebCore/dom/Document.h:
* Source/WebCore/dom/Element.cpp:
(WebCore::Element::resolveURLStringIfNeeded const):
* Source/WebCore/dom/make_names.pl:
(printTagNameCppFile):
(printDefinitions):
* Source/WebCore/platform/graphics/FontCascadeFonts.cpp:
(WebCore::FontCascadeFonts::realizeFallbackRangesAt):
* Source/WebCore/style/StyleResolveForFontRaw.cpp:
(WebCore::Style::resolveForFontRaw):
* Source/WebKit/Scripts/PreferencesTemplates/WebPreferencesFeatures.cpp.erb:
* Source/WebKit/Shared/EntryPointUtilities/Cocoa/XPCService/XPCServiceMain.mm:
(WebKit::XPCServiceMain):
* Tools/TestWebKitAPI/Tests/WTF/StringImpl.cpp:
(TestWebKitAPI::TEST):
(): Deleted.

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




More information about the webkit-changes mailing list