Thunder

Copyright © 2024 J. M. Spivey
Jump to navigation Jump to search

Thunder is a portable library for dynamic generation of machine code, with backends (so far) for the x86/amd64 (in both 32 and 64 bit mode), the ARM32 and the MIPS32. It presents an interface rather like a generic RISC machine, and on each target generates the native instructions needed to realise each RISC operation.

Thunder was designed to support a JIT-based implementation of the Keiko stack machine, itself the target of the Oxford Oberon-2 compiler. It began as a re-implementation of GNU Lightning, but has evolved since. GNU Lightning supports fairly well applications where target registers are used for fixed tasks, but it does not work so well when the client is (like the Keiko JIT) able to allocate and use multiple general-purpose registers: in such cases, the compile-time simplifications assumed by the design of Lightning are less effective, and there is danger of significant code bloat.

Thunder can be downloaded from GitHub (https://github.com/Spivoxity/thunder), and there is a page here with a basic tutorial, another page that discusses a larger example, and a listing of the Thunder instruction set.