lua-users home
lua-l archive

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

On 2 March 2015 at 00:53, Dibyendu Majumdar <> wrote:
> Just looking at the logic in FORLOOP makes it clear that there are
> some obvious optimizations.
> For instance it is known when FORPREP executes whether the loop has
> integer or float index, and whether the step is negative or positive.
> So then one could branch to more specialized implementation of FORLOOP
> from FORPREP and avoid the if/else logic inside FORLOOP.
> Right now Ravi's implementation is naive i.e. replicates the logic in lvm.c.

Also I was stupid enough to use the Lua stack/register for the index,
limit and step ... obviously these are hidden so the JIT version can
simply use native C stack variables. Only the external variable needs
to be retained on the Lua stack.

So it seems:
a) Use native C stack variable for the loop index, limit and step
b) Create separate loop control blocks for int/float, and
increasing/decreasing, and depending on FORPREP analysis use the
correct loop control block.

Time to redo this :-( it was messy enough to implement the naive version!
But on the other hand if I could get Ravi close to LuaJIT performance ... !

BTW I hope people don't mind my sharing my experiences here ... if you
do, shout and I will stop.