3 ms·
I would personally try cranelift for this. Its goals are around producing executable code quickly rather than optimally, which is pretty much the opposite of ll
by stormbrew 4y ago
I would personally try cranelift for this. Its goals are around producing executable code quickly rather than optimally, which is pretty much the opposite of llvm. There are lots of things out there that use llvm for jit, but even its jit library layer is pretty heavy and you’ll probably spend more time generating code than you’d like.
That said, cranelift is still experimental.
- gpm 4y agoI haven't used it, but cranelift is also my first thought for this. If you want a stable interface though, I might use wasm on top of it via wasmtime. I'm not sure how stable the API for wasmtime is, but at least the IR (wasm) is, and there's an ecosystem of tools around it. https://github.com/bytecodealliance/wasmtime https://github.com/bytecodealliance/wasmtime
- tyingq 4y agoThe toy demo does seem like it's a great starting point for the original poster. https://github.com/bytecodealliance/cranelift-jit-demo https://github.com/bytecodealliance/cranelift-jit-demo
- __s 4y agoAs another small example, there's my Befunge JIT which includes recompilation: https://github.com/serprex/Befunge/tree/master/barfs https://github.com/serprex/Befunge/tree/master/barfs
- cfallin 4y ago> That said, cranelift is still experimental. Echoing everyone else in this thread that Cranelift might work well for this case; just wanted to add: Cranelift is definitely not "experimental" anymore, though it is still young. It's in production in a number of places (my employer and others) and we test thoroughly, including differential fuzzing against other engines/compilers. It just got a new register allocator, and we even have some academics working on formal verification! We'd be happy to help with any issues that arise; our Zulip instance (bytecodealliance.zulipchat.com) is probably the best place to find us. (Disclosure: I work full-time on Cranelift, and have a ton of fun doing it)
- stormbrew 4y agofair enough! I guess I was thinking of the specific context of the rust cranelift backend, which I believe is still experimental?
- cfallin 4y agoAh, yes, that is indeed experimental, though it seems to be coming along nicely (I'm not involved but talk with the main author to support it).