|
David Manura wrote:
[snip] Here, "compile" would convert the given Lua-like code snippet to afunction object, under the assumption that all variables in the snippet are local and of type number. These restrictions are made so that the code can be compiled to a more specialized bytecode format and interpreted under a specialized VM optimized for numeric code.
I doubt you'd get much of a speedup using interpretation. Too much overhead. What kind of interpreted virtual instructions do you have in mind that would be worth the effort to implement?
The language recognized by "compile" might also include extensions to the Lua language, such as intrinsic operators like trigonometric and bitwise, as you would see in a CPU and FPU. [snip] SSE-like ops may be added as well, which can give some speedups even in ANSI C [3].
But in order to compile really efficiently, add all the hinting and change all the normal rules and you'd end up with something rather different from standard Lua -- a "Dr Jekyll" Lua and a "Mr Hyde" Lua and you'd need another task switch for your programming brain.
Is it worth the effort? I don't think it's going to win many benchmarks. I don't see a clear 'win' here... anything that ends up running native code will still be much faster.
-- Cheers, Kein-Hong Man (esq.) Kuala Lumpur, Malaysia