Inlining
What is planned and open about the WebAssembly backend's inliner
This page keeps what is planned and open about the inliner of the WebAssembly backend. How it works today is in Inlining in the Deep dives section, and what it means for users in Inlining. It is part of the compilation workstream.
Plan
- Tune the size limits (
sizeLimit,handlerLimit,copyLimit) against the generated-code benchmarks. - Lower only what a program reaches (#1848). Inlining goes over only what the start reaches, but lowering lowers every definition that is not generic, and emits each once to find out whether it can be, which is most of hello world’s emit. Lowering on demand from the start would mean a definition the program never reaches doesn’t report that it can’t be compiled, which is to be decided.
- Later: inlining across modules, and the other builders and handlers in the standard library.
Open questions
- The size limit, and whether a function can ask to be inlined, or not, with an attribute.
- Code size. Aggressive inlining grows the module. A function stops taking more at 4,000 nodes, and a handler
called more than once is held to
handlerLimit; a budget relative to the function’s own size may do better. Nodes undercount some code: anInterpolateis one node however much WAT it writes. - Across modules. A function from another module, including the standard library, can only be inlined if its core IR is available where it is called. That holds while a program compiles as one module, but not once packages compile separately.