lua-users home
lua-l archive

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


On Sat, 16 Jan 2010 00:45:52 +0100
Richard Hundt <richardhundt@gmail.com> wrote:

> If the Lua compiler did [insert favourite algorithm] register 
> allocation, you'd end up reusing registers lower down the stack, and 
> when an instruction were encountered which wanted to operate on a
> list of values, then they'd need to be moved into consecutive
> registers, some of which would then need to be allocated anyway.

Nod.  Although a simple algorithm to detect if there's already a local
with the same name declared within the same scope, and to reuse that
register (after emptying it) would be a solution to the problem.  The
down side is that it'd generate an extra opcode (to nil the value, or
set it to its initial value), but the upside is early GCing of the
shadowed value and having a spare register for some more locals, should
you need them.

B.