luajit

DSP, Plugin and Host development discussion.
RELATED
PRODUCTS

Post

mystran wrote:
Mayae wrote: e: is it still true for lua that it doesn't have native integers?
Sort of.. there is no separate integer type in the language, but the native arrays treat small integers (that is integer values of the numeric type) specially, so in some sense integers are meaningful, they just share the same type (in the language) with other numbers.

IIRC LuaJIT will generate integer code (optimization is known as type narrowing) in various situations when it decides it's the right thing to do (induction variables and such should at least get narrowed). Also if I'm not mistaken, you can use the bitops to do integer arithmetic explicitly.
I remember reading that it would pose no significant speedup using native integers (isn't this the same for python aswell, btw?) - i only asked because it might create a problem some day down the road on x64, if one is trying to do integer / pointer / index arithmetic in lua (given how doubles are incapable if representing large 64-bit integers accurately)
mystran wrote:
camsr wrote:Isn't x64 calling convention limited to only cdecl?
x64 calling conventions (different operating systems use slightly different variants) are different from the 32-bit cdecl convention, but yeah, you should normally get the same thing whether you specify cdecl or something else.
This is where TCC x64 starts to get fun :) Had some weird problems with this.. Tcc passes floats/doubles in integer registers, which is quite weird
(http://stackoverflow.com/questions/2288 ... -functions)

Post

Mayae wrote: I remember reading that it would pose no significant speedup using native integers (isn't this the same for python aswell, btw?)
Depends on how you're going to use the result. Arithmetic runs fast either way, but conversions takes time, so it makes sense to use integers (or compiler to narrow to integers) where they are used for array indexing or loop counters (free condition flags), etc.

Python has the usual two integer types, no idea what they are called, but there's the "fits in machine word" integers (traditionally know as fixnums) and then there's the large integers (traditionally known as bignums) and it automatically promotes from the former to the latter as necessary (so if you do something like 2**123 it'll give you 10633823966279326983230456482242756608L and basically you can go as large as memory allows). And then there's floating point (double IIRC).

[edit: as for size of exact numbers in lua.. I don't see it being an issue with array indexes, as arrays with more than 2^52 elements are not that common.. but in theory you could always implements bignums using a base that fits the exact range ;)]

Post Reply

Return to “DSP and Plugin Development”