Coverage Report

Created: 2026-04-12 06:41

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/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
0
#  define HASH_CALC_READ val = Z_U32_FROM_LE(zng_memread_4(strstart));
24
#endif
25
26
/* ===========================================================================
27
 * Update a hash value with the given input byte
28
 * IN  assertion: all calls to UPDATE_HASH are made with consecutive
29
 *    input characters, so that a running hash key can be computed from the
30
 *    previous key instead of complete recalculation each time.
31
 */
32
1.36M
Z_FORCEINLINE static uint32_t UPDATE_HASH(uint32_t h, uint32_t val) {
33
1.36M
    HASH_CALC(h, val);
34
1.36M
    return h & HASH_CALC_MASK;
35
1.36M
}
deflate.c:update_hash_roll
Line
Count
Source
32
15.1k
Z_FORCEINLINE static uint32_t UPDATE_HASH(uint32_t h, uint32_t val) {
33
15.1k
    HASH_CALC(h, val);
34
15.1k
    return h & HASH_CALC_MASK;
35
15.1k
}
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
compare256_avx2.c:update_hash_roll
Line
Count
Source
32
1.35M
Z_FORCEINLINE static uint32_t UPDATE_HASH(uint32_t h, uint32_t val) {
33
1.35M
    HASH_CALC(h, val);
34
1.35M
    return h & HASH_CALC_MASK;
35
1.35M
}
Unexecuted instantiation: compare256_avx2.c:update_hash
Unexecuted instantiation: compare256_avx512.c:update_hash_roll
Unexecuted instantiation: compare256_avx512.c:update_hash
36
37
/* ===========================================================================
38
 * Quick insert string str in the dictionary using a pre-read value and set match_head
39
 * to the previous head of the hash chain (the most recent string with same hash key).
40
 * Return the previous length of the hash chain.
41
 */
42
0
Z_FORCEINLINE static uint32_t QUICK_INSERT_VALUE(deflate_state *const s, uint32_t str, uint32_t val) {
43
0
    uint32_t hm, head;
44
45
0
    HASH_CALC_VAR_INIT;
46
0
    HASH_CALC(HASH_CALC_VAR, val);
47
0
    HASH_CALC_VAR &= HASH_CALC_MASK;
48
0
    hm = HASH_CALC_VAR;
49
50
0
    head = s->head[hm];
51
0
    if (LIKELY(head != str)) {
52
0
        s->prev[str & W_MASK(s)] = (Pos)head;
53
0
        s->head[hm] = (Pos)str;
54
0
    }
55
0
    return head;
56
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
57
58
/* ===========================================================================
59
 * Quick insert string str in the dictionary and set match_head to the previous head
60
 * of the hash chain (the most recent string with same hash key). Return
61
 * the previous length of the hash chain.
62
 */
63
3.44M
Z_FORCEINLINE static uint32_t QUICK_INSERT_STRING(deflate_state *const s, uint32_t str) {
64
3.44M
    uint8_t *strstart = s->window + str + HASH_CALC_OFFSET;
65
3.44M
    uint32_t val, hm, head;
66
67
3.44M
    HASH_CALC_VAR_INIT;
68
3.44M
    HASH_CALC_READ;
69
3.44M
    HASH_CALC(HASH_CALC_VAR, val);
70
3.44M
    HASH_CALC_VAR &= HASH_CALC_MASK;
71
3.44M
    hm = HASH_CALC_VAR;
72
73
3.44M
    head = s->head[hm];
74
3.44M
    if (LIKELY(head != str)) {
75
3.44M
        s->prev[str & W_MASK(s)] = (Pos)head;
76
3.44M
        s->head[hm] = (Pos)str;
77
3.44M
    }
78
3.44M
    return head;
79
3.44M
}
Unexecuted instantiation: deflate.c:quick_insert_string
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
Unexecuted instantiation: deflate_medium.c:quick_insert_string
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
deflate_slow.c:quick_insert_string_roll
Line
Count
Source
63
3.44M
Z_FORCEINLINE static uint32_t QUICK_INSERT_STRING(deflate_state *const s, uint32_t str) {
64
3.44M
    uint8_t *strstart = s->window + str + HASH_CALC_OFFSET;
65
3.44M
    uint32_t val, hm, head;
66
67
3.44M
    HASH_CALC_VAR_INIT;
68
3.44M
    HASH_CALC_READ;
69
3.44M
    HASH_CALC(HASH_CALC_VAR, val);
70
3.44M
    HASH_CALC_VAR &= HASH_CALC_MASK;
71
3.44M
    hm = HASH_CALC_VAR;
72
73
3.44M
    head = s->head[hm];
74
3.44M
    if (LIKELY(head != str)) {
75
3.44M
        s->prev[str & W_MASK(s)] = (Pos)head;
76
3.44M
        s->head[hm] = (Pos)str;
77
3.44M
    }
78
3.44M
    return head;
79
3.44M
}
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
80
81
/* ===========================================================================
82
 * Insert string str in the dictionary and set match_head to the previous head
83
 * of the hash chain (the most recent string with same hash key). Return
84
 * the previous length of the hash chain.
85
 * IN  assertion: all calls to INSERT_STRING are made with consecutive
86
 *    input characters and the first STD_MIN_MATCH bytes of str are valid
87
 *    (except for the last STD_MIN_MATCH-1 bytes of the input file).
88
 */
89
1.72M
Z_FORCEINLINE static void INSERT_STRING(deflate_state *const s, uint32_t str, uint32_t count) {
90
1.72M
    uint8_t *strstart = s->window + str + HASH_CALC_OFFSET;
91
1.72M
    uint8_t *strend = strstart + count;
92
93
    /* Local pointers to avoid indirection */
94
1.72M
    Pos *headp = s->head;
95
1.72M
    Pos *prevp = s->prev;
96
1.72M
    const unsigned int w_mask = W_MASK(s);
97
98
441M
    for (uint32_t idx = str; strstart < strend; idx++, strstart++) {
99
439M
        uint32_t val, hm, head;
100
101
439M
        HASH_CALC_VAR_INIT;
102
439M
        HASH_CALC_READ;
103
439M
        HASH_CALC(HASH_CALC_VAR, val);
104
439M
        HASH_CALC_VAR &= HASH_CALC_MASK;
105
439M
        hm = HASH_CALC_VAR;
106
107
439M
        head = headp[hm];
108
439M
        if (LIKELY(head != idx)) {
109
439M
            prevp[idx & w_mask] = (Pos)head;
110
439M
            headp[hm] = (Pos)idx;
111
439M
        }
112
439M
    }
113
1.72M
}
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
Unexecuted instantiation: insert_string.c:insert_string_static
insert_string.c:insert_string_roll_static
Line
Count
Source
89
1.72M
Z_FORCEINLINE static void INSERT_STRING(deflate_state *const s, uint32_t str, uint32_t count) {
90
1.72M
    uint8_t *strstart = s->window + str + HASH_CALC_OFFSET;
91
1.72M
    uint8_t *strend = strstart + count;
92
93
    /* Local pointers to avoid indirection */
94
1.72M
    Pos *headp = s->head;
95
1.72M
    Pos *prevp = s->prev;
96
1.72M
    const unsigned int w_mask = W_MASK(s);
97
98
441M
    for (uint32_t idx = str; strstart < strend; idx++, strstart++) {
99
439M
        uint32_t val, hm, head;
100
101
439M
        HASH_CALC_VAR_INIT;
102
439M
        HASH_CALC_READ;
103
439M
        HASH_CALC(HASH_CALC_VAR, val);
104
439M
        HASH_CALC_VAR &= HASH_CALC_MASK;
105
439M
        hm = HASH_CALC_VAR;
106
107
439M
        head = headp[hm];
108
439M
        if (LIKELY(head != idx)) {
109
439M
            prevp[idx & w_mask] = (Pos)head;
110
439M
            headp[hm] = (Pos)idx;
111
439M
        }
112
439M
    }
113
1.72M
}
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
114
115
// Cleanup
116
#undef HASH_SLIDE
117
#undef HASH_CALC
118
#undef HASH_CALC_READ
119
#undef HASH_CALC_MASK
120
#undef HASH_CALC_OFFSET
121
#undef HASH_CALC_VAR
122
#undef HASH_CALC_VAR_INIT
123
#undef UPDATE_HASH
124
#undef INSERT_STRING
125
#undef QUICK_INSERT_STRING
126
#undef QUICK_INSERT_VALUE