Skip to content

Inlining

Dibyendu Majumdar edited this page Jul 11, 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. We also need to ensure that the up-value representing the function has no updates - i.e. up-value / and local are both never re-assigned

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