/src/zlib-ng/insert_string_tpl.h
Line | Count | Source |
1 | | /* insert_string_tpl.h -- Private insert_string functions shared with more than |
2 | | * one insert string implementation |
3 | | * |
4 | | * Copyright (C) 1995-2024 Jean-loup Gailly and Mark Adler |
5 | | * |
6 | | * Copyright (C) 2013 Intel Corporation. All rights reserved. |
7 | | * Authors: |
8 | | * Wajdi Feghali <wajdi.k.feghali@intel.com> |
9 | | * Jim Guilford <james.guilford@intel.com> |
10 | | * Vinodh Gopal <vinodh.gopal@intel.com> |
11 | | * Erdinc Ozturk <erdinc.ozturk@intel.com> |
12 | | * Jim Kukunas <james.t.kukunas@linux.intel.com> |
13 | | * |
14 | | * Portions are Copyright (C) 2016 12Sided Technology, LLC. |
15 | | * Author: |
16 | | * Phil Vachon <pvachon@12sidedtech.com> |
17 | | * |
18 | | * For conditions of distribution and use, see copyright notice in zlib.h |
19 | | * |
20 | | */ |
21 | | |
22 | | #ifndef HASH_CALC_READ |
23 | | # if BYTE_ORDER == LITTLE_ENDIAN |
24 | | # define HASH_CALC_READ \ |
25 | 163M | val = zng_memread_4(strstart); |
26 | | # else |
27 | | # define HASH_CALC_READ \ |
28 | | val = ZSWAP32(zng_memread_4(strstart)); |
29 | | # endif |
30 | | #endif |
31 | | |
32 | | /* =========================================================================== |
33 | | * Update a hash value with the given input byte |
34 | | * IN assertion: all calls to UPDATE_HASH are made with consecutive |
35 | | * input characters, so that a running hash key can be computed from the |
36 | | * previous key instead of complete recalculation each time. |
37 | | */ |
38 | 0 | Z_FORCEINLINE static uint32_t UPDATE_HASH(uint32_t h, uint32_t val) { |
39 | 0 | HASH_CALC(h, val); |
40 | 0 | return h & HASH_CALC_MASK; |
41 | 0 | } Unexecuted instantiation: deflate.c:update_hash_roll Unexecuted instantiation: deflate.c:update_hash Unexecuted instantiation: deflate_fast.c:update_hash Unexecuted instantiation: deflate_fast.c:update_hash_roll Unexecuted instantiation: deflate_medium.c:update_hash Unexecuted instantiation: deflate_medium.c:update_hash_roll Unexecuted instantiation: deflate_quick.c:update_hash Unexecuted instantiation: deflate_quick.c:update_hash_roll Unexecuted instantiation: deflate_slow.c:update_hash Unexecuted instantiation: deflate_slow.c:update_hash_roll Unexecuted instantiation: insert_string.c:update_hash Unexecuted instantiation: insert_string.c:update_hash_roll Unexecuted instantiation: compare256_sse2.c:update_hash_roll Unexecuted instantiation: compare256_sse2.c:update_hash Unexecuted instantiation: compare256_avx2.c:update_hash_roll Unexecuted instantiation: compare256_avx2.c:update_hash Unexecuted instantiation: compare256_avx512.c:update_hash_roll Unexecuted instantiation: compare256_avx512.c:update_hash |
42 | | |
43 | | /* =========================================================================== |
44 | | * Quick insert string str in the dictionary using a pre-read value and set match_head |
45 | | * to the previous head of the hash chain (the most recent string with same hash key). |
46 | | * Return the previous length of the hash chain. |
47 | | */ |
48 | 0 | Z_FORCEINLINE static uint32_t QUICK_INSERT_VALUE(deflate_state *const s, uint32_t str, uint32_t val) { |
49 | 0 | uint32_t hm, head; |
50 | |
|
51 | 0 | HASH_CALC_VAR_INIT; |
52 | 0 | HASH_CALC(HASH_CALC_VAR, val); |
53 | 0 | HASH_CALC_VAR &= HASH_CALC_MASK; |
54 | 0 | hm = HASH_CALC_VAR; |
55 | |
|
56 | 0 | head = s->head[hm]; |
57 | 0 | if (LIKELY(head != str)) { |
58 | 0 | s->prev[str & W_MASK(s)] = (Pos)head; |
59 | 0 | s->head[hm] = (Pos)str; |
60 | 0 | } |
61 | 0 | return head; |
62 | 0 | } Unexecuted instantiation: deflate.c:quick_insert_value Unexecuted instantiation: deflate.c:quick_insert_value_roll Unexecuted instantiation: deflate_fast.c:quick_insert_value Unexecuted instantiation: deflate_fast.c:quick_insert_value_roll Unexecuted instantiation: deflate_medium.c:quick_insert_value Unexecuted instantiation: deflate_medium.c:quick_insert_value_roll Unexecuted instantiation: deflate_quick.c:quick_insert_value Unexecuted instantiation: deflate_quick.c:quick_insert_value_roll Unexecuted instantiation: deflate_slow.c:quick_insert_value Unexecuted instantiation: deflate_slow.c:quick_insert_value_roll Unexecuted instantiation: insert_string.c:quick_insert_value Unexecuted instantiation: insert_string.c:quick_insert_value_roll Unexecuted instantiation: compare256_sse2.c:quick_insert_value Unexecuted instantiation: compare256_sse2.c:quick_insert_value_roll Unexecuted instantiation: compare256_avx2.c:quick_insert_value Unexecuted instantiation: compare256_avx2.c:quick_insert_value_roll Unexecuted instantiation: compare256_avx512.c:quick_insert_value Unexecuted instantiation: compare256_avx512.c:quick_insert_value_roll |
63 | | |
64 | | /* =========================================================================== |
65 | | * Quick insert string str in the dictionary and set match_head to the previous head |
66 | | * of the hash chain (the most recent string with same hash key). Return |
67 | | * the previous length of the hash chain. |
68 | | */ |
69 | 128M | Z_FORCEINLINE static uint32_t QUICK_INSERT_STRING(deflate_state *const s, uint32_t str) { |
70 | 128M | uint8_t *strstart = s->window + str + HASH_CALC_OFFSET; |
71 | 128M | uint32_t val, hm, head; |
72 | | |
73 | 128M | HASH_CALC_VAR_INIT; |
74 | 128M | HASH_CALC_READ; |
75 | 128M | HASH_CALC(HASH_CALC_VAR, val); |
76 | 128M | HASH_CALC_VAR &= HASH_CALC_MASK; |
77 | 128M | hm = HASH_CALC_VAR; |
78 | | |
79 | 128M | head = s->head[hm]; |
80 | 128M | if (LIKELY(head != str)) { |
81 | 128M | s->prev[str & W_MASK(s)] = (Pos)head; |
82 | 128M | s->head[hm] = (Pos)str; |
83 | 128M | } |
84 | 128M | return head; |
85 | 128M | } deflate.c:quick_insert_string Line | Count | Source | 69 | 4.86k | Z_FORCEINLINE static uint32_t QUICK_INSERT_STRING(deflate_state *const s, uint32_t str) { | 70 | 4.86k | uint8_t *strstart = s->window + str + HASH_CALC_OFFSET; | 71 | 4.86k | uint32_t val, hm, head; | 72 | | | 73 | 4.86k | HASH_CALC_VAR_INIT; | 74 | 4.86k | HASH_CALC_READ; | 75 | 4.86k | HASH_CALC(HASH_CALC_VAR, val); | 76 | 4.86k | HASH_CALC_VAR &= HASH_CALC_MASK; | 77 | 4.86k | hm = HASH_CALC_VAR; | 78 | | | 79 | 4.86k | head = s->head[hm]; | 80 | 4.86k | if (LIKELY(head != str)) { | 81 | 15 | s->prev[str & W_MASK(s)] = (Pos)head; | 82 | 15 | s->head[hm] = (Pos)str; | 83 | 15 | } | 84 | 4.86k | return head; | 85 | 4.86k | } |
Unexecuted instantiation: deflate.c:quick_insert_string_roll Unexecuted instantiation: deflate_fast.c:quick_insert_string Unexecuted instantiation: deflate_fast.c:quick_insert_string_roll deflate_medium.c:quick_insert_string Line | Count | Source | 69 | 128M | Z_FORCEINLINE static uint32_t QUICK_INSERT_STRING(deflate_state *const s, uint32_t str) { | 70 | 128M | uint8_t *strstart = s->window + str + HASH_CALC_OFFSET; | 71 | 128M | uint32_t val, hm, head; | 72 | | | 73 | 128M | HASH_CALC_VAR_INIT; | 74 | 128M | HASH_CALC_READ; | 75 | 128M | HASH_CALC(HASH_CALC_VAR, val); | 76 | 128M | HASH_CALC_VAR &= HASH_CALC_MASK; | 77 | 128M | hm = HASH_CALC_VAR; | 78 | | | 79 | 128M | head = s->head[hm]; | 80 | 128M | if (LIKELY(head != str)) { | 81 | 128M | s->prev[str & W_MASK(s)] = (Pos)head; | 82 | 128M | s->head[hm] = (Pos)str; | 83 | 128M | } | 84 | 128M | return head; | 85 | 128M | } |
Unexecuted instantiation: deflate_medium.c:quick_insert_string_roll Unexecuted instantiation: deflate_quick.c:quick_insert_string Unexecuted instantiation: deflate_quick.c:quick_insert_string_roll Unexecuted instantiation: deflate_slow.c:quick_insert_string_roll Unexecuted instantiation: deflate_slow.c:quick_insert_string Unexecuted instantiation: insert_string.c:quick_insert_string Unexecuted instantiation: insert_string.c:quick_insert_string_roll Unexecuted instantiation: compare256_sse2.c:quick_insert_string Unexecuted instantiation: compare256_sse2.c:quick_insert_string_roll Unexecuted instantiation: compare256_avx2.c:quick_insert_string Unexecuted instantiation: compare256_avx2.c:quick_insert_string_roll Unexecuted instantiation: compare256_avx512.c:quick_insert_string Unexecuted instantiation: compare256_avx512.c:quick_insert_string_roll |
86 | | |
87 | | /* =========================================================================== |
88 | | * Insert string str in the dictionary and set match_head to the previous head |
89 | | * of the hash chain (the most recent string with same hash key). Return |
90 | | * the previous length of the hash chain. |
91 | | * IN assertion: all calls to INSERT_STRING are made with consecutive |
92 | | * input characters and the first STD_MIN_MATCH bytes of str are valid |
93 | | * (except for the last STD_MIN_MATCH-1 bytes of the input file). |
94 | | */ |
95 | 3.50M | Z_FORCEINLINE static void INSERT_STRING(deflate_state *const s, uint32_t str, uint32_t count) { |
96 | 3.50M | uint8_t *strstart = s->window + str + HASH_CALC_OFFSET; |
97 | 3.50M | uint8_t *strend = strstart + count; |
98 | | |
99 | | /* Local pointers to avoid indirection */ |
100 | 3.50M | Pos *headp = s->head; |
101 | 3.50M | Pos *prevp = s->prev; |
102 | 3.50M | const unsigned int w_mask = W_MASK(s); |
103 | | |
104 | 38.8M | for (uint32_t idx = str; strstart < strend; idx++, strstart++) { |
105 | 35.3M | uint32_t val, hm, head; |
106 | | |
107 | 35.3M | HASH_CALC_VAR_INIT; |
108 | 35.3M | HASH_CALC_READ; |
109 | 35.3M | HASH_CALC(HASH_CALC_VAR, val); |
110 | 35.3M | HASH_CALC_VAR &= HASH_CALC_MASK; |
111 | 35.3M | hm = HASH_CALC_VAR; |
112 | | |
113 | 35.3M | head = headp[hm]; |
114 | 35.3M | if (LIKELY(head != idx)) { |
115 | 35.3M | prevp[idx & w_mask] = (Pos)head; |
116 | 35.3M | headp[hm] = (Pos)idx; |
117 | 35.3M | } |
118 | 35.3M | } |
119 | 3.50M | } Unexecuted instantiation: deflate.c:insert_string_static Unexecuted instantiation: deflate.c:insert_string_roll_static Unexecuted instantiation: deflate_fast.c:insert_string_static Unexecuted instantiation: deflate_fast.c:insert_string_roll_static Unexecuted instantiation: deflate_medium.c:insert_string_static Unexecuted instantiation: deflate_medium.c:insert_string_roll_static Unexecuted instantiation: deflate_quick.c:insert_string_static Unexecuted instantiation: deflate_quick.c:insert_string_roll_static Unexecuted instantiation: deflate_slow.c:insert_string_static Unexecuted instantiation: deflate_slow.c:insert_string_roll_static insert_string.c:insert_string_static Line | Count | Source | 95 | 3.50M | Z_FORCEINLINE static void INSERT_STRING(deflate_state *const s, uint32_t str, uint32_t count) { | 96 | 3.50M | uint8_t *strstart = s->window + str + HASH_CALC_OFFSET; | 97 | 3.50M | uint8_t *strend = strstart + count; | 98 | | | 99 | | /* Local pointers to avoid indirection */ | 100 | 3.50M | Pos *headp = s->head; | 101 | 3.50M | Pos *prevp = s->prev; | 102 | 3.50M | const unsigned int w_mask = W_MASK(s); | 103 | | | 104 | 38.8M | for (uint32_t idx = str; strstart < strend; idx++, strstart++) { | 105 | 35.3M | uint32_t val, hm, head; | 106 | | | 107 | 35.3M | HASH_CALC_VAR_INIT; | 108 | 35.3M | HASH_CALC_READ; | 109 | 35.3M | HASH_CALC(HASH_CALC_VAR, val); | 110 | 35.3M | HASH_CALC_VAR &= HASH_CALC_MASK; | 111 | 35.3M | hm = HASH_CALC_VAR; | 112 | | | 113 | 35.3M | head = headp[hm]; | 114 | 35.3M | if (LIKELY(head != idx)) { | 115 | 35.3M | prevp[idx & w_mask] = (Pos)head; | 116 | 35.3M | headp[hm] = (Pos)idx; | 117 | 35.3M | } | 118 | 35.3M | } | 119 | 3.50M | } |
Unexecuted instantiation: insert_string.c:insert_string_roll_static Unexecuted instantiation: compare256_sse2.c:insert_string_static Unexecuted instantiation: compare256_sse2.c:insert_string_roll_static Unexecuted instantiation: compare256_avx2.c:insert_string_static Unexecuted instantiation: compare256_avx2.c:insert_string_roll_static Unexecuted instantiation: compare256_avx512.c:insert_string_static Unexecuted instantiation: compare256_avx512.c:insert_string_roll_static |