Re:Clue 0.6 - C to Lua, Javascript, Java and Perl compiler
by Dylan16807 on Friday March 15, 2013 @12:46PM
(#5381486)
Looking at the source "boils down to a switch statement" appears to be a chain of ifs. It makes me wonder how fast it would have been to use tail calls.
Also possibly worth noting is that lua 5.1 bytecode has gotos, if you're willing to step down a level.
Re:Clue 0.6 - C to Lua, Javascript, Java and Perl compiler
by david-given on Friday March 15, 2013 @12:58PM
(#5381550)
Clue 0.3 did precisely that. Unfortunately it required a patched Lua to produce the special bytecode. I decided that that was cheating --- plus it meant the Lua backend wouldn't generate code for LuaJIT.
Changing it to generate tail calls would be an excellent idea, but to do it right would require a major rewrite of the backend (most of the code generator is common code).
Re:Clue 0.6 - C to Lua, Javascript, Java and Perl compiler
by gngeal on Friday March 15, 2013 @01:13PM
(#5381640)
Lua 5.1 doesn't have this, which means I have to fake goto using what boils down to a switch statement. This is much less efficient.
Or he could just use tail calls and be done with it. I mean, that's the reason why the tail calls are there in the first place.
Why is Lua 5.2 so much faster than Lua 5.1? Lua 5.2 supports a new goto keyword. This is incredibly useful when doing this kind of compilation as it allows me to pass execution directly from basic block to basic block. Lua 5.1 doesn't have this, which means I have to fake goto using what boils down to a switch statement. This is much less efficient.