Ronald Caesar 35ef021fc9 engine: add magic numbers to verify struct integrity
The main focus of this commit is 'bal_safety.h'. This header file
adds magic numbers to prevent Undefined Behavior. Right now this
has only been added to 'bal_assembler_t'.

This introduces 3 magic numbers:

#define BAL_MAGIC_UNINITIALIZED 0x00000000U
#define BAL_ASSEMBLER_MAGIC_ALIVE 0xBA11A550U
#define BAL_ASSEMBLER_MAGIC_DEAD  0xDEADBA11U

'ALIVE' magic numbers will be set only if the struct has been
initialized properly. Every function should check a struct's magic
number to make sure it's not operating on a memory corrupted struct.

'DEAD' magic numbers should be set on a struct's 'destory()' function.
This is done to prevent Double Free and Use-After-Free scenarios.

Convenience macro 'BAL_CHECK_MAGIC' and 'BAL_CHECK_MAGIC_VOID' have
been added to easily validate struct integrity.

Signed-off-by: Ronald Caesar <github43132@proton.me>
2026-06-17 03:20:17 -04:00
2026-06-11 22:11:21 -04:00
2026-06-05 03:49:36 -04:00
2026-06-07 18:55:17 -04:00
2025-12-12 18:29:36 -04:00
2025-12-07 13:09:15 -04:00
2026-06-12 04:57:24 -04:00

The Ballistic JIT Engine

„The world's fastest ARM recompiler“

Overview

This is a rewrite of the dynarmic recompiler, with the goal of fixing its many flaws.

Version 1.0 Goals

  • Create Tier 1 backend compiler.
  • Create Tier 2 backend compiler.
  • Support MOVZ, MOVK, MOVN instructions on both compilers.
  • Add more peephole optimizations.
  • Have 100% branch coverage.
  • Have a config to change Ballistic behavior at runtime.
  • Support Block linking.
  • Map ARM flags to x86 flags.
  • Support 128-bit types and x86 SSE/AVX instructions.
  • Add exception handling and recover guest CPU state.
  • Add register spilling.
  • Add Software Page Tables for MMIO and expose the page table memory layout.
  • Handle Guest W^X and Guest RO/RW.
  • Support Guest Write permissions and MMIO write traps for bal_translate_write_function_t.
  • Allow the Guest to inform the memory subsystem that a Guest page has changed state.
  • Invalidate JIT caches when Guest memory is modified using bal_invalidate_git_cache_function_t.
  • Rewrite tools/cdoc.c
  • Rewrite all Python scripts in Lua.
  • Add code examples on how to use a header file like in bal_x86_sliding_window.h.
  • Reorganize all functions in alphabetical order in .c and .h files.
  • Add benchmarks measuring compilation speed compared to other JIT compilers.

Building Ballistic

Install Dependencies

macOS

brew install cmake python3 llvm

Debian/Ubuntu

sudo apt update
sudo apt install build-essential cmake python3

Fedora

sudo dnf install cmake python3 gcc-c++

Configure CMake

mkdir build
cd build
cmake ..

Build Binaries

cmake --build .

The compiled executables will be created in the build/bin and build/lib directories.

See tools/ for more information on these executables.

S
Description
No description provided
Readme GPL-2.0 72 MiB
Languages
C 37.7%
cpp 36.8%
Lua 21.3%
XSLT 2%
C++ 1.2%
Other 1%