]> git.proxmox.com Git - ceph.git/blobdiff - ceph/src/isa-l/igzip/igzip_finish.asm
Import ceph 15.2.8
[ceph.git] / ceph / src / isa-l / igzip / igzip_finish.asm
index e8d5e36049462e67ab78fa13678f2357fbfcf008..36823e13883ab50ef42fd9d34761a7546b43e5dd 100644 (file)
 %define f_i            rdi
 
 %define code_len2      rbp
+%define hmask1         rbp
 
 %define m_out_buf      r8
 
 %define m_bits         r9
 
 %define dist           r10
+%define hmask2         r10
 
 %define m_bit_count    r11
 
@@ -126,29 +128,31 @@ skip_SLOP:
 
        mov     curr_data %+ d, [file_start + f_i]
 
-       cmp     dword [stream + _internal_state_has_hist], 0
+       cmp     byte [stream + _internal_state_has_hist], IGZIP_NO_HIST
        jne     skip_write_first_byte
 
        cmp     m_out_buf, [stream + _internal_state_bitbuf_m_out_end]
        ja      end_loop_2
-
+       mov     hmask1 %+ d, dword [stream + _internal_state_hash_mask]
        compute_hash    hash, curr_data
-       and     hash %+ d, HASH_MASK
+       and     hash %+ d, hmask1 %+ d
        mov     [stream + _internal_state_head + 2 * hash], f_i %+ w
-       mov     dword [stream + _internal_state_has_hist], 1
+       mov     byte [stream + _internal_state_has_hist], IGZIP_HIST
        jmp     encode_literal
 
 skip_write_first_byte:
 
 loop2:
+       mov     tmp3 %+ d, dword [stream + _internal_state_dist_mask]
+       mov     hmask1 %+ d,  dword [stream + _internal_state_hash_mask]
        ; if (state->bitbuf.is_full()) {
        cmp     m_out_buf, [stream + _internal_state_bitbuf_m_out_end]
        ja      end_loop_2
 
-       ; hash = compute_hash(state->file_start + f_i) & HASH_MASK;
+       ; hash = compute_hash(state->file_start + f_i) & hash_mask;
        mov     curr_data %+ d, [file_start + f_i]
        compute_hash    hash, curr_data
-       and     hash %+ d, HASH_MASK
+       and     hash %+ d, hmask1 %+ d
 
        ; f_index = state->head[hash];
        movzx   f_index %+ d, word [stream + _internal_state_head + 2 * hash]
@@ -164,7 +168,7 @@ loop2:
        ; if ((dist-1) <= (D-1)) {
        mov     tmp1 %+ d, dist %+ d
        sub     tmp1 %+ d, 1
-       cmp     tmp1 %+ d, (D-1)
+       cmp     tmp1 %+ d, tmp3 %+ d
        jae     encode_literal
 
        ; len = f_end_i - f_i;
@@ -196,6 +200,7 @@ loop2:
        ; get_len_code(len, &code, &code_len);
        get_len_code    len, code, rcx, hufftables      ;; rcx is code_len
 
+       mov     hmask2 %+ d,  dword [stream + _internal_state_hash_mask]
        ; code2 <<= code_len
        ; code2 |= code
        ; code_len2 += code_len
@@ -211,24 +216,24 @@ loop2:
 
        ; only update hash twice
 
-       ; hash = compute_hash(state->file_start + k) & HASH_MASK;
+       ; hash = compute_hash(state->file_start + k) & hash_mask;
        mov     tmp6 %+ d, dword [file_start + tmp3]
        compute_hash    hash, tmp6
-       and     hash %+ d, HASH_MASK
+       and     hash %+ d, hmask2 %+ d
        ; state->head[hash] = k;
        mov     [stream + _internal_state_head + 2 * hash], tmp3 %+ w
 
        add     tmp3, 1
 
-       ; hash = compute_hash(state->file_start + k) & HASH_MASK;
+       ; hash = compute_hash(state->file_start + k) & hash_mask;
        mov     tmp6 %+ d, dword [file_start + tmp3]
        compute_hash    hash, tmp6
-       and     hash %+ d, HASH_MASK
+       and     hash %+ d, hmask2 %+ d
        ; state->head[hash] = k;
        mov     [stream + _internal_state_head + 2 * hash], tmp3 %+ w
 
 skip_hash_update:
-       write_bits      m_bits, m_bit_count, code2, code_len2, m_out_buf, tmp5
+       write_bits      m_bits, m_bit_count, code2, code_len2, m_out_buf
 
        ; continue
        cmp     f_i, [rsp + f_end_i_mem_offset]
@@ -240,7 +245,7 @@ encode_literal:
        movzx   tmp5, byte [file_start + f_i]
        get_lit_code    tmp5, code2, code_len2, hufftables
 
-       write_bits      m_bits, m_bit_count, code2, code_len2, m_out_buf, tmp5
+       write_bits      m_bits, m_bit_count, code2, code_len2, m_out_buf
 
        ; continue
        add     f_i, 1
@@ -261,7 +266,7 @@ final_bytes:
        ja      not_end
        movzx   tmp5, byte [file_start + f_i]
        get_lit_code    tmp5, code2, code_len2, hufftables
-       write_bits      m_bits, m_bit_count, code2, code_len2, m_out_buf, tmp3
+       write_bits      m_bits, m_bit_count, code2, code_len2, m_out_buf
 
        inc     f_i
        cmp     f_i, [rsp + f_end_i_mem_offset]
@@ -274,10 +279,10 @@ write_eob:
        ;       get_lit_code(256, &code2, &code_len2);
        get_lit_code    256, code2, code_len2, hufftables
 
-       write_bits      m_bits, m_bit_count, code2, code_len2, m_out_buf, tmp1
+       write_bits      m_bits, m_bit_count, code2, code_len2, m_out_buf
 
-       mov     dword [stream + _internal_state_has_eob], 1
-       cmp     dword [stream + _end_of_stream], 1
+       mov     byte [stream + _internal_state_has_eob], 1
+       cmp     word [stream + _end_of_stream], 1
        jne     sync_flush
        ;          state->state = ZSTATE_TRL;
        mov     dword [stream + _internal_state_state], ZSTATE_TRL