feat(decompress): move sequence decoder policy into Rust
Port sequence-decoder selection and offset-history policy into Rust. The Rust block decoder now handles short/long selection, offset-table analysis, history thresholds, and prefetch sequencing; C projects only the decoder mode and private context fields required by the ABI. Test Plan: - cargo test --manifest-path rust/Cargo.toml --all-targets -- --test-threads=1 - cargo clippy --manifest-path rust/Cargo.toml --all-targets -- -D warnings - make -B -C lib -j2 lib ZSTD_FORCE_DECOMPRESS_SEQUENCES_SHORT=1 ZSTD_FORCE_DECOMPRESS_SEQUENCES_LONG=0 - make -B -C lib -j2 lib ZSTD_FORCE_DECOMPRESS_SEQUENCES_SHORT=0 ZSTD_FORCE_DECOMPRESS_SEQUENCES_LONG=1 - make -B -C tests -j2 test-zstd
This commit is contained in:
@@ -20,6 +20,19 @@
|
||||
#include "zstd_decompress_internal.h"
|
||||
#include "zstd_decompress_block.h"
|
||||
|
||||
#if defined(ZSTD_FORCE_DECOMPRESS_SEQUENCES_SHORT) && \
|
||||
defined(ZSTD_FORCE_DECOMPRESS_SEQUENCES_LONG)
|
||||
#error "Cannot force the use of the short and the long ZSTD_decompressSequences variants!"
|
||||
#endif
|
||||
|
||||
#if defined(ZSTD_FORCE_DECOMPRESS_SEQUENCES_SHORT)
|
||||
#define ZSTD_RUST_SEQUENCE_DECODER_MODE 1
|
||||
#elif defined(ZSTD_FORCE_DECOMPRESS_SEQUENCES_LONG)
|
||||
#define ZSTD_RUST_SEQUENCE_DECODER_MODE 2
|
||||
#else
|
||||
#define ZSTD_RUST_SEQUENCE_DECODER_MODE 0
|
||||
#endif
|
||||
|
||||
typedef char ZSTD_rust_block_seq_symbol_layout[(sizeof(ZSTD_seqSymbol) == 8) ? 1 : -1];
|
||||
typedef char ZSTD_rust_block_entropy_rep_offset[
|
||||
(offsetof(ZSTD_entropyDTables_t, rep) == 26652) ? 1 : -1];
|
||||
@@ -53,6 +66,7 @@ typedef struct {
|
||||
ZSTD_litLocation_e* litBufferLocation;
|
||||
BYTE* litExtraBuffer;
|
||||
size_t litExtraBufferSize;
|
||||
int sequenceDecoderMode;
|
||||
} ZSTD_rustBlockCtx;
|
||||
|
||||
static ZSTD_rustBlockCtx ZSTD_rust_block_context(ZSTD_DCtx* dctx)
|
||||
@@ -84,6 +98,7 @@ static ZSTD_rustBlockCtx ZSTD_rust_block_context(ZSTD_DCtx* dctx)
|
||||
ctx.litBufferLocation = &dctx->litBufferLocation;
|
||||
ctx.litExtraBuffer = dctx->litExtraBuffer;
|
||||
ctx.litExtraBufferSize = ZSTD_LITBUFFEREXTRASIZE;
|
||||
ctx.sequenceDecoderMode = ZSTD_RUST_SEQUENCE_DECODER_MODE;
|
||||
return ctx;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user