HJMP: JIT-Compiled HQ9+ Interpreter
You’re a HQ9+ programmer. You’re sick of slow HQ9+ implementations written in unstructured, messy code. You’re tired of running HQ9+ interpreters inside of those “better” scripting languages, taunting you with their “features” and “performance.” You want more.
Introducing HJMP (pronounced “HIGH-JUMP”), also known as the Fastest HQ9+ Interpreter in the World. HJMP is a C++ implementation of HQ9+ that uses Just In Time (JIT) compilation to dynamically compile HQ9+ source into machine code and execute it.
HJMP features a clean object-oriented design that allows the user to easily configure HJMP for different HQ9+ implementation backends and runtime detection of platform, allowing it to target the machine code for maximum compatibility and performance. Adding a new target platform requires only the knowledge of the platform’s calling conventions, register clobbering, and assembly instruction set, which almost all HQ9+ programmers have anyways.
HJMP is cross-platform. With JIT compilation enabled, it works on all *nix AMD64 systems, all Windows AMD64 systems, and all x86 systems that use cdecl as its C/C++ calling convention. With JIT compilation disabled, HJMP is still functional as a interpreter that executes HQ9+ source directly.
Source: http://github.com/GHF/hjmp (download archive or
git clone http://github.com/GHF/hjmp.git; *nix Makefile and build instructions included)
Windows 64-bit binaries (produced by MinGW-w64 GCC 4.5.0): //geekshavefeelings.com/files/hjmp/hjmp_bin_win64.zip
Windows 32-bit binaries (produced by TDM MinGW 4.4.1-2): //geekshavefeelings.com/files/hjmp/hjmp_bin_win32.zip
HJMP is, of course, more or less tongue-in-cheek. It is my experiment with using an object-oriented approach to dynamic machine code generation (JIT compilation). Its purpose was not so much to run HQ9+ code, but to explore runtime detection and targeting of code emitters, as well as calling conventions and assembly language on different platforms.
At the time of writing (early 2010), 64-bit computer systems have not yet fully saturated the software market, and we are still in a transitory period between 32-bit and 64-bit. So, HJMP has proved a valuable exercise towards the understanding of the new ISA and its OS-specific details. After all, I say, if you haven’t written machine code or worse, a structured machine code generator for your platform, you don’t fully understand your computer.