From Kaffeine to AROS: the 68k JIT lands in mainline

On this page

On November 24, the JIT engine I wrote for Kaffeine landed in the AROS main branch as m68kjit.library. It translates Motorola 68k code into AArch64 instructions and plugs into the compatibility library AROS already uses. The engine was merged, not the whole Kaffeine project. The route to that merge started with a less glamorous problem than speed: making a program behave correctly before making it faster.

What the preview taught me

The first ARM64 preview of Kaffeine asked a practical question: how much Amiga 68k software can run inside native AROS without booting an entire emulated Amiga? Personal Paint was a useful test because it had to do more than execute a loop. It had to open, draw, save a file and read it back. That QEMU demonstration documented one working path in the preview. It was neither a general compatibility claim nor a test of the newly merged JIT.

An application sees more than the CPU. It expects the right stack size, arguments and streams when launched from the Shell, a loader that understands HUNK executables, and libraries that follow 68k calling conventions. I started with process stacks, arguments and streams, then worked on loader checks and the lifetime of copied segment lists. If m68kemu.library is missing, the loader now refuses to enter 68k code as if it were native.

Two fixes show what separates executing instructions from running software. A call such as SystemTagList() could report success without starting the command: I corrected the offsets and registers used by the DOS bridge. I also fixed how pointers are returned. A native address does not become valid for a 68k program just because it fits below 4 GiB. The program needs an address in its own space or a handle. Both fixes matter even with the JIT off.

Two pull requests, with the interpreter still in charge

The original proposal bundled the interface and translator. It was too large to review in one pass, so I split it. The optional engine interface landed on November 21, with tests that use dummy engines to execute one instruction or decline them all. The AArch64 translator landed on November 24, adapted from code I wrote for Kaffeine and contributed under the AROS Public License. During review I removed the fast table, made code memory grow on demand and corrected overflow reporting for signed long division.

The result is not a second emulator running alongside the first. m68kemu.library keeps Moira as its reference interpreter. The JIT runs a stretch of code when it can and returns control for library calls, exceptions or instructions it does not translate. The interpreter remains the default. With M68KEMU_CPU=auto, AROS falls back to the interpreter if the engine is unavailable or cannot take the program. With M68KEMU_CPU=jit, the program does not start in that situation. The merged engine is AArch64-only and does not translate FPU or MMU instructions.

What the tests establish

The PR records 71,636 host checks with no failures and differential comparisons over millions of cases. The JIT did not execute every case: declined instructions and stops were counted separately. For division where Moira differed, the Motorola manual was the reference. On an AROS raspi-aarch64 guest in QEMU, all 14 test_m68kemu subtests passed with and without the JIT; the documented runs also covered BOOPSI callbacks and timers. A faster synthetic loop under QEMU is not a Personal Paint benchmark, and the cover is an illustration, not evidence of a test on a Raspberry Pi 500.

The merge puts the engine in the AROS source tree. It is not an announcement of a new installable release. Kaffeine can still be my test bed while fixes go into the shared compatibility layer and the engine remains an option rather than replacing the interpreter. The next result I want is repeatable evidence from real applications on AArch64 hardware, running the same program with and without the JIT.

Sources

AUTHOR

IT specialist, developer and systems engineer with a long history across code, Linux servers, retrocomputers and e-learning platforms. On AndroidLab he brings a technical, pragmatic eye: less brochure smoke, more attention to infrastructure, usability, privacy, updates and the real consequences of manufacturers' choices.

Leave a Comment