12 releases

0.2.2 Mar 1, 2023
0.2.1 Mar 1, 2023
0.2.0 Feb 2, 2022
0.1.8 Feb 25, 2022
0.1.4 Sep 29, 2021

#55 in Programming languages

Download history 3/week @ 2022-12-01 1/week @ 2022-12-08 11/week @ 2022-12-22 1/week @ 2022-12-29 2/week @ 2023-01-05 2/week @ 2023-01-12 9/week @ 2023-01-19 11/week @ 2023-01-26 11/week @ 2023-02-02 10/week @ 2023-02-09 30/week @ 2023-02-16 18/week @ 2023-02-23 22/week @ 2023-03-02 21/week @ 2023-03-16

61 downloads per month


7.5K SLoC


An experimental JIT compiler generator.

Mijit consists of the following components:

  • A domain-specific language ("Mijit code") that is particularly amenable to optimising, and barely expressive enough for writing interpreters.
  • A back-end that lowers Mijit code to machine code (in RAM) and executes it.
  • A profile-guided optimizer that reads and writes Mijit code.


Suppose you are writing a high-level programming language. It compiles to some kind of virtual code, which runs on an interpreter, written in C, say. You want it to go faster.

You write a Rust program that uses crate mijit. You implement trait Machine, porting the performance- critical parts of your interpreter to Mijit code. Mijit provides you with an equivalent JIT compiler. You wrap it in an ergonomic Rust API that is specific to your language. You write C bindings for your Rust API. You drop it in as a replacement for your interpreter, reusing the existing non-performance- critical parts.


The best example of using Mijit is Bee. Pass the "--with-mijit" flag to its "./configure" to enable the Mijit backend. A cut-down version of the related Beetle is included in Mijit as a unit test.


Working, but unfinished. The specification of Mijit code is in flux. There are two back-ends, for x86_64 and AArch64. Other 64-bit targets are planned. Mijit can run some programs, but the generated code is poor, and it only runs at about 40% of the speed of compiled C. A rough outline of the optimizer has been written and is enabled, but so far it doesn't know many optimizations. The profiler is not written yet.


Versions 0.1.x are obsolete. Versions 0.2.0 onwards will improve the API and the internals in backwards-incompatible ways. As long as the version number begins with a "0" we reserve the right to change the design arbitrarily.


    $ cargo build --release


Mijit is primarily a library. However, it does provide some executable tests.

    $ cargo test


~12K SLoC