News for hackers. Stuff that matters.
Re:Building a baseline JIT for Lua automatically by djwatson24 on Friday May 12, 2023 @07:27PM (#35923793)
Deegen is my research meta-compiler to make high-performance VMs easier to write. Deegen takes in a semantic description of the VM bytecodes in C++, and use it as the single source of truth to automatically generate a high-performance VM at build time
Re:Building a baseline JIT for Lua automatically by russellsprouts on Friday May 12, 2023 @08:44PM (#35924294)
> To solve [forward branches], those bytecodes would push information about how the branch destination address shall be fixed up into a late-patch buffer.

This reminds me of how Forth `if` and `then` can be compiled in a single pass -- `if` writes the branch instruction and pushes the current instruction pointer to the stack, and `then` pops it and patches the instruction to point to the current instruction pointer.

Re:Building a baseline JIT for Lua automatically by sillycross on Saturday May 13, 2023 @01:42AM (#35925928)
That's an interesting approach :) Though it only works if the control flow in the language is exactly "paired" (no continue/break, no goto, etc), I guess?
Re:Building a baseline JIT for Lua automatically by celeritascelery on Saturday May 13, 2023 @12:44AM (#35925614)
Great work! This was a very interesting read. A lot of clever approaches here to make a generic JIT. How would one try out deegen?
Re:Building a baseline JIT for Lua automatically by celeritascelery on Saturday May 13, 2023 @01:08AM (#35925762)
I don’t understand how you can remove the calls with copy-and-patch. It seems like you would have to inline evaluate_lhs and evaluate_rhs to remove calls completely.
Re:Building a baseline JIT for Lua automatically by sillycross on Saturday May 13, 2023 @01:44AM (#35925933)
Look at the CPS-version of the add.
Re:Building a baseline JIT for Lua automatically by celeritascelery on Saturday May 13, 2023 @10:26AM (#35928741)
I saw that. I think I understand a little better. The CPS is to remove the calls between bytecodes, but wouldn’t do anything about lua function calls.
Re:Building a baseline JIT for Lua automatically by sillycross on Saturday May 13, 2023 @06:58PM (#35933623)
That's correct. Lua function calls are not that easy to remove, as function is first-class value in Lua so can be redefined at any time. To remove a function call, you need speculative compilation and OSR-exit, which is outside the job of the baseline JIT.