-
The usual recommendation have been given. Now for more touristic approach what I would like to use if given excuse and time. All those options are mostly written in C:
- QBE [1] - small compiler backend with nice IL
- DynASM [2] - IIUC the laujit's backend, that can and is used by other languages
- uBPF - Userspace eBPF VM. Depending on your DSL the eBPF toolchain could fit your use-case, but this would probably be the biggest excursion.
[1] https://c9x.me/compile/
[2] https://luajit.org/dynasm.html
[3] https://github.com/iovisor/ubpf
-
SaaSHub
SaaSHub - Software Alternatives and Reviews. SaaSHub helps you find the best software and product alternatives
-
mir
A lightweight JIT compiler based on MIR (Medium Internal Representation) and C11 JIT compiler and interpreter based on MIR
-
-
Oberon
Oberon parser, code model & browser, compiler and IDE with debugger, and an implementation of the Oberon+ programming language
If your DSL is statically typed then I recommend that you have a look at the Mono CLR; it's compatible with the ECMA-335 standard and the IR (CIL) is well documented, even with secondary literature.
If your DSL is dynamically typed I recommend LuaJIT; the bytecode is lean and documented (not as good as CIL though). LuaJIT also works well with statically typed languages, but Mono is faster in the latter case. Even if it was originally built for Lua any compiler can generate LuaJIT bytecode.
Both approaches are lean (Mono about 8 MB, LuaJIT about 1 MB), general purpose, available on many platforms and work well (see e.g. https://github.com/rochus-keller/Oberon/ and https://github.com/rochus-keller/Som/).
-
If your DSL is statically typed then I recommend that you have a look at the Mono CLR; it's compatible with the ECMA-335 standard and the IR (CIL) is well documented, even with secondary literature.
If your DSL is dynamically typed I recommend LuaJIT; the bytecode is lean and documented (not as good as CIL though). LuaJIT also works well with statically typed languages, but Mono is faster in the latter case. Even if it was originally built for Lua any compiler can generate LuaJIT bytecode.
Both approaches are lean (Mono about 8 MB, LuaJIT about 1 MB), general purpose, available on many platforms and work well (see e.g. https://github.com/rochus-keller/Oberon/ and https://github.com/rochus-keller/Som/).
-
Maybe take a look at MiniVM[0]? It was on HN a couple months ago[1].
[0]: https://github.com/fastvm/minivm
-
I 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
-
The usual recommendation have been given. Now for more touristic approach what I would like to use if given excuse and time. All those options are mostly written in C:
- QBE [1] - small compiler backend with nice IL
- DynASM [2] - IIUC the laujit's backend, that can and is used by other languages
- uBPF - Userspace eBPF VM. Depending on your DSL the eBPF toolchain could fit your use-case, but this would probably be the biggest excursion.
[1] https://c9x.me/compile/
[2] https://luajit.org/dynasm.html
[3] https://github.com/iovisor/ubpf
-
-
-
Related posts
-
Book – Writing a C Compiler: Build a Real Programming Language from Scratch
-
What part of Rust compilation is the bottleneck?
-
Rust port of B3 from WebKit, LLVM-like backend
-
Rust is now officially supported on some Infineon microcontrollers! (more to come later this year)
-
What is the LLVM archive rewrite in Rust all about?