lua-users home
lua-l archive

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


Hmm, I didn't remember that you can do that.   luac -l crashes with
the Windows binary from Lua Binaries.  My own compiled version works
though.

Linux:
main <test.lua:0,0> (7 instructions, 28 bytes at 0x8060d48)
0+ params, 2 slots, 0 upvalues, 0 locals, 3 constants, 0 functions
       1       [1]     GETGLOBAL       0 -1    ; num
       2       [1]     LT              0 0 -2  ; - 4294967296
       3       [1]     JMP             0       ; to 4
       4       [2]     GETGLOBAL       0 -1    ; num
       5       [2]     LT              0 0 -3  ; - 68719476736
       6       [2]     JMP             0       ; to 7
       7       [2]     RETURN          0 1

main <test.lua:0,0> (7 instructions, 28 bytes at 002F5B78)
0+ params, 2 slots, 0 upvalues, 0 locals, 2 constants, 0 functions
       1       [1]     GETGLOBAL       0 -1    ; num
       2       [1]     LT              0 0 -2  ; - 4294967295
       3       [1]     JMP             0       ; to 4
       4       [2]     GETGLOBAL       0 -1    ; num
       5       [2]     LT              0 0 -2  ; - 4294967295
       6       [2]     JMP             0       ; to 7
       7       [2]     RETURN          0 1

As you mentioned it looks like the Windows version is overflowing.
Ah, now I see it's a problem with the "0x" hex parsing because if I
use the normal integer value there is no problem.  Ugh, I hate
inconsistent behaviour ;)

Thanks!  I'll have to remember "-l" next time.  I'll look into the 0x
parsing and see what the issue is.

CR


On 1/29/07, Rici Lake <lua@ricilake.net> wrote:

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.win 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 test.win
>
> 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.)