[webkit-changes] [WebKit/WebKit] 8b1d21: [WTF] Add countMatchedCharacters

Yusuke Suzuki noreply at github.com
Sun Dec 8 17:26:30 PST 2024


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 8b1d21ad4f48861d383244dc0b75c7356c9eedae
      https://github.com/WebKit/WebKit/commit/8b1d21ad4f48861d383244dc0b75c7356c9eedae
  Author: Yusuke Suzuki <ysuzuki at apple.com>
  Date:   2024-12-08 (Sun, 08 Dec 2024)

  Changed paths:
    M Source/JavaScriptCore/runtime/JSGenericTypedArrayViewConstructor.cpp
    M Source/JavaScriptCore/runtime/JSGenericTypedArrayViewPrototype.cpp
    M Source/JavaScriptCore/runtime/JSONObject.cpp
    M Source/JavaScriptCore/runtime/RegExpObjectInlines.h
    M Source/JavaScriptCore/runtime/RegExpSubstringGlobalAtomCache.cpp
    M Source/WTF/wtf/SIMDHelpers.h
    M Source/WTF/wtf/text/StringCommon.h
    M Tools/TestWebKitAPI/Tests/WTF/StringCommon.cpp

  Log Message:
  -----------
  [WTF] Add countMatchedCharacters
https://bugs.webkit.org/show_bug.cgi?id=284223
rdar://141088656

Reviewed by Justin Michaud.

This patch implements countMatchedCharacters with SIMD. We deploy
the algorithm used in bytecount module (MIT license, see license
term in the SIMDHelpers.h), and implement countMatchedCharacters with
that algorithm. We extend it to support uint16_t / uint32_t too.

We also tweak our SIMD loop to make them faster. Since they are too hot,
this kind of small tweaking can affect actually.

* Source/JavaScriptCore/runtime/JSGenericTypedArrayViewConstructor.cpp:
(JSC::decodeHexImpl):
* Source/JavaScriptCore/runtime/JSGenericTypedArrayViewPrototype.cpp:
(JSC::JSC_DEFINE_HOST_FUNCTION):
* Source/JavaScriptCore/runtime/JSONObject.cpp:
(JSC::stringCopySameType):
(JSC::stringCopyUpconvert):
* Source/JavaScriptCore/runtime/RegExpObjectInlines.h:
(JSC::collectGlobalAtomMatches):
(JSC::countMatchedCharacters): Deleted.
* Source/JavaScriptCore/runtime/RegExpSubstringGlobalAtomCache.cpp:
(JSC::RegExpSubstringGlobalAtomCache::collectMatches):
* Source/WTF/wtf/SIMDHelpers.h:
(WTF::SIMD::load4x):
(WTF::SIMD::store4x):
(WTF::SIMD::sum):
(WTF::SIMD::sub):
(WTF::SIMD::find):
(WTF::SIMD::findInterleaved):
(WTF::SIMD::count):
* Source/WTF/wtf/text/StringCommon.h:
(WTF::charactersContain):
(WTF::countMatchedCharacters):
* Tools/TestWebKitAPI/Tests/WTF/StringCommon.cpp:
(TestWebKitAPI::TEST(WTF_StringCommon, CountMatchedCharacters8)):
(TestWebKitAPI::TEST(WTF_StringCommon, CountMatchedCharacters16)):

Canonical link: https://commits.webkit.org/287526@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