# JIT calculator challenge implemented with ejit

This is an implementation of the
[JIT calculator challenge](https://ochagavia.nl/blog/the-jit-calculator-challenge/)
using my [ejit](https://metanimi.dy.fi/cgit/ejit/) library in C. Possibly not
quite what was intended with the challenge, but at least I had a nice evening.

## Building

This repository uses submodules, remember to run
```
git submodule update --init --recursive
```

To build, run
```
make
```

which should produce a `calc` binary. You can add compilation parameters like
```
make RELEASE=1 LTO=1
```

to build an optimized binary. Remember to `make clean` before you specify new
parameters.

## `ejit`

`ejit` is a library that implements a bytecode interpreter for a language
(almost) identical to the one used by the massively cool
[lightening](https://gitlab.com/wingo/lightening) JIT library. The idea is that
`ejit` transparently lowers all bytecode instructions to the equivalent
`lightening` instructions, which in turn are lowered to machine code when on a
supported machine. For machines not (yet) supported by `lightening`, the
bytecode interpeter means that programs written with `ejit` will still function
correctly, just a bit slower.