feat(compress): project continue overflow correction into Rust
Pass the existing overflow-correction projection directly through the compressContinue ABI so Rust owns the correction decision and ordering while C retains only the table/workspace callbacks. Remove the redundant C forwarding adapter and keep the stack projection valid for synchronous dispatch. Test Plan: - ulimit -v 41943040; CARGO_BUILD_JOBS=1 cargo fmt --all -- --check - ulimit -v 41943040; CARGO_BUILD_JOBS=1 cargo test --lib zstd_compress::tests::compress_continue -- --nocapture - ulimit -v 41943040; CARGO_BUILD_JOBS=1 cargo clippy --all-targets -- -D warnings - ulimit -v 41943040; CARGO_BUILD_JOBS=1 cargo test - ulimit -v 41943040; make -j1 - ulimit -v 41943040; make -j1 -C tests test-zstream ZSTREAM_TESTTIME=-T2s - ulimit -v 41943040; make -j1 -C tests test-fuzzer FUZZERTEST=-T3s FUZZER_FLAGS=--no-big-tests
This commit is contained in:
@@ -888,9 +888,6 @@ typedef struct {
|
||||
} ZSTD_rust_compressContinueWindowState;
|
||||
typedef char ZSTD_rust_compress_continue_window_state_layout[
|
||||
(sizeof(ZSTD_rust_compressContinueWindowState) == 7 * sizeof(void*)) ? 1 : -1];
|
||||
typedef void (*ZSTD_rust_compressContinueWindow_f)(void* context,
|
||||
const void* src,
|
||||
size_t srcSize);
|
||||
typedef size_t (*ZSTD_rust_compressContinueBlock_f)(void* context,
|
||||
void* dst,
|
||||
size_t dstCapacity,
|
||||
@@ -901,7 +898,7 @@ typedef struct {
|
||||
void* callbackContext;
|
||||
ZSTD_rust_compressContinueWindowState* windowState;
|
||||
ZSTD_rust_compressContinueWindowState* ldmWindowState;
|
||||
ZSTD_rust_compressContinueWindow_f correctOverflow;
|
||||
const ZSTD_rust_overflowCorrectState* overflowState;
|
||||
ZSTD_rust_compressContinueBlock_f compressFrameChunk;
|
||||
ZSTD_rust_compressContinueBlock_f compressBlock;
|
||||
ZSTD_compressionStage_e* stage;
|
||||
@@ -927,7 +924,7 @@ typedef char ZSTD_rust_compress_continue_state_layout[
|
||||
(offsetof(ZSTD_rust_compressContinueState, callbackContext) == 0
|
||||
&& offsetof(ZSTD_rust_compressContinueState, windowState) == sizeof(void*)
|
||||
&& offsetof(ZSTD_rust_compressContinueState, ldmWindowState) == 2 * sizeof(void*)
|
||||
&& offsetof(ZSTD_rust_compressContinueState, correctOverflow) == 3 * sizeof(void*)
|
||||
&& offsetof(ZSTD_rust_compressContinueState, overflowState) == 3 * sizeof(void*)
|
||||
&& offsetof(ZSTD_rust_compressContinueState, compressFrameChunk) == 4 * sizeof(void*)
|
||||
&& offsetof(ZSTD_rust_compressContinueState, compressBlock) == 5 * sizeof(void*)
|
||||
&& offsetof(ZSTD_rust_compressContinueState, stage) == 6 * sizeof(void*)
|
||||
@@ -5618,17 +5615,6 @@ static size_t ZSTD_compress_frameChunk(ZSTD_CCtx* cctx,
|
||||
}
|
||||
|
||||
|
||||
static void ZSTD_rust_compressContinue_correctOverflow(
|
||||
void* context, const void* src, size_t srcSize)
|
||||
{
|
||||
ZSTD_CCtx* const cctx = (ZSTD_CCtx*)context;
|
||||
ZSTD_MatchState_t* const ms = &cctx->blockState.matchState;
|
||||
|
||||
ZSTD_overflowCorrectIfNeeded(
|
||||
ms, &cctx->workspace, &cctx->appliedParams,
|
||||
src, (const BYTE*)src + srcSize);
|
||||
}
|
||||
|
||||
static size_t ZSTD_rust_compressContinue_frameChunk(
|
||||
void* context, void* dst, size_t dstCapacity,
|
||||
const void* src, size_t srcSize, U32 lastFrameChunk)
|
||||
@@ -5657,6 +5643,8 @@ static size_t ZSTD_compressContinue_dispatch(
|
||||
ZSTD_rust_compressContinueState state;
|
||||
ZSTD_rust_compressContinueWindowState windowState;
|
||||
ZSTD_rust_compressContinueWindowState ldmWindowState;
|
||||
ZSTD_rust_overflowCorrectContext overflowContext;
|
||||
ZSTD_rust_overflowCorrectState overflowState;
|
||||
ZSTD_MatchState_t* const ms = &cctx->blockState.matchState;
|
||||
ZSTD_window_t* const window = &ms->window;
|
||||
ZSTD_window_t* const ldmWindow = &cctx->ldmState.window;
|
||||
@@ -5676,10 +5664,23 @@ static size_t ZSTD_compressContinue_dispatch(
|
||||
ldmWindowState.forceNonContiguous = NULL;
|
||||
ldmWindowState.nextToUpdate = NULL;
|
||||
|
||||
overflowContext.matchState = ms;
|
||||
overflowContext.workspace = &cctx->workspace;
|
||||
overflowContext.params = &cctx->appliedParams;
|
||||
overflowState.callbackContext = &overflowContext;
|
||||
overflowState.nextToUpdate = &ms->nextToUpdate;
|
||||
overflowState.needCorrection = ZSTD_rust_overflowCorrect_need;
|
||||
overflowState.correctOverflow = ZSTD_rust_overflowCorrect_correct;
|
||||
overflowState.markTablesDirty = ZSTD_rust_overflowCorrect_markTablesDirty;
|
||||
overflowState.reduceIndex = ZSTD_rust_overflowCorrect_reduceIndex;
|
||||
overflowState.markTablesClean = ZSTD_rust_overflowCorrect_markTablesClean;
|
||||
overflowState.loadedDictEnd = &ms->loadedDictEnd;
|
||||
overflowState.dictMatchState = &ms->dictMatchState;
|
||||
|
||||
state.callbackContext = cctx;
|
||||
state.windowState = &windowState;
|
||||
state.ldmWindowState = &ldmWindowState;
|
||||
state.correctOverflow = ZSTD_rust_compressContinue_correctOverflow;
|
||||
state.overflowState = &overflowState;
|
||||
state.compressFrameChunk = ZSTD_rust_compressContinue_frameChunk;
|
||||
state.compressBlock = ZSTD_rust_compressContinue_block;
|
||||
state.stage = &cctx->stage;
|
||||
|
||||
Reference in New Issue
Block a user