feat(compress): move window lifecycle predicates into Rust
Move shared window initialization and the empty-window and external-dictionary predicates behind the Rust compression seam. Rust now owns the projected five-field lifecycle state, while C retains the containing window and its overflow-correction counter. Test Plan: - ulimit -v 41943040; CARGO_BUILD_JOBS=1; cargo test --manifest-path rust/Cargo.toml - ulimit -v 41943040; CARGO_BUILD_JOBS=1; cargo clippy --manifest-path rust/Cargo.toml --all-targets -- -D warnings - ulimit -v 41943040; make -B -C programs -j1 zstd - ulimit -v 41943040; make -C tests -j1 test-zstream ZSTREAM_TESTTIME=-T1s
This commit is contained in:
@@ -669,6 +669,10 @@ typedef char ZSTD_rust_window_update_state_layout[
|
||||
&& offsetof(ZSTD_rust_windowUpdateState, dictLimit) == 3 * sizeof(void*)
|
||||
&& offsetof(ZSTD_rust_windowUpdateState, lowLimit) == 3 * sizeof(void*) + sizeof(U32)
|
||||
&& sizeof(ZSTD_rust_windowUpdateState) == 3 * sizeof(void*) + 2 * sizeof(U32)) ? 1 : -1];
|
||||
void ZSTD_rust_windowInit(ZSTD_rust_windowUpdateState* state);
|
||||
U32 ZSTD_rust_windowIsEmpty(const void* nextSrc, const void* base,
|
||||
U32 dictLimit, U32 lowLimit);
|
||||
U32 ZSTD_rust_windowHasExtDict(U32 dictLimit, U32 lowLimit);
|
||||
U32 ZSTD_rust_windowUpdate(ZSTD_rust_windowUpdateState* state,
|
||||
const void* src, size_t srcSize,
|
||||
int forceNonContiguous);
|
||||
@@ -1046,9 +1050,8 @@ MEM_STATIC U64 ZSTD_rollingHash_rotate(U64 hash, BYTE toRemove, BYTE toAdd, U64
|
||||
|
||||
MEM_STATIC U32 ZSTD_window_isEmpty(ZSTD_window_t const window)
|
||||
{
|
||||
return window.dictLimit == ZSTD_WINDOW_START_INDEX &&
|
||||
window.lowLimit == ZSTD_WINDOW_START_INDEX &&
|
||||
(window.nextSrc - window.base) == ZSTD_WINDOW_START_INDEX;
|
||||
return ZSTD_rust_windowIsEmpty(window.nextSrc, window.base,
|
||||
window.dictLimit, window.lowLimit);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1057,7 +1060,7 @@ MEM_STATIC U32 ZSTD_window_isEmpty(ZSTD_window_t const window)
|
||||
*/
|
||||
MEM_STATIC U32 ZSTD_window_hasExtDict(ZSTD_window_t const window)
|
||||
{
|
||||
return window.lowLimit < window.dictLimit;
|
||||
return ZSTD_rust_windowHasExtDict(window.dictLimit, window.lowLimit);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1305,13 +1308,13 @@ ZSTD_checkDictValidity(const ZSTD_window_t* window,
|
||||
}
|
||||
|
||||
MEM_STATIC void ZSTD_window_init(ZSTD_window_t* window) {
|
||||
ZSTD_memset(window, 0, sizeof(*window));
|
||||
window->base = (BYTE const*)" ";
|
||||
window->dictBase = (BYTE const*)" ";
|
||||
ZSTD_STATIC_ASSERT(ZSTD_DUBT_UNSORTED_MARK < ZSTD_WINDOW_START_INDEX); /* Start above ZSTD_DUBT_UNSORTED_MARK */
|
||||
window->dictLimit = ZSTD_WINDOW_START_INDEX; /* start from >0, so that 1st position is valid */
|
||||
window->lowLimit = ZSTD_WINDOW_START_INDEX; /* it ensures first and later CCtx usages compress the same */
|
||||
window->nextSrc = window->base + ZSTD_WINDOW_START_INDEX; /* see issue #1241 */
|
||||
ZSTD_rust_windowUpdateState state;
|
||||
ZSTD_rust_windowInit(&state);
|
||||
window->nextSrc = (BYTE const*)state.nextSrc;
|
||||
window->base = (BYTE const*)state.base;
|
||||
window->dictBase = (BYTE const*)state.dictBase;
|
||||
window->dictLimit = state.dictLimit;
|
||||
window->lowLimit = state.lowLimit;
|
||||
window->nbOverflowCorrections = 0;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user