/src/zlib-ng/insert_string_p.h
Line | Count | Source |
1 | | /* insert_string_p.h -- static single and batch hash insert functions |
2 | | * |
3 | | * Copyright (C) 1995-2024 Jean-loup Gailly and Mark Adler |
4 | | * For conditions of distribution and use, see copyright notice in zlib.h |
5 | | */ |
6 | | #ifndef INSERT_STRING_P_H_ |
7 | | #define INSERT_STRING_P_H_ |
8 | | |
9 | 324M | #define KNUTH_SHIFT (32 - HASH_BITS) |
10 | 324M | #define UPDATE_HASH_KNUTH(h,val) h = (((val) * 2654435761U) >> KNUTH_SHIFT) |
11 | | |
12 | | #if (HASH_SIZE) > 65536u |
13 | | # define ROLL_HASH_SIZE 65536 |
14 | | #else |
15 | | # define ROLL_HASH_SIZE HASH_SIZE |
16 | | #endif |
17 | 0 | #define ROLL_MASK ((HASH_SIZE / 2) - 1u)) |
18 | 0 | #define UPDATE_HASH_ROLL(h,val) h = (((h << 5) ^ ((uint8_t)(val))) & ROLL_MASK |
19 | | |
20 | | /* =========================================================================== |
21 | | * Update a hash value with the given input byte |
22 | | * IN assertion: all calls to UPDATE_HASH are made with consecutive |
23 | | * input characters, so that a running hash key can be computed from the |
24 | | * previous key instead of complete recalculation each time. |
25 | | */ |
26 | 0 | Z_FORCEINLINE static uint32_t update_hash_roll(uint32_t h, uint32_t val) { |
27 | 0 | UPDATE_HASH_ROLL(h, val); |
28 | 0 | return h; |
29 | 0 | } Unexecuted instantiation: deflate.c:update_hash_roll Unexecuted instantiation: deflate_fast.c:update_hash_roll Unexecuted instantiation: deflate_medium.c:update_hash_roll Unexecuted instantiation: deflate_quick.c:update_hash_roll Unexecuted instantiation: deflate_slow.c:update_hash_roll Unexecuted instantiation: insert_string.c:update_hash_roll Unexecuted instantiation: compare256_sse2.c:update_hash_roll Unexecuted instantiation: compare256_avx2.c:update_hash_roll Unexecuted instantiation: compare256_avx512.c:update_hash_roll |
30 | | |
31 | | /* =========================================================================== |
32 | | * Insert string str in the dictionary using a pre-read value and set match_head |
33 | | * to the previous head of the hash chain (the most recent string with same hash key). |
34 | | * Return the previous length of the hash chain. |
35 | | */ |
36 | 0 | Z_FORCEINLINE static uint32_t insert_knuth_val(deflate_state *const s, uint32_t str, uint32_t val) { |
37 | 0 | uint32_t h, head; |
38 | |
|
39 | 0 | UPDATE_HASH_KNUTH(h, val); |
40 | |
|
41 | 0 | head = s->head[h]; |
42 | 0 | if (LIKELY(head != str)) { |
43 | 0 | s->prev[str & W_MASK(s)] = (Pos)head; |
44 | 0 | s->head[h] = (Pos)str; |
45 | 0 | } |
46 | 0 | return head; |
47 | 0 | } Unexecuted instantiation: deflate.c:insert_knuth_val Unexecuted instantiation: deflate_fast.c:insert_knuth_val Unexecuted instantiation: deflate_medium.c:insert_knuth_val Unexecuted instantiation: deflate_quick.c:insert_knuth_val Unexecuted instantiation: deflate_slow.c:insert_knuth_val Unexecuted instantiation: insert_string.c:insert_knuth_val Unexecuted instantiation: compare256_sse2.c:insert_knuth_val Unexecuted instantiation: compare256_avx2.c:insert_knuth_val Unexecuted instantiation: compare256_avx512.c:insert_knuth_val |
48 | | |
49 | | /* =========================================================================== |
50 | | * Insert string str using a pre-read value, returning the previous head of the |
51 | | * hash chain. The prev link is left untouched since deflate_quick only inspects |
52 | | * the chain head and never walks the chain. |
53 | | */ |
54 | 0 | Z_FORCEINLINE static uint32_t insert_knuth_val_head(deflate_state *const s, uint32_t str, uint32_t val) { |
55 | 0 | uint32_t h, head; |
56 | |
|
57 | 0 | UPDATE_HASH_KNUTH(h, val); |
58 | |
|
59 | 0 | head = s->head[h]; |
60 | 0 | s->head[h] = (Pos)str; |
61 | 0 | return head; |
62 | 0 | } Unexecuted instantiation: deflate.c:insert_knuth_val_head Unexecuted instantiation: deflate_fast.c:insert_knuth_val_head Unexecuted instantiation: deflate_medium.c:insert_knuth_val_head Unexecuted instantiation: deflate_quick.c:insert_knuth_val_head Unexecuted instantiation: deflate_slow.c:insert_knuth_val_head Unexecuted instantiation: insert_string.c:insert_knuth_val_head Unexecuted instantiation: compare256_sse2.c:insert_knuth_val_head Unexecuted instantiation: compare256_avx2.c:insert_knuth_val_head Unexecuted instantiation: compare256_avx512.c:insert_knuth_val_head |
63 | | |
64 | | /* =========================================================================== |
65 | | * 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 | 309M | Z_FORCEINLINE static uint32_t insert_knuth(deflate_state *const s, unsigned char *window, uint32_t str) { |
70 | 309M | uint8_t *strstart = window + str; |
71 | 309M | uint32_t val, h, head; |
72 | | |
73 | 309M | val = Z_U32_FROM_LE(zng_memread_4(strstart)); |
74 | 309M | UPDATE_HASH_KNUTH(h, val); |
75 | | |
76 | 309M | head = s->head[h]; |
77 | 309M | if (LIKELY(head != str)) { |
78 | 136M | s->prev[str & W_MASK(s)] = (Pos)head; |
79 | 136M | s->head[h] = (Pos)str; |
80 | 136M | } |
81 | 309M | return head; |
82 | 309M | } Line | Count | Source | 69 | 172M | Z_FORCEINLINE static uint32_t insert_knuth(deflate_state *const s, unsigned char *window, uint32_t str) { | 70 | 172M | uint8_t *strstart = window + str; | 71 | 172M | uint32_t val, h, head; | 72 | | | 73 | 172M | val = Z_U32_FROM_LE(zng_memread_4(strstart)); | 74 | 172M | UPDATE_HASH_KNUTH(h, val); | 75 | | | 76 | 172M | head = s->head[h]; | 77 | 172M | if (LIKELY(head != str)) { | 78 | 72.2k | s->prev[str & W_MASK(s)] = (Pos)head; | 79 | 72.2k | s->head[h] = (Pos)str; | 80 | 72.2k | } | 81 | 172M | return head; | 82 | 172M | } |
Unexecuted instantiation: deflate_fast.c:insert_knuth deflate_medium.c:insert_knuth Line | Count | Source | 69 | 136M | Z_FORCEINLINE static uint32_t insert_knuth(deflate_state *const s, unsigned char *window, uint32_t str) { | 70 | 136M | uint8_t *strstart = window + str; | 71 | 136M | uint32_t val, h, head; | 72 | | | 73 | 136M | val = Z_U32_FROM_LE(zng_memread_4(strstart)); | 74 | 136M | UPDATE_HASH_KNUTH(h, val); | 75 | | | 76 | 136M | head = s->head[h]; | 77 | 136M | if (LIKELY(head != str)) { | 78 | 136M | s->prev[str & W_MASK(s)] = (Pos)head; | 79 | 136M | s->head[h] = (Pos)str; | 80 | 136M | } | 81 | 136M | return head; | 82 | 136M | } |
Unexecuted instantiation: deflate_quick.c:insert_knuth Unexecuted instantiation: deflate_slow.c:insert_knuth Unexecuted instantiation: insert_string.c:insert_knuth Unexecuted instantiation: compare256_sse2.c:insert_knuth Unexecuted instantiation: compare256_avx2.c:insert_knuth Unexecuted instantiation: compare256_avx512.c:insert_knuth |
83 | | |
84 | | /* =========================================================================== |
85 | | * Insert string str read from the window, returning the previous head of the |
86 | | * hash chain. Like insert_knuth but leaves the prev link untouched for |
87 | | * deflate_quick, which only inspects the chain head. |
88 | | */ |
89 | 0 | Z_FORCEINLINE static uint32_t insert_knuth_head(deflate_state *const s, unsigned char *window, uint32_t str) { |
90 | 0 | uint8_t *strstart = window + str; |
91 | 0 | uint32_t val, h, head; |
92 | |
|
93 | 0 | val = Z_U32_FROM_LE(zng_memread_4(strstart)); |
94 | 0 | UPDATE_HASH_KNUTH(h, val); |
95 | |
|
96 | 0 | head = s->head[h]; |
97 | 0 | s->head[h] = (Pos)str; |
98 | 0 | return head; |
99 | 0 | } Unexecuted instantiation: deflate.c:insert_knuth_head Unexecuted instantiation: deflate_fast.c:insert_knuth_head Unexecuted instantiation: deflate_medium.c:insert_knuth_head Unexecuted instantiation: deflate_quick.c:insert_knuth_head Unexecuted instantiation: deflate_slow.c:insert_knuth_head Unexecuted instantiation: insert_string.c:insert_knuth_head Unexecuted instantiation: compare256_sse2.c:insert_knuth_head Unexecuted instantiation: compare256_avx2.c:insert_knuth_head Unexecuted instantiation: compare256_avx512.c:insert_knuth_head |
100 | | |
101 | | /* =========================================================================== |
102 | | * Insert a single position into the dictionary using passed table pointers. |
103 | | */ |
104 | 0 | Z_FORCEINLINE static void insert_knuth_one(Pos *headp, Pos *prevp, const unsigned int w_mask, const unsigned char *window, uint32_t idx) { |
105 | 0 | uint32_t val, h, head; |
106 | |
|
107 | 0 | val = Z_U32_FROM_LE(zng_memread_4(window + idx)); |
108 | 0 | UPDATE_HASH_KNUTH(h, val); |
109 | |
|
110 | 0 | head = headp[h]; |
111 | 0 | if (LIKELY(head != idx)) { |
112 | 0 | prevp[idx & w_mask] = (Pos)head; |
113 | 0 | headp[h] = (Pos)idx; |
114 | 0 | } |
115 | 0 | } Unexecuted instantiation: deflate.c:insert_knuth_one Unexecuted instantiation: deflate_fast.c:insert_knuth_one Unexecuted instantiation: deflate_medium.c:insert_knuth_one Unexecuted instantiation: deflate_quick.c:insert_knuth_one Unexecuted instantiation: deflate_slow.c:insert_knuth_one Unexecuted instantiation: insert_string.c:insert_knuth_one Unexecuted instantiation: compare256_sse2.c:insert_knuth_one Unexecuted instantiation: compare256_avx2.c:insert_knuth_one Unexecuted instantiation: compare256_avx512.c:insert_knuth_one |
116 | | |
117 | 0 | Z_FORCEINLINE static uint32_t insert_roll(deflate_state *const s, unsigned char *window, uint32_t str) { |
118 | 0 | uint8_t *strstart = window + str + (STD_MIN_MATCH-1); |
119 | 0 | uint32_t h, head; |
120 | |
|
121 | 0 | h = s->ins_h; |
122 | 0 | UPDATE_HASH_ROLL(h, strstart[0]); |
123 | 0 | s->ins_h = h; |
124 | |
|
125 | 0 | head = s->head[h]; |
126 | 0 | if (LIKELY(head != str)) { |
127 | 0 | s->prev[str & W_MASK(s)] = (Pos)head; |
128 | 0 | s->head[h] = (Pos)str; |
129 | 0 | } |
130 | 0 | return head; |
131 | 0 | } Unexecuted instantiation: deflate.c:insert_roll Unexecuted instantiation: deflate_fast.c:insert_roll Unexecuted instantiation: deflate_medium.c:insert_roll Unexecuted instantiation: deflate_quick.c:insert_roll Unexecuted instantiation: deflate_slow.c:insert_roll Unexecuted instantiation: insert_string.c:insert_roll Unexecuted instantiation: compare256_sse2.c:insert_roll Unexecuted instantiation: compare256_avx2.c:insert_roll Unexecuted instantiation: compare256_avx512.c:insert_roll |
132 | | |
133 | | /* =========================================================================== |
134 | | * Insert string str in the dictionary and set match_head to the previous head |
135 | | * of the hash chain (the most recent string with same hash key). Return |
136 | | * the previous length of the hash chain. |
137 | | * IN assertion: all calls to insert_knuth_batch are made with consecutive |
138 | | * input characters and the first STD_MIN_MATCH bytes of str are valid |
139 | | * (except for the last STD_MIN_MATCH-1 bytes of the input file). |
140 | | */ |
141 | 2.35M | Z_FORCEINLINE static void insert_knuth_batch_static(deflate_state *const s, unsigned char *window, uint32_t str, uint32_t count) { |
142 | 2.35M | uint8_t *strstart = window + str; |
143 | 2.35M | uint8_t *strend = strstart + count; |
144 | | |
145 | | /* Local pointers to avoid indirection */ |
146 | 2.35M | Pos *headp = s->head; |
147 | 2.35M | Pos *prevp = s->prev; |
148 | 2.35M | const unsigned int w_mask = W_MASK(s); |
149 | | |
150 | 16.3M | for (uint32_t idx = str; strstart < strend; idx++, strstart++) { |
151 | 13.9M | uint32_t val, h, head; |
152 | | |
153 | 13.9M | val = Z_U32_FROM_LE(zng_memread_4(strstart)); |
154 | 13.9M | UPDATE_HASH_KNUTH(h, val); |
155 | | |
156 | 13.9M | head = headp[h]; |
157 | 13.9M | if (LIKELY(head != idx)) { |
158 | 13.9M | prevp[idx & w_mask] = (Pos)head; |
159 | 13.9M | headp[h] = (Pos)idx; |
160 | 13.9M | } |
161 | 13.9M | } |
162 | 2.35M | } Unexecuted instantiation: deflate.c:insert_knuth_batch_static Unexecuted instantiation: deflate_fast.c:insert_knuth_batch_static Unexecuted instantiation: deflate_medium.c:insert_knuth_batch_static Unexecuted instantiation: deflate_quick.c:insert_knuth_batch_static Unexecuted instantiation: deflate_slow.c:insert_knuth_batch_static insert_string.c:insert_knuth_batch_static Line | Count | Source | 141 | 2.35M | Z_FORCEINLINE static void insert_knuth_batch_static(deflate_state *const s, unsigned char *window, uint32_t str, uint32_t count) { | 142 | 2.35M | uint8_t *strstart = window + str; | 143 | 2.35M | uint8_t *strend = strstart + count; | 144 | | | 145 | | /* Local pointers to avoid indirection */ | 146 | 2.35M | Pos *headp = s->head; | 147 | 2.35M | Pos *prevp = s->prev; | 148 | 2.35M | const unsigned int w_mask = W_MASK(s); | 149 | | | 150 | 16.3M | for (uint32_t idx = str; strstart < strend; idx++, strstart++) { | 151 | 13.9M | uint32_t val, h, head; | 152 | | | 153 | 13.9M | val = Z_U32_FROM_LE(zng_memread_4(strstart)); | 154 | 13.9M | UPDATE_HASH_KNUTH(h, val); | 155 | | | 156 | 13.9M | head = headp[h]; | 157 | 13.9M | if (LIKELY(head != idx)) { | 158 | 13.9M | prevp[idx & w_mask] = (Pos)head; | 159 | 13.9M | headp[h] = (Pos)idx; | 160 | 13.9M | } | 161 | 13.9M | } | 162 | 2.35M | } |
Unexecuted instantiation: compare256_sse2.c:insert_knuth_batch_static Unexecuted instantiation: compare256_avx2.c:insert_knuth_batch_static Unexecuted instantiation: compare256_avx512.c:insert_knuth_batch_static |
163 | | |
164 | | /* =========================================================================== |
165 | | * Like insert_knuth_batch_static(), except this spreads out max_inserts hashes over |
166 | | * the length of count. Also ensures that both the first and last entry gets hashed. |
167 | | * This assumes both count and max_inserts are 258 or less. |
168 | | */ |
169 | 18.3k | Z_FORCEINLINE static void insert_knuth_stepped_static(deflate_state *const s, unsigned char *window, uint32_t str, uint32_t count, uint32_t max_inserts) { |
170 | 18.3k | Assert(count >= 3, "Insert count too low"); |
171 | 18.3k | Assert(max_inserts >= 2, "max_inserts too low"); |
172 | | |
173 | | /* Local pointers to avoid indirection */ |
174 | 18.3k | Pos *headp = s->head; |
175 | 18.3k | Pos *prevp = s->prev; |
176 | 18.3k | const unsigned int w_mask = W_MASK(s); |
177 | | |
178 | 18.3k | uint32_t inserts = (count < max_inserts) ? count : max_inserts; |
179 | 18.3k | uint32_t intervals = inserts - 1; |
180 | | |
181 | | /* |
182 | | * Calculate a 32-bit Fixed-Point Scale with a 16-bit fraction. |
183 | | * Safe from overflow since (count - 1) <= 257, meaning ((257 << 16) + 256) fits easily in 32 bits. |
184 | | * The rounding bias guarantees hitting the exact tail end ('str + count - 1') smoothly. |
185 | | */ |
186 | 18.3k | uint32_t inc_fp = (((count - 1) << 16) + (intervals - 1)) / intervals; |
187 | | |
188 | | /* Initialize the fixed-point index tracking register */ |
189 | 18.3k | uint32_t idx_fp = str << 16; |
190 | | |
191 | 1.04M | for (uint32_t i = 0; i < inserts; i++) { |
192 | 1.02M | uint32_t val, h, head, idx; |
193 | | |
194 | | /* Extract the real window index by shifting out the fractional bits */ |
195 | 1.02M | idx = idx_fp >> 16; |
196 | | |
197 | | /* Increment offset for next iteration */ |
198 | 1.02M | idx_fp += inc_fp; |
199 | | |
200 | 1.02M | val = Z_U32_FROM_LE(zng_memread_4(window + idx)); |
201 | 1.02M | UPDATE_HASH_KNUTH(h, val); |
202 | | |
203 | 1.02M | head = headp[h]; |
204 | 1.02M | if (LIKELY(head != idx)) { |
205 | 1.02M | prevp[idx & w_mask] = (Pos)head; |
206 | 1.02M | headp[h] = (Pos)idx; |
207 | 1.02M | } |
208 | 1.02M | } |
209 | 18.3k | } Unexecuted instantiation: deflate.c:insert_knuth_stepped_static Unexecuted instantiation: deflate_fast.c:insert_knuth_stepped_static Unexecuted instantiation: deflate_medium.c:insert_knuth_stepped_static Unexecuted instantiation: deflate_quick.c:insert_knuth_stepped_static Unexecuted instantiation: deflate_slow.c:insert_knuth_stepped_static insert_string.c:insert_knuth_stepped_static Line | Count | Source | 169 | 18.3k | Z_FORCEINLINE static void insert_knuth_stepped_static(deflate_state *const s, unsigned char *window, uint32_t str, uint32_t count, uint32_t max_inserts) { | 170 | 18.3k | Assert(count >= 3, "Insert count too low"); | 171 | 18.3k | Assert(max_inserts >= 2, "max_inserts too low"); | 172 | | | 173 | | /* Local pointers to avoid indirection */ | 174 | 18.3k | Pos *headp = s->head; | 175 | 18.3k | Pos *prevp = s->prev; | 176 | 18.3k | const unsigned int w_mask = W_MASK(s); | 177 | | | 178 | 18.3k | uint32_t inserts = (count < max_inserts) ? count : max_inserts; | 179 | 18.3k | uint32_t intervals = inserts - 1; | 180 | | | 181 | | /* | 182 | | * Calculate a 32-bit Fixed-Point Scale with a 16-bit fraction. | 183 | | * Safe from overflow since (count - 1) <= 257, meaning ((257 << 16) + 256) fits easily in 32 bits. | 184 | | * The rounding bias guarantees hitting the exact tail end ('str + count - 1') smoothly. | 185 | | */ | 186 | 18.3k | uint32_t inc_fp = (((count - 1) << 16) + (intervals - 1)) / intervals; | 187 | | | 188 | | /* Initialize the fixed-point index tracking register */ | 189 | 18.3k | uint32_t idx_fp = str << 16; | 190 | | | 191 | 1.04M | for (uint32_t i = 0; i < inserts; i++) { | 192 | 1.02M | uint32_t val, h, head, idx; | 193 | | | 194 | | /* Extract the real window index by shifting out the fractional bits */ | 195 | 1.02M | idx = idx_fp >> 16; | 196 | | | 197 | | /* Increment offset for next iteration */ | 198 | 1.02M | idx_fp += inc_fp; | 199 | | | 200 | 1.02M | val = Z_U32_FROM_LE(zng_memread_4(window + idx)); | 201 | 1.02M | UPDATE_HASH_KNUTH(h, val); | 202 | | | 203 | 1.02M | head = headp[h]; | 204 | 1.02M | if (LIKELY(head != idx)) { | 205 | 1.02M | prevp[idx & w_mask] = (Pos)head; | 206 | 1.02M | headp[h] = (Pos)idx; | 207 | 1.02M | } | 208 | 1.02M | } | 209 | 18.3k | } |
Unexecuted instantiation: compare256_sse2.c:insert_knuth_stepped_static Unexecuted instantiation: compare256_avx2.c:insert_knuth_stepped_static Unexecuted instantiation: compare256_avx512.c:insert_knuth_stepped_static |
210 | | |
211 | | /* =========================================================================== |
212 | | * Like insert_knuth_stepped_static(), except optimized for small max_inserts (deflate_fast levels) |
213 | | * The first and last position are always hashed, and an approximate middle position as well. |
214 | | * Larger max_inserts fall back to insert_knuth_stepped_static(). |
215 | | */ |
216 | 0 | Z_FORCEINLINE static void insert_knuth_spread_static(deflate_state *const s, unsigned char *window, uint32_t str, uint32_t count, uint32_t max_inserts) { |
217 | 0 | Assert(count >= 3, "Insert count too low"); |
218 | 0 | Assert(max_inserts >= 2, "max_inserts too low"); |
219 | |
|
220 | 0 | if (UNLIKELY(max_inserts > 3)) { |
221 | | /* In case count is bigger than 3: tuned deflate_fast level params, or NO_MEDIUM_STRATEGY */ |
222 | 0 | insert_knuth_stepped(s, window, str, count, max_inserts); |
223 | 0 | return; |
224 | 0 | } |
225 | | |
226 | | /* Local pointers to avoid indirection */ |
227 | 0 | Pos *headp = s->head; |
228 | 0 | Pos *prevp = s->prev; |
229 | 0 | const unsigned int w_mask = W_MASK(s); |
230 | | |
231 | | /* Insert head and tail, and middle if needed */ |
232 | 0 | insert_knuth_one(headp, prevp, w_mask, window, str); |
233 | 0 | if (max_inserts == 3) |
234 | 0 | insert_knuth_one(headp, prevp, w_mask, window, str + ((count - 1) >> 1)); |
235 | 0 | insert_knuth_one(headp, prevp, w_mask, window, str + count - 1); |
236 | 0 | } Unexecuted instantiation: deflate.c:insert_knuth_spread_static Unexecuted instantiation: deflate_fast.c:insert_knuth_spread_static Unexecuted instantiation: deflate_medium.c:insert_knuth_spread_static Unexecuted instantiation: deflate_quick.c:insert_knuth_spread_static Unexecuted instantiation: deflate_slow.c:insert_knuth_spread_static Unexecuted instantiation: insert_string.c:insert_knuth_spread_static Unexecuted instantiation: compare256_sse2.c:insert_knuth_spread_static Unexecuted instantiation: compare256_avx2.c:insert_knuth_spread_static Unexecuted instantiation: compare256_avx512.c:insert_knuth_spread_static |
237 | | |
238 | | /* =========================================================================== |
239 | | * Insert count strings read from the window, leaving the prev links untouched. |
240 | | * Used by fill_window during deflate_quick, which only inspects the chain head. |
241 | | */ |
242 | 0 | Z_FORCEINLINE static void insert_knuth_batch_head_static(deflate_state *const s, unsigned char *window, uint32_t str, uint32_t count) { |
243 | 0 | uint8_t *strstart = window + str; |
244 | 0 | uint8_t *strend = strstart + count; |
245 | 0 | Pos *headp = s->head; |
246 | |
|
247 | 0 | for (uint32_t idx = str; strstart < strend; idx++, strstart++) { |
248 | 0 | uint32_t val, h; |
249 | |
|
250 | 0 | val = Z_U32_FROM_LE(zng_memread_4(strstart)); |
251 | 0 | UPDATE_HASH_KNUTH(h, val); |
252 | |
|
253 | 0 | headp[h] = (Pos)idx; |
254 | 0 | } |
255 | 0 | } Unexecuted instantiation: deflate.c:insert_knuth_batch_head_static Unexecuted instantiation: deflate_fast.c:insert_knuth_batch_head_static Unexecuted instantiation: deflate_medium.c:insert_knuth_batch_head_static Unexecuted instantiation: deflate_quick.c:insert_knuth_batch_head_static Unexecuted instantiation: deflate_slow.c:insert_knuth_batch_head_static Unexecuted instantiation: insert_string.c:insert_knuth_batch_head_static Unexecuted instantiation: compare256_sse2.c:insert_knuth_batch_head_static Unexecuted instantiation: compare256_avx2.c:insert_knuth_batch_head_static Unexecuted instantiation: compare256_avx512.c:insert_knuth_batch_head_static |
256 | | |
257 | 0 | Z_FORCEINLINE static void insert_roll_batch_static(deflate_state *const s, unsigned char *window, uint32_t str, uint32_t count) { |
258 | 0 | uint8_t *strstart = window + str + (STD_MIN_MATCH-1); |
259 | 0 | uint8_t *strend = strstart + count; |
260 | | |
261 | | /* Local pointers to avoid indirection */ |
262 | 0 | Pos *headp = s->head; |
263 | 0 | Pos *prevp = s->prev; |
264 | 0 | uint32_t h = s->ins_h; |
265 | 0 | const unsigned int w_mask = W_MASK(s); |
266 | |
|
267 | 0 | for (uint32_t idx = str; strstart < strend; idx++, strstart++) { |
268 | 0 | uint32_t head; |
269 | |
|
270 | 0 | UPDATE_HASH_ROLL(h, strstart[0]); |
271 | |
|
272 | 0 | head = headp[h]; |
273 | 0 | if (LIKELY(head != idx)) { |
274 | 0 | prevp[idx & w_mask] = (Pos)head; |
275 | 0 | headp[h] = (Pos)idx; |
276 | 0 | } |
277 | 0 | } |
278 | 0 | s->ins_h = h; |
279 | 0 | } Unexecuted instantiation: deflate.c:insert_roll_batch_static Unexecuted instantiation: deflate_fast.c:insert_roll_batch_static Unexecuted instantiation: deflate_medium.c:insert_roll_batch_static Unexecuted instantiation: deflate_quick.c:insert_roll_batch_static Unexecuted instantiation: deflate_slow.c:insert_roll_batch_static Unexecuted instantiation: insert_string.c:insert_roll_batch_static Unexecuted instantiation: compare256_sse2.c:insert_roll_batch_static Unexecuted instantiation: compare256_avx2.c:insert_roll_batch_static Unexecuted instantiation: compare256_avx512.c:insert_roll_batch_static |
280 | | |
281 | | /* =========================================================================== |
282 | | * Mark count strings as the end of their hash chain without inserting them. |
283 | | * longest_match reads prev for every position inside a candidate match, so a |
284 | | * skipped string must not keep a link from earlier input. |
285 | | */ |
286 | 0 | Z_FORCEINLINE static void insert_skip(deflate_state *const s, uint32_t str, uint32_t count) { |
287 | 0 | uint32_t idx = str & W_MASK(s); |
288 | | /* The range wraps around the end of prev at most once. */ |
289 | 0 | uint32_t first = MIN(count, s->w_size - idx); |
290 | |
|
291 | 0 | memset(&s->prev[idx], 0, first * sizeof(Pos)); |
292 | 0 | memset(s->prev, 0, (count - first) * sizeof(Pos)); |
293 | 0 | } Unexecuted instantiation: deflate.c:insert_skip Unexecuted instantiation: deflate_fast.c:insert_skip Unexecuted instantiation: deflate_medium.c:insert_skip Unexecuted instantiation: deflate_quick.c:insert_skip Unexecuted instantiation: deflate_slow.c:insert_skip Unexecuted instantiation: insert_string.c:insert_skip Unexecuted instantiation: compare256_sse2.c:insert_skip Unexecuted instantiation: compare256_avx2.c:insert_skip Unexecuted instantiation: compare256_avx512.c:insert_skip |
294 | | |
295 | | /* =========================================================================== |
296 | | * Insert only the last tail strings of a batch and end the chains of the rest. |
297 | | * IN assertion: tail < count. |
298 | | */ |
299 | | Z_FORCEINLINE static void insert_knuth_batch_tail_static(deflate_state *const s, unsigned char *window, uint32_t str, |
300 | 0 | uint32_t count, uint32_t tail) { |
301 | 0 | uint32_t skip = count - tail; |
302 | |
|
303 | 0 | insert_skip(s, str, skip); |
304 | 0 | insert_knuth_batch_static(s, window, str + skip, tail); |
305 | 0 | } Unexecuted instantiation: deflate.c:insert_knuth_batch_tail_static Unexecuted instantiation: deflate_fast.c:insert_knuth_batch_tail_static Unexecuted instantiation: deflate_medium.c:insert_knuth_batch_tail_static Unexecuted instantiation: deflate_quick.c:insert_knuth_batch_tail_static Unexecuted instantiation: deflate_slow.c:insert_knuth_batch_tail_static Unexecuted instantiation: insert_string.c:insert_knuth_batch_tail_static Unexecuted instantiation: compare256_sse2.c:insert_knuth_batch_tail_static Unexecuted instantiation: compare256_avx2.c:insert_knuth_batch_tail_static Unexecuted instantiation: compare256_avx512.c:insert_knuth_batch_tail_static |
306 | | |
307 | | Z_FORCEINLINE static void insert_roll_batch_tail_static(deflate_state *const s, unsigned char *window, uint32_t str, |
308 | 0 | uint32_t count, uint32_t tail) { |
309 | 0 | uint32_t skip = count - tail; |
310 | |
|
311 | 0 | insert_skip(s, str, skip); |
312 | 0 | str += skip; |
313 | | /* Seed the rolling hash with two bytes, the insert feeds the third. */ |
314 | 0 | s->ins_h = update_hash_roll(window[str], window[str + 1]); |
315 | 0 | insert_roll_batch_static(s, window, str, tail); |
316 | 0 | } Unexecuted instantiation: deflate.c:insert_roll_batch_tail_static Unexecuted instantiation: deflate_fast.c:insert_roll_batch_tail_static Unexecuted instantiation: deflate_medium.c:insert_roll_batch_tail_static Unexecuted instantiation: deflate_quick.c:insert_roll_batch_tail_static Unexecuted instantiation: deflate_slow.c:insert_roll_batch_tail_static Unexecuted instantiation: insert_string.c:insert_roll_batch_tail_static Unexecuted instantiation: compare256_sse2.c:insert_roll_batch_tail_static Unexecuted instantiation: compare256_avx2.c:insert_roll_batch_tail_static Unexecuted instantiation: compare256_avx512.c:insert_roll_batch_tail_static |
317 | | |
318 | | #endif |