2 ms·
We do this to run Ruby C extensions on the JVM - compile the extension to LLVM IR instead of native code, then JIT compile the IR using the JVM's JIT. It's fast
by chrisseaton 10y ago
We do this to run Ruby C extensions on the JVM - compile the extension to LLVM IR instead of native code, then JIT compile the IR using the JVM's JIT. It's fast!
- chc 10y agoHuh? You use the JVM's JIT to compile LLVM IR? How does that work? Isn't it a bytecode compiler?
- chrisseaton 10y agoWell yes but at some point in the pipeline the byte code is long gone. So you can use it for anything by using just the parts beyond that point. But really we don't directly compile the IR. We have an interpreter for IR, and we JIT compile the interpreter, sort of constant folded with the IR. It achieves the same thing without getting more technical. https://github.com/graalvm/sulong https://github.com/graalvm/sulong