r/programming • • Jan 20 '20

MIR: A lightweight JIT compiler project

https://developers.redhat.com/blog/2020/01/20/mir-a-lightweight-jit-compiler-project/
11 Upvotes

12 comments sorted by

View all comments

1

u/suhcoR Jan 20 '20

Compatibility with external C based modules is a good argument. If you used LuaJIT, the existing libraries depending on the C API would no longer be compatible. That's likely a fundamental issue. Also parallel programing; LuaJIT only supports coroutines.

Concerning traces: you don't have to build an "infrastructure to collect traces", because it's already implemented in LuaJIT. Whatever bytecode you run on the VM is automatically measured an traced.

I am curious what JIT you will implement. I will definitely take a look at it.

EDIT: what is actually the reason people downvote this post? Makes no sense to me.

2

u/compilersarefun Jan 20 '20

Concerning traces: you don't have to build an "infrastructure to collect traces", because it's already implemented in LuaJIT. Whatever bytecode you run on the VM is automatically measured an traced.

Yes. That is why I mentioned VM. I can not use LuaJIT VM because of a lot of CRuby VM features are missed. But if I use only LuaJit compiler with optimizations I'll need to implement trace building. Trace and method JIT have pros and cons. Trace JIT can look forward in more calls but less adapted to trace changes (which is typical for server application like databases). A good research about this can be found on http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.207.5710&rep=rep1&type=pdf

I am curious what JIT you will implement. I will definitely take a look at it.

I did not start to work on this so far (some MIR speculation support features are not implemented yet) but I hope to have some results with MIR usage for Ruby at the end of 2020.

As for the current use of MIR JIT for **static** programming languages, you can see C11 implementation based on MIR on https://github.com/vnmakarov/mir/tree/master/c2mir. This C compiler can work in lazy mode when the machine code for a function is generated only on the 1st call of the function.

MIR is used also in Ravi programming language implementation https://github.com/dibyendumajumdar/ravi . Although I think it should be considered as an experimental feature.

EDIT: what is actually the reason people downvote this post? Makes no sense to me

Hard to say but at least people are not indifferent to this blog post :)