a brainf*ck JIT
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.


Brainf*ck JIT

A JIT compiler for Brainf*ck programs made using LibJIT.

It does very naive optimizations right now, like folding of multiple same instructions into one.

Blog post about the same is here.

Build Instructions

  • Download and build LibJIT. I have a compiled version for my own system (Linux 32-bit) in the repo itself, you can use that.
  • Update the LIBJIT_PATH variable in the Makefile if you are using your own LibJIT binaries.
  • Run make.


The bench folder has a bench.sh script that tests the Mandelbrot program with different implementations. The results on my system are:

Implementation                      Time
Mandelbrot (C Unoptimized)       22.343s
Mandelbrot (C Optimized)          1.241s
Mandelbrot (BF Interpreter)       8.304s
Mandelbrot (BF JIT)               1.609s

The unoptimized JIT is 5x faster than the optimizing interpreter and almost at par with the optimized C code.