Skip to content

Commit 68eced0

Browse files
committed
[WTF] Integrate simdutf
https://bugs.webkit.org/show_bug.cgi?id=250112 rdar://104145576 Reviewed by Michael Saboff. Add simdutf for faster base64 processing for new Base64 features in ECMAScript. Once it implements replacement character handling, we can also consider using it for UTF-8 / UTF-16 conversion too. Apple OSS Approval: OSS-13396 * Source/WTF/WTF.xcodeproj/project.pbxproj: * Source/WTF/wtf/CMakeLists.txt: * Source/WTF/wtf/simdutf/LICENSE-simdutf.txt: Added. * Source/WTF/wtf/simdutf/simdutf.cpp: Added. (_mm512_set_epi8): (simdutf::implementation::supported_by_runtime_system const): (simdutf::get_available_implementations): (simdutf::get_active_implementation): (simdutf::match_system): (simdutf::to_string): (simdutf::BOM::check_bom): (simdutf::BOM::bom_byte_size): (simdutf::result::result): * Source/WTF/wtf/simdutf/simdutf.h: Added. (simdutf::internal::detect_supported_architectures): (simdutf::internal::cpuid): (simdutf::implementation::name const): (simdutf::implementation::description const): (simdutf::implementation::required_instruction_sets const): (simdutf::implementation::implementation): (simdutf::internal::available_implementation_list::available_implementation_list): (simdutf::internal::atomic_ptr::atomic_ptr): (simdutf::internal::atomic_ptr::operator const T* const): (simdutf::internal::atomic_ptr::operator* const): (simdutf::internal::atomic_ptr::operator-> const): (simdutf::internal::atomic_ptr::operator T*): (simdutf::internal::atomic_ptr::operator*): (simdutf::internal::atomic_ptr::operator->): (simdutf::internal::atomic_ptr::operator=): Canonical link: https://commits.webkit.org/281011@main
1 parent 4d43216 commit 68eced0

7 files changed

Lines changed: 42410 additions & 0 deletions

File tree

Source/WTF/WTF.xcodeproj/project.pbxproj

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -824,6 +824,8 @@
824824
E32AB5022B5CE35D00B9FAAE /* LazyUniqueRef.h in Headers */ = {isa = PBXBuildFile; fileRef = E32AB5002B5CE35D00B9FAAE /* LazyUniqueRef.h */; settings = {ATTRIBUTES = (Private, ); }; };
825825
E336674A2722551100259122 /* Int128.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E33667492722550900259122 /* Int128.cpp */; };
826826
E336BD2F2BAB8A0400E8471C /* CharacterProperties.h in Headers */ = {isa = PBXBuildFile; fileRef = E336BD2E2BAB8A0400E8471C /* CharacterProperties.h */; settings = {ATTRIBUTES = (Private, ); }; };
827+
E34745D22945E33700F670F2 /* simdutf_impl.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E34745D02945E33700F670F2 /* simdutf_impl.cpp */; };
828+
E34745D32945E33700F670F2 /* simdutf_impl.h in Headers */ = {isa = PBXBuildFile; fileRef = E34745D12945E33700F670F2 /* simdutf_impl.h */; settings = {ATTRIBUTES = (Private, ); }; };
827829
E3618AB92AD8C4BA00DA7E43 /* ButterflyArray.h in Headers */ = {isa = PBXBuildFile; fileRef = E3618AB82AD8C4B900DA7E43 /* ButterflyArray.h */; settings = {ATTRIBUTES = (Private, ); }; };
828830
E361DB532891159C00B2A2B8 /* FastFloat.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E361DB512891159B00B2A2B8 /* FastFloat.cpp */; };
829831
E361DB542891159C00B2A2B8 /* FastFloat.h in Headers */ = {isa = PBXBuildFile; fileRef = E361DB522891159C00B2A2B8 /* FastFloat.h */; settings = {ATTRIBUTES = (Private, ); }; };
@@ -842,6 +844,7 @@
842844
E383AAC92B6C730B00058E60 /* AdaptiveStringSearcher.h in Headers */ = {isa = PBXBuildFile; fileRef = E383AAC82B6C730B00058E60 /* AdaptiveStringSearcher.h */; settings = {ATTRIBUTES = (Private, ); }; };
843845
E388886F20C9095100E632BC /* WorkerPool.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E388886D20C9095100E632BC /* WorkerPool.cpp */; };
844846
E38C41281EB4E0680042957D /* CPUTime.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E38C41261EB4E0680042957D /* CPUTime.cpp */; };
847+
E38C7CD82C366A1800BB9B18 /* SIMDUTF.h in Headers */ = {isa = PBXBuildFile; fileRef = E38C7CD72C366A1800BB9B18 /* SIMDUTF.h */; settings = {ATTRIBUTES = (Private, ); }; };
845848
E38C82692BECAE9D0071EF52 /* SIMDHelpers.h in Headers */ = {isa = PBXBuildFile; fileRef = E38C82682BECAE9D0071EF52 /* SIMDHelpers.h */; settings = {ATTRIBUTES = (Private, ); }; };
846849
E38D6E271F5522E300A75CC4 /* StringBuilderJSON.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E38D6E261F5522E300A75CC4 /* StringBuilderJSON.cpp */; };
847850
E392FA2722E92BFF00ECDC73 /* ResourceUsageCocoa.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E392FA2622E92BFF00ECDC73 /* ResourceUsageCocoa.cpp */; };
@@ -1765,6 +1768,8 @@
17651768
E336BD2E2BAB8A0400E8471C /* CharacterProperties.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CharacterProperties.h; sourceTree = "<group>"; };
17661769
E339C163244B4E8700359DA9 /* DataRef.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DataRef.h; sourceTree = "<group>"; };
17671770
E33D5F871FBED66700BF625E /* RecursableLambda.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RecursableLambda.h; sourceTree = "<group>"; };
1771+
E34745D02945E33700F670F2 /* simdutf_impl.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = simdutf_impl.cpp; sourceTree = "<group>"; };
1772+
E34745D12945E33700F670F2 /* simdutf_impl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = simdutf_impl.h; sourceTree = "<group>"; };
17681773
E34CD0D022810A020020D299 /* Packed.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = Packed.h; sourceTree = "<group>"; };
17691774
E3538D4C276220880075DA50 /* EmbeddedFixedVector.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = EmbeddedFixedVector.h; sourceTree = "<group>"; };
17701775
E3538D4D276220880075DA50 /* TrailingArray.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = TrailingArray.h; sourceTree = "<group>"; };
@@ -1795,6 +1800,7 @@
17951800
E388886E20C9095100E632BC /* WorkerPool.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WorkerPool.h; sourceTree = "<group>"; };
17961801
E38C41261EB4E0680042957D /* CPUTime.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CPUTime.cpp; sourceTree = "<group>"; };
17971802
E38C41271EB4E0680042957D /* CPUTime.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CPUTime.h; sourceTree = "<group>"; };
1803+
E38C7CD72C366A1800BB9B18 /* SIMDUTF.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SIMDUTF.h; sourceTree = "<group>"; };
17981804
E38C82682BECAE9D0071EF52 /* SIMDHelpers.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SIMDHelpers.h; sourceTree = "<group>"; };
17991805
E38D6E261F5522E300A75CC4 /* StringBuilderJSON.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = StringBuilderJSON.cpp; sourceTree = "<group>"; };
18001806
E392FA2622E92BFF00ECDC73 /* ResourceUsageCocoa.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ResourceUsageCocoa.cpp; sourceTree = "<group>"; };
@@ -2043,6 +2049,7 @@
20432049
E43A46851E228B5700276B05 /* persistence */,
20442050
A331D96321F24A2E009F02AA /* posix */,
20452051
E396C11C2BE885D9000CBAE1 /* simde */,
2052+
E34745CE2945E33600F670F2 /* simdutf */,
20462053
DDF306BF27C08654006A526F /* spi */,
20472054
A8A4731B151A825B004123FF /* text */,
20482055
A8A47339151A825B004123FF /* threads */,
@@ -2382,6 +2389,7 @@
23822389
0FEB3DCE1BB5D684009D7AAD /* SharedTask.h */,
23832390
862A8D32278DE74A0014120C /* SignedPtr.h */,
23842391
E38C82682BECAE9D0071EF52 /* SIMDHelpers.h */,
2392+
E38C7CD72C366A1800BB9B18 /* SIMDUTF.h */,
23852393
A8A4730A151A825B004123FF /* SimpleStats.h */,
23862394
795212021F42588800BD6421 /* SingleRootGraph.h */,
23872395
463CCFBB2B251D77009AB04E /* SingleThreadIntegralWrapper.h */,
@@ -2958,6 +2966,15 @@
29582966
path = darwin;
29592967
sourceTree = "<group>";
29602968
};
2969+
E34745CE2945E33600F670F2 /* simdutf */ = {
2970+
isa = PBXGroup;
2971+
children = (
2972+
E34745D02945E33700F670F2 /* simdutf_impl.cpp */,
2973+
E34745D12945E33700F670F2 /* simdutf_impl.h */,
2974+
);
2975+
path = simdutf;
2976+
sourceTree = "<group>";
2977+
};
29612978
E361DB56289115D000B2A2B8 /* fast_float */ = {
29622979
isa = PBXGroup;
29632980
children = (
@@ -3431,6 +3448,8 @@
34313448
DD03059327B5DA0D00344002 /* SignedPtr.h in Headers */,
34323449
E3ABBABE2BE88FBE00D84916 /* simde.h in Headers */,
34333450
E38C82692BECAE9D0071EF52 /* SIMDHelpers.h in Headers */,
3451+
E38C7CD82C366A1800BB9B18 /* SIMDUTF.h in Headers */,
3452+
E34745D32945E33700F670F2 /* simdutf_impl.h in Headers */,
34343453
E361DB63289115D000B2A2B8 /* simple_decimal_conversion.h in Headers */,
34353454
DD3DC8F727A4BF8E007E5B61 /* SimpleStats.h in Headers */,
34363455
DD3DC97627A4BF8E007E5B61 /* SingleRootGraph.h in Headers */,
@@ -4033,6 +4052,7 @@
40334052
0FA6F38F20CC580F00A03DCD /* SegmentedVector.cpp in Sources */,
40344053
A8A47421151A825B004123FF /* SHA1.cpp in Sources */,
40354054
5311BD531EA71CAD00525281 /* Signals.cpp in Sources */,
4055+
E34745D22945E33700F670F2 /* simdutf_impl.cpp in Sources */,
40364056
A748745217A0BDAE00FA04CB /* SixCharacterHash.cpp in Sources */,
40374057
A8A47425151A825B004123FF /* SizeLimits.cpp in Sources */,
40384058
0FA6F39320CC73A300A03DCD /* SmallSet.cpp in Sources */,

Source/WTF/wtf/CMakeLists.txt

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,7 @@ set(WTF_PUBLIC_HEADERS
249249
RunLoop.h
250250
SHA1.h
251251
SIMDHelpers.h
252+
SIMDUTF.h
252253
SafeStrerror.h
253254
SaturatedArithmetic.h
254255
SchedulePair.h
@@ -402,6 +403,8 @@ set(WTF_PUBLIC_HEADERS
402403
simde/arm/neon.h
403404
simde/arm/sve.h
404405

406+
simdutf/simdutf_impl.h
407+
405408
text/ASCIIFastPath.h
406409
text/ASCIILiteral.h
407410
text/AdaptiveStringSearcher.h
@@ -580,6 +583,8 @@ set(WTF_SOURCES
580583
persistence/PersistentDecoder.cpp
581584
persistence/PersistentEncoder.cpp
582585

586+
simdutf/simdutf_impl.cpp
587+
583588
text/ASCIILiteral.cpp
584589
text/AtomString.cpp
585590
text/AtomStringImpl.cpp
@@ -687,6 +692,7 @@ set(WTF_PRIVATE_INCLUDE_DIRECTORIES
687692
"${WTF_DIR}/wtf/dtoa"
688693
"${WTF_DIR}/wtf/fast_float"
689694
"${WTF_DIR}/wtf/persistence"
695+
"${WTF_DIR}/wtf/simdutf"
690696
"${WTF_DIR}/wtf/text"
691697
"${WTF_DIR}/wtf/text/icu"
692698
"${WTF_DIR}/wtf/threads"
@@ -731,6 +737,14 @@ WEBKIT_FRAMEWORK(WTF)
731737
if (MSVC)
732738
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /SUBSYSTEM:WINDOWS")
733739
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /SUBSYSTEM:WINDOWS")
740+
else ()
741+
# Prior to GCC 13, GCC has a bug that warning suppression pragma cannot be effective on preprocessor itself.
742+
# We need to disable preprocessor related warnings manually here.
743+
# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53431
744+
set_source_files_properties(
745+
simdutf/simdutf_impl.cpp
746+
text/Base64.cpp
747+
PROPERTIES COMPILE_FLAGS "-Wno-error=undef -Wno-undef")
734748
endif ()
735749

736750
file(MAKE_DIRECTORY ${WTF_SCRIPTS_DIR})

Source/WTF/wtf/SIMDUTF.h

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/*
2+
* Copyright (C) 2024 Apple Inc. All rights reserved.
3+
*
4+
* Redistribution and use in source and binary forms, with or without
5+
* modification, are permitted provided that the following conditions
6+
* are met:
7+
* 1. Redistributions of source code must retain the above copyright
8+
* notice, this list of conditions and the following disclaimer.
9+
* 2. Redistributions in binary form must reproduce the above copyright
10+
* notice, this list of conditions and the following disclaimer in the
11+
* documentation and/or other materials provided with the distribution.
12+
*
13+
* THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY
14+
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
15+
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
16+
* DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY
17+
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
18+
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
19+
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
20+
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
21+
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
22+
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23+
*/
24+
25+
#pragma once
26+
27+
#include <wtf/Compiler.h>
28+
29+
IGNORE_WARNINGS_BEGIN("error=undef")
30+
IGNORE_WARNINGS_BEGIN("undef")
31+
IGNORE_WARNINGS_BEGIN("missing-prototypes")
32+
IGNORE_WARNINGS_BEGIN("cast-qual")
33+
IGNORE_WARNINGS_BEGIN("cast-align")
34+
IGNORE_WARNINGS_BEGIN("documentation")
35+
36+
#include <wtf/simdutf/simdutf_impl.h>
37+
38+
IGNORE_WARNINGS_END
39+
IGNORE_WARNINGS_END
40+
IGNORE_WARNINGS_END
41+
IGNORE_WARNINGS_END
42+
IGNORE_WARNINGS_END
43+
IGNORE_WARNINGS_END
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
Copyright 2021 The simdutf authors
2+
3+
Permission is hereby granted, free of charge, to any person obtaining a copy of
4+
this software and associated documentation files (the "Software"), to deal in
5+
the Software without restriction, including without limitation the rights to
6+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
7+
the Software, and to permit persons to whom the Software is furnished to do so,
8+
subject to the following conditions:
9+
10+
The above copyright notice and this permission notice shall be included in all
11+
copies or substantial portions of the Software.
12+
13+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
15+
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
16+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
17+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
18+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

0 commit comments

Comments
 (0)