Stream: git-wasmtime

Topic: wasmtime / PR #14453 cranelift: clear exception_tables in...


view this post on Zulip Wasmtime GitHub notifications bot (Sep 30 2026 at 11:28):

andrewgazelka opened PR #14453 from andrewgazelka:clear-exception-tables-in-dfg-clear to bytecodealliance:main:

Fixes a missing reset in DataFlowGraph::clear: it clears insts, blocks, signatures, ext_funcs,
constants, immediates, jump_tables, mem_flags and alias_regions, but not exception_tables.

Why it matters: Compiler::function_compiler in crates/cranelift/src/compiler.rs pools a CompilerContext per
thread and calls codegen_context.clear() before reusing it. FunctionStencil (and so its dfg) 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. With Config::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 on main at 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. Clearing exception_tables after the pooled context's clear() (a one-line
change in function_compiler, which is what I tested end to end) made identical recompiles miss 0 lookups. A 60-function
WAT module with imports, exports and call_indirect reproduces 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; resetting func.stencil did.

I did not run the end-to-end cache measurement against main itself, only against 48.0.1; the change here is the
DataFlowGraph::clear fix 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_compilation makes no new cache inserts), I can add one.

view this post on Zulip Wasmtime GitHub notifications bot (Sep 30 2026 at 11:28):

andrewgazelka requested wasmtime-compiler-reviewers for a review on PR #14453.

view this post on Zulip Wasmtime GitHub notifications bot (Sep 30 2026 at 11:28):

andrewgazelka requested cfallin for a review on PR #14453.

view this post on Zulip Wasmtime GitHub notifications bot (Sep 30 2026 at 13:00):

github-actions[bot] added the label cranelift on PR #14453.

view this post on Zulip Wasmtime GitHub notifications bot (Sep 30 2026 at 15:08):

:thumbs_up: cfallin submitted PR review:

Thanks! Fix LGTM, just a thought on the test below.

view this post on Zulip Wasmtime GitHub notifications bot (Sep 30 2026 at 15:08):

:speech_balloon: cfallin created PR review comment:

This is oddly specific to just one entity; perhaps we should have a test that checks that clear clears 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