#jit-compiler #white-space #assembly #instructions #benchmark #executing #wsc

bin+lib whitespacers

A whitespace JIT-compiler, for when your whitespace just isn't executing fast enough

9 releases (2 stable)

Uses old Rust 2015

1.1.0 Apr 26, 2024
1.0.0 Aug 27, 2020
0.2.0 Apr 24, 2018
0.1.3 May 31, 2017
0.0.1 Oct 20, 2016

#326 in Programming languages

MPL-2.0 license

200KB
4.5K SLoC

A whitespace JIT compiler, written in Rust

Features

  • Provides both a library for embedding and a command-line tool.
  • Implements the whole whitespace standard, including arbitrary precision integers.
  • Extremely fast. Whitespace code can be compiled to near-native speed levels. Executing over a billion whitespace instructions per second is common.
  • Provides options for interpretation for unclear parts of the standard.
  • Can convert whitespace code to/from a readable assembly language.

Why

  • I needed a project to learn Rust with.
  • Every language needs a whitespace interpreter!
  • I ended up overdoing it a bit.

Benchmarks:

Whitespacers offers several interpretation methods. These benchmarks show the difference between the techniques and fallbacks. These benchmarks were created by executing wsinterws.ws (a whitespace interpreter written in whitespace) on this whitespace program. Correct execution requires the execution of 3.329.985.013 whitespace instructions. Executing this program requires --unchecked-heap.

The time mentioned is purely the execution time. Other operations are very insignificant compared to it as the second largest time consumer is parsing at approximately 0.001 s.

The used machine for benchmarking is a 2.6 GHz i7-4720HQ.

Execution tactic Time [s] whitespace instructions per second
The fallback bignum interpreter 193.514444790 17.207.940
The reference interpreter 35.265381255 94.426.457
Optimized interpretation 12.077388375 275.720.620
JIT-compilation 3.311839939 1.005.478.849

It should however be noted that this benchmark is heap-heavy code. In pure stack code speeds in excess of 3.000.000.000 instructions per second have been reached.

Documentation

Documentation is available here.

Build instructions

Just run cargo run --release to run the interpreter. The library can also be downloaded directly from crates.io.

License

MPL-2.0, see LICENSE

Dependencies

~3MB
~68K SLoC