3 ms·
This could be pretty cool. Right now you have to drop down to non-portable, assembly-style JIT like Xbyak (https://github.com/herumi/xbyak https://github.com/he
by m0zg 7y ago
This could be pretty cool. Right now you have to drop down to non-portable, assembly-style JIT like Xbyak (https://github.com/herumi/xbyak https://github.com/herumi/xbyak) or VIXL on ARM (https://community.arm.com/developer/ip-products/processors/b/processors-ip-blog/posts/announcing-vixl-a-dynamic-code-generation-toolkit-for-armv8 https://community.arm.com/developer/ip-products/processors/b...). It might not be obvious why you'd want something like that, so I'll explain. Basically think of this as templates which you don't have to pre-instantiate. You can specify exactly how long your loops are, so the compiler will be able to do a much better job of vectorizing, eliminating branches, etc etc. In a tight math-kernel style code this could easily improve the perf by 2x or more. Combined with intrinsics this could eliminate the need for assembly in many cases.
This would be exciting if it came to fruition at some point. Unfortunately C++ standard being what it is, we're looking at like 2025 before we see the first standard compliant implementation. Perhaps other languages could take this idea and run with it.
- jcelerier 7y ago> This could be pretty cool. Right now you have to drop down to non-portable, do you ? I've been doing JIT in C++ with the clang api for quite some time already. Sure, it's heavy in terms of "compile time" and binary size increase since you have to ship clang & llvm, but it enables some pretty cool stuff.
- m0zg 7y agoXbyak works in both Clang and GCC though. And presumably in other compilers as well. As far as I can tell, Clang-based JIT only works with Clang. Clang, unfortunately, usually produces measurably slower non-jit code.
- Fronzie 7y agoThere are higher-level JIT libraries for C++ as well: https://blog.quarkslab.com/easyjit-just-in-time-compilation-for-c.html https://blog.quarkslab.com/easyjit-just-in-time-compilation-...
- Reelin 7y ago> Perhaps other languages could take this idea and run with it. Does Lua-Terra (http://terralang.org/ http://terralang.org/) accomplish what you're thinking of here, or have I completely misunderstood you? Another commenter already mentioned LLVM, but here is a concrete example (https://weliveindetail.github.io/blog/post/2017/07/25/compile-with-clang-at-runtime-simple.html https://weliveindetail.github.io/blog/post/2017/07/25/compil...). Of course it would still be nice not to be tied to a single compiler...