lua-users home
lua-l archive

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

On 29-Jan-07, at 4:16 PM, Chris wrote:

I have this simple test.lua file:

 if num < 0x100000000 then end
 if num < 0x1000000000 then end

Using vanilla source Lua 5.1.1:

On Ubuntu Linux:
luac -o test.linux test.lua

On Windows:
luac.exe -o test.lua

$ ls -l
-rw-r--r-- 1 user user    143 2007-01-29 15:46 test.linux
-rw------- 1 user user    134 2007-01-29 15:48

Notice the size difference.  The bytecode is very different when I
compare it.  What's happening?

The weird thing is, if you remove one of the "if" statements they
compile the same.  You have to have both of them in there.  Also, both
numbers must be greater than 32-bit but not all combinations produce
different bytecode.

You'd get a clearer idea if you used luac -l to print the bytecode in a human readable form. Or maybe you did, and just didn't put the results in this message.

My guess, since I don't have windows handy, is that on Windows both of those numbers are actually 0, while on Ubuntu they're actually the correct value. That means that on Windows, there is only one constant (0) and hence the compiled byte code is shorter by one number (type byte + 8 bytes for the numbers == 9 bytes, exactly the difference you're showing.)