Just-in-time Brainfuck compiler
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
Máté Kukri 1758bc7ea1 Improve code generator 1 year ago
src Improve code generator 1 year ago
test Improve code generator 1 year ago
.gitignore import 1 year ago
Makefile Switch to in-memory code generation 1 year ago
license.txt Updated readme 1 year ago
readme.md Updated readme 1 year ago

readme.md

bfjit

Optimizing compiler from brainfuck to AMD64. It turns a brainfuck input file into AMD64 code in memory then executes it.

Code generation is done in two steps. First the brainfuck program is turned into a custom IL, applying a few optimizations in the process. The IL tree is then fed into the machine code generator which generates x86_64 code from the tree.

Perfomance testing was done using Erik Bosman's Mandelbrot set viewer on an Intel i7-4700M. The results are the sum of compile and execution time averaged across 3 runs.

Compiler/interpreter type Performance
Simple interpreter 52s
Jump pre-computing interpreter 30s
Brainfuck to C translator (-O0) 0.2s + 3.5s
Brainfuck to C translator (-O3) 2s + 1s
bfjit 0.01s + 1s

Currently bfjit only does optimizations on the Brainfuck tree, but further optimizations are possible both in the Brainfuck and IL stages.