Coverage Report

Created: 2025-12-14 06:55

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
#  if BYTE_ORDER == LITTLE_ENDIAN
24
#    define HASH_CALC_READ \
25
167M
        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 Pos QUICK_INSERT_VALUE(deflate_state *const s, uint32_t str, uint32_t val) {
49
0
    uint32_t hm;
50
0
    Pos head;
51
52
0
    HASH_CALC_VAR_INIT;
53
0
    HASH_CALC(HASH_CALC_VAR, val);
54
0
    HASH_CALC_VAR &= HASH_CALC_MASK;
55
0
    hm = HASH_CALC_VAR;
56
57
0
    head = s->head[hm];
58
0
    if (LIKELY(head != str)) {
59
0
        s->prev[str & W_MASK(s)] = head;
60
0
        s->head[hm] = (Pos)str;
61
0
    }
62
0
    return head;
63
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
64
65
/* ===========================================================================
66
 * Quick insert string str in the dictionary and set match_head to the previous head
67
 * of the hash chain (the most recent string with same hash key). Return
68
 * the previous length of the hash chain.
69
 */
70
130M
Z_FORCEINLINE static Pos QUICK_INSERT_STRING(deflate_state *const s, uint32_t str) {
71
130M
    uint8_t *strstart = s->window + str + HASH_CALC_OFFSET;
72
130M
    uint32_t val, hm;
73
130M
    Pos head;
74
75
130M
    HASH_CALC_VAR_INIT;
76
130M
    HASH_CALC_READ;
77
130M
    HASH_CALC(HASH_CALC_VAR, val);
78
130M
    HASH_CALC_VAR &= HASH_CALC_MASK;
79
130M
    hm = HASH_CALC_VAR;
80
81
130M
    head = s->head[hm];
82
130M
    if (LIKELY(head != str)) {
83
130M
        s->prev[str & W_MASK(s)] = head;
84
130M
        s->head[hm] = (Pos)str;
85
130M
    }
86
130M
    return head;
87
130M
}
deflate.c:quick_insert_string
Line
Count
Source
70
4.95k
Z_FORCEINLINE static Pos QUICK_INSERT_STRING(deflate_state *const s, uint32_t str) {
71
4.95k
    uint8_t *strstart = s->window + str + HASH_CALC_OFFSET;
72
4.95k
    uint32_t val, hm;
73
4.95k
    Pos head;
74
75
4.95k
    HASH_CALC_VAR_INIT;
76
4.95k
    HASH_CALC_READ;
77
4.95k
    HASH_CALC(HASH_CALC_VAR, val);
78
4.95k
    HASH_CALC_VAR &= HASH_CALC_MASK;
79
4.95k
    hm = HASH_CALC_VAR;
80
81
4.95k
    head = s->head[hm];
82
4.95k
    if (LIKELY(head != str)) {
83
7
        s->prev[str & W_MASK(s)] = head;
84
7
        s->head[hm] = (Pos)str;
85
7
    }
86
4.95k
    return head;
87
4.95k
}
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
70
130M
Z_FORCEINLINE static Pos QUICK_INSERT_STRING(deflate_state *const s, uint32_t str) {
71
130M
    uint8_t *strstart = s->window + str + HASH_CALC_OFFSET;
72
130M
    uint32_t val, hm;
73
130M
    Pos head;
74
75
130M
    HASH_CALC_VAR_INIT;
76
130M
    HASH_CALC_READ;
77
130M
    HASH_CALC(HASH_CALC_VAR, val);
78
130M
    HASH_CALC_VAR &= HASH_CALC_MASK;
79
130M
    hm = HASH_CALC_VAR;
80
81
130M
    head = s->head[hm];
82
130M
    if (LIKELY(head != str)) {
83
130M
        s->prev[str & W_MASK(s)] = head;
84
130M
        s->head[hm] = (Pos)str;
85
130M
    }
86
130M
    return head;
87
130M
}
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
88
89
/* ===========================================================================
90
 * Insert string str in the dictionary and set match_head to the previous head
91
 * of the hash chain (the most recent string with same hash key). Return
92
 * the previous length of the hash chain.
93
 * IN  assertion: all calls to INSERT_STRING are made with consecutive
94
 *    input characters and the first STD_MIN_MATCH bytes of str are valid
95
 *    (except for the last STD_MIN_MATCH-1 bytes of the input file).
96
 */
97
3.58M
Z_FORCEINLINE static void INSERT_STRING(deflate_state *const s, uint32_t str, uint32_t count) {
98
3.58M
    uint8_t *strstart = s->window + str + HASH_CALC_OFFSET;
99
3.58M
    uint8_t *strend = strstart + count;
100
101
    /* Local pointers to avoid indirection */
102
3.58M
    Pos *headp = s->head;
103
3.58M
    Pos *prevp = s->prev;
104
3.58M
    const unsigned int w_mask = W_MASK(s);
105
106
40.9M
    for (Pos idx = (Pos)str; strstart < strend; idx++, strstart++) {
107
37.3M
        uint32_t val, hm;
108
109
37.3M
        HASH_CALC_VAR_INIT;
110
37.3M
        HASH_CALC_READ;
111
37.3M
        HASH_CALC(HASH_CALC_VAR, val);
112
37.3M
        HASH_CALC_VAR &= HASH_CALC_MASK;
113
37.3M
        hm = HASH_CALC_VAR;
114
115
37.3M
        Pos head = headp[hm];
116
37.3M
        if (LIKELY(head != idx)) {
117
37.3M
            prevp[idx & w_mask] = head;
118
37.3M
            headp[hm] = idx;
119
37.3M
        }
120
37.3M
    }
121
3.58M
}
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
97
3.58M
Z_FORCEINLINE static void INSERT_STRING(deflate_state *const s, uint32_t str, uint32_t count) {
98
3.58M
    uint8_t *strstart = s->window + str + HASH_CALC_OFFSET;
99
3.58M
    uint8_t *strend = strstart + count;
100
101
    /* Local pointers to avoid indirection */
102
3.58M
    Pos *headp = s->head;
103
3.58M
    Pos *prevp = s->prev;
104
3.58M
    const unsigned int w_mask = W_MASK(s);
105
106
40.9M
    for (Pos idx = (Pos)str; strstart < strend; idx++, strstart++) {
107
37.3M
        uint32_t val, hm;
108
109
37.3M
        HASH_CALC_VAR_INIT;
110
37.3M
        HASH_CALC_READ;
111
37.3M
        HASH_CALC(HASH_CALC_VAR, val);
112
37.3M
        HASH_CALC_VAR &= HASH_CALC_MASK;
113
37.3M
        hm = HASH_CALC_VAR;
114
115
37.3M
        Pos head = headp[hm];
116
37.3M
        if (LIKELY(head != idx)) {
117
37.3M
            prevp[idx & w_mask] = head;
118
37.3M
            headp[hm] = idx;
119
37.3M
        }
120
37.3M
    }
121
3.58M
}
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