2016-10-03 23:50:52 +02:00
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
; Copyright(c) 2011-2016 Intel Corporation All rights reserved.
|
|
|
|
;
|
|
|
|
; Redistribution and use in source and binary forms, with or without
|
|
|
|
; modification, are permitted provided that the following conditions
|
|
|
|
; are met:
|
|
|
|
; * Redistributions of source code must retain the above copyright
|
|
|
|
; notice, this list of conditions and the following disclaimer.
|
|
|
|
; * Redistributions in binary form must reproduce the above copyright
|
|
|
|
; notice, this list of conditions and the following disclaimer in
|
|
|
|
; the documentation and/or other materials provided with the
|
|
|
|
; distribution.
|
|
|
|
; * Neither the name of Intel Corporation nor the names of its
|
|
|
|
; contributors may be used to endorse or promote products derived
|
|
|
|
; from this software without specific prior written permission.
|
|
|
|
;
|
|
|
|
; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
|
|
; "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
|
|
; LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
|
|
; A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
|
|
; OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
|
|
; SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
|
|
; LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
|
|
; DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
|
|
; THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
; (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
|
|
; OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
%include "options.asm"
|
|
|
|
|
|
|
|
%include "lz0a_const.asm"
|
|
|
|
%include "data_struct2.asm"
|
|
|
|
%include "bitbuf2.asm"
|
|
|
|
%include "huffman.asm"
|
|
|
|
%include "igzip_compare_types.asm"
|
|
|
|
%include "reg_sizes.asm"
|
|
|
|
|
|
|
|
%include "stdmac.asm"
|
|
|
|
|
|
|
|
%ifdef DEBUG
|
|
|
|
%macro MARK 1
|
|
|
|
global %1
|
|
|
|
%1:
|
|
|
|
%endm
|
|
|
|
%else
|
|
|
|
%macro MARK 1
|
|
|
|
%endm
|
|
|
|
%endif
|
|
|
|
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
2017-02-07 01:40:41 +01:00
|
|
|
%define file_start rdi
|
|
|
|
%define file_length r15
|
2017-11-30 17:58:30 +01:00
|
|
|
%define level_buf r14
|
2017-02-07 01:40:41 +01:00
|
|
|
%define f_i r10
|
|
|
|
%define m_out_buf r11
|
2016-10-03 23:50:52 +02:00
|
|
|
|
|
|
|
%define curr_data rax
|
|
|
|
|
2017-02-07 01:40:41 +01:00
|
|
|
%define tmp2 rcx
|
|
|
|
|
2016-10-03 23:50:52 +02:00
|
|
|
%define dist rbx
|
2017-02-07 01:40:41 +01:00
|
|
|
%define dist_code2 rbx
|
|
|
|
%define lit_code2 rbx
|
2016-10-03 23:50:52 +02:00
|
|
|
|
2017-02-07 01:40:41 +01:00
|
|
|
%define dist2 r12
|
|
|
|
%define dist_code r12
|
2016-10-03 23:50:52 +02:00
|
|
|
|
|
|
|
%define tmp1 rsi
|
2017-02-07 01:40:41 +01:00
|
|
|
%define lit_code rsi
|
2016-10-03 23:50:52 +02:00
|
|
|
|
|
|
|
%define curr_data2 r8
|
|
|
|
%define len2 r8
|
2017-02-07 01:40:41 +01:00
|
|
|
%define tmp4 r8
|
2016-10-03 23:50:52 +02:00
|
|
|
|
2017-02-07 01:40:41 +01:00
|
|
|
%define len rdx
|
|
|
|
%define len_code rdx
|
|
|
|
%define hash3 rdx
|
2016-10-03 23:50:52 +02:00
|
|
|
|
2017-11-30 17:58:30 +01:00
|
|
|
%define stream r13
|
2016-10-03 23:50:52 +02:00
|
|
|
%define tmp3 r13
|
|
|
|
|
2017-02-07 01:40:41 +01:00
|
|
|
%define hash rbp
|
|
|
|
%define hash2 r9
|
2016-10-03 23:50:52 +02:00
|
|
|
|
|
|
|
;; GPR r8 & r15 can be used
|
|
|
|
|
|
|
|
%define xtmp0 xmm0 ; tmp
|
|
|
|
%define xtmp1 xmm1 ; tmp
|
|
|
|
%define xdata xmm4
|
|
|
|
|
|
|
|
%define ytmp0 ymm0 ; tmp
|
|
|
|
%define ytmp1 ymm1 ; tmp
|
|
|
|
|
2017-11-30 21:07:22 +01:00
|
|
|
%define hash_table level_buf + _hash8k_hash_table
|
2017-11-30 17:58:30 +01:00
|
|
|
%define lit_len_hist level_buf + _hist_lit_len
|
|
|
|
%define dist_hist level_buf + _hist_dist
|
2016-10-03 23:50:52 +02:00
|
|
|
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
|
|
|
|
m_out_end equ 0 ; local variable (8 bytes)
|
|
|
|
m_out_start equ 8
|
|
|
|
f_end_i_mem_offset equ 16
|
2017-11-30 17:58:30 +01:00
|
|
|
stream_offset equ 24
|
|
|
|
gpr_save_mem_offset equ 32 ; gpr save area (8*8 bytes)
|
|
|
|
xmm_save_mem_offset equ gpr_save_mem_offset + 8*8 ; xmm save area (4*16 bytes) (16 byte aligned)
|
|
|
|
stack_size equ 5*8 + 8*8 + 4*16
|
2017-02-07 01:40:41 +01:00
|
|
|
|
2016-10-03 23:50:52 +02:00
|
|
|
;;; 8 because stack address is odd multiple of 8 after a function call and
|
|
|
|
;;; we want it aligned to 16 bytes
|
|
|
|
|
|
|
|
; void isal_deflate_icf_body ( isal_zstream *stream )
|
|
|
|
; arg 1: rcx: addr of stream
|
2017-11-30 21:07:22 +01:00
|
|
|
global isal_deflate_icf_body_hash8k_ %+ ARCH
|
|
|
|
isal_deflate_icf_body_hash8k_ %+ ARCH %+ :
|
2016-10-03 23:50:52 +02:00
|
|
|
%ifidn __OUTPUT_FORMAT__, elf64
|
|
|
|
mov rcx, rdi
|
|
|
|
%endif
|
|
|
|
|
|
|
|
;; do nothing if (avail_in == 0)
|
|
|
|
cmp dword [rcx + _avail_in], 0
|
|
|
|
jne skip1
|
|
|
|
|
|
|
|
;; Set stream's next state
|
|
|
|
mov rdx, ZSTATE_FLUSH_READ_BUFFER
|
|
|
|
mov rax, ZSTATE_CREATE_HDR
|
2017-07-20 22:26:26 +02:00
|
|
|
cmp word [rcx + _end_of_stream], 0
|
2016-10-03 23:50:52 +02:00
|
|
|
cmovne rax, rdx
|
2017-07-20 22:26:26 +02:00
|
|
|
cmp word [rcx + _flush], _NO_FLUSH
|
2016-10-03 23:50:52 +02:00
|
|
|
cmovne rax, rdx
|
|
|
|
mov dword [rcx + _internal_state_state], eax
|
|
|
|
ret
|
|
|
|
skip1:
|
|
|
|
|
|
|
|
%ifdef ALIGN_STACK
|
|
|
|
push rbp
|
|
|
|
mov rbp, rsp
|
|
|
|
sub rsp, stack_size
|
|
|
|
and rsp, ~15
|
|
|
|
%else
|
|
|
|
sub rsp, stack_size
|
|
|
|
%endif
|
|
|
|
|
|
|
|
mov [rsp + gpr_save_mem_offset + 0*8], rbx
|
|
|
|
mov [rsp + gpr_save_mem_offset + 1*8], rsi
|
|
|
|
mov [rsp + gpr_save_mem_offset + 2*8], rdi
|
|
|
|
mov [rsp + gpr_save_mem_offset + 3*8], rbp
|
|
|
|
mov [rsp + gpr_save_mem_offset + 4*8], r12
|
|
|
|
mov [rsp + gpr_save_mem_offset + 5*8], r13
|
|
|
|
mov [rsp + gpr_save_mem_offset + 6*8], r14
|
|
|
|
mov [rsp + gpr_save_mem_offset + 7*8], r15
|
|
|
|
|
|
|
|
mov stream, rcx
|
2017-11-30 17:58:30 +01:00
|
|
|
mov [rsp + stream_offset], stream
|
|
|
|
|
2017-10-27 19:38:13 +02:00
|
|
|
mov byte [stream + _internal_state_has_eob], 0
|
2016-10-03 23:50:52 +02:00
|
|
|
|
|
|
|
; state->bitbuf.set_buf(stream->next_out, stream->avail_out);
|
2017-11-30 17:58:30 +01:00
|
|
|
mov level_buf, [stream + _level_buf]
|
|
|
|
mov m_out_buf, [level_buf + _icf_buf_next]
|
2016-10-03 23:50:52 +02:00
|
|
|
|
|
|
|
mov [rsp + m_out_start], m_out_buf
|
2017-11-30 17:58:30 +01:00
|
|
|
mov tmp1, [level_buf + _icf_buf_avail_out]
|
2016-10-03 23:50:52 +02:00
|
|
|
add tmp1, m_out_buf
|
|
|
|
sub tmp1, SLOP
|
|
|
|
|
|
|
|
mov [rsp + m_out_end], tmp1
|
|
|
|
|
|
|
|
mov file_start, [stream + _next_in]
|
|
|
|
|
|
|
|
mov f_i %+ d, dword [stream + _total_in]
|
|
|
|
sub file_start, f_i
|
|
|
|
|
2017-02-07 01:40:41 +01:00
|
|
|
mov file_length %+ d, [stream + _avail_in]
|
|
|
|
add file_length, f_i
|
2016-10-03 23:50:52 +02:00
|
|
|
|
2017-02-07 01:40:41 +01:00
|
|
|
; file_length -= LA;
|
|
|
|
sub file_length, LA
|
|
|
|
; if (file_length <= 0) continue;
|
2016-10-03 23:50:52 +02:00
|
|
|
|
2017-02-07 01:40:41 +01:00
|
|
|
cmp file_length, f_i
|
2016-10-03 23:50:52 +02:00
|
|
|
jle input_end
|
|
|
|
|
2017-02-07 01:40:41 +01:00
|
|
|
; for (f_i = f_start_i; f_i < file_length; f_i++) {
|
2016-10-03 23:50:52 +02:00
|
|
|
MARK __body_compute_hash_ %+ ARCH
|
|
|
|
MOVDQU xdata, [file_start + f_i]
|
|
|
|
mov curr_data, [file_start + f_i]
|
2017-11-30 17:58:30 +01:00
|
|
|
mov tmp1, curr_data
|
|
|
|
mov tmp2, curr_data
|
2016-10-03 23:50:52 +02:00
|
|
|
|
|
|
|
compute_hash hash, curr_data
|
|
|
|
|
2017-11-30 17:58:30 +01:00
|
|
|
shr tmp1, 8
|
|
|
|
compute_hash hash2, tmp1
|
2016-10-03 23:50:52 +02:00
|
|
|
|
2017-11-30 21:07:22 +01:00
|
|
|
and hash, HASH8K_HASH_MASK
|
|
|
|
and hash2, HASH8K_HASH_MASK
|
2016-10-03 23:50:52 +02:00
|
|
|
|
2017-10-27 19:38:13 +02:00
|
|
|
cmp byte [stream + _internal_state_has_hist], IGZIP_NO_HIST
|
2016-10-03 23:50:52 +02:00
|
|
|
je write_first_byte
|
|
|
|
|
|
|
|
jmp loop2
|
|
|
|
align 16
|
|
|
|
|
|
|
|
loop2:
|
|
|
|
; if (state->bitbuf.is_full()) {
|
|
|
|
cmp m_out_buf, [rsp + m_out_end]
|
|
|
|
ja output_end
|
|
|
|
|
|
|
|
xor dist, dist
|
|
|
|
xor dist2, dist2
|
|
|
|
xor tmp3, tmp3
|
|
|
|
|
|
|
|
lea tmp1, [file_start + f_i]
|
|
|
|
|
|
|
|
mov dist %+ w, f_i %+ w
|
|
|
|
dec dist
|
2017-11-29 01:19:53 +01:00
|
|
|
sub dist %+ w, word [hash_table + 2 * hash]
|
|
|
|
mov [hash_table + 2 * hash], f_i %+ w
|
2016-10-03 23:50:52 +02:00
|
|
|
|
|
|
|
inc f_i
|
|
|
|
|
2017-02-07 01:40:41 +01:00
|
|
|
mov tmp2, curr_data
|
|
|
|
shr curr_data, 16
|
|
|
|
compute_hash hash, curr_data
|
2017-11-30 21:07:22 +01:00
|
|
|
and hash %+ d, HASH8K_HASH_MASK
|
2016-10-03 23:50:52 +02:00
|
|
|
|
|
|
|
mov dist2 %+ w, f_i %+ w
|
|
|
|
dec dist2
|
2017-11-29 01:19:53 +01:00
|
|
|
sub dist2 %+ w, word [hash_table + 2 * hash2]
|
|
|
|
mov [hash_table + 2 * hash2], f_i %+ w
|
2016-10-03 23:50:52 +02:00
|
|
|
|
|
|
|
; if ((dist-1) < (D-1)) {
|
|
|
|
and dist %+ d, (D-1)
|
|
|
|
neg dist
|
|
|
|
|
2017-02-07 01:40:41 +01:00
|
|
|
shr tmp2, 24
|
|
|
|
compute_hash hash2, tmp2
|
2017-11-30 21:07:22 +01:00
|
|
|
and hash2 %+ d, HASH8K_HASH_MASK
|
2016-10-03 23:50:52 +02:00
|
|
|
|
|
|
|
and dist2 %+ d, (D-1)
|
|
|
|
neg dist2
|
|
|
|
|
|
|
|
MARK __body_compare_ %+ ARCH
|
|
|
|
;; Check for long len/dist match (>7) with first literal
|
|
|
|
MOVQ len, xdata
|
|
|
|
mov curr_data, len
|
|
|
|
PSRLDQ xdata, 1
|
|
|
|
xor len, [tmp1 + dist - 1]
|
|
|
|
jz compare_loop
|
|
|
|
|
|
|
|
;; Check for len/dist match (>7) with second literal
|
|
|
|
MOVQ len2, xdata
|
|
|
|
xor len2, [tmp1 + dist2]
|
|
|
|
jz compare_loop2
|
|
|
|
|
2017-02-07 01:40:41 +01:00
|
|
|
movzx lit_code, curr_data %+ b
|
|
|
|
shr curr_data, 8
|
|
|
|
|
2016-10-03 23:50:52 +02:00
|
|
|
;; Check for len/dist match for first literal
|
|
|
|
test len %+ d, 0xFFFFFFFF
|
|
|
|
jz len_dist_huffman_pre
|
|
|
|
|
2017-11-29 01:19:53 +01:00
|
|
|
inc word [lit_len_hist + HIST_ELEM_SIZE*lit_code]
|
2017-02-07 01:40:41 +01:00
|
|
|
movzx lit_code2, curr_data %+ b
|
2016-10-03 23:50:52 +02:00
|
|
|
;; Check for len/dist match for second literal
|
|
|
|
test len2 %+ d, 0xFFFFFFFF
|
|
|
|
jnz write_lit_bits
|
|
|
|
|
|
|
|
MARK __body_len_dist_lit_huffman_ %+ ARCH
|
|
|
|
len_dist_lit_huffman_pre:
|
|
|
|
bsf len2, len2
|
|
|
|
shr len2, 3
|
|
|
|
|
|
|
|
len_dist_lit_huffman:
|
2017-02-07 01:40:41 +01:00
|
|
|
or lit_code, LIT
|
|
|
|
movnti dword [m_out_buf], lit_code %+ d
|
|
|
|
|
2016-10-03 23:50:52 +02:00
|
|
|
neg dist2
|
|
|
|
|
2017-02-07 01:40:41 +01:00
|
|
|
get_dist_icf_code dist2, dist_code2, tmp1
|
2016-10-03 23:50:52 +02:00
|
|
|
|
2017-02-07 01:40:41 +01:00
|
|
|
;; Setup for updating hash
|
|
|
|
lea tmp3, [f_i + 1] ; tmp3 <= k
|
2016-10-03 23:50:52 +02:00
|
|
|
|
2017-02-07 01:40:41 +01:00
|
|
|
add file_start, f_i
|
|
|
|
MOVDQU xdata, [file_start + len2]
|
|
|
|
mov tmp1, [file_start + len2]
|
2016-10-03 23:50:52 +02:00
|
|
|
|
2017-02-07 01:40:41 +01:00
|
|
|
shr curr_data, 24
|
|
|
|
compute_hash hash3, curr_data
|
2017-11-30 21:07:22 +01:00
|
|
|
and hash3, HASH8K_HASH_MASK
|
2016-10-03 23:50:52 +02:00
|
|
|
|
2017-02-07 01:40:41 +01:00
|
|
|
mov curr_data, tmp1
|
|
|
|
shr tmp1, 8
|
|
|
|
|
|
|
|
sub file_start, f_i
|
|
|
|
add f_i, len2
|
2016-10-03 23:50:52 +02:00
|
|
|
|
2017-11-29 01:19:53 +01:00
|
|
|
mov [hash_table + 2 * hash], tmp3 %+ w
|
2016-10-03 23:50:52 +02:00
|
|
|
|
|
|
|
compute_hash hash, curr_data
|
|
|
|
|
|
|
|
add tmp3,1
|
2017-11-29 01:19:53 +01:00
|
|
|
mov [hash_table + 2 * hash2], tmp3 %+ w
|
2016-10-03 23:50:52 +02:00
|
|
|
|
2017-02-07 01:40:41 +01:00
|
|
|
compute_hash hash2, tmp1
|
2016-10-03 23:50:52 +02:00
|
|
|
|
2017-02-07 01:40:41 +01:00
|
|
|
add tmp3, 1
|
2017-11-29 01:19:53 +01:00
|
|
|
mov [hash_table + 2 * hash3], tmp3 %+ w
|
2016-10-03 23:50:52 +02:00
|
|
|
|
2017-02-07 01:40:41 +01:00
|
|
|
add dist_code2, 254
|
|
|
|
add dist_code2, len2
|
2016-10-03 23:50:52 +02:00
|
|
|
|
2017-11-29 01:19:53 +01:00
|
|
|
inc word [lit_len_hist + HIST_ELEM_SIZE*(len2 + 254)]
|
2016-10-03 23:50:52 +02:00
|
|
|
|
2017-02-07 01:40:41 +01:00
|
|
|
movnti dword [m_out_buf + 4], dist_code2 %+ d
|
|
|
|
add m_out_buf, 8
|
2016-10-03 23:50:52 +02:00
|
|
|
|
2017-02-07 01:40:41 +01:00
|
|
|
shr dist_code2, DIST_OFFSET
|
|
|
|
and dist_code2, 0x1F
|
2017-11-29 01:19:53 +01:00
|
|
|
inc word [dist_hist + HIST_ELEM_SIZE*dist_code2]
|
2016-10-03 23:50:52 +02:00
|
|
|
|
2017-11-30 21:07:22 +01:00
|
|
|
; hash = compute_hash(state->file_start + f_i) & HASH8K_HASH_MASK;
|
|
|
|
and hash %+ d, HASH8K_HASH_MASK
|
|
|
|
and hash2 %+ d, HASH8K_HASH_MASK
|
2016-10-03 23:50:52 +02:00
|
|
|
|
|
|
|
; continue
|
2017-02-07 01:40:41 +01:00
|
|
|
cmp f_i, file_length
|
2016-10-03 23:50:52 +02:00
|
|
|
jl loop2
|
|
|
|
jmp input_end
|
|
|
|
;; encode as dist/len
|
|
|
|
|
|
|
|
MARK __body_len_dist_huffman_ %+ ARCH
|
|
|
|
len_dist_huffman_pre:
|
|
|
|
bsf len, len
|
|
|
|
shr len, 3
|
|
|
|
|
|
|
|
len_dist_huffman:
|
|
|
|
dec f_i
|
2017-02-07 01:40:41 +01:00
|
|
|
;; Setup for updateing hash
|
|
|
|
lea tmp3, [f_i + 2] ; tmp3 <= k
|
|
|
|
|
2016-10-03 23:50:52 +02:00
|
|
|
neg dist
|
|
|
|
|
|
|
|
; get_dist_code(dist, &code2, &code_len2);
|
2017-02-07 01:40:41 +01:00
|
|
|
get_dist_icf_code dist, dist_code, tmp1
|
2016-10-03 23:50:52 +02:00
|
|
|
|
2017-02-07 01:40:41 +01:00
|
|
|
add file_start, f_i
|
|
|
|
MOVDQU xdata, [file_start + len]
|
|
|
|
mov curr_data2, [file_start + len]
|
|
|
|
mov curr_data, curr_data2
|
|
|
|
sub file_start, f_i
|
2016-10-03 23:50:52 +02:00
|
|
|
add f_i, len
|
2017-02-07 01:40:41 +01:00
|
|
|
; get_len_code(len, &code, &code_len);
|
|
|
|
lea len_code, [len + 254]
|
|
|
|
or dist_code, len_code
|
2016-10-03 23:50:52 +02:00
|
|
|
|
2017-11-29 01:19:53 +01:00
|
|
|
mov [hash_table + 2 * hash], tmp3 %+ w
|
2016-10-03 23:50:52 +02:00
|
|
|
add tmp3,1
|
2017-11-29 01:19:53 +01:00
|
|
|
mov [hash_table + 2 * hash2], tmp3 %+ w
|
2016-10-03 23:50:52 +02:00
|
|
|
|
|
|
|
compute_hash hash, curr_data
|
|
|
|
|
|
|
|
shr curr_data2, 8
|
|
|
|
compute_hash hash2, curr_data2
|
|
|
|
|
2017-11-29 01:19:53 +01:00
|
|
|
inc word [lit_len_hist + HIST_ELEM_SIZE*len_code]
|
2017-02-07 01:40:41 +01:00
|
|
|
|
|
|
|
movnti dword [m_out_buf], dist_code %+ d
|
|
|
|
add m_out_buf, 4
|
|
|
|
|
|
|
|
shr dist_code, DIST_OFFSET
|
|
|
|
and dist_code, 0x1F
|
2017-11-29 01:19:53 +01:00
|
|
|
inc word [dist_hist + HIST_ELEM_SIZE*dist_code]
|
2017-02-07 01:40:41 +01:00
|
|
|
|
2017-11-30 21:07:22 +01:00
|
|
|
; hash = compute_hash(state->file_start + f_i) & HASH8K_HASH_MASK;
|
|
|
|
and hash %+ d, HASH8K_HASH_MASK
|
|
|
|
and hash2 %+ d, HASH8K_HASH_MASK
|
2016-10-03 23:50:52 +02:00
|
|
|
|
|
|
|
; continue
|
2017-02-07 01:40:41 +01:00
|
|
|
cmp f_i, file_length
|
2016-10-03 23:50:52 +02:00
|
|
|
jl loop2
|
|
|
|
jmp input_end
|
|
|
|
|
|
|
|
MARK __body_write_lit_bits_ %+ ARCH
|
|
|
|
write_lit_bits:
|
|
|
|
MOVDQU xdata, [file_start + f_i + 1]
|
|
|
|
add f_i, 1
|
2017-02-07 01:40:41 +01:00
|
|
|
MOVQ curr_data, xdata
|
2017-01-31 23:15:29 +01:00
|
|
|
|
2017-11-29 01:19:53 +01:00
|
|
|
inc word [lit_len_hist + HIST_ELEM_SIZE*lit_code2]
|
2017-01-31 23:15:29 +01:00
|
|
|
|
2017-02-07 01:40:41 +01:00
|
|
|
shl lit_code2, DIST_OFFSET
|
|
|
|
lea lit_code, [lit_code + lit_code2 + (31 << DIST_OFFSET)]
|
2016-10-03 23:50:52 +02:00
|
|
|
|
2017-02-07 01:40:41 +01:00
|
|
|
movnti dword [m_out_buf], lit_code %+ d
|
|
|
|
add m_out_buf, 4
|
2016-10-03 23:50:52 +02:00
|
|
|
|
|
|
|
; continue
|
2017-02-07 01:40:41 +01:00
|
|
|
cmp f_i, file_length
|
2016-10-03 23:50:52 +02:00
|
|
|
jl loop2
|
|
|
|
|
|
|
|
input_end:
|
2017-11-30 17:58:30 +01:00
|
|
|
mov stream, [rsp + stream_offset]
|
2016-10-03 23:50:52 +02:00
|
|
|
mov tmp1, ZSTATE_FLUSH_READ_BUFFER
|
2017-02-07 01:40:41 +01:00
|
|
|
mov tmp2, ZSTATE_BODY
|
2017-07-20 22:26:26 +02:00
|
|
|
cmp word [stream + _end_of_stream], 0
|
2017-02-07 01:40:41 +01:00
|
|
|
cmovne tmp2, tmp1
|
2017-07-20 22:26:26 +02:00
|
|
|
cmp word [stream + _flush], _NO_FLUSH
|
2017-02-07 01:40:41 +01:00
|
|
|
|
|
|
|
cmovne tmp2, tmp1
|
|
|
|
mov dword [stream + _internal_state_state], tmp2 %+ d
|
2016-10-03 23:50:52 +02:00
|
|
|
jmp end
|
|
|
|
|
|
|
|
output_end:
|
2017-11-30 17:58:30 +01:00
|
|
|
mov stream, [rsp + stream_offset]
|
2016-10-03 23:50:52 +02:00
|
|
|
mov dword [stream + _internal_state_state], ZSTATE_CREATE_HDR
|
|
|
|
|
|
|
|
end:
|
|
|
|
;; update input buffer
|
2017-02-07 01:40:41 +01:00
|
|
|
add file_length, LA
|
2016-10-03 23:50:52 +02:00
|
|
|
mov [stream + _total_in], f_i %+ d
|
2017-10-27 19:43:46 +02:00
|
|
|
mov [stream + _internal_state_block_end], f_i %+ d
|
2016-10-03 23:50:52 +02:00
|
|
|
add file_start, f_i
|
|
|
|
mov [stream + _next_in], file_start
|
2017-02-07 01:40:41 +01:00
|
|
|
sub file_length, f_i
|
|
|
|
mov [stream + _avail_in], file_length %+ d
|
2016-10-03 23:50:52 +02:00
|
|
|
|
|
|
|
;; update output buffer
|
2017-11-30 17:58:30 +01:00
|
|
|
mov [level_buf + _icf_buf_next], m_out_buf
|
2016-10-03 23:50:52 +02:00
|
|
|
sub m_out_buf, [rsp + m_out_start]
|
2017-11-30 17:58:30 +01:00
|
|
|
sub [level_buf + _icf_buf_avail_out], m_out_buf %+ d
|
2016-10-03 23:50:52 +02:00
|
|
|
|
|
|
|
mov rbx, [rsp + gpr_save_mem_offset + 0*8]
|
|
|
|
mov rsi, [rsp + gpr_save_mem_offset + 1*8]
|
|
|
|
mov rdi, [rsp + gpr_save_mem_offset + 2*8]
|
|
|
|
mov rbp, [rsp + gpr_save_mem_offset + 3*8]
|
|
|
|
mov r12, [rsp + gpr_save_mem_offset + 4*8]
|
|
|
|
mov r13, [rsp + gpr_save_mem_offset + 5*8]
|
|
|
|
mov r14, [rsp + gpr_save_mem_offset + 6*8]
|
|
|
|
mov r15, [rsp + gpr_save_mem_offset + 7*8]
|
|
|
|
|
|
|
|
%ifndef ALIGN_STACK
|
|
|
|
add rsp, stack_size
|
|
|
|
%else
|
|
|
|
mov rsp, rbp
|
|
|
|
pop rbp
|
|
|
|
%endif
|
|
|
|
ret
|
|
|
|
|
|
|
|
MARK __body_compare_loops_ %+ ARCH
|
|
|
|
compare_loop:
|
|
|
|
lea tmp2, [tmp1 + dist - 1]
|
|
|
|
%if (COMPARE_TYPE == 1)
|
|
|
|
compare250 tmp1, tmp2, len, tmp3
|
|
|
|
%elif (COMPARE_TYPE == 2)
|
|
|
|
compare250_x tmp1, tmp2, len, tmp3, xtmp0, xtmp1
|
|
|
|
%elif (COMPARE_TYPE == 3)
|
|
|
|
compare250_y tmp1, tmp2, len, tmp3, ytmp0, ytmp1
|
|
|
|
%else
|
|
|
|
%error Unknown Compare type COMPARE_TYPE
|
|
|
|
% error
|
|
|
|
%endif
|
|
|
|
jmp len_dist_huffman
|
|
|
|
|
|
|
|
compare_loop2:
|
|
|
|
lea tmp2, [tmp1 + dist2]
|
|
|
|
add tmp1, 1
|
|
|
|
%if (COMPARE_TYPE == 1)
|
|
|
|
compare250 tmp1, tmp2, len2, tmp3
|
|
|
|
%elif (COMPARE_TYPE == 2)
|
|
|
|
compare250_x tmp1, tmp2, len2, tmp3, xtmp0, xtmp1
|
|
|
|
%elif (COMPARE_TYPE == 3)
|
|
|
|
compare250_y tmp1, tmp2, len2, tmp3, ytmp0, ytmp1
|
|
|
|
%else
|
|
|
|
%error Unknown Compare type COMPARE_TYPE
|
|
|
|
% error
|
|
|
|
%endif
|
2017-02-07 01:40:41 +01:00
|
|
|
movzx lit_code, curr_data %+ b
|
|
|
|
shr curr_data, 8
|
2017-11-29 01:19:53 +01:00
|
|
|
inc word [lit_len_hist + HIST_ELEM_SIZE*lit_code]
|
2016-10-03 23:50:52 +02:00
|
|
|
jmp len_dist_lit_huffman
|
|
|
|
|
|
|
|
MARK __write_first_byte_ %+ ARCH
|
|
|
|
write_first_byte:
|
|
|
|
cmp m_out_buf, [rsp + m_out_end]
|
|
|
|
ja output_end
|
|
|
|
|
2017-10-27 19:38:13 +02:00
|
|
|
mov byte [stream + _internal_state_has_hist], IGZIP_HIST
|
2016-10-03 23:50:52 +02:00
|
|
|
|
2017-11-29 01:19:53 +01:00
|
|
|
mov [hash_table + 2 * hash], f_i %+ w
|
2016-10-03 23:50:52 +02:00
|
|
|
|
|
|
|
mov hash, hash2
|
2017-11-30 17:58:30 +01:00
|
|
|
shr tmp2, 16
|
|
|
|
compute_hash hash2, tmp2
|
2016-10-03 23:50:52 +02:00
|
|
|
|
|
|
|
and curr_data, 0xff
|
2017-11-29 01:19:53 +01:00
|
|
|
inc word [lit_len_hist + HIST_ELEM_SIZE*curr_data]
|
2016-10-03 23:50:52 +02:00
|
|
|
or curr_data, LIT
|
|
|
|
|
2017-02-07 01:40:41 +01:00
|
|
|
movnti dword [m_out_buf], curr_data %+ d
|
|
|
|
add m_out_buf, 4
|
|
|
|
|
2016-10-03 23:50:52 +02:00
|
|
|
MOVDQU xdata, [file_start + f_i + 1]
|
|
|
|
add f_i, 1
|
|
|
|
mov curr_data, [file_start + f_i]
|
2017-11-30 21:07:22 +01:00
|
|
|
and hash %+ d, HASH8K_HASH_MASK
|
|
|
|
and hash2 %+ d, HASH8K_HASH_MASK
|
2016-10-03 23:50:52 +02:00
|
|
|
|
2017-02-07 01:40:41 +01:00
|
|
|
cmp f_i, file_length
|
2016-10-03 23:50:52 +02:00
|
|
|
jl loop2
|
|
|
|
jmp input_end
|