react-native-quick-crypto 1.0.19 → 1.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/QuickCrypto.podspec +12 -38
- package/README.md +2 -0
- package/android/CMakeLists.txt +3 -0
- package/android/build.gradle +5 -1
- package/cpp/argon2/HybridArgon2.cpp +10 -3
- package/cpp/blake3/HybridBlake3.cpp +5 -3
- package/cpp/cipher/CCMCipher.cpp +29 -16
- package/cpp/cipher/CCMCipher.hpp +2 -4
- package/cpp/cipher/ChaCha20Cipher.cpp +14 -18
- package/cpp/cipher/ChaCha20Cipher.hpp +2 -4
- package/cpp/cipher/ChaCha20Poly1305Cipher.cpp +34 -23
- package/cpp/cipher/ChaCha20Poly1305Cipher.hpp +2 -4
- package/cpp/cipher/GCMCipher.cpp +14 -15
- package/cpp/cipher/HybridCipher.cpp +39 -36
- package/cpp/cipher/HybridCipher.hpp +17 -1
- package/cpp/cipher/HybridRsaCipher.cpp +74 -29
- package/cpp/cipher/OCBCipher.cpp +4 -3
- package/cpp/cipher/XChaCha20Poly1305Cipher.cpp +14 -13
- package/cpp/cipher/XSalsa20Cipher.cpp +72 -6
- package/cpp/cipher/XSalsa20Cipher.hpp +25 -3
- package/cpp/cipher/XSalsa20Poly1305Cipher.cpp +21 -25
- package/cpp/dh/HybridDiffieHellman.cpp +29 -0
- package/cpp/ec/HybridEcKeyPair.cpp +35 -33
- package/cpp/ec/HybridEcKeyPair.hpp +3 -7
- package/cpp/ecdh/HybridECDH.cpp +23 -0
- package/cpp/ed25519/HybridEdKeyPair.cpp +73 -117
- package/cpp/ed25519/HybridEdKeyPair.hpp +5 -9
- package/cpp/hash/HybridHash.cpp +5 -7
- package/cpp/hkdf/HybridHkdf.cpp +6 -4
- package/cpp/hmac/HybridHmac.cpp +4 -6
- package/cpp/kmac/HybridKmac.cpp +4 -4
- package/cpp/mldsa/HybridMlDsaKeyPair.cpp +37 -49
- package/cpp/mlkem/HybridMlKemKeyPair.cpp +39 -43
- package/cpp/pbkdf2/HybridPbkdf2.cpp +7 -8
- package/cpp/rsa/HybridRsaKeyPair.cpp +5 -8
- package/cpp/rsa/HybridRsaKeyPair.hpp +4 -7
- package/cpp/scrypt/HybridScrypt.cpp +6 -4
- package/cpp/sign/HybridSignHandle.cpp +25 -68
- package/cpp/sign/HybridVerifyHandle.cpp +23 -60
- package/cpp/utils/HybridUtils.cpp +213 -111
- package/cpp/utils/HybridUtils.hpp +9 -2
- package/cpp/utils/QuickCryptoUtils.hpp +72 -0
- package/deps/simdutf/LICENSE-APACHE +201 -0
- package/deps/simdutf/LICENSE-MIT +18 -0
- package/deps/simdutf/README.md +2782 -0
- package/deps/simdutf/include/simdutf/avx512.h +79 -0
- package/deps/simdutf/include/simdutf/base64_implementation.h +158 -0
- package/deps/simdutf/include/simdutf/base64_tables.h +887 -0
- package/deps/simdutf/include/simdutf/common_defs.h +186 -0
- package/deps/simdutf/include/simdutf/compiler_check.h +50 -0
- package/deps/simdutf/include/simdutf/constexpr_ptr.h +138 -0
- package/deps/simdutf/include/simdutf/encoding_types.h +189 -0
- package/deps/simdutf/include/simdutf/error.h +126 -0
- package/deps/simdutf/include/simdutf/implementation.h +7081 -0
- package/deps/simdutf/include/simdutf/internal/isadetection.h +325 -0
- package/deps/simdutf/include/simdutf/portability.h +285 -0
- package/deps/simdutf/include/simdutf/scalar/ascii.h +86 -0
- package/deps/simdutf/include/simdutf/scalar/atomic_util.h +105 -0
- package/deps/simdutf/include/simdutf/scalar/base64.h +911 -0
- package/deps/simdutf/include/simdutf/scalar/latin1.h +26 -0
- package/deps/simdutf/include/simdutf/scalar/latin1_to_utf16/latin1_to_utf16.h +52 -0
- package/deps/simdutf/include/simdutf/scalar/latin1_to_utf32/latin1_to_utf32.h +27 -0
- package/deps/simdutf/include/simdutf/scalar/latin1_to_utf8/latin1_to_utf8.h +191 -0
- package/deps/simdutf/include/simdutf/scalar/swap_bytes.h +35 -0
- package/deps/simdutf/include/simdutf/scalar/utf16.h +226 -0
- package/deps/simdutf/include/simdutf/scalar/utf16_to_latin1/utf16_to_latin1.h +108 -0
- package/deps/simdutf/include/simdutf/scalar/utf16_to_latin1/valid_utf16_to_latin1.h +40 -0
- package/deps/simdutf/include/simdutf/scalar/utf16_to_utf32/utf16_to_utf32.h +86 -0
- package/deps/simdutf/include/simdutf/scalar/utf16_to_utf32/valid_utf16_to_utf32.h +44 -0
- package/deps/simdutf/include/simdutf/scalar/utf16_to_utf8/utf16_to_utf8.h +295 -0
- package/deps/simdutf/include/simdutf/scalar/utf16_to_utf8/valid_utf16_to_utf8.h +91 -0
- package/deps/simdutf/include/simdutf/scalar/utf32.h +82 -0
- package/deps/simdutf/include/simdutf/scalar/utf32_to_latin1/utf32_to_latin1.h +68 -0
- package/deps/simdutf/include/simdutf/scalar/utf32_to_latin1/valid_utf32_to_latin1.h +67 -0
- package/deps/simdutf/include/simdutf/scalar/utf32_to_utf16/utf32_to_utf16.h +84 -0
- package/deps/simdutf/include/simdutf/scalar/utf32_to_utf16/valid_utf32_to_utf16.h +44 -0
- package/deps/simdutf/include/simdutf/scalar/utf32_to_utf8/utf32_to_utf8.h +142 -0
- package/deps/simdutf/include/simdutf/scalar/utf32_to_utf8/valid_utf32_to_utf8.h +72 -0
- package/deps/simdutf/include/simdutf/scalar/utf8.h +326 -0
- package/deps/simdutf/include/simdutf/scalar/utf8_to_latin1/utf8_to_latin1.h +225 -0
- package/deps/simdutf/include/simdutf/scalar/utf8_to_latin1/valid_utf8_to_latin1.h +87 -0
- package/deps/simdutf/include/simdutf/scalar/utf8_to_utf16/utf8_to_utf16.h +342 -0
- package/deps/simdutf/include/simdutf/scalar/utf8_to_utf16/valid_utf8_to_utf16.h +106 -0
- package/deps/simdutf/include/simdutf/scalar/utf8_to_utf32/utf8_to_utf32.h +299 -0
- package/deps/simdutf/include/simdutf/scalar/utf8_to_utf32/valid_utf8_to_utf32.h +83 -0
- package/deps/simdutf/include/simdutf/simdutf_version.h +26 -0
- package/deps/simdutf/include/simdutf.h +26 -0
- package/deps/simdutf/include/simdutf_c.h +342 -0
- package/deps/simdutf/src/arm64/arm_base64.cpp +791 -0
- package/deps/simdutf/src/arm64/arm_convert_latin1_to_utf16.cpp +24 -0
- package/deps/simdutf/src/arm64/arm_convert_latin1_to_utf32.cpp +24 -0
- package/deps/simdutf/src/arm64/arm_convert_latin1_to_utf8.cpp +70 -0
- package/deps/simdutf/src/arm64/arm_convert_utf16_to_latin1.cpp +61 -0
- package/deps/simdutf/src/arm64/arm_convert_utf16_to_utf32.cpp +185 -0
- package/deps/simdutf/src/arm64/arm_convert_utf16_to_utf8.cpp +780 -0
- package/deps/simdutf/src/arm64/arm_convert_utf32_to_latin1.cpp +60 -0
- package/deps/simdutf/src/arm64/arm_convert_utf32_to_utf16.cpp +208 -0
- package/deps/simdutf/src/arm64/arm_convert_utf32_to_utf8.cpp +505 -0
- package/deps/simdutf/src/arm64/arm_convert_utf8_to_latin1.cpp +69 -0
- package/deps/simdutf/src/arm64/arm_convert_utf8_to_utf16.cpp +313 -0
- package/deps/simdutf/src/arm64/arm_convert_utf8_to_utf32.cpp +179 -0
- package/deps/simdutf/src/arm64/arm_find.cpp +199 -0
- package/deps/simdutf/src/arm64/arm_utf16fix.cpp +185 -0
- package/deps/simdutf/src/arm64/arm_validate_utf16.cpp +165 -0
- package/deps/simdutf/src/arm64/arm_validate_utf32le.cpp +65 -0
- package/deps/simdutf/src/arm64/implementation.cpp +1442 -0
- package/deps/simdutf/src/encoding_types.cpp +67 -0
- package/deps/simdutf/src/error.cpp +3 -0
- package/deps/simdutf/src/fallback/implementation.cpp +589 -0
- package/deps/simdutf/src/generic/ascii_validation.h +50 -0
- package/deps/simdutf/src/generic/base64.h +233 -0
- package/deps/simdutf/src/generic/base64lengths.h +63 -0
- package/deps/simdutf/src/generic/buf_block_reader.h +109 -0
- package/deps/simdutf/src/generic/find.h +75 -0
- package/deps/simdutf/src/generic/utf16/change_endianness.h +24 -0
- package/deps/simdutf/src/generic/utf16/count_code_points_bytemask.h +58 -0
- package/deps/simdutf/src/generic/utf16/to_well_formed.h +93 -0
- package/deps/simdutf/src/generic/utf16/utf32_length_from_utf16.h +15 -0
- package/deps/simdutf/src/generic/utf16/utf8_length_from_utf16.h +35 -0
- package/deps/simdutf/src/generic/utf16/utf8_length_from_utf16_bytemask.h +199 -0
- package/deps/simdutf/src/generic/utf16.h +73 -0
- package/deps/simdutf/src/generic/utf32.h +136 -0
- package/deps/simdutf/src/generic/utf8/utf16_length_from_utf8_bytemask.h +53 -0
- package/deps/simdutf/src/generic/utf8.h +92 -0
- package/deps/simdutf/src/generic/utf8_to_latin1/utf8_to_latin1.h +316 -0
- package/deps/simdutf/src/generic/utf8_to_latin1/valid_utf8_to_latin1.h +78 -0
- package/deps/simdutf/src/generic/utf8_to_utf16/utf8_to_utf16.h +332 -0
- package/deps/simdutf/src/generic/utf8_to_utf16/valid_utf8_to_utf16.h +74 -0
- package/deps/simdutf/src/generic/utf8_to_utf32/utf8_to_utf32.h +318 -0
- package/deps/simdutf/src/generic/utf8_to_utf32/valid_utf8_to_utf32.h +42 -0
- package/deps/simdutf/src/generic/utf8_validation/utf8_lookup4_algorithm.h +223 -0
- package/deps/simdutf/src/generic/utf8_validation/utf8_validator.h +84 -0
- package/deps/simdutf/src/generic/validate_utf16.h +164 -0
- package/deps/simdutf/src/generic/validate_utf32.h +99 -0
- package/deps/simdutf/src/haswell/avx2_base64.cpp +837 -0
- package/deps/simdutf/src/haswell/avx2_convert_latin1_to_utf16.cpp +28 -0
- package/deps/simdutf/src/haswell/avx2_convert_latin1_to_utf32.cpp +20 -0
- package/deps/simdutf/src/haswell/avx2_convert_latin1_to_utf8.cpp +83 -0
- package/deps/simdutf/src/haswell/avx2_convert_utf16_to_latin1.cpp +83 -0
- package/deps/simdutf/src/haswell/avx2_convert_utf16_to_utf32.cpp +210 -0
- package/deps/simdutf/src/haswell/avx2_convert_utf16_to_utf8.cpp +602 -0
- package/deps/simdutf/src/haswell/avx2_convert_utf32_to_latin1.cpp +116 -0
- package/deps/simdutf/src/haswell/avx2_convert_utf32_to_utf16.cpp +164 -0
- package/deps/simdutf/src/haswell/avx2_convert_utf32_to_utf8.cpp +569 -0
- package/deps/simdutf/src/haswell/avx2_convert_utf8_to_latin1.cpp +60 -0
- package/deps/simdutf/src/haswell/avx2_convert_utf8_to_utf16.cpp +195 -0
- package/deps/simdutf/src/haswell/avx2_convert_utf8_to_utf32.cpp +135 -0
- package/deps/simdutf/src/haswell/avx2_utf16fix.cpp +173 -0
- package/deps/simdutf/src/haswell/avx2_validate_utf16.cpp +17 -0
- package/deps/simdutf/src/haswell/implementation.cpp +1447 -0
- package/deps/simdutf/src/icelake/icelake_ascii_validation.inl.cpp +19 -0
- package/deps/simdutf/src/icelake/icelake_base64.inl.cpp +630 -0
- package/deps/simdutf/src/icelake/icelake_common.inl.cpp +37 -0
- package/deps/simdutf/src/icelake/icelake_convert_latin1_to_utf16.inl.cpp +36 -0
- package/deps/simdutf/src/icelake/icelake_convert_latin1_to_utf32.inl.cpp +23 -0
- package/deps/simdutf/src/icelake/icelake_convert_latin1_to_utf8.inl.cpp +107 -0
- package/deps/simdutf/src/icelake/icelake_convert_utf16_to_latin1.inl.cpp +103 -0
- package/deps/simdutf/src/icelake/icelake_convert_utf16_to_utf32.inl.cpp +136 -0
- package/deps/simdutf/src/icelake/icelake_convert_utf16_to_utf8.inl.cpp +206 -0
- package/deps/simdutf/src/icelake/icelake_convert_utf32_to_latin1.inl.cpp +74 -0
- package/deps/simdutf/src/icelake/icelake_convert_utf32_to_utf16.inl.cpp +338 -0
- package/deps/simdutf/src/icelake/icelake_convert_utf32_to_utf8.inl.cpp +574 -0
- package/deps/simdutf/src/icelake/icelake_convert_utf8_to_latin1.inl.cpp +104 -0
- package/deps/simdutf/src/icelake/icelake_convert_utf8_to_utf16.inl.cpp +75 -0
- package/deps/simdutf/src/icelake/icelake_convert_valid_utf8_to_latin1.inl.cpp +69 -0
- package/deps/simdutf/src/icelake/icelake_find.inl.cpp +146 -0
- package/deps/simdutf/src/icelake/icelake_from_utf8.inl.cpp +266 -0
- package/deps/simdutf/src/icelake/icelake_from_valid_utf8.inl.cpp +136 -0
- package/deps/simdutf/src/icelake/icelake_macros.inl.cpp +143 -0
- package/deps/simdutf/src/icelake/icelake_utf16fix.cpp +138 -0
- package/deps/simdutf/src/icelake/icelake_utf32_validation.inl.cpp +63 -0
- package/deps/simdutf/src/icelake/icelake_utf8_common.inl.cpp +753 -0
- package/deps/simdutf/src/icelake/icelake_utf8_length_from_utf16.inl.cpp +269 -0
- package/deps/simdutf/src/icelake/icelake_utf8_validation.inl.cpp +116 -0
- package/deps/simdutf/src/icelake/implementation.cpp +1903 -0
- package/deps/simdutf/src/implementation.cpp +2526 -0
- package/deps/simdutf/src/lasx/implementation.cpp +1531 -0
- package/deps/simdutf/src/lasx/lasx_base64.cpp +695 -0
- package/deps/simdutf/src/lasx/lasx_convert_latin1_to_utf16.cpp +76 -0
- package/deps/simdutf/src/lasx/lasx_convert_latin1_to_utf32.cpp +55 -0
- package/deps/simdutf/src/lasx/lasx_convert_latin1_to_utf8.cpp +65 -0
- package/deps/simdutf/src/lasx/lasx_convert_utf16_to_latin1.cpp +64 -0
- package/deps/simdutf/src/lasx/lasx_convert_utf16_to_utf32.cpp +183 -0
- package/deps/simdutf/src/lasx/lasx_convert_utf16_to_utf8.cpp +550 -0
- package/deps/simdutf/src/lasx/lasx_convert_utf32_to_latin1.cpp +73 -0
- package/deps/simdutf/src/lasx/lasx_convert_utf32_to_utf16.cpp +218 -0
- package/deps/simdutf/src/lasx/lasx_convert_utf32_to_utf8.cpp +589 -0
- package/deps/simdutf/src/lasx/lasx_convert_utf8_to_latin1.cpp +72 -0
- package/deps/simdutf/src/lasx/lasx_convert_utf8_to_utf16.cpp +296 -0
- package/deps/simdutf/src/lasx/lasx_convert_utf8_to_utf32.cpp +190 -0
- package/deps/simdutf/src/lasx/lasx_find.cpp +64 -0
- package/deps/simdutf/src/lasx/lasx_validate_utf16.cpp +13 -0
- package/deps/simdutf/src/lasx/lasx_validate_utf32le.cpp +84 -0
- package/deps/simdutf/src/lsx/implementation.cpp +1417 -0
- package/deps/simdutf/src/lsx/lsx_base64.cpp +675 -0
- package/deps/simdutf/src/lsx/lsx_convert_latin1_to_utf16.cpp +39 -0
- package/deps/simdutf/src/lsx/lsx_convert_latin1_to_utf32.cpp +27 -0
- package/deps/simdutf/src/lsx/lsx_convert_latin1_to_utf8.cpp +56 -0
- package/deps/simdutf/src/lsx/lsx_convert_utf16_to_latin1.cpp +64 -0
- package/deps/simdutf/src/lsx/lsx_convert_utf16_to_utf32.cpp +133 -0
- package/deps/simdutf/src/lsx/lsx_convert_utf16_to_utf8.cpp +518 -0
- package/deps/simdutf/src/lsx/lsx_convert_utf32_to_latin1.cpp +66 -0
- package/deps/simdutf/src/lsx/lsx_convert_utf32_to_utf16.cpp +155 -0
- package/deps/simdutf/src/lsx/lsx_convert_utf32_to_utf8.cpp +459 -0
- package/deps/simdutf/src/lsx/lsx_convert_utf8_to_latin1.cpp +75 -0
- package/deps/simdutf/src/lsx/lsx_convert_utf8_to_utf16.cpp +291 -0
- package/deps/simdutf/src/lsx/lsx_convert_utf8_to_utf32.cpp +179 -0
- package/deps/simdutf/src/lsx/lsx_find.cpp +60 -0
- package/deps/simdutf/src/lsx/lsx_validate_utf16.cpp +13 -0
- package/deps/simdutf/src/lsx/lsx_validate_utf32le.cpp +68 -0
- package/deps/simdutf/src/ppc64/implementation.cpp +992 -0
- package/deps/simdutf/src/ppc64/ppc64_base64.cpp +480 -0
- package/deps/simdutf/src/ppc64/ppc64_base64_internal_tests.cpp +401 -0
- package/deps/simdutf/src/ppc64/ppc64_convert_latin1_to_utf16.cpp +12 -0
- package/deps/simdutf/src/ppc64/ppc64_convert_latin1_to_utf32.cpp +12 -0
- package/deps/simdutf/src/ppc64/ppc64_convert_latin1_to_utf8.cpp +149 -0
- package/deps/simdutf/src/ppc64/ppc64_convert_utf16_to_latin1.cpp +67 -0
- package/deps/simdutf/src/ppc64/ppc64_convert_utf16_to_utf32.cpp +87 -0
- package/deps/simdutf/src/ppc64/ppc64_convert_utf16_to_utf8.cpp +296 -0
- package/deps/simdutf/src/ppc64/ppc64_convert_utf32_to_latin1.cpp +57 -0
- package/deps/simdutf/src/ppc64/ppc64_convert_utf32_to_utf16.cpp +117 -0
- package/deps/simdutf/src/ppc64/ppc64_convert_utf32_to_utf8.cpp +166 -0
- package/deps/simdutf/src/ppc64/ppc64_convert_utf8_to_latin1.cpp +69 -0
- package/deps/simdutf/src/ppc64/ppc64_convert_utf8_to_utf16.cpp +211 -0
- package/deps/simdutf/src/ppc64/ppc64_convert_utf8_to_utf32.cpp +153 -0
- package/deps/simdutf/src/ppc64/ppc64_utf16_to_utf8_tables.h +1011 -0
- package/deps/simdutf/src/ppc64/ppc64_utf8_length_from_latin1.cpp +37 -0
- package/deps/simdutf/src/ppc64/ppc64_validate_utf16.cpp +19 -0
- package/deps/simdutf/src/ppc64/templates.cpp +91 -0
- package/deps/simdutf/src/rvv/implementation.cpp +138 -0
- package/deps/simdutf/src/rvv/rvv_find.cpp +27 -0
- package/deps/simdutf/src/rvv/rvv_helpers.inl.cpp +23 -0
- package/deps/simdutf/src/rvv/rvv_latin1_to.inl.cpp +71 -0
- package/deps/simdutf/src/rvv/rvv_length_from.inl.cpp +164 -0
- package/deps/simdutf/src/rvv/rvv_utf16_to.inl.cpp +399 -0
- package/deps/simdutf/src/rvv/rvv_utf16fix.cpp +110 -0
- package/deps/simdutf/src/rvv/rvv_utf32_to.inl.cpp +307 -0
- package/deps/simdutf/src/rvv/rvv_utf8_to.inl.cpp +435 -0
- package/deps/simdutf/src/rvv/rvv_validate.inl.cpp +275 -0
- package/deps/simdutf/src/simdutf/arm64/begin.h +2 -0
- package/deps/simdutf/src/simdutf/arm64/bitmanipulation.h +34 -0
- package/deps/simdutf/src/simdutf/arm64/end.h +2 -0
- package/deps/simdutf/src/simdutf/arm64/implementation.h +307 -0
- package/deps/simdutf/src/simdutf/arm64/intrinsics.h +10 -0
- package/deps/simdutf/src/simdutf/arm64/simd.h +547 -0
- package/deps/simdutf/src/simdutf/arm64/simd16-inl.h +403 -0
- package/deps/simdutf/src/simdutf/arm64/simd32-inl.h +129 -0
- package/deps/simdutf/src/simdutf/arm64/simd64-inl.h +28 -0
- package/deps/simdutf/src/simdutf/arm64.h +43 -0
- package/deps/simdutf/src/simdutf/fallback/begin.h +1 -0
- package/deps/simdutf/src/simdutf/fallback/bitmanipulation.h +13 -0
- package/deps/simdutf/src/simdutf/fallback/end.h +1 -0
- package/deps/simdutf/src/simdutf/fallback/implementation.h +331 -0
- package/deps/simdutf/src/simdutf/fallback.h +42 -0
- package/deps/simdutf/src/simdutf/haswell/begin.h +15 -0
- package/deps/simdutf/src/simdutf/haswell/bitmanipulation.h +35 -0
- package/deps/simdutf/src/simdutf/haswell/end.h +13 -0
- package/deps/simdutf/src/simdutf/haswell/implementation.h +338 -0
- package/deps/simdutf/src/simdutf/haswell/intrinsics.h +67 -0
- package/deps/simdutf/src/simdutf/haswell/simd.h +363 -0
- package/deps/simdutf/src/simdutf/haswell/simd16-inl.h +261 -0
- package/deps/simdutf/src/simdutf/haswell/simd32-inl.h +111 -0
- package/deps/simdutf/src/simdutf/haswell/simd64-inl.h +34 -0
- package/deps/simdutf/src/simdutf/haswell.h +63 -0
- package/deps/simdutf/src/simdutf/icelake/begin.h +14 -0
- package/deps/simdutf/src/simdutf/icelake/bitmanipulation.h +44 -0
- package/deps/simdutf/src/simdutf/icelake/end.h +12 -0
- package/deps/simdutf/src/simdutf/icelake/implementation.h +346 -0
- package/deps/simdutf/src/simdutf/icelake/intrinsics.h +138 -0
- package/deps/simdutf/src/simdutf/icelake/simd.h +17 -0
- package/deps/simdutf/src/simdutf/icelake/simd16-inl.h +90 -0
- package/deps/simdutf/src/simdutf/icelake/simd32-inl.h +47 -0
- package/deps/simdutf/src/simdutf/icelake.h +81 -0
- package/deps/simdutf/src/simdutf/lasx/begin.h +8 -0
- package/deps/simdutf/src/simdutf/lasx/bitmanipulation.h +25 -0
- package/deps/simdutf/src/simdutf/lasx/end.h +8 -0
- package/deps/simdutf/src/simdutf/lasx/implementation.h +310 -0
- package/deps/simdutf/src/simdutf/lasx/intrinsics.h +319 -0
- package/deps/simdutf/src/simdutf/lasx/simd.h +551 -0
- package/deps/simdutf/src/simdutf/lasx/simd16-inl.h +234 -0
- package/deps/simdutf/src/simdutf/lasx/simd32-inl.h +74 -0
- package/deps/simdutf/src/simdutf/lasx/simd64-inl.h +52 -0
- package/deps/simdutf/src/simdutf/lasx.h +49 -0
- package/deps/simdutf/src/simdutf/lsx/begin.h +2 -0
- package/deps/simdutf/src/simdutf/lsx/bitmanipulation.h +25 -0
- package/deps/simdutf/src/simdutf/lsx/end.h +2 -0
- package/deps/simdutf/src/simdutf/lsx/implementation.h +309 -0
- package/deps/simdutf/src/simdutf/lsx/intrinsics.h +196 -0
- package/deps/simdutf/src/simdutf/lsx/simd.h +421 -0
- package/deps/simdutf/src/simdutf/lsx/simd16-inl.h +242 -0
- package/deps/simdutf/src/simdutf/lsx/simd32-inl.h +69 -0
- package/deps/simdutf/src/simdutf/lsx/simd64-inl.h +50 -0
- package/deps/simdutf/src/simdutf/lsx.h +52 -0
- package/deps/simdutf/src/simdutf/ppc64/begin.h +1 -0
- package/deps/simdutf/src/simdutf/ppc64/bitmanipulation.h +29 -0
- package/deps/simdutf/src/simdutf/ppc64/end.h +1 -0
- package/deps/simdutf/src/simdutf/ppc64/implementation.h +348 -0
- package/deps/simdutf/src/simdutf/ppc64/intrinsics.h +19 -0
- package/deps/simdutf/src/simdutf/ppc64/simd.h +177 -0
- package/deps/simdutf/src/simdutf/ppc64/simd16-inl.h +327 -0
- package/deps/simdutf/src/simdutf/ppc64/simd32-inl.h +247 -0
- package/deps/simdutf/src/simdutf/ppc64/simd8-inl.h +618 -0
- package/deps/simdutf/src/simdutf/ppc64.h +40 -0
- package/deps/simdutf/src/simdutf/rvv/begin.h +7 -0
- package/deps/simdutf/src/simdutf/rvv/end.h +7 -0
- package/deps/simdutf/src/simdutf/rvv/implementation.h +321 -0
- package/deps/simdutf/src/simdutf/rvv/intrinsics.h +131 -0
- package/deps/simdutf/src/simdutf/rvv.h +41 -0
- package/deps/simdutf/src/simdutf/westmere/begin.h +8 -0
- package/deps/simdutf/src/simdutf/westmere/bitmanipulation.h +37 -0
- package/deps/simdutf/src/simdutf/westmere/end.h +8 -0
- package/deps/simdutf/src/simdutf/westmere/implementation.h +338 -0
- package/deps/simdutf/src/simdutf/westmere/intrinsics.h +38 -0
- package/deps/simdutf/src/simdutf/westmere/simd.h +379 -0
- package/deps/simdutf/src/simdutf/westmere/simd16-inl.h +242 -0
- package/deps/simdutf/src/simdutf/westmere/simd32-inl.h +151 -0
- package/deps/simdutf/src/simdutf/westmere/simd64-inl.h +33 -0
- package/deps/simdutf/src/simdutf/westmere.h +59 -0
- package/deps/simdutf/src/simdutf.cpp +152 -0
- package/deps/simdutf/src/simdutf_c.cpp +525 -0
- package/deps/simdutf/src/tables/utf16_to_utf8_tables.h +768 -0
- package/deps/simdutf/src/tables/utf32_to_utf16_tables.h +53 -0
- package/deps/simdutf/src/tables/utf8_to_utf16_tables.h +826 -0
- package/deps/simdutf/src/westmere/implementation.cpp +1479 -0
- package/deps/simdutf/src/westmere/internal/loader.cpp +7 -0
- package/deps/simdutf/src/westmere/internal/write_v_u16_11bits_to_utf8.cpp +66 -0
- package/deps/simdutf/src/westmere/sse_base64.cpp +672 -0
- package/deps/simdutf/src/westmere/sse_convert_latin1_to_utf16.cpp +21 -0
- package/deps/simdutf/src/westmere/sse_convert_latin1_to_utf32.cpp +31 -0
- package/deps/simdutf/src/westmere/sse_convert_latin1_to_utf8.cpp +71 -0
- package/deps/simdutf/src/westmere/sse_convert_utf16_to_latin1.cpp +70 -0
- package/deps/simdutf/src/westmere/sse_convert_utf16_to_utf32.cpp +206 -0
- package/deps/simdutf/src/westmere/sse_convert_utf16_to_utf8.cpp +504 -0
- package/deps/simdutf/src/westmere/sse_convert_utf32_to_latin1.cpp +82 -0
- package/deps/simdutf/src/westmere/sse_convert_utf32_to_utf16.cpp +209 -0
- package/deps/simdutf/src/westmere/sse_convert_utf32_to_utf8.cpp +589 -0
- package/deps/simdutf/src/westmere/sse_convert_utf8_to_latin1.cpp +58 -0
- package/deps/simdutf/src/westmere/sse_convert_utf8_to_utf16.cpp +197 -0
- package/deps/simdutf/src/westmere/sse_convert_utf8_to_utf32.cpp +141 -0
- package/deps/simdutf/src/westmere/sse_utf16fix.cpp +82 -0
- package/deps/simdutf/src/westmere/sse_validate_utf16.cpp +17 -0
- package/lib/commonjs/argon2.js +51 -2
- package/lib/commonjs/argon2.js.map +1 -1
- package/lib/commonjs/cipher.js +109 -11
- package/lib/commonjs/cipher.js.map +1 -1
- package/lib/commonjs/dsa.js +8 -2
- package/lib/commonjs/dsa.js.map +1 -1
- package/lib/commonjs/hash.js +15 -5
- package/lib/commonjs/hash.js.map +1 -1
- package/lib/commonjs/hkdf.js +33 -6
- package/lib/commonjs/hkdf.js.map +1 -1
- package/lib/commonjs/hmac.js +15 -5
- package/lib/commonjs/hmac.js.map +1 -1
- package/lib/commonjs/keys/publicCipher.js +10 -4
- package/lib/commonjs/keys/publicCipher.js.map +1 -1
- package/lib/commonjs/random.js +11 -2
- package/lib/commonjs/random.js.map +1 -1
- package/lib/commonjs/rsa.js +12 -5
- package/lib/commonjs/rsa.js.map +1 -1
- package/lib/commonjs/scrypt.js +47 -6
- package/lib/commonjs/scrypt.js.map +1 -1
- package/lib/commonjs/subtle.js +76 -5
- package/lib/commonjs/subtle.js.map +1 -1
- package/lib/commonjs/utils/cipher.js +18 -7
- package/lib/commonjs/utils/cipher.js.map +1 -1
- package/lib/commonjs/utils/conversion.js +33 -9
- package/lib/commonjs/utils/conversion.js.map +1 -1
- package/lib/commonjs/utils/timingSafeEqual.js +7 -2
- package/lib/commonjs/utils/timingSafeEqual.js.map +1 -1
- package/lib/commonjs/x509certificate.js +6 -6
- package/lib/commonjs/x509certificate.js.map +1 -1
- package/lib/module/argon2.js +51 -2
- package/lib/module/argon2.js.map +1 -1
- package/lib/module/cipher.js +109 -11
- package/lib/module/cipher.js.map +1 -1
- package/lib/module/dsa.js +8 -2
- package/lib/module/dsa.js.map +1 -1
- package/lib/module/hash.js +15 -5
- package/lib/module/hash.js.map +1 -1
- package/lib/module/hkdf.js +33 -6
- package/lib/module/hkdf.js.map +1 -1
- package/lib/module/hmac.js +15 -5
- package/lib/module/hmac.js.map +1 -1
- package/lib/module/keys/publicCipher.js +10 -4
- package/lib/module/keys/publicCipher.js.map +1 -1
- package/lib/module/random.js +11 -2
- package/lib/module/random.js.map +1 -1
- package/lib/module/rsa.js +11 -4
- package/lib/module/rsa.js.map +1 -1
- package/lib/module/scrypt.js +47 -6
- package/lib/module/scrypt.js.map +1 -1
- package/lib/module/subtle.js +76 -5
- package/lib/module/subtle.js.map +1 -1
- package/lib/module/utils/cipher.js +18 -7
- package/lib/module/utils/cipher.js.map +1 -1
- package/lib/module/utils/conversion.js +33 -9
- package/lib/module/utils/conversion.js.map +1 -1
- package/lib/module/utils/timingSafeEqual.js +8 -3
- package/lib/module/utils/timingSafeEqual.js.map +1 -1
- package/lib/module/x509certificate.js +6 -6
- package/lib/module/x509certificate.js.map +1 -1
- package/lib/typescript/argon2.d.ts.map +1 -1
- package/lib/typescript/cipher.d.ts +2 -2
- package/lib/typescript/cipher.d.ts.map +1 -1
- package/lib/typescript/dsa.d.ts.map +1 -1
- package/lib/typescript/hash.d.ts +2 -2
- package/lib/typescript/hash.d.ts.map +1 -1
- package/lib/typescript/hkdf.d.ts.map +1 -1
- package/lib/typescript/hmac.d.ts +2 -2
- package/lib/typescript/hmac.d.ts.map +1 -1
- package/lib/typescript/index.d.ts +1 -1
- package/lib/typescript/index.d.ts.map +1 -1
- package/lib/typescript/keys/publicCipher.d.ts.map +1 -1
- package/lib/typescript/random.d.ts.map +1 -1
- package/lib/typescript/rsa.d.ts.map +1 -1
- package/lib/typescript/scrypt.d.ts.map +1 -1
- package/lib/typescript/specs/utils.nitro.d.ts +0 -2
- package/lib/typescript/specs/utils.nitro.d.ts.map +1 -1
- package/lib/typescript/subtle.d.ts.map +1 -1
- package/lib/typescript/utils/cipher.d.ts +13 -1
- package/lib/typescript/utils/cipher.d.ts.map +1 -1
- package/lib/typescript/utils/conversion.d.ts +9 -6
- package/lib/typescript/utils/conversion.d.ts.map +1 -1
- package/lib/typescript/utils/timingSafeEqual.d.ts.map +1 -1
- package/lib/typescript/x509certificate.d.ts.map +1 -1
- package/nitrogen/generated/shared/c++/HybridUtilsSpec.cpp +0 -2
- package/nitrogen/generated/shared/c++/HybridUtilsSpec.hpp +0 -3
- package/package.json +38 -6
- package/src/argon2.ts +80 -2
- package/src/cipher.ts +139 -15
- package/src/dsa.ts +11 -2
- package/src/hash.ts +17 -7
- package/src/hkdf.ts +44 -6
- package/src/hmac.ts +17 -7
- package/src/keys/publicCipher.ts +10 -4
- package/src/random.ts +11 -2
- package/src/rsa.ts +18 -4
- package/src/scrypt.ts +73 -6
- package/src/specs/utils.nitro.ts +0 -2
- package/src/subtle.ts +90 -8
- package/src/utils/cipher.ts +30 -8
- package/src/utils/conversion.ts +58 -20
- package/src/utils/timingSafeEqual.ts +8 -3
- package/src/x509certificate.ts +5 -6
- package/deps/blake3/.cargo/config.toml +0 -2
- package/deps/blake3/.git-blame-ignore-revs +0 -2
- package/deps/blake3/.github/workflows/build_b3sum.py +0 -38
- package/deps/blake3/.github/workflows/ci.yml +0 -491
- package/deps/blake3/.github/workflows/tag.yml +0 -43
- package/deps/blake3/.github/workflows/upload_github_release_asset.py +0 -73
- package/deps/blake3/CONTRIBUTING.md +0 -31
- package/deps/blake3/Cargo.toml +0 -135
- package/deps/blake3/b3sum/Cargo.lock +0 -513
- package/deps/blake3/b3sum/Cargo.toml +0 -26
- package/deps/blake3/b3sum/README.md +0 -72
- package/deps/blake3/b3sum/src/main.rs +0 -564
- package/deps/blake3/b3sum/src/unit_tests.rs +0 -235
- package/deps/blake3/b3sum/tests/cli_tests.rs +0 -680
- package/deps/blake3/b3sum/what_does_check_do.md +0 -176
- package/deps/blake3/benches/bench.rs +0 -623
- package/deps/blake3/build.rs +0 -389
- package/deps/blake3/c/CMakeLists.txt +0 -383
- package/deps/blake3/c/CMakePresets.json +0 -73
- package/deps/blake3/c/Makefile.testing +0 -82
- package/deps/blake3/c/blake3-config.cmake.in +0 -14
- package/deps/blake3/c/blake3_avx2.c +0 -326
- package/deps/blake3/c/blake3_avx2_x86-64_unix.S +0 -1815
- package/deps/blake3/c/blake3_avx2_x86-64_windows_gnu.S +0 -1817
- package/deps/blake3/c/blake3_avx2_x86-64_windows_msvc.asm +0 -1828
- package/deps/blake3/c/blake3_avx512.c +0 -1388
- package/deps/blake3/c/blake3_avx512_x86-64_unix.S +0 -4824
- package/deps/blake3/c/blake3_avx512_x86-64_windows_gnu.S +0 -2615
- package/deps/blake3/c/blake3_avx512_x86-64_windows_msvc.asm +0 -2634
- package/deps/blake3/c/blake3_c_rust_bindings/Cargo.toml +0 -32
- package/deps/blake3/c/blake3_c_rust_bindings/README.md +0 -4
- package/deps/blake3/c/blake3_c_rust_bindings/benches/bench.rs +0 -477
- package/deps/blake3/c/blake3_c_rust_bindings/build.rs +0 -253
- package/deps/blake3/c/blake3_c_rust_bindings/cross_test.sh +0 -31
- package/deps/blake3/c/blake3_c_rust_bindings/src/lib.rs +0 -333
- package/deps/blake3/c/blake3_c_rust_bindings/src/test.rs +0 -696
- package/deps/blake3/c/blake3_sse2.c +0 -566
- package/deps/blake3/c/blake3_sse2_x86-64_unix.S +0 -2291
- package/deps/blake3/c/blake3_sse2_x86-64_windows_gnu.S +0 -2332
- package/deps/blake3/c/blake3_sse2_x86-64_windows_msvc.asm +0 -2350
- package/deps/blake3/c/blake3_sse41.c +0 -560
- package/deps/blake3/c/blake3_sse41_x86-64_unix.S +0 -2028
- package/deps/blake3/c/blake3_sse41_x86-64_windows_gnu.S +0 -2069
- package/deps/blake3/c/blake3_sse41_x86-64_windows_msvc.asm +0 -2089
- package/deps/blake3/c/blake3_tbb.cpp +0 -37
- package/deps/blake3/c/dependencies/CMakeLists.txt +0 -3
- package/deps/blake3/c/dependencies/tbb/CMakeLists.txt +0 -28
- package/deps/blake3/c/example.c +0 -36
- package/deps/blake3/c/example_tbb.c +0 -57
- package/deps/blake3/c/libblake3.pc.in +0 -12
- package/deps/blake3/c/main.c +0 -166
- package/deps/blake3/c/test.py +0 -97
- package/deps/blake3/media/B3.svg +0 -70
- package/deps/blake3/media/BLAKE3.svg +0 -85
- package/deps/blake3/media/speed.svg +0 -1474
- package/deps/blake3/reference_impl/Cargo.toml +0 -8
- package/deps/blake3/reference_impl/README.md +0 -14
- package/deps/blake3/reference_impl/reference_impl.rs +0 -374
- package/deps/blake3/src/ffi_avx2.rs +0 -65
- package/deps/blake3/src/ffi_avx512.rs +0 -169
- package/deps/blake3/src/ffi_neon.rs +0 -82
- package/deps/blake3/src/ffi_sse2.rs +0 -126
- package/deps/blake3/src/ffi_sse41.rs +0 -126
- package/deps/blake3/src/guts.rs +0 -60
- package/deps/blake3/src/hazmat.rs +0 -704
- package/deps/blake3/src/io.rs +0 -64
- package/deps/blake3/src/join.rs +0 -92
- package/deps/blake3/src/lib.rs +0 -1835
- package/deps/blake3/src/platform.rs +0 -587
- package/deps/blake3/src/portable.rs +0 -198
- package/deps/blake3/src/rust_avx2.rs +0 -474
- package/deps/blake3/src/rust_sse2.rs +0 -775
- package/deps/blake3/src/rust_sse41.rs +0 -766
- package/deps/blake3/src/test.rs +0 -1049
- package/deps/blake3/src/traits.rs +0 -227
- package/deps/blake3/src/wasm32_simd.rs +0 -794
- package/deps/blake3/test_vectors/Cargo.toml +0 -19
- package/deps/blake3/test_vectors/cross_test.sh +0 -25
- package/deps/blake3/test_vectors/src/bin/generate.rs +0 -4
- package/deps/blake3/test_vectors/src/lib.rs +0 -350
- package/deps/blake3/test_vectors/test_vectors.json +0 -217
- package/deps/blake3/tools/compiler_version/Cargo.toml +0 -7
- package/deps/blake3/tools/compiler_version/build.rs +0 -6
- package/deps/blake3/tools/compiler_version/src/main.rs +0 -27
- package/deps/blake3/tools/instruction_set_support/Cargo.toml +0 -6
- package/deps/blake3/tools/instruction_set_support/src/main.rs +0 -10
- package/deps/blake3/tools/release.md +0 -16
- package/deps/ncrypto/.bazelignore +0 -4
- package/deps/ncrypto/.bazelrc +0 -1
- package/deps/ncrypto/.bazelversion +0 -1
- package/deps/ncrypto/.clang-format +0 -111
- package/deps/ncrypto/.github/workflows/bazel.yml +0 -58
- package/deps/ncrypto/.github/workflows/commitlint.yml +0 -16
- package/deps/ncrypto/.github/workflows/linter.yml +0 -38
- package/deps/ncrypto/.github/workflows/macos.yml +0 -43
- package/deps/ncrypto/.github/workflows/release-please.yml +0 -16
- package/deps/ncrypto/.github/workflows/ubuntu.yml +0 -128
- package/deps/ncrypto/.github/workflows/visual-studio.yml +0 -49
- package/deps/ncrypto/.python-version +0 -1
- package/deps/ncrypto/.release-please-manifest.json +0 -3
- package/deps/ncrypto/BUILD.bazel +0 -44
- package/deps/ncrypto/CHANGELOG.md +0 -37
- package/deps/ncrypto/CMakeLists.txt +0 -79
- package/deps/ncrypto/MODULE.bazel +0 -16
- package/deps/ncrypto/MODULE.bazel.lock +0 -461
- package/deps/ncrypto/cmake/CPM.cmake +0 -1225
- package/deps/ncrypto/cmake/ncrypto-flags.cmake +0 -17
- package/deps/ncrypto/ncrypto.pc.in +0 -10
- package/deps/ncrypto/patches/0001-Expose-libdecrepit-so-NodeJS-can-use-it-for-ncrypto.patch +0 -28
- package/deps/ncrypto/pyproject.toml +0 -38
- package/deps/ncrypto/release-please-config.json +0 -11
- package/deps/ncrypto/src/CMakeLists.txt +0 -40
- package/deps/ncrypto/tests/BUILD.bazel +0 -11
- package/deps/ncrypto/tests/CMakeLists.txt +0 -7
- package/deps/ncrypto/tests/basic.cpp +0 -856
- package/deps/ncrypto/tools/run-clang-format.sh +0 -42
- package/lib/tsconfig.tsbuildinfo +0 -1
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
// file included directly
|
|
2
|
+
|
|
3
|
+
// File contains conversion procedure from possibly invalid UTF-8 strings.
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Attempts to convert up to len 1-byte code units from in (in UTF-8 format) to
|
|
7
|
+
* out.
|
|
8
|
+
* Returns the position of the input and output after the processing is
|
|
9
|
+
* completed. Upon error, the output is set to null.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
template <endianness big_endian>
|
|
13
|
+
utf8_to_utf16_result
|
|
14
|
+
fast_avx512_convert_utf8_to_utf16(const char *in, size_t len, char16_t *out) {
|
|
15
|
+
const char *const final_in = in + len;
|
|
16
|
+
bool result = true;
|
|
17
|
+
while (result) {
|
|
18
|
+
if (final_in - in >= 64) {
|
|
19
|
+
result = process_block_utf8_to_utf16<SIMDUTF_FULL, big_endian>(
|
|
20
|
+
in, out, final_in - in);
|
|
21
|
+
} else if (in < final_in) {
|
|
22
|
+
result = process_block_utf8_to_utf16<SIMDUTF_TAIL, big_endian>(
|
|
23
|
+
in, out, final_in - in);
|
|
24
|
+
} else {
|
|
25
|
+
break;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
if (!result) {
|
|
29
|
+
out = nullptr;
|
|
30
|
+
}
|
|
31
|
+
return std::make_pair(in, out);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
template <endianness big_endian>
|
|
35
|
+
simdutf::result fast_avx512_convert_utf8_to_utf16_with_errors(const char *in,
|
|
36
|
+
size_t len,
|
|
37
|
+
char16_t *out) {
|
|
38
|
+
const char *const init_in = in;
|
|
39
|
+
const char16_t *const init_out = out;
|
|
40
|
+
const char *const final_in = in + len;
|
|
41
|
+
bool result = true;
|
|
42
|
+
while (result) {
|
|
43
|
+
if (final_in - in >= 64) {
|
|
44
|
+
result = process_block_utf8_to_utf16<SIMDUTF_FULL, big_endian>(
|
|
45
|
+
in, out, final_in - in);
|
|
46
|
+
} else if (in < final_in) {
|
|
47
|
+
result = process_block_utf8_to_utf16<SIMDUTF_TAIL, big_endian>(
|
|
48
|
+
in, out, final_in - in);
|
|
49
|
+
} else {
|
|
50
|
+
break;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
if (!result) {
|
|
54
|
+
size_t pos = size_t(in - init_in);
|
|
55
|
+
if (pos < len && (init_in[pos] & 0xc0) == 0x80 && pos >= 64) {
|
|
56
|
+
// We must check whether we are the fourth continuation byte
|
|
57
|
+
bool c1 = (init_in[pos - 1] & 0xc0) == 0x80;
|
|
58
|
+
bool c2 = (init_in[pos - 2] & 0xc0) == 0x80;
|
|
59
|
+
bool c3 = (init_in[pos - 3] & 0xc0) == 0x80;
|
|
60
|
+
if (c1 && c2 && c3) {
|
|
61
|
+
return {simdutf::TOO_LONG, pos};
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
// rewind_and_convert_with_errors will seek a potential error from in
|
|
65
|
+
// onward, with the ability to go back up to in - init_in bytes, and read
|
|
66
|
+
// final_in - in bytes forward.
|
|
67
|
+
simdutf::result res =
|
|
68
|
+
scalar::utf8_to_utf16::rewind_and_convert_with_errors<big_endian>(
|
|
69
|
+
in - init_in, in, final_in - in, out);
|
|
70
|
+
res.count += (in - init_in);
|
|
71
|
+
return res;
|
|
72
|
+
} else {
|
|
73
|
+
return simdutf::result(error_code::SUCCESS, out - init_out);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
// file included directly
|
|
2
|
+
|
|
3
|
+
// File contains conversion procedure from valid UTF-8 strings.
|
|
4
|
+
|
|
5
|
+
template <bool is_remaining>
|
|
6
|
+
simdutf_really_inline size_t process_valid_block_from_utf8_to_latin1(
|
|
7
|
+
const char *buf, size_t len, char *latin_output, __m512i minus64,
|
|
8
|
+
__m512i one, __mmask64 *next_leading_ptr, __mmask64 *next_bit6_ptr) {
|
|
9
|
+
__mmask64 load_mask =
|
|
10
|
+
is_remaining ? _bzhi_u64(~0ULL, (unsigned int)len) : ~0ULL;
|
|
11
|
+
__m512i input = _mm512_maskz_loadu_epi8(load_mask, (__m512i *)buf);
|
|
12
|
+
__mmask64 nonascii = _mm512_movepi8_mask(input);
|
|
13
|
+
|
|
14
|
+
if (nonascii == 0) {
|
|
15
|
+
is_remaining
|
|
16
|
+
? _mm512_mask_storeu_epi8((__m512i *)latin_output, load_mask, input)
|
|
17
|
+
: _mm512_storeu_si512((__m512i *)latin_output, input);
|
|
18
|
+
return len;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
__mmask64 leading = _mm512_cmpge_epu8_mask(input, minus64);
|
|
22
|
+
|
|
23
|
+
__m512i highbits = _mm512_xor_si512(input, _mm512_set1_epi8(-62));
|
|
24
|
+
|
|
25
|
+
*next_leading_ptr = leading >> 63;
|
|
26
|
+
|
|
27
|
+
__mmask64 bit6 = _mm512_cmpeq_epi8_mask(highbits, one);
|
|
28
|
+
input =
|
|
29
|
+
_mm512_mask_sub_epi8(input, (bit6 << 1) | *next_bit6_ptr, input, minus64);
|
|
30
|
+
*next_bit6_ptr = bit6 >> 63;
|
|
31
|
+
|
|
32
|
+
__mmask64 retain = ~leading & load_mask;
|
|
33
|
+
__m512i output = _mm512_maskz_compress_epi8(retain, input);
|
|
34
|
+
int64_t written_out = count_ones(retain);
|
|
35
|
+
if (written_out == 0) {
|
|
36
|
+
return 0; // Indicates error
|
|
37
|
+
}
|
|
38
|
+
__mmask64 store_mask = ~UINT64_C(0) >> (64 - written_out);
|
|
39
|
+
// Optimization opportunity: sometimes, masked writes are not needed.
|
|
40
|
+
_mm512_mask_storeu_epi8((__m512i *)latin_output, store_mask, output);
|
|
41
|
+
return written_out;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
size_t valid_utf8_to_latin1_avx512(const char *buf, size_t len,
|
|
45
|
+
char *latin_output) {
|
|
46
|
+
char *start = latin_output;
|
|
47
|
+
size_t pos = 0;
|
|
48
|
+
__m512i minus64 = _mm512_set1_epi8(-64); // 11111111111 ... 1100 0000
|
|
49
|
+
__m512i one = _mm512_set1_epi8(1);
|
|
50
|
+
__mmask64 next_leading = 0;
|
|
51
|
+
__mmask64 next_bit6 = 0;
|
|
52
|
+
|
|
53
|
+
while (pos + 64 <= len) {
|
|
54
|
+
size_t written = process_valid_block_from_utf8_to_latin1<false>(
|
|
55
|
+
buf + pos, 64, latin_output, minus64, one, &next_leading, &next_bit6);
|
|
56
|
+
latin_output += written;
|
|
57
|
+
pos += 64;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
if (pos < len) {
|
|
61
|
+
size_t remaining = len - pos;
|
|
62
|
+
size_t written = process_valid_block_from_utf8_to_latin1<true>(
|
|
63
|
+
buf + pos, remaining, latin_output, minus64, one, &next_leading,
|
|
64
|
+
&next_bit6);
|
|
65
|
+
latin_output += written;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
return (size_t)(latin_output - start);
|
|
69
|
+
}
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
simdutf_really_inline const char *util_find(const char *start, const char *end,
|
|
2
|
+
char character) noexcept {
|
|
3
|
+
// Handle empty or invalid range
|
|
4
|
+
if (start >= end)
|
|
5
|
+
return end;
|
|
6
|
+
const size_t step = 64;
|
|
7
|
+
__m512i char_vec = _mm512_set1_epi8(character);
|
|
8
|
+
|
|
9
|
+
// Handle unaligned beginning with a masked load
|
|
10
|
+
uintptr_t misalignment = reinterpret_cast<uintptr_t>(start) % step;
|
|
11
|
+
if (misalignment != 0) {
|
|
12
|
+
size_t adjustment = step - misalignment;
|
|
13
|
+
if (size_t(end - start) < adjustment) {
|
|
14
|
+
adjustment = end - start;
|
|
15
|
+
}
|
|
16
|
+
__mmask64 load_mask = 0xFFFFFFFFFFFFFFFF >> (64 - adjustment);
|
|
17
|
+
__m512i data = _mm512_maskz_loadu_epi8(
|
|
18
|
+
load_mask, reinterpret_cast<const __m512i *>(start));
|
|
19
|
+
__mmask64 match_mask = _mm512_cmpeq_epi8_mask(data, char_vec);
|
|
20
|
+
|
|
21
|
+
if (match_mask != 0) {
|
|
22
|
+
size_t index = _tzcnt_u64(match_mask);
|
|
23
|
+
return start + index;
|
|
24
|
+
}
|
|
25
|
+
start += adjustment;
|
|
26
|
+
}
|
|
27
|
+
// Process 64 bytes (512 bits) at a time with AVX-512
|
|
28
|
+
// Main loop for full 128-byte chunks
|
|
29
|
+
while (size_t(end - start) >= 2 * step) {
|
|
30
|
+
__m512i data1 =
|
|
31
|
+
_mm512_loadu_si512(reinterpret_cast<const __m512i *>(start));
|
|
32
|
+
__mmask64 mask1 = _mm512_cmpeq_epi8_mask(data1, char_vec);
|
|
33
|
+
|
|
34
|
+
__m512i data2 =
|
|
35
|
+
_mm512_loadu_si512(reinterpret_cast<const __m512i *>(start + step));
|
|
36
|
+
__mmask64 mask2 = _mm512_cmpeq_epi8_mask(data2, char_vec);
|
|
37
|
+
if (!_kortestz_mask64_u8(mask1, mask2)) {
|
|
38
|
+
if (mask1 != 0) {
|
|
39
|
+
// Found a match, return the first one
|
|
40
|
+
size_t index = _tzcnt_u64(mask1);
|
|
41
|
+
return start + index;
|
|
42
|
+
}
|
|
43
|
+
size_t index = _tzcnt_u64(mask2);
|
|
44
|
+
return start + index + step;
|
|
45
|
+
}
|
|
46
|
+
start += 2 * step;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// Main loop for full 64-byte chunks
|
|
50
|
+
while (size_t(end - start) >= step) {
|
|
51
|
+
__m512i data = _mm512_loadu_si512(reinterpret_cast<const __m512i *>(start));
|
|
52
|
+
__mmask64 mask = _mm512_cmpeq_epi8_mask(data, char_vec);
|
|
53
|
+
|
|
54
|
+
if (mask != 0) {
|
|
55
|
+
// Found a match, return the first one
|
|
56
|
+
size_t index = _tzcnt_u64(mask);
|
|
57
|
+
return start + index;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
start += step;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// Handle remaining bytes with masked load
|
|
64
|
+
size_t remaining = end - start;
|
|
65
|
+
if (remaining > 0) {
|
|
66
|
+
// Create a mask for the remaining bytes using shifted 0xFFFFFFFFFFFFFFFF
|
|
67
|
+
__mmask64 load_mask = 0xFFFFFFFFFFFFFFFF >> (64 - remaining);
|
|
68
|
+
__m512i data = _mm512_maskz_loadu_epi8(
|
|
69
|
+
load_mask, reinterpret_cast<const __m512i *>(start));
|
|
70
|
+
__mmask64 match_mask = _mm512_cmpeq_epi8_mask(data, char_vec);
|
|
71
|
+
|
|
72
|
+
// Apply load mask to avoid false positives
|
|
73
|
+
match_mask &= load_mask;
|
|
74
|
+
|
|
75
|
+
if (match_mask != 0) {
|
|
76
|
+
// Found a match in the remaining bytes
|
|
77
|
+
size_t index = _tzcnt_u64(match_mask);
|
|
78
|
+
return start + index;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
return end;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
simdutf_really_inline const char16_t *util_find(const char16_t *start,
|
|
86
|
+
const char16_t *end,
|
|
87
|
+
char16_t character) noexcept {
|
|
88
|
+
// Handle empty or invalid range
|
|
89
|
+
if (start >= end)
|
|
90
|
+
return end;
|
|
91
|
+
|
|
92
|
+
// Process 32 char16_t (64 bytes, 512 bits) at a time with AVX-512
|
|
93
|
+
const size_t step = 32;
|
|
94
|
+
__m512i char_vec = _mm512_set1_epi16(character);
|
|
95
|
+
|
|
96
|
+
// Handle unaligned beginning with a masked load
|
|
97
|
+
uintptr_t misalignment =
|
|
98
|
+
reinterpret_cast<uintptr_t>(start) % (step * sizeof(char16_t));
|
|
99
|
+
if (misalignment != 0 && misalignment % 2 == 0) {
|
|
100
|
+
size_t adjustment =
|
|
101
|
+
(step * sizeof(char16_t) - misalignment) / sizeof(char16_t);
|
|
102
|
+
if (size_t(end - start) < adjustment) {
|
|
103
|
+
adjustment = end - start;
|
|
104
|
+
}
|
|
105
|
+
__mmask32 load_mask = 0xFFFFFFFF >> (32 - adjustment);
|
|
106
|
+
__m512i data = _mm512_maskz_loadu_epi16(
|
|
107
|
+
load_mask, reinterpret_cast<const __m512i *>(start));
|
|
108
|
+
__mmask32 match_mask = _mm512_cmpeq_epi16_mask(data, char_vec);
|
|
109
|
+
|
|
110
|
+
if (match_mask != 0) {
|
|
111
|
+
size_t index = _tzcnt_u32(match_mask);
|
|
112
|
+
return start + index;
|
|
113
|
+
}
|
|
114
|
+
start += adjustment;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
// Main loop for full 32-element chunks
|
|
118
|
+
while (size_t(end - start) >= step) {
|
|
119
|
+
__m512i data = _mm512_loadu_si512(reinterpret_cast<const __m512i *>(start));
|
|
120
|
+
__mmask32 mask = _mm512_cmpeq_epi16_mask(data, char_vec);
|
|
121
|
+
|
|
122
|
+
if (mask != 0) {
|
|
123
|
+
// Found a match, return the first one
|
|
124
|
+
size_t index = _tzcnt_u32(mask);
|
|
125
|
+
return start + index;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
start += step;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
// Handle remaining elements with masked load
|
|
132
|
+
size_t remaining = end - start;
|
|
133
|
+
if (remaining > 0) {
|
|
134
|
+
__mmask32 load_mask = 0xFFFFFFFF >> (32 - remaining);
|
|
135
|
+
__m512i data = _mm512_maskz_loadu_epi16(
|
|
136
|
+
load_mask, reinterpret_cast<const __m512i *>(start));
|
|
137
|
+
__mmask32 match_mask = _mm512_cmpeq_epi16_mask(data, char_vec);
|
|
138
|
+
|
|
139
|
+
if (match_mask != 0) {
|
|
140
|
+
size_t index = _tzcnt_u32(match_mask);
|
|
141
|
+
return start + index;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
return end;
|
|
146
|
+
}
|
|
@@ -0,0 +1,266 @@
|
|
|
1
|
+
// file included directly
|
|
2
|
+
|
|
3
|
+
// File contains conversion procedure from possibly invalid UTF-8 strings.
|
|
4
|
+
|
|
5
|
+
template <endianness big_endian, typename OUTPUT>
|
|
6
|
+
// todo: replace with the utf-8 to utf-16 routine adapted to utf-32. This code
|
|
7
|
+
// is legacy.
|
|
8
|
+
std::pair<const char *, OUTPUT *>
|
|
9
|
+
validating_utf8_to_fixed_length(const char *str, size_t len, OUTPUT *dwords) {
|
|
10
|
+
constexpr bool UTF32 = std::is_same<OUTPUT, uint32_t>::value;
|
|
11
|
+
constexpr bool UTF16 = std::is_same<OUTPUT, char16_t>::value;
|
|
12
|
+
static_assert(
|
|
13
|
+
UTF32 or UTF16,
|
|
14
|
+
"output type has to be uint32_t (for UTF-32) or char16_t (for UTF-16)");
|
|
15
|
+
static_assert(!(UTF32 and big_endian),
|
|
16
|
+
"we do not currently support big-endian UTF-32");
|
|
17
|
+
|
|
18
|
+
const char *ptr = str;
|
|
19
|
+
const char *end = ptr + len;
|
|
20
|
+
__m512i byteflip = _mm512_setr_epi64(0x0607040502030001, 0x0e0f0c0d0a0b0809,
|
|
21
|
+
0x0607040502030001, 0x0e0f0c0d0a0b0809,
|
|
22
|
+
0x0607040502030001, 0x0e0f0c0d0a0b0809,
|
|
23
|
+
0x0607040502030001, 0x0e0f0c0d0a0b0809);
|
|
24
|
+
OUTPUT *output = dwords;
|
|
25
|
+
avx512_utf8_checker checker{};
|
|
26
|
+
/**
|
|
27
|
+
* In the main loop, we consume 64 bytes per iteration,
|
|
28
|
+
* but we access 64 + 4 bytes.
|
|
29
|
+
* We use masked writes to avoid overruns, see
|
|
30
|
+
* https://github.com/simdutf/simdutf/issues/471
|
|
31
|
+
*/
|
|
32
|
+
while (end - ptr >= 64 + 4) {
|
|
33
|
+
const __m512i utf8 = _mm512_loadu_si512((const __m512i *)ptr);
|
|
34
|
+
if (checker.check_next_input(utf8)) {
|
|
35
|
+
SIMDUTF_ICELAKE_STORE_ASCII(UTF32, utf8, output)
|
|
36
|
+
output += 64;
|
|
37
|
+
ptr += 64;
|
|
38
|
+
continue;
|
|
39
|
+
}
|
|
40
|
+
const __m512i lane0 = broadcast_epi128<0>(utf8);
|
|
41
|
+
const __m512i lane1 = broadcast_epi128<1>(utf8);
|
|
42
|
+
int valid_count0;
|
|
43
|
+
__m512i vec0 = expand_and_identify(lane0, lane1, valid_count0);
|
|
44
|
+
const __m512i lane2 = broadcast_epi128<2>(utf8);
|
|
45
|
+
int valid_count1;
|
|
46
|
+
__m512i vec1 = expand_and_identify(lane1, lane2, valid_count1);
|
|
47
|
+
if (valid_count0 + valid_count1 <= 16) {
|
|
48
|
+
vec0 = _mm512_mask_expand_epi32(
|
|
49
|
+
vec0, __mmask16(((1 << valid_count1) - 1) << valid_count0), vec1);
|
|
50
|
+
valid_count0 += valid_count1;
|
|
51
|
+
vec0 = expand_utf8_to_utf32(vec0);
|
|
52
|
+
SIMDUTF_ICELAKE_WRITE_UTF16_OR_UTF32(vec0, valid_count0, true)
|
|
53
|
+
} else {
|
|
54
|
+
vec0 = expand_utf8_to_utf32(vec0);
|
|
55
|
+
vec1 = expand_utf8_to_utf32(vec1);
|
|
56
|
+
SIMDUTF_ICELAKE_WRITE_UTF16_OR_UTF32(vec0, valid_count0, true)
|
|
57
|
+
SIMDUTF_ICELAKE_WRITE_UTF16_OR_UTF32(vec1, valid_count1, true)
|
|
58
|
+
}
|
|
59
|
+
const __m512i lane3 = broadcast_epi128<3>(utf8);
|
|
60
|
+
int valid_count2;
|
|
61
|
+
__m512i vec2 = expand_and_identify(lane2, lane3, valid_count2);
|
|
62
|
+
uint32_t tmp1;
|
|
63
|
+
::memcpy(&tmp1, ptr + 64, sizeof(tmp1));
|
|
64
|
+
const __m512i lane4 = _mm512_set1_epi32(tmp1);
|
|
65
|
+
int valid_count3;
|
|
66
|
+
__m512i vec3 = expand_and_identify(lane3, lane4, valid_count3);
|
|
67
|
+
if (valid_count2 + valid_count3 <= 16) {
|
|
68
|
+
vec2 = _mm512_mask_expand_epi32(
|
|
69
|
+
vec2, __mmask16(((1 << valid_count3) - 1) << valid_count2), vec3);
|
|
70
|
+
valid_count2 += valid_count3;
|
|
71
|
+
vec2 = expand_utf8_to_utf32(vec2);
|
|
72
|
+
SIMDUTF_ICELAKE_WRITE_UTF16_OR_UTF32(vec2, valid_count2, true)
|
|
73
|
+
} else {
|
|
74
|
+
vec2 = expand_utf8_to_utf32(vec2);
|
|
75
|
+
vec3 = expand_utf8_to_utf32(vec3);
|
|
76
|
+
SIMDUTF_ICELAKE_WRITE_UTF16_OR_UTF32(vec2, valid_count2, true)
|
|
77
|
+
SIMDUTF_ICELAKE_WRITE_UTF16_OR_UTF32(vec3, valid_count3, true)
|
|
78
|
+
}
|
|
79
|
+
ptr += 4 * 16;
|
|
80
|
+
}
|
|
81
|
+
const char *validatedptr = ptr; // validated up to ptr
|
|
82
|
+
|
|
83
|
+
// For the final pass, we validate 64 bytes, but we only transcode
|
|
84
|
+
// 3*16 bytes, so we may end up double-validating 16 bytes.
|
|
85
|
+
if (end - ptr >= 64) {
|
|
86
|
+
const __m512i utf8 = _mm512_loadu_si512((const __m512i *)ptr);
|
|
87
|
+
if (checker.check_next_input(utf8)) {
|
|
88
|
+
SIMDUTF_ICELAKE_STORE_ASCII(UTF32, utf8, output)
|
|
89
|
+
output += 64;
|
|
90
|
+
ptr += 64;
|
|
91
|
+
} else {
|
|
92
|
+
const __m512i lane0 = broadcast_epi128<0>(utf8);
|
|
93
|
+
const __m512i lane1 = broadcast_epi128<1>(utf8);
|
|
94
|
+
int valid_count0;
|
|
95
|
+
__m512i vec0 = expand_and_identify(lane0, lane1, valid_count0);
|
|
96
|
+
const __m512i lane2 = broadcast_epi128<2>(utf8);
|
|
97
|
+
int valid_count1;
|
|
98
|
+
__m512i vec1 = expand_and_identify(lane1, lane2, valid_count1);
|
|
99
|
+
if (valid_count0 + valid_count1 <= 16) {
|
|
100
|
+
vec0 = _mm512_mask_expand_epi32(
|
|
101
|
+
vec0, __mmask16(((1 << valid_count1) - 1) << valid_count0), vec1);
|
|
102
|
+
valid_count0 += valid_count1;
|
|
103
|
+
vec0 = expand_utf8_to_utf32(vec0);
|
|
104
|
+
SIMDUTF_ICELAKE_WRITE_UTF16_OR_UTF32(vec0, valid_count0, true)
|
|
105
|
+
} else {
|
|
106
|
+
vec0 = expand_utf8_to_utf32(vec0);
|
|
107
|
+
vec1 = expand_utf8_to_utf32(vec1);
|
|
108
|
+
SIMDUTF_ICELAKE_WRITE_UTF16_OR_UTF32(vec0, valid_count0, true)
|
|
109
|
+
SIMDUTF_ICELAKE_WRITE_UTF16_OR_UTF32(vec1, valid_count1, true)
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
const __m512i lane3 = broadcast_epi128<3>(utf8);
|
|
113
|
+
SIMDUTF_ICELAKE_TRANSCODE16(lane2, lane3, true)
|
|
114
|
+
|
|
115
|
+
ptr += 3 * 16;
|
|
116
|
+
}
|
|
117
|
+
validatedptr += 4 * 16;
|
|
118
|
+
}
|
|
119
|
+
if (end != validatedptr) {
|
|
120
|
+
const __m512i utf8 =
|
|
121
|
+
_mm512_maskz_loadu_epi8(~UINT64_C(0) >> (64 - (end - validatedptr)),
|
|
122
|
+
(const __m512i *)validatedptr);
|
|
123
|
+
checker.check_next_input(utf8);
|
|
124
|
+
}
|
|
125
|
+
checker.check_eof();
|
|
126
|
+
if (checker.errors()) {
|
|
127
|
+
return {ptr, nullptr}; // We found an error.
|
|
128
|
+
}
|
|
129
|
+
return {ptr, output};
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
// Like validating_utf8_to_fixed_length but returns as soon as an error is
|
|
133
|
+
// identified todo: replace with the utf-8 to utf-16 routine adapted to utf-32.
|
|
134
|
+
// This code is legacy.
|
|
135
|
+
template <endianness big_endian, typename OUTPUT>
|
|
136
|
+
std::tuple<const char *, OUTPUT *, bool>
|
|
137
|
+
validating_utf8_to_fixed_length_with_constant_checks(const char *str,
|
|
138
|
+
size_t len,
|
|
139
|
+
OUTPUT *dwords) {
|
|
140
|
+
constexpr bool UTF32 = std::is_same<OUTPUT, uint32_t>::value;
|
|
141
|
+
constexpr bool UTF16 = std::is_same<OUTPUT, char16_t>::value;
|
|
142
|
+
static_assert(
|
|
143
|
+
UTF32 or UTF16,
|
|
144
|
+
"output type has to be uint32_t (for UTF-32) or char16_t (for UTF-16)");
|
|
145
|
+
static_assert(!(UTF32 and big_endian),
|
|
146
|
+
"we do not currently support big-endian UTF-32");
|
|
147
|
+
|
|
148
|
+
const char *ptr = str;
|
|
149
|
+
const char *end = ptr + len;
|
|
150
|
+
__m512i byteflip = _mm512_setr_epi64(0x0607040502030001, 0x0e0f0c0d0a0b0809,
|
|
151
|
+
0x0607040502030001, 0x0e0f0c0d0a0b0809,
|
|
152
|
+
0x0607040502030001, 0x0e0f0c0d0a0b0809,
|
|
153
|
+
0x0607040502030001, 0x0e0f0c0d0a0b0809);
|
|
154
|
+
OUTPUT *output = dwords;
|
|
155
|
+
avx512_utf8_checker checker{};
|
|
156
|
+
/**
|
|
157
|
+
* In the main loop, we consume 64 bytes per iteration,
|
|
158
|
+
* but we access 64 + 4 bytes.
|
|
159
|
+
*/
|
|
160
|
+
while (end - ptr >= 4 + 64) {
|
|
161
|
+
const __m512i utf8 = _mm512_loadu_si512((const __m512i *)ptr);
|
|
162
|
+
bool ascii = checker.check_next_input(utf8);
|
|
163
|
+
if (checker.errors()) {
|
|
164
|
+
return {ptr, output, false}; // We found an error.
|
|
165
|
+
}
|
|
166
|
+
if (ascii) {
|
|
167
|
+
SIMDUTF_ICELAKE_STORE_ASCII(UTF32, utf8, output)
|
|
168
|
+
output += 64;
|
|
169
|
+
ptr += 64;
|
|
170
|
+
continue;
|
|
171
|
+
}
|
|
172
|
+
const __m512i lane0 = broadcast_epi128<0>(utf8);
|
|
173
|
+
const __m512i lane1 = broadcast_epi128<1>(utf8);
|
|
174
|
+
int valid_count0;
|
|
175
|
+
__m512i vec0 = expand_and_identify(lane0, lane1, valid_count0);
|
|
176
|
+
const __m512i lane2 = broadcast_epi128<2>(utf8);
|
|
177
|
+
int valid_count1;
|
|
178
|
+
__m512i vec1 = expand_and_identify(lane1, lane2, valid_count1);
|
|
179
|
+
if (valid_count0 + valid_count1 <= 16) {
|
|
180
|
+
vec0 = _mm512_mask_expand_epi32(
|
|
181
|
+
vec0, __mmask16(((1 << valid_count1) - 1) << valid_count0), vec1);
|
|
182
|
+
valid_count0 += valid_count1;
|
|
183
|
+
vec0 = expand_utf8_to_utf32(vec0);
|
|
184
|
+
SIMDUTF_ICELAKE_WRITE_UTF16_OR_UTF32(vec0, valid_count0, true)
|
|
185
|
+
} else {
|
|
186
|
+
vec0 = expand_utf8_to_utf32(vec0);
|
|
187
|
+
vec1 = expand_utf8_to_utf32(vec1);
|
|
188
|
+
SIMDUTF_ICELAKE_WRITE_UTF16_OR_UTF32(vec0, valid_count0, true)
|
|
189
|
+
SIMDUTF_ICELAKE_WRITE_UTF16_OR_UTF32(vec1, valid_count1, true)
|
|
190
|
+
}
|
|
191
|
+
const __m512i lane3 = broadcast_epi128<3>(utf8);
|
|
192
|
+
int valid_count2;
|
|
193
|
+
__m512i vec2 = expand_and_identify(lane2, lane3, valid_count2);
|
|
194
|
+
uint32_t tmp1;
|
|
195
|
+
::memcpy(&tmp1, ptr + 64, sizeof(tmp1));
|
|
196
|
+
const __m512i lane4 = _mm512_set1_epi32(tmp1);
|
|
197
|
+
int valid_count3;
|
|
198
|
+
__m512i vec3 = expand_and_identify(lane3, lane4, valid_count3);
|
|
199
|
+
if (valid_count2 + valid_count3 <= 16) {
|
|
200
|
+
vec2 = _mm512_mask_expand_epi32(
|
|
201
|
+
vec2, __mmask16(((1 << valid_count3) - 1) << valid_count2), vec3);
|
|
202
|
+
valid_count2 += valid_count3;
|
|
203
|
+
vec2 = expand_utf8_to_utf32(vec2);
|
|
204
|
+
SIMDUTF_ICELAKE_WRITE_UTF16_OR_UTF32(vec2, valid_count2, true)
|
|
205
|
+
} else {
|
|
206
|
+
vec2 = expand_utf8_to_utf32(vec2);
|
|
207
|
+
vec3 = expand_utf8_to_utf32(vec3);
|
|
208
|
+
SIMDUTF_ICELAKE_WRITE_UTF16_OR_UTF32(vec2, valid_count2, true)
|
|
209
|
+
SIMDUTF_ICELAKE_WRITE_UTF16_OR_UTF32(vec3, valid_count3, true)
|
|
210
|
+
}
|
|
211
|
+
ptr += 4 * 16;
|
|
212
|
+
}
|
|
213
|
+
const char *validatedptr = ptr; // validated up to ptr
|
|
214
|
+
|
|
215
|
+
// For the final pass, we validate 64 bytes, but we only transcode
|
|
216
|
+
// 3*16 bytes, so we may end up double-validating 16 bytes.
|
|
217
|
+
if (end - ptr >= 64) {
|
|
218
|
+
const __m512i utf8 = _mm512_loadu_si512((const __m512i *)ptr);
|
|
219
|
+
bool ascii = checker.check_next_input(utf8);
|
|
220
|
+
if (checker.errors()) {
|
|
221
|
+
return {ptr, output, false}; // We found an error.
|
|
222
|
+
}
|
|
223
|
+
if (ascii) {
|
|
224
|
+
SIMDUTF_ICELAKE_STORE_ASCII(UTF32, utf8, output)
|
|
225
|
+
output += 64;
|
|
226
|
+
ptr += 64;
|
|
227
|
+
} else {
|
|
228
|
+
const __m512i lane0 = broadcast_epi128<0>(utf8);
|
|
229
|
+
const __m512i lane1 = broadcast_epi128<1>(utf8);
|
|
230
|
+
int valid_count0;
|
|
231
|
+
__m512i vec0 = expand_and_identify(lane0, lane1, valid_count0);
|
|
232
|
+
const __m512i lane2 = broadcast_epi128<2>(utf8);
|
|
233
|
+
int valid_count1;
|
|
234
|
+
__m512i vec1 = expand_and_identify(lane1, lane2, valid_count1);
|
|
235
|
+
if (valid_count0 + valid_count1 <= 16) {
|
|
236
|
+
vec0 = _mm512_mask_expand_epi32(
|
|
237
|
+
vec0, __mmask16(((1 << valid_count1) - 1) << valid_count0), vec1);
|
|
238
|
+
valid_count0 += valid_count1;
|
|
239
|
+
vec0 = expand_utf8_to_utf32(vec0);
|
|
240
|
+
SIMDUTF_ICELAKE_WRITE_UTF16_OR_UTF32(vec0, valid_count0, true)
|
|
241
|
+
} else {
|
|
242
|
+
vec0 = expand_utf8_to_utf32(vec0);
|
|
243
|
+
vec1 = expand_utf8_to_utf32(vec1);
|
|
244
|
+
SIMDUTF_ICELAKE_WRITE_UTF16_OR_UTF32(vec0, valid_count0, true)
|
|
245
|
+
SIMDUTF_ICELAKE_WRITE_UTF16_OR_UTF32(vec1, valid_count1, true)
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
const __m512i lane3 = broadcast_epi128<3>(utf8);
|
|
249
|
+
SIMDUTF_ICELAKE_TRANSCODE16(lane2, lane3, true)
|
|
250
|
+
|
|
251
|
+
ptr += 3 * 16;
|
|
252
|
+
}
|
|
253
|
+
validatedptr += 4 * 16;
|
|
254
|
+
}
|
|
255
|
+
if (end != validatedptr) {
|
|
256
|
+
const __m512i utf8 =
|
|
257
|
+
_mm512_maskz_loadu_epi8(~UINT64_C(0) >> (64 - (end - validatedptr)),
|
|
258
|
+
(const __m512i *)validatedptr);
|
|
259
|
+
checker.check_next_input(utf8);
|
|
260
|
+
}
|
|
261
|
+
checker.check_eof();
|
|
262
|
+
if (checker.errors()) {
|
|
263
|
+
return {ptr, output, false}; // We found an error.
|
|
264
|
+
}
|
|
265
|
+
return {ptr, output, true};
|
|
266
|
+
}
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
// file included directly
|
|
2
|
+
|
|
3
|
+
// File contains conversion procedure from VALID UTF-8 strings.
|
|
4
|
+
|
|
5
|
+
/*
|
|
6
|
+
valid_utf8_to_fixed_length converts a valid UTF-8 string into UTF-32.
|
|
7
|
+
|
|
8
|
+
The `OUTPUT` template type decides what to do with UTF-32: store
|
|
9
|
+
it directly or convert into UTF-16 (with AVX512).
|
|
10
|
+
|
|
11
|
+
Input:
|
|
12
|
+
- str - valid UTF-8 string
|
|
13
|
+
- len - string length
|
|
14
|
+
- out_buffer - output buffer
|
|
15
|
+
|
|
16
|
+
Result:
|
|
17
|
+
- pair.first - the first unprocessed input byte
|
|
18
|
+
- pair.second - the first unprocessed output word
|
|
19
|
+
*/
|
|
20
|
+
template <endianness big_endian, typename OUTPUT>
|
|
21
|
+
std::pair<const char *, OUTPUT *>
|
|
22
|
+
valid_utf8_to_fixed_length(const char *str, size_t len, OUTPUT *dwords) {
|
|
23
|
+
constexpr bool UTF32 = std::is_same<OUTPUT, uint32_t>::value;
|
|
24
|
+
constexpr bool UTF16 = std::is_same<OUTPUT, char16_t>::value;
|
|
25
|
+
static_assert(
|
|
26
|
+
UTF32 or UTF16,
|
|
27
|
+
"output type has to be uint32_t (for UTF-32) or char16_t (for UTF-16)");
|
|
28
|
+
static_assert(!(UTF32 and big_endian),
|
|
29
|
+
"we do not currently support big-endian UTF-32");
|
|
30
|
+
|
|
31
|
+
__m512i byteflip = _mm512_setr_epi64(0x0607040502030001, 0x0e0f0c0d0a0b0809,
|
|
32
|
+
0x0607040502030001, 0x0e0f0c0d0a0b0809,
|
|
33
|
+
0x0607040502030001, 0x0e0f0c0d0a0b0809,
|
|
34
|
+
0x0607040502030001, 0x0e0f0c0d0a0b0809);
|
|
35
|
+
const char *ptr = str;
|
|
36
|
+
const char *end = ptr + len;
|
|
37
|
+
|
|
38
|
+
OUTPUT *output = dwords;
|
|
39
|
+
/**
|
|
40
|
+
* In the main loop, we consume 64 bytes per iteration,
|
|
41
|
+
* but we access 64 + 4 bytes.
|
|
42
|
+
* We check for ptr + 64 + 64 <= end because
|
|
43
|
+
* we want to be do maskless writes without overruns.
|
|
44
|
+
*/
|
|
45
|
+
while (end - ptr >= 64 + 4) {
|
|
46
|
+
const __m512i utf8 = _mm512_loadu_si512((const __m512i *)ptr);
|
|
47
|
+
const __m512i v_80 = _mm512_set1_epi8(char(0x80));
|
|
48
|
+
const __mmask64 ascii = _mm512_test_epi8_mask(utf8, v_80);
|
|
49
|
+
if (ascii == 0) {
|
|
50
|
+
SIMDUTF_ICELAKE_STORE_ASCII(UTF32, utf8, output)
|
|
51
|
+
output += 64;
|
|
52
|
+
ptr += 64;
|
|
53
|
+
continue;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
const __m512i lane0 = broadcast_epi128<0>(utf8);
|
|
57
|
+
const __m512i lane1 = broadcast_epi128<1>(utf8);
|
|
58
|
+
int valid_count0;
|
|
59
|
+
__m512i vec0 = expand_and_identify(lane0, lane1, valid_count0);
|
|
60
|
+
const __m512i lane2 = broadcast_epi128<2>(utf8);
|
|
61
|
+
int valid_count1;
|
|
62
|
+
__m512i vec1 = expand_and_identify(lane1, lane2, valid_count1);
|
|
63
|
+
if (valid_count0 + valid_count1 <= 16) {
|
|
64
|
+
vec0 = _mm512_mask_expand_epi32(
|
|
65
|
+
vec0, __mmask16(((1 << valid_count1) - 1) << valid_count0), vec1);
|
|
66
|
+
valid_count0 += valid_count1;
|
|
67
|
+
vec0 = expand_utf8_to_utf32(vec0);
|
|
68
|
+
SIMDUTF_ICELAKE_WRITE_UTF16_OR_UTF32(vec0, valid_count0, true)
|
|
69
|
+
} else {
|
|
70
|
+
vec0 = expand_utf8_to_utf32(vec0);
|
|
71
|
+
vec1 = expand_utf8_to_utf32(vec1);
|
|
72
|
+
SIMDUTF_ICELAKE_WRITE_UTF16_OR_UTF32(vec0, valid_count0, true)
|
|
73
|
+
SIMDUTF_ICELAKE_WRITE_UTF16_OR_UTF32(vec1, valid_count1, true)
|
|
74
|
+
}
|
|
75
|
+
const __m512i lane3 = broadcast_epi128<3>(utf8);
|
|
76
|
+
int valid_count2;
|
|
77
|
+
__m512i vec2 = expand_and_identify(lane2, lane3, valid_count2);
|
|
78
|
+
uint32_t tmp1;
|
|
79
|
+
::memcpy(&tmp1, ptr + 64, sizeof(tmp1));
|
|
80
|
+
const __m512i lane4 = _mm512_set1_epi32(tmp1);
|
|
81
|
+
int valid_count3;
|
|
82
|
+
__m512i vec3 = expand_and_identify(lane3, lane4, valid_count3);
|
|
83
|
+
if (valid_count2 + valid_count3 <= 16) {
|
|
84
|
+
vec2 = _mm512_mask_expand_epi32(
|
|
85
|
+
vec2, __mmask16(((1 << valid_count3) - 1) << valid_count2), vec3);
|
|
86
|
+
valid_count2 += valid_count3;
|
|
87
|
+
vec2 = expand_utf8_to_utf32(vec2);
|
|
88
|
+
SIMDUTF_ICELAKE_WRITE_UTF16_OR_UTF32(vec2, valid_count2, true)
|
|
89
|
+
} else {
|
|
90
|
+
vec2 = expand_utf8_to_utf32(vec2);
|
|
91
|
+
vec3 = expand_utf8_to_utf32(vec3);
|
|
92
|
+
SIMDUTF_ICELAKE_WRITE_UTF16_OR_UTF32(vec2, valid_count2, true)
|
|
93
|
+
SIMDUTF_ICELAKE_WRITE_UTF16_OR_UTF32(vec3, valid_count3, true)
|
|
94
|
+
}
|
|
95
|
+
ptr += 4 * 16;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
if (end - ptr >= 64) {
|
|
99
|
+
const __m512i utf8 = _mm512_loadu_si512((const __m512i *)ptr);
|
|
100
|
+
const __m512i v_80 = _mm512_set1_epi8(char(0x80));
|
|
101
|
+
const __mmask64 ascii = _mm512_test_epi8_mask(utf8, v_80);
|
|
102
|
+
if (ascii == 0) {
|
|
103
|
+
SIMDUTF_ICELAKE_STORE_ASCII(UTF32, utf8, output)
|
|
104
|
+
output += 64;
|
|
105
|
+
ptr += 64;
|
|
106
|
+
} else {
|
|
107
|
+
const __m512i lane0 = broadcast_epi128<0>(utf8);
|
|
108
|
+
const __m512i lane1 = broadcast_epi128<1>(utf8);
|
|
109
|
+
int valid_count0;
|
|
110
|
+
__m512i vec0 = expand_and_identify(lane0, lane1, valid_count0);
|
|
111
|
+
const __m512i lane2 = broadcast_epi128<2>(utf8);
|
|
112
|
+
int valid_count1;
|
|
113
|
+
__m512i vec1 = expand_and_identify(lane1, lane2, valid_count1);
|
|
114
|
+
if (valid_count0 + valid_count1 <= 16) {
|
|
115
|
+
vec0 = _mm512_mask_expand_epi32(
|
|
116
|
+
vec0, __mmask16(((1 << valid_count1) - 1) << valid_count0), vec1);
|
|
117
|
+
valid_count0 += valid_count1;
|
|
118
|
+
vec0 = expand_utf8_to_utf32(vec0);
|
|
119
|
+
SIMDUTF_ICELAKE_WRITE_UTF16_OR_UTF32(vec0, valid_count0, true)
|
|
120
|
+
} else {
|
|
121
|
+
vec0 = expand_utf8_to_utf32(vec0);
|
|
122
|
+
vec1 = expand_utf8_to_utf32(vec1);
|
|
123
|
+
SIMDUTF_ICELAKE_WRITE_UTF16_OR_UTF32(vec0, valid_count0, true)
|
|
124
|
+
SIMDUTF_ICELAKE_WRITE_UTF16_OR_UTF32(vec1, valid_count1, true)
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
const __m512i lane3 = broadcast_epi128<3>(utf8);
|
|
128
|
+
SIMDUTF_ICELAKE_TRANSCODE16(lane2, lane3, true)
|
|
129
|
+
|
|
130
|
+
ptr += 3 * 16;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
return {ptr, output};
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
using utf8_to_utf16_result = std::pair<const char *, char16_t *>;
|