lua-users home
lua-l archive

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


On Mon, 12 Dec 2022 at 10:19, bil til <biltil52@gmail.com> wrote:
> Am Mo., 12. Dez. 2022 um 09:43 Uhr schrieb Rolf Kalbermatter
> <rolf.kalbermatter@kalbermatter.nl>:
> > But the Lua byte code generator could store the loop variable somewhere else than
> > as a reference to the Lua stack, for instance directly in a reserved CPU register
> > for performance reason ...
> ... sorry, but this is definitely NOT possible. Lua is delivered in
> "multi-system" C code. It has NO knowledge about the CPU, on which Lua
> will finally run.

Lua compiles to byte code which runs in an VM, which gives it complete
knowledge of the VCPU it uses. For loop can use some VM features which
are not accessible to the rest, like reserved Vregisters. I'm not
going to check the current implementation, as it is changed
periodically, but I'm sure it can use some tricks, and if you search
for OP_FORLOOP and friends in the sources you will see some of them.

Francisco Olarte.