Add a pass to relax nullabilities of definitions

Aperta
#9,352 0 commenti 0 reazioni 1 assegnatario Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@stevenfontanella ci sta già lavorando.

Dal 5/11/2026.

  • #9353 di @stevenfontanella — aperta

Valutazione

Questa issue non è ancora stata valutata.

Descrizione

As a form of generalization, we can make all definitions nullable (e.g. globals, locals, function params, struct fields, arrays, tags), and insert ref.as_non_null as needed for cases that can't be relaxed (e.g. imported/exported functions, public structs). This transformation is valid since it only introduces ref.as_non_nulls that are no-ops.

The benefits of this are:

  • When --traps-never-happen is enabled, it allows us to remove the majority of ref.as_non_null instructions with --strip-refining-casts
  • It exposes more opportunities for locals to share a declaration group
  • It also exposes more opportunities for type merging by causing more function and struct types to be identical

TypeGeneralizing (which is WIP) may also relax nullability, however it would never 'overgeneralize' and allow something to be nullable that would require inserting ref.as_non_null. So this pass may still be useful even alongside TypeGeneralizing.

In a prototype of this pass, I found that this pass reduces the size of a Google Wasm binary by ~3 percent (both in gzipped and uncompressed size).


Implementation plan:

  • RelaxNullability for locals and params (#9349)
  • Relax private struct/array fields
  • Relax private functions even if they may be called indirectly
  • Handle multi-value returns
  • Double-check if relaxing return values is worth it
Lingua principale
WebAssembly
Stelle
8.7k
Fork
905
Merge medio
1g 23h
PR unite (30g)
86

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di WebAssembly/binaryen

Tutte le issue di WebAssembly/binaryen

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.