feat(compress): move deprecated block adapter into Rust
Project the existing sequence-store and block-internal states through the continue context so Rust builds deprecated blocks and enters the migrated block leaf directly. Remove the C forwarding adapter while retaining the private matchfinder and CCtx callbacks behind the existing build projection. 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:
@@ -921,6 +921,9 @@ size_t ZSTD_rust_compressContinue(
|
||||
void* dst, size_t dstCapacity,
|
||||
const void* src, size_t srcSize,
|
||||
U32 frame, U32 lastFrameChunk);
|
||||
size_t ZSTD_rust_compressContinueBlock(
|
||||
void* context, void* dst, size_t dstCapacity,
|
||||
const void* src, size_t srcSize, U32 lastFrameChunk);
|
||||
typedef char ZSTD_rust_compress_continue_state_layout[
|
||||
(offsetof(ZSTD_rust_compressContinueState, callbackContext) == 0
|
||||
&& offsetof(ZSTD_rust_compressContinueState, windowState) == sizeof(void*)
|
||||
@@ -5422,6 +5425,13 @@ typedef struct {
|
||||
const ZSTD_CCtx_params* params;
|
||||
} ZSTD_rust_overflowCorrectContext;
|
||||
|
||||
typedef struct {
|
||||
const ZSTD_rust_buildSeqStoreState* buildSeqStoreState;
|
||||
const ZSTD_rust_blockInternalState* blockInternalState;
|
||||
} ZSTD_rust_compressContinueBlockState;
|
||||
typedef char ZSTD_rust_compress_continue_block_state_layout[
|
||||
(sizeof(ZSTD_rust_compressContinueBlockState) == 2 * sizeof(void*)) ? 1 : -1];
|
||||
|
||||
/* All continue entry points use this synchronous stack projection. The
|
||||
* private CCtx and match-state layouts remain behind the direct field
|
||||
* projections and context-sensitive leaf callbacks. */
|
||||
@@ -5434,6 +5444,9 @@ typedef struct {
|
||||
ZSTD_rust_frameChunkClampState frameChunkClampState;
|
||||
ZSTD_rust_overflowCorrectContext overflowContext;
|
||||
ZSTD_rust_overflowCorrectState overflowState;
|
||||
ZSTD_rust_buildSeqStoreState buildSeqStoreState;
|
||||
ZSTD_rust_blockInternalState blockInternalState;
|
||||
ZSTD_rust_compressContinueBlockState blockState;
|
||||
} ZSTD_rust_compressContinueContext;
|
||||
|
||||
static int ZSTD_rust_overflowCorrect_need(
|
||||
@@ -5573,16 +5586,6 @@ static size_t ZSTD_rust_frameChunk_compressInternal(
|
||||
1 /* frame */);
|
||||
}
|
||||
|
||||
static size_t ZSTD_rust_compressContinue_block(
|
||||
void* context, void* dst, size_t dstCapacity,
|
||||
const void* src, size_t srcSize, U32 lastFrameChunk)
|
||||
{
|
||||
(void)lastFrameChunk;
|
||||
return ZSTD_compressBlock_internal(
|
||||
(ZSTD_CCtx*)context, dst, dstCapacity, src, srcSize,
|
||||
0 /* frame */);
|
||||
}
|
||||
|
||||
static void ZSTD_compressContinue_prepare(
|
||||
ZSTD_CCtx* cctx, size_t blockSizeMax, int checkBlockSize,
|
||||
ZSTD_rust_compressContinueContext* context)
|
||||
@@ -5633,6 +5636,21 @@ static void ZSTD_compressContinue_prepare(
|
||||
context->frameChunkState.compressSplit = ZSTD_rust_frameChunk_compressSplit;
|
||||
context->frameChunkState.compressInternal = ZSTD_rust_frameChunk_compressInternal;
|
||||
|
||||
ZSTD_initBuildSeqStoreState(cctx, &context->buildSeqStoreState);
|
||||
context->blockInternalState.seqStore = &cctx->seqStore;
|
||||
context->blockInternalState.prevCBlock = &cctx->blockState.prevCBlock;
|
||||
context->blockInternalState.nextCBlock = &cctx->blockState.nextCBlock;
|
||||
context->blockInternalState.tmpWorkspace = cctx->tmpWorkspace;
|
||||
context->blockInternalState.tmpWkspSize = cctx->tmpWkspSize;
|
||||
context->blockInternalState.seqCollector = &cctx->seqCollector;
|
||||
context->blockInternalState.strategy = (int)cctx->appliedParams.cParams.strategy;
|
||||
context->blockInternalState.disableLiteralCompression =
|
||||
ZSTD_literalsCompressionIsDisabled(&cctx->appliedParams);
|
||||
context->blockInternalState.bmi2 = cctx->bmi2;
|
||||
context->blockInternalState.isFirstBlock = cctx->isFirstBlock;
|
||||
context->blockState.buildSeqStoreState = &context->buildSeqStoreState;
|
||||
context->blockState.blockInternalState = &context->blockInternalState;
|
||||
|
||||
context->overflowContext.matchState = ms;
|
||||
context->overflowContext.workspace = &cctx->workspace;
|
||||
context->overflowContext.params = &cctx->appliedParams;
|
||||
@@ -5646,12 +5664,12 @@ static void ZSTD_compressContinue_prepare(
|
||||
context->overflowState.loadedDictEnd = &ms->loadedDictEnd;
|
||||
context->overflowState.dictMatchState = &ms->dictMatchState;
|
||||
|
||||
context->state.callbackContext = cctx;
|
||||
context->state.callbackContext = &context->blockState;
|
||||
context->state.windowState = &context->windowState;
|
||||
context->state.ldmWindowState = &context->ldmWindowState;
|
||||
context->state.overflowState = &context->overflowState;
|
||||
context->state.frameChunkState = &context->frameChunkState;
|
||||
context->state.compressBlock = ZSTD_rust_compressContinue_block;
|
||||
context->state.compressBlock = ZSTD_rust_compressContinueBlock;
|
||||
context->state.stage = &cctx->stage;
|
||||
context->state.consumedSrcSize = &cctx->consumedSrcSize;
|
||||
context->state.producedCSize = &cctx->producedCSize;
|
||||
|
||||
Reference in New Issue
Block a user