> Is there an explanation somewhere about how Lua decides which
> registers to use during codegen?
Basically it gets the next available free register. Because Lua does
few optimizations on its opcodes, the use of registers most of the
time follows a stack discipline. Moreover, as each function can use
as much as 250 free registers, reducing register use is not a concern.