The compiler currently requires all local and temporary variables to be boxed. This introduces a significant performance penalty.
For instance, in the following snippet:
local x = 0
for i = 1, 10 do
x = x + i
end
every arithmetic operation with x or i involves unboxing it, performing the operation, and boxing the result again. Boxing here is not necessary: it can be determined statically that x is and i are integers, so they can be replaced with primitives while maintaining semantics.
How to go about this
The required static type analysis is already in place. The only remaining thing to do is to change the layout of the generated code to support unboxed local variables and temporaries, and wire the operations up accordingly.
The compiler currently requires all local and temporary variables to be boxed. This introduces a significant performance penalty.
For instance, in the following snippet:
every arithmetic operation with
x
ori
involves unboxing it, performing the operation, and boxing the result again. Boxing here is not necessary: it can be determined statically thatx
is andi
are integers, so they can be replaced with primitives while maintaining semantics.How to go about this
The required static type analysis is already in place. The only remaining thing to do is to change the layout of the generated code to support unboxed local variables and temporaries, and wire the operations up accordingly.