feat(compress): move match-state invalidation leaf into Rust
Route match-state invalidation through a Rust leaf. C still computes the private window pointer difference and passes the opaque dictionary-state pointer, while Rust preserves the window-limit, next-index, dictionary, optimal-parser, and dictionary-match-state reset order. Add a focused test for all invalidated fields and use the concrete C pointer type at the ABI boundary to avoid strict-aliasing warnings. Test Plan: - cargo fmt --manifest-path rust/Cargo.toml -- --check - ulimit -v 41943040 && CARGO_BUILD_JOBS=1 cargo clippy --manifest-path rust/Cargo.toml --all-targets -- -D warnings - ulimit -v 41943040 && CARGO_BUILD_JOBS=1 cargo test --manifest-path rust/Cargo.toml zstd_compress::tests::invalidate_match_state -- --nocapture - ulimit -v 41943040 && make -j1 - ulimit -v 41943040 && make -j1 -C tests test-fuzzer FUZZERTEST=-T3s FUZZER_FLAGS=--no-big-tests
This commit is contained in:
@@ -1722,6 +1722,10 @@ size_t ZSTD_rust_buildBlockEntropyStats(
|
||||
void* workspace, size_t wkspSize);
|
||||
void ZSTD_rust_resetCompressedBlockState(ZSTD_compressedBlockState_t* bs);
|
||||
void ZSTD_rust_invalidateRepCodes(U32 rep[ZSTD_REP_NUM]);
|
||||
void ZSTD_rust_invalidateMatchState(
|
||||
size_t endT, U32* lowLimit, U32* dictLimit,
|
||||
U32* nextToUpdate, U32* loadedDictEnd, U32* litLengthSum,
|
||||
const ZSTD_MatchState_t** dictMatchState);
|
||||
typedef char ZSTD_rust_invalidate_rep_count[(ZSTD_REP_NUM == 3) ? 1 : -1];
|
||||
void ZSTD_rust_confirmRepcodesAndEntropyTables(
|
||||
ZSTD_compressedBlockState_t** prevCBlock,
|
||||
@@ -3718,21 +3722,6 @@ void ZSTD_reset_compressedBlockState(ZSTD_compressedBlockState_t* bs)
|
||||
ZSTD_rust_resetCompressedBlockState(bs);
|
||||
}
|
||||
|
||||
/*! ZSTD_invalidateMatchState()
|
||||
* Invalidate all the matches in the match finder tables.
|
||||
* Requires nextSrc and base to be set (can be NULL).
|
||||
*/
|
||||
static void ZSTD_invalidateMatchState(ZSTD_MatchState_t* ms)
|
||||
{
|
||||
ZSTD_rust_windowClear((size_t)(ms->window.nextSrc - ms->window.base),
|
||||
&ms->window.lowLimit, &ms->window.dictLimit);
|
||||
|
||||
ms->nextToUpdate = ms->window.dictLimit;
|
||||
ms->loadedDictEnd = 0;
|
||||
ms->opt.litLengthSum = 0; /* force reset of btopt stats */
|
||||
ms->dictMatchState = NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Controls, for this matchState reset, whether the tables need to be cleared /
|
||||
* prepared for the coming compression (ZSTDcrp_makeClean), or whether the
|
||||
@@ -3807,7 +3796,13 @@ static void ZSTD_rust_resetMatchState_invalidate(void* opaque)
|
||||
{
|
||||
ZSTD_rust_resetMatchStateContext* const context =
|
||||
(ZSTD_rust_resetMatchStateContext*)opaque;
|
||||
ZSTD_invalidateMatchState(context->ms);
|
||||
ZSTD_MatchState_t* const ms = context->ms;
|
||||
ZSTD_rust_invalidateMatchState(
|
||||
(size_t)(ms->window.nextSrc - ms->window.base),
|
||||
&ms->window.lowLimit, &ms->window.dictLimit,
|
||||
&ms->nextToUpdate, &ms->loadedDictEnd,
|
||||
&ms->opt.litLengthSum,
|
||||
&ms->dictMatchState);
|
||||
}
|
||||
|
||||
static void ZSTD_rust_resetMatchState_clearTables(void* opaque)
|
||||
|
||||
Reference in New Issue
Block a user