[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Optimizations during compilation
- From: Roberto Ierusalimschy <roberto@...>
- Date: Fri, 18 Jun 2004 15:00:29 -0300
An interesting characteristic of the Lua virtual machine is that local
variables are always registers. That means that several optimizations
in Lua can be done at the source-code level. For instance, a change
from
a.b.c = a.b.x[k+d] + y[k+d]
to
local _1 = a.b; local _2 = k+d; _1.c = _1.x[_2] + y[_2]
is as good as you can get without changing the virtual machine.
A nice project would be a source-code optimizer for Lua (which could be
used as a pre-processor for luac, for instance). It could easily perform
constant propagation, common-subexpression ellimination (eventually with
switches to control how much it could assume about metamethods), loop
optimizations, etc.
-- Roberto