lua-users home
lua-l archive

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


Mike Pall wrote:
Peter Sommerfeld wrote:
I'm not sure I understand the benchmark and the numbers correctly.
Does it mean that there is no reason to avoid costly patterns
like objects using closures (PiL 16.4) and others anymore?

Basically yes. But I should note that it's easier for the compiler
to optimize access to tables holding instances than to closures.

The one thing you need to watch out for right now is that it's not
a good idea to create lots of closures for the same prototype and
call different ones from the same inner loops. The JIT compiler
specializes to each individual closure and not the prototype and
it's hard to teach it to back off on specialization.

Understood. But my question aims to the normal use of closures
too, not necessarily within loops. Of course, pushing the closure
into the heap cannot be avoided but what's about the access.
Is there a remarkable difference between Lua 5.1 and JIT-2?

Peter