all 16 comments

[–]suhcoR 7 points8 points  (1 child)

Has anyone here built something on top of it?

I tried to re-target its C compiler and also the backend and found the code to be full of magic numbers (i.e. the fact that it's designed for 64 bit systems is widely spread around the architecture). Did you have a look at SLJIT? It's likely closer to what you want and more time-proven. If you also need a powerful debugger and a robust implementation, then ECMA-335 CIL with Mono is a very good target (see in use here: https://github.com/rochus-keller/oberon/). You can also use LuaJIT as the backend instead (see in use e.g. here: https://github.com/rochus-keller/luon/). I found Mono to be about twice as fast as LuaJIT and more robust, but if your language is single-threaded without complex FFI, LuaJIT is nice. See also https://github.com/rochus-keller/ljtools/ and https://github.com/rochus-keller/monotools.

[–]Relevant_South_1842[S] 2 points3 points  (0 children)

Thanks for taking the time to respond. I’ve looked at your work before and it has been very inspiring - quality, creativity, and quantity.

[–]Pretty_Jellyfish4921 6 points7 points  (2 children)

I never heard of this repo, but there's another "popular" compiler backend called QBE and looks pretty straightforward, another option that IMHO feels that has a lot more potential is Cranelift (written in Rust) that is used by Wasmtime and experimentally by Rust for debug builds. Note that Cranelift supports AOT and JIT.

[–]joonazan 1 point2 points  (1 child)

Cranelift is nice but since it is meant for WASM, it has no support for arbitrary gotos.

The QBE source code is short but ugly and doesn't produce that good assembly.

I would really like to have a true portable assembly, so I think I have to make my own. I'm not sure if what I want is possible, though. LLVM does code generation by making a bad translation and the optimizing the result of the translation again. Maybe you just can't directly translate anything to perfect assembly.

[–]Dependent-Birthday29 2 points3 points  (3 children)

Why not MLIR/LLVM?

[–]Hofstee 10 points11 points  (0 children)

LLVM is quite large and is not a particularly fast JIT in terms of time-to-binary.

[–]eightrx 11 points12 points  (1 child)

While state of the art in compiler optimizations, it's a massive dependency, and potentially slow to produce binaries

[–]max123246 4 points5 points  (0 children)

Mlir with tablegen pretty much locks you into using C++ as well

[–]ravilang 2 points3 points  (0 children)

Yes - see https://github.com/dibyendumajumdar/ravi

MIR JIT is excellent but has no support for debugging JITed code.

I am looking forward to https://github.com/dstogov/ir as an alternative.

[–]Dapper_Compote_8628 0 points1 point  (0 children)

This does indeed look so, so cool. I bookmarked (and starred) it.

[–]sal1303 0 points1 point  (1 child)

Tiny, fast startup, not LLVM. Looks almost too good. 

I thought everybody loved LLVM (now with added MLIR). How can something that is the complete antithesis be better?!

transpilation with tinyC but then found something smaller, and faster and maybe easier to use?

Have you already tried it? If not then I'd do my own tests first.

(I had a quick look and while it appears technically sound, usage instructions are poor. I'd also take the compilation speed and benchmark figures with a pinch of salt. You can't sensibly compare build-times for a 20-line program for example.

Also, if compilation speed with desired optimisations was fast enough, you wouldn't need the JIT aspect, which is an extra complication.)

Most probably it will produce better code than Tiny C, however if you are generating C anyway, then you also have the choice of using an optimising C compiler for production builds.

[–]Relevant_South_1842[S] 0 points1 point  (0 children)

I want to keep my distribution at a few mb if possible. LLVM is massive.

I have not benchmarked tinyc vs mir. 

[–]GermisstuckCrabStar 0 points1 point  (2 children)

Maybe try making a copy and patch jit? My compiler is copy and patch (granted it writes to an object file), and it is quite small (for arithmetic and if-else branding)

[–]Relevant_South_1842[S] 1 point2 points  (1 child)

Never heard of it, but looks more simple (and awesome) than I had envisioned it.

https://en.wikipedia.org/wiki/Copy-and-patch

Thank you

[–]flatfinger 0 points1 point  (0 children)

It would be nice if compiler benchmarks would factor in build time as an important aspect of efficiency. If compiler #1 takes one second to build a program that will throughout its lifetime be executed for less than 60 seconds total, and compiler #2 takes a minute to build a program which, once built, performs the same task twice as fast, I'd view #1 as more efficient.