Add a pass to relax nullabilities of definitions
維護者通常 1 天內回覆
評估
這個 Issue 還沒有評估資料。
描述
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
- 主要語言
- WebAssembly
- 星號
- 8.7k
- 分支
- 905
- 平均合併
- 1 天 23 小時
- 30 天內合併 PR
- 86
環境準備
- 沒有 Dockerfile 或 Docker Compose 檔案
- 沒有 Pull Request 範本
- 閱讀貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
WebAssembly/binaryen 的其他 Issue
-
難度 1/5 1 小時以內 新手友好度 88/100
WebAssembly/binaryen#9135 · 1 則留言 ·
維護者通常 1 天內回覆
-
難度 2/5 半天 新手友好度 76/100
WebAssembly/binaryen#9018 · 3 則留言 ·
維護者通常 1 天內回覆
-
難度 3/5 1-2 天 新手友好度 68/100
WebAssembly/binaryen#9366 ·
維護者通常 1 天內回覆
-
難度 3/5 1-2 天 新手友好度 68/100
WebAssembly/binaryen#9365 ·
維護者通常 1 天內回覆
-
難度 4/5 3-5 天 新手友好度 45/100
WebAssembly/binaryen#9307 · 2 則留言 ·
維護者通常 1 天內回覆