Skip to content

Inlining

Dibyendu Majumdar edited this page Jul 7, 2020 · 5 revisions

Some random thoughts about inlining.

What should be inlined?

Function that has no upvalues ... ? That doesn't take varargs. Total number of locals must be inside a range

We need to be able to establish that the function cannot be replaced. So it must not be a global. It needs to be a local function in the same chunk. It also cannot have escaped (i.e. referenced as up-value).

TODO so what do we know at a call-site?

How to do it

Maybe at AST level. Duplicate the body of the function to the call-site. Assign args. Assign return values.

Pre-requisites

Variables and blocks must still make sense after the inlining.

Clone this wiki locally