[Oberon] New Oberon to Lua Transpiler
rochus.keller at bluewin.ch
rochus.keller at bluewin.ch
Sat Oct 12 15:26:07 CEST 2019
@ Luca Boasso:
Meanwhile I found some time to further analyze the generated IR and machine code using the -jdump option of LuaJIT.
If you have this Lua code "increment(function(set,val) if set then x = val else return x end end)" as in LuaDemo2 of my article then LuaJIT indeed finds the following trace into increment() and the thunk but then aborts because it cannot handle traces including the FNEW opcode as it seems:
---- TRACE 2 start 1/0 VarDemo1.lua:10
0001 ISF 0
0002 JMP 2 => 0005
0005 UGET 2 0 ; x
0006 RET1 2 2
0005 ADDVN 3 3 0 ; 1
0006 CALL 1 1 3
0000 . JFUNCF 3 1 ; VarDemo1.lua:10
0001 . ISF 0
0002 . JMP 2 => 0005
0003 . USETV 0 1 ; x
0004 . JMP 2 => 0007
0007 . RET0 0 1
0007 RET0 0 1
0014 FORL 3 => 0011
0011 MOV 7 1
0012 FNEW 8 3 ; VarDemo1.lua:10
---- TRACE 2 abort VarDemo1.lua:10 -- NYI: bytecode 49 ; FNEW
If I don't define the thunk inline but use a local variable for the thunk instead, full inlining works and the runtime is as fast as corresponding C code.
I therefore need to redesign my Lua code generator to no longer inline the thunk definitions and to even take the thunk declarations out of loops. To do that I likely need a separate optimization pass to rewrite the AST which is not feasible with my current, syntax directed approach. I will come back with results.
Best
R.
More information about the Oberon
mailing list