Add a pass to relax nullabilities of definitions

Aberta
#9,352 0 comentários 0 reações 1 responsável Ver no GitHub

Mantenedores costumam responder em até 1 dia

@stevenfontanella já está trabalhando nisso.

Desde 5/11/2026.

  • #9353 de @stevenfontanella — aberto

Avaliação

Esta issue ainda não foi avaliada.

Descrição

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
Linguagem predominante
WebAssembly
Estrelas
8.7k
Forks
905
Merge médio
1d 23h
PRs com merge (30d)
86

Preparar o ambiente

Primeiros passos

  1. Leia a issue inteira e depois o guia de contribuição do projeto.
  2. Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
  3. Faça um fork do repositório e trabalhe em uma branch.
  4. Abra um pull request que referencie o número da issue.

Mais de WebAssembly/binaryen

Todas as issues de WebAssembly/binaryen

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.