matthargett opened PR #13910 from rebeckerspecialties:call-indirect-null-elision to bytecodealliance:main:
Stacked on #13445 and #13909 — only the last commit here is new. It builds on the sig-check PR because the null-slot analysis extends the same
Module::static_funcref_imageproof, and the elision is wired through the sameStaticMatchpath.What this does
After the table-entry load,
call_indirectchecks that the loaded function reference isn't null before calling through it. This PR drops that check when the table's static image proves no in-bounds slot can ever be null.The proof lives in a new
Module::table_never_contains_nullhelper and requires, on top of the static image from the sig-check PR (immutable table, fully precomputed contents, no element segments deferred to instantiation):
- the image covers every slot of the table's size — slots past the end of the image are null at runtime, so an image shorter than the table disqualifies it (the table's size is fixed here, since a static image implies the table can never grow); and
- no covered slot is null.
The bounds check is unaffected: an out-of-bounds index still traps as before.
Where this matters
Native backends with signals-based traps already get the null check nearly for free — it's trap metadata on the code-pointer load, not an extra instruction — so this mostly changes configurations that emit explicit checks: interpreters (Pulley, the motivating case) and
signals_based_traps(false)embeddings, where it removes a dispatched branch per call.Tests
- new disas test: fully-covered uniform table, dispatch path reduced to bounds check + lazy-init + load + call, no null-handling block
- runtime
*.wastcoverage for the shapes that must keep the check: a uniform table with a null hole, element segments covering only a prefix of the table, a deferred null write over a slot the static image filled, andtable.setof null followed by a dispatch that must trap
matthargett updated PR #13910.
github-actions[bot] added the label wasmtime:api on PR #13910.
:cross_mark: matthargett closed without merge PR #13910.
matthargett commented on PR #13910:
Per the discussion on #13445 , this work stream (and the product goal it supports) isn't a good match for the wasmtime project. Closing.
Last updated: Jul 29 2026 at 05:03 UTC