Add a pass to relax nullabilities of definitions

Abierto
#9,352 0 comentarios 0 reacciones 1 asignado Ver en GitHub

Los mantenedores suelen responder en 1 día

@stevenfontanella ya está trabajando en esto.

Desde el 5/11/2026.

  • #9353 de @stevenfontanella — abierto

Evaluación

Este issue todavía no se ha evaluado.

Descripción

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
Lenguaje dominante
WebAssembly
Estrellas
8.7k
Forks
905
Merge medio
1 d 23 h
PR fusionados (30 d)
86

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de WebAssembly/binaryen

Todos los issues de WebAssembly/binaryen

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.