Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'deps/v8/third_party/zlib/contrib/optimizations/insert_string.h')
-rw-r--r--deps/v8/third_party/zlib/contrib/optimizations/insert_string.h59
1 files changed, 30 insertions, 29 deletions
diff --git a/deps/v8/third_party/zlib/contrib/optimizations/insert_string.h b/deps/v8/third_party/zlib/contrib/optimizations/insert_string.h
index 1826601b7fb..d3bc33c5ab0 100644
--- a/deps/v8/third_party/zlib/contrib/optimizations/insert_string.h
+++ b/deps/v8/third_party/zlib/contrib/optimizations/insert_string.h
@@ -4,45 +4,47 @@
* Use of this source code is governed by a BSD-style license that can be
* found in the Chromium source repository LICENSE file.
*/
-#ifdef _MSC_VER
+
+#if defined(_MSC_VER)
#define INLINE __inline
#else
#define INLINE inline
#endif
#include "cpu_features.h"
-/* Optimized insert_string block */
-#if defined(CRC32_SIMD_SSE42_PCLMUL) || defined(CRC32_ARMV8_CRC32)
-#define TARGET_CPU_WITH_CRC
+
// clang-format off
#if defined(CRC32_SIMD_SSE42_PCLMUL)
- /* Required to make MSVC bot build pass. */
- #include <smmintrin.h>
- #if defined(__GNUC__) || defined(__clang__)
- #undef TARGET_CPU_WITH_CRC
+ #include <smmintrin.h> /* Required to make MSVC bot build pass. */
+
+ #if defined(__clang__) || defined(__GNUC__)
#define TARGET_CPU_WITH_CRC __attribute__((target("sse4.2")))
+ #else
+ #define TARGET_CPU_WITH_CRC
#endif
#define _cpu_crc32_u32 _mm_crc32_u32
#elif defined(CRC32_ARMV8_CRC32)
#if defined(__clang__)
- #undef TARGET_CPU_WITH_CRC
#define __crc32cw __builtin_arm_crc32cw
#endif
- #define _cpu_crc32_u32 __crc32cw
-
#if defined(__aarch64__)
#define TARGET_CPU_WITH_CRC __attribute__((target("crc")))
#else // !defined(__aarch64__)
#define TARGET_CPU_WITH_CRC __attribute__((target("armv8-a,crc")))
#endif // defined(__aarch64__)
+
+ #define _cpu_crc32_u32 __crc32cw
+
#endif
// clang-format on
+
+#if defined(TARGET_CPU_WITH_CRC)
+
TARGET_CPU_WITH_CRC
-local INLINE Pos insert_string_optimized(deflate_state* const s,
- const Pos str) {
+local INLINE Pos insert_string_simd(deflate_state* const s, const Pos str) {
Pos ret;
unsigned *ip, val, h = 0;
@@ -64,7 +66,8 @@ local INLINE Pos insert_string_optimized(deflate_state* const s,
s->prev[str & s->w_mask] = ret;
return ret;
}
-#endif /* Optimized insert_string block */
+
+#endif // TARGET_CPU_WITH_CRC
/* ===========================================================================
* Update a hash value with the given input byte
@@ -99,24 +102,22 @@ local INLINE Pos insert_string_c(deflate_state* const s, const Pos str) {
}
local INLINE Pos insert_string(deflate_state* const s, const Pos str) {
-/* String dictionary insertion: faster symbol hashing has a positive impact
- * on data compression speeds (around 20% on Intel and 36% on Arm Cortex big
- * cores).
- * A misfeature is that the generated compressed output will differ from
- * vanilla zlib (even though it is still valid 'DEFLATE-d' content).
+/* insert_string_simd string dictionary insertion: this SIMD symbol hashing
+ * significantly improves data compression speed.
*
- * We offer here a way to disable the optimization if there is the expectation
- * that compressed content should match when compared to vanilla zlib.
+ * Note: the generated compressed output is a valid DEFLATE stream but will
+ * differ from vanilla zlib output ...
*/
-#if !defined(CHROMIUM_ZLIB_NO_CASTAGNOLI)
- /* TODO(cavalcantii): unify CPU features code. */
-#if defined(CRC32_ARMV8_CRC32)
- if (arm_cpu_enable_crc32)
- return insert_string_optimized(s, str);
-#elif defined(CRC32_SIMD_SSE42_PCLMUL)
+#if defined(CHROMIUM_ZLIB_NO_CASTAGNOLI)
+/* ... so this build-time option can used to disable the SIMD symbol hasher
+ * if matching vanilla zlib DEFLATE output is required.
+ */ (;) /* FALLTHOUGH */
+#elif defined(TARGET_CPU_WITH_CRC) && defined(CRC32_SIMD_SSE42_PCLMUL)
if (x86_cpu_enable_simd)
- return insert_string_optimized(s, str);
-#endif
+ return insert_string_simd(s, str);
+#elif defined(TARGET_CPU_WITH_CRC) && defined(CRC32_ARMV8_CRC32)
+ if (arm_cpu_enable_crc32)
+ return insert_string_simd(s, str);
#endif
return insert_string_c(s, str);
}