|
jam 0.0.1
A compacting generational garbage collector for C++26
|
This directory adapts jam to collect Java objects on HotSpot and Native Image, with both Java reference processing and GHC-style generalized weak pointers. The intended consumer is thc: Haskell running through Truffle/Graal, with its closures in the host heap.
First, download a runtime or build the patched JDK. Then select Jam with that JVM:
Keep -Xms and -Xmx equal. JamYoungSize sets the nursery capacity; JamPromoteEvery sets the interval between whole-nursery promotion attempts. Java code continues to use its ordinary reference classes.
This requires the Jam-enabled JDK. HotSpot's collector registration is compiled into the VM; a stock JVM cannot load Jam as a collector plugin. See the build guide for dependencies and library paths.
A generalized weak pointer associates a key with a value and an optional finalizer. The value may refer back to the key without keeping the association alive. Java's stock reference types don't provide that operation.
Build the Java/JNI API, then register an association:
Now you can read its value while the association is live:
Any caller can run pending finalizers:
Finalizers are JVM Runnables. A runnable can enter whatever guest context it needs; context identity is invisible to jam-vm. The pump runs callbacks on its calling thread and completes each claim even when execution throws. The integration guide covers explicit finalization, low-level claims, native loading and the thc handoff.
The current targets are macOS arm64, Linux x86_64 and Windows x86_64, using the patched JDK 25 or GraalVM 25.3.4.1, with fixed capacities, stop-the-world collection and compressed oops. Native executables use the SubstrateVM adapter, selected with native-image --gc=jam. See the package platform requirements for OS floors.
The source manifest pins OpenJDK, Graal and the reference implementations. The adapter links the Jam library from this checkout; the root CMake build owns the native dependency. Jam is used directly through its hosted collection API. The HotSpot patch adds the registered collector. Java objects live in jam's heap, using its SIMD compactor and work scheduler.
Original code is BSD-2-Clause OR Apache-2.0. Imported code and patches retain their own terms. See LICENSE.md and NOTICE.md.
Contributions and bug reports are welcome!
Please feel free to contact me through GitHub.
-Edward Kmett