lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


IIRC lua allocates registers on a per function basis. That means the
registers aren't really global like on a CPU. On the other hand, the
lua bytecode instructions act on registers as opposed to data pushed
onto a stack (JVM uses stack machine). Therefore, the code generator
views registers as properties of functions, which is what we see here:
https://github.com/lua/lua/blob/6b01b6cf6a1631f7ca2ce527a5c355517095c209/lparser.h#L135.

On Sat, Mar 17, 2018 at 5:36 AM, Dibyendu Majumdar
<mobile@majumdar.org.uk> wrote:
> An aspect of the Lua's code generator I don't fully understand are the
> rules around register allocation. It appears that code generator does
> not keep a list of free registers, instead the registers are treated
> as a stack, so you have (in what cases?) free registers in stack
> order.
>
> My question is - suppose instead I maintain free list of registers and
> not worry about stack order - are there any gotchas with that?
>
> Thanks and Regards
> Dibyendu
>