andrewgazelka opened PR #14453 from andrewgazelka:clear-exception-tables-in-dfg-clear to bytecodealliance:main:
Fixes a missing reset in
DataFlowGraph::clear: it clearsinsts,blocks,signatures,ext_funcs,
constants,immediates,jump_tables,mem_flagsandalias_regions, but notexception_tables.Why it matters:
Compiler::function_compilerincrates/cranelift/src/compiler.rspools aCompilerContextper
thread and callscodegen_context.clear()before reusing it.FunctionStencil(and so itsdfg) is part of the
incremental compilation cache key, so a reused context that still holds an earlier function's exception tables
produces a different key for the same function. WithConfig::enable_incremental_compilation, the key of a function
therefore depends on which functions that pooled context happened to compile before it (and on whether they were cache
hits or compiles).What I saw (wasmtime 48.0.1,
Strategy::Cranelift,wasm_threads,shared_memory,epoch_interruption; this
code is unchanged onmainat c21f5ed): compiling the same 450 KB module twice through one incremental cache kept
missing on 100 to 200 of about 670 lookups instead of hitting all of them, and for two modules with byte-identical
function bodies about 60 functions missed. Clearingexception_tablesafter the pooled context'sclear()(a one-line
change infunction_compiler, which is what I tested end to end) made identical recompiles miss 0 lookups. A 60-function
WAT module with imports, exports andcall_indirectreproduces it too (25 of 124 lookups missed on an identical
recompile). I bisected by resetting parts of the pooled context: the translator, the ABI, the validator allocations and
the debug slot made no difference; resettingfunc.stencildid.I did not run the end-to-end cache measurement against
mainitself, only against 48.0.1; the change here is the
DataFlowGraph::clearfix plus a unit test that fails without it.Open question: I don't know which kind of function creates the leftover exception tables in wasmtime's pipeline; I
only know they accumulate. If you'd rather have a test at the wasmtime level (identical recompile through
enable_incremental_compilationmakes no new cache inserts), I can add one.
andrewgazelka requested wasmtime-compiler-reviewers for a review on PR #14453.
andrewgazelka requested cfallin for a review on PR #14453.
github-actions[bot] added the label cranelift on PR #14453.
:thumbs_up: cfallin submitted PR review:
Thanks! Fix LGTM, just a thought on the test below.
:speech_balloon: cfallin created PR review comment:
This is oddly specific to just one entity; perhaps we should have a test that checks that
clearclears all entities instead?It might be easiest to do this by using the CLIF printer to print and verifying that the function is trivial (
function %u0:0 {}plus whatever other details e.g. callconv are there by default).
Last updated: Oct 11 2026 at 04:10 UTC