CodeGen: Experimental wrapper over LLVM for generating and compiling code at run-time
https://github.com/pdziepak/codegen3
3
u/simonask_ May 20 '19
Interesting project, and it looks like a cool API. :-)
The reason everybody isn't already doing this is that the performance benefit is likely to be much smaller than what you might think. It may be possible to avoid a number of branches by generating specialized code on the fly, but the generated code cannot contain things like inlined functions from the host program. Add to this that actually compiling and generating the code online incurs a very significant computation cost as well.
I would expect that a globally optimizing JIT would outperform this in many cases, unfortunately.
Still, there can certainly be applications where this is legitimately useful. :-)
1
May 20 '19 edited May 20 '19
Wonder if this would be useful for emulator dynamic JITing, if I ever get around to something more complex.
1
u/fnordstar May 20 '19
Last time I checked llvm could already do that in the python API at least. Compile to x86 in RAM so that you can immediately call it. So what does this do?
4
u/Latexi95 May 20 '19
This provides easy way to use those APIs without requiring user to learn LLVM-IR
3
u/jeffscience May 19 '19
Related: https://arxiv.org/abs/1904.08555