[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: LuaJIT and tail call recursion
- From: Mike Pall <mikelu-1107@...>
- Date: Wed, 6 Jul 2011 17:05:09 +0200
Benjamin Segovia wrote:
> As executing the code on the HW is somehow difficult, I am starting to
> write a translater ASM->LuaJIT which turns the assembly into a lua
> string directly executed by the Luajit VM.
>
> To handle all branch instructions, I'll put each basic block into a
> function and use tail call recusion to simulate goto.
See: http://lua-users.org/lists/lua-l/2011-02/threads.html#00658
> does tail call recursion abort traces?
No, that works just fine. The -jv output of the current git HEAD
also tells you what kind of control-flow construct it's compiling:
local f1, f2
function f1(n) if n <= 0 then return 0 else return f2(n-1) end end
function f2(n) return f1(n) end
f1(1000)
$ luajit -jv test.lua
[TRACE 1 test.lua:2 tail-recursion]
--Mike