Finally! The wonders of just-in-time compilation are available in C++:
runtime specialization, code derived from data structures, and many more!
Easy::jit provides a simple interface over the LLVM's just-in-time compiler.
No specific compiler knowledge is required!
A single function call serves as the specification for the generated code and
entry point for the just-in-time compiler.
The user can precisely control when the compilation is launched,
do it in a separate thread if desired or cache the generated code,
and manage the lifetime of the generated code.
int baz(int a, int b) { ... }
int foo(int a) {
// compile a specialized version of baz
auto baz_2 = easy::jit(baz, _1, 2); // mimics std::bind
return baz_2(a); // run !
}
The call to easy::jit
generates a mix of compiler directives and runtime
library calls, that are picked up by an especial LLVM pass.
This pass embeds metadata and bitcode versions of the C++ code in the
resulting binary.
A runtime library parses the metadata and bitcode, and generates assembly
code based on the runtime library calls in the code.
This talk introduces the Easy::jit library, the approach of a compiler-assisted library,
its current limitations, and tries to gather feedback from experts and potential users.