Compiling a Lisp to x86-64: Labelled procedure calls
bernsteinbear.com
bernsteinbear.com
If you, dear reader, have a better solution, please let me know.
Assuming you know the byte offset into the code buffer, of your "main" equivalent label, you should be able to use the following:
byte* start_address = buf->address + offset;
JitFunction function = *(JitFunction*)(&start_address);
return function(heap);
I'm guessing you were running into the issue that you can't do this in one line while also suppressing the warning about the data pointer to function pointer.The "normal" way to do this would be the following, but it has the downside of the compiler warning:
JitFunction function = (JitFunction)(buf->address + offset);
return function(heap);It might help to read skeeto's blogs [0][1][2].
[0] https://nullprogram.com/blog/2015/03/19/
I've updated the post.
https://pragprog.com/titles/tpdsl/language-implementation-pa... Language Implementation Patterns Create Your Own Domain-Specific and General Programming Languages by Terence Parr (Antlr)
https://craftinginterpreters.com/ by Bob Nystrom
https://interpreterbook.com/ Writing An Interpreter In Go by Thorsten Ball (also has a compiler book)
The Implementation of Lua 5.0 (short) https://www.lua.org/doc/jucs05.pdf
A Deep Introduction to JIT Compilers: JITs are not very Just-in-time https://carolchen.me/blog/jits-intro/ by Carol Chen
video series: JIT programming language development in C https://www.youtube.com/watch?v=k3gDvF-Fbpw&list=PLvdK1vRmp8... by Dmitriy Kubyshkin
Book: https://keleshev.com/compiling-to-assembly-from-scratch/
Looking forward to more content from you! Thanks!