Latest posts

JIT Compiler with LLVM - Part 5 - Bitcode, PCH, exceptions handling, module linking and more...

So a good week has passed since my last article on my JIT Compiler experiment. And I must admit I've been playing with this code a lot in the past few days :-). In case you don't remember, my primary goal was to be able to generate C++ code directly from the Lua scripting language. So that's precisely what I did, and in the process, I built a “frontend” for my JIT compiler in Lua, that kept evolving and that I'm now using to perform most of my tests. During this part of my journey, I also worked on precompiled header (PCH) generation, LLVM module constructors and destructors, C++ unit testing from scripts, exceptions handling, and module linking concerns. So I think it's now already high time I stop coding a moment and try to share what I learnt on all those points in case this could be of interest to someone (or actually, even just to remember what I did in case I need to get back to it someday ;-))

→

2020/04/25 16:51 · 0 Comments

JIT Compiler with LLVM - Part 4 - CRT dependency

In the (previous article on this topic) we have seen how to fix the IR module optimization crashes or memory leaks that were due to some incorrect build setup. Now, in this post I want to discuss the issues I faced when first trying a slighty more avanced JIT compilation: the basic idea was to verify that we could indeed rely on external libraries from our JIT compiled code, which is obviously a key feature. And this prooved to be far less easy than I thought it would be…

→

2020/04/18 10:21 · 1 Comment

JIT Compiler with LLVM - Part 3 - Fixing the ModulePassManager crash

If you read my previous article on this topic (JIT C++ compiler with LLVM - Part 2) then you probably noticed there was a serious issue with the “NervJIT” implementation I described (as well as in the toy implementation in the runClang() described in the very first article): I couldn't release the IR optimization pass resources, nor the llvm::orc::LLJIT object as trying to do so was producing silent crashes. In this new post, we will focus on the steps I took to finaly get rid of this problem.

So let's get to it! :-)

→

2020/04/16 17:25 · 0 Comments

JIT C++ compiler with LLVM - Part 2

In my previous article on this topic I described how I tried to use LLVM and clang to perform some initial dynamic C++ compilation tests. Now, in this post, I want to push this concept a bit further and build a working JIT compiler that I could eventually use “in production” either directly from C++ code or from Lua or other bindings.

→

2020/04/14 09:53 · 0 Comments

Dynamic C++ compilation with LLVM & clang

In the past few days I'm been generating a lot of C++ bindings for Lua (mainly for some toy experiments on mesh generation with OpenCascade, which is really fun/interesting by the way, but that's not the topic here…). And one thing that bothered me in the end was that: I'm OK with using Lua to generate configuration or perform pre-run computations, but I would not want to use it for a continuous update loop in a game engine for instance (In fact I already tried that a long time ago, and even with LuaJIT, you quickly face some performance limits).

Instead, I want my update loop to be in pure C++, but then, if you need to set this up differently from Lua [depending on your experiment at hand], you loose a good share of the scripting advantages because you must have this update loop code somehow ready to use somewhere in your C++ world anyway. Sure you could think about a “generic loop” system where you would inject a sequence of “operations” but it's still the same problem: some where, you must have C++ defined classes or functions representing those operations if you want to call them.

So, from that point I started my journey to investigate how to generate C++ code dynamically [from Lua]: because if I could do that, then, my “lua configuration pass” could also be used to setup and build a custom C++ loop function that would be specific to each experiment I want to perform, and still allow me to keep maximum performances :-).

So here we go!

→

2020/04/10 15:53 · 0 Comments

Older entries >>

Blog History

2017-09: 7 entries 2017-11: 1 entry 2018-12: 6 entries 2019-01: 5 entries 2019-02: 2 entries 2019-03: 9 entries 2020-12: 1 entry 2020-04: 5 entries