This idea has been kicked around a few times on IRC and elsewhere, and
I think it's pretty clever. The idea is to JIT by making a valid
dylib/dll/so (heceforth, dylib) with the JITed code in memory, and
then convincing the loader to load it. This is nice for the reasons
listed above.
I think it would be neat if LLVM could package up this functionality,
since it fits most use cases for the current LLVM JIT. LLVM
compilation is already heavyweight, so the overhead of linking and
loading the library shouldn't be too bad.
For now, this can be achieved by rolling your own compilation pipeline of:
1. run llc or the equivalent to make a .s in a temp dir
2. assemble it
3. link it to make a dylib in the temp dir
4. dlopen it
5. use dladdr to get the function pointer for your code
1 and 2 can already be done in memory with LLVM.
3 cannot, and doesn't look like it is on anyone's roadmap.
I think 4 may become possible on OS X, and there's this feature
request for glibc that essentially implements "dlopen from memory":
http://sourceware.org/bugzilla/show_bug.cgi?id=11767
5 is trivial.
Even a prototype of this initial JIT model that uses temporaries on
the filesystem would be useful for JIT users doing debugging or
profiling.
I don't really have time to implement this. I'm just kicking the
proverbial can down the road. I may file a feature request PR or
write up something in the style of sabre's LLVMNotes:
http://nondot.org/sabre/LLVMNotes/
Reid