r/cpp • u/No-Summer-1475 • 1h ago
I built Uranium: A statically typed language with a hand-rolled x86_64 JIT (no LLVM) and generational GC in modern C++
Hey everyone,
I wanted to share some architecture insights from a large hobby project I have been developing in modern C++ (C++17/20): an execution environment and compiler runtime called Uranium.
Rather than wiring up heavy third-party backends like LLVM, the goal was to build the entire systems layer directly in C++ to understand execution mechanics at the hardware level.
Key C++ architecture details:
JIT without external libraries (src/native_jit_x64.cpp): Implemented a lightweight assembler in C++ that allocates executable pages (VirtualAlloc on Windows, mprotect on POSIX) and emits raw x86_64 opcodes directly for hot numeric loops and branch patching. It detects hot execution paths via loop back-edge tracking in the interpreter dispatch loop.
Generational GC and Memory Management (src/heap.cpp): Instead of generic smart pointers or standard allocators, memory is managed through an anti-fragmentation object pool using placement new. It features a two-tier generational Mark & Sweep (young nursery vs full sweep) guarded by pointer write barriers (writeBarrier) to maintain remembered sets.
Concurrency & Native Subsystems: Built a cooperative async task scheduler, custom socket abstraction for raw TCP, and embedded SQLite3, all unified within the C++ runtime.
Repository: https://github.com/bruhgit/Uranium-Programming-Language
I would love to get feedback on the modern C++ idioms, memory layout, or any potential architectural bottlenecks from fellow C++ systems developers!