lua-users home
lua-l archive

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


I was wondering why Lua 5.2 does not preform the same optimisation for
bytecode which 5.1 did when a there is not an operation before an
OP_LOADNIL, for 5.1 the generator would remove the load nil
instructions. For example a simple file which just contains a local
which will be set to nil:
$ cat ./op_loadnil.lua
local a

For 5.1 produces the following:
$ luac -l ./op_loadnil.lua
main <./op_loadnil.lua:0,0> (1 instruction, 4 bytes at 0x100101050)
0+ params, 2 slots, 0 upvalues, 1 local, 0 constants, 0 functions
	1	[1]	RETURN   	0 1

Yet for 5.2 it leaves in the instruction:
$ ./luac -l ./op_loadnil.lua
main <./op_loadnil.lua:0,0> (2 instructions at 0x100100ee0)
0+ params, 2 slots, 1 upvalue, 1 local, 0 constants, 0 functions
	1	[1]	LOADNIL  	0 0
	2	[1]	RETURN   	0 1

Would someone please shine some light on this and any implications
that may follow it.

Thanks.
Liam