lua-users home
lua-l archive

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

Florian Weimer wrote:
> > Umm, and this doesn't mean you'd be able to run bytecode patched
> > with gotos. Ok, the interpreter would grok it, but the region
> > analysis used by the trace recorder might get confused.
> But doesn't Lua have got gotos?  Non-escaping local functions with
> tailcalls are kind of equivalent.

Yes, this is handled by the trace recorder. Recording continues
across tail-calls, effectively inlining the target function. The
trace is aborted when the same target appears more than once,
except if it's the initiator. Amortized over time this has the
same effect as region analysis for regular loops. But it's less
precise and may need multiple attempts to discover natural loops.

David's current solution patches the bytecode with JMPs. These may
jump between arbitrary regions, e.g. from the middle of one loop
into the middle of another. Even assuming neither loop has any
locals (since they could alias under Lua's stack discipline) the
shortcuts used to determine the live stack slots for loop exits
might fail. And the tree building heuristics would have trouble
deciding whether a trace fragment stays inside the loop or not.