A scheme that makes code fly.

HAWK

HAWK is a VM and JIT compiler for the Scheme programming language. It currently targets the R4RS scheme standard. It is currently known to run on x86_64 linux and OSX. It requires a recent version of clang that supports [[mustttail]] attribute. It is likely that the VM will work on most 64-bit platforms. GCC is known to correctly compile all tail calls in Release mode, but not Debug.

HAWK can be found on github. It is licensed under the MIT License.

Building

Hawk has no dependencies other than a recent (> 13) clang. It has an optional dependency on libcapstone, and elf headers for debugging. Currently chezscheme or chicken is used for bootstrapping, but is not used after install.

$ sudo apt install chezscheme	  
$ git clone https://github.com/djwatson/hawk.git
$ cd hawk
$ cmake .
$ make -j
$ sudo make install

Quickstart

fib.scm:
(define (fib n)
  (if (< n 2)
	 n
	 (+
	   (fib (- n 1))
	   (fib (- n 2)))))

(display (fib 40))
And run it:
$ hawk fib.scm
Or build a binary:
$ hawk --exe fib.scm
    $ ./fib

Optimizations

Hawk currently supports these classical compiler optimizations:

Benchmarks

A few benchmarks taken from ecravens r7rs-benchmark suite. Tests were run on an AMD Ryxen 9 5900X.

Versions are: Loko 0.12.1, Hawk 0.3.9, Chez 9.5.4, Gambit 4.4.3.

Hawk has an unoptimized continuation representation.
Hawk JIT does not currently support flonums, so all flonums benchmarks mostly use the VM.
Hawk does not currently support ratnums, complex nums, or bignums. Bytevectors are just defined to be strings.