Skip to content

fplaunchpad/mmtk-ocaml

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

mmtk-ocaml

MMTk memory management bindings for OCaml 5.x, implementing the MMTk VMBinding trait as a drop-in GC backend for the OCaml runtime.

Note: This project uses a modified fork of OCaml 5 with minimal runtime patches to wire in MMTk. These patches should eventually be upstreamed into the official OCaml repository.

Repository layout

mmtk-ocaml/
├── Cargo.toml              # Cargo workspace root (mmtk pulled from crates.io)
├── ocaml-5/                # OCaml 5.4.1 fork (git submodule — built in-tree)
├── mmtk-ocaml-5/           # OCaml 5.x MMTk binding
│   ├── src/
│   ├── include/mmtk_ocaml.h
│   └── Cargo.toml
└── tests/                  # End-to-end tests (C + OCaml)

Getting started

git clone --recursive https://github.com/your-org/mmtk-ocaml
cd mmtk-ocaml

If you already cloned without --recursive:

git submodule update --init

Prerequisites

Dependency Version Notes
Rust stable 2021 rustup update stable
GCC / make system for building OCaml and C tests
mmtk-core 0.32.0 (crates.io) fetched automatically by Cargo
OCaml 5.4.1 pinned in submodule built in-tree via make ocaml

Building

# Build the Rust binding
cargo build

# Build the OCaml compiler from the submodule (needed for OCaml tests)
make ocaml

make ocaml runs ./configure && make inside ocaml-5/ and produces ocaml-5/ocamlopt.opt. This is a one-time step; subsequent make test calls skip it if the compiler is already built.

Running tests

# C test only (no OCaml compiler needed)
make test-c

# Both tests (builds OCaml compiler first if not already done)
make test

# Release build
make test PROFILE=release

Architecture

OCaml runtime (C)
       │  calls
       ▼
mmtk_alloc / mmtk_init / …   ← C API (include/mmtk_ocaml.h)
       │
       ▼
OCaml5VM : VMBinding          ← Rust (mmtk-ocaml-5)
       │  delegates
       ▼
mmtk-core                     ← GC plans: NoGC → MarkSweep → Immix

The OCaml value representation uses LSB=1 for integer immediates. FieldSlot filters these so MMTk never traces integers as heap pointers.

Status

Component OCaml 5.x
VMObjectModel ✅ complete
VMSlot (FieldSlot) ✅ complete
scan_object ✅ complete
spawn_gc_thread
VMActivePlan ✅ domain registry
VMScanning (roots) ⬜ todo
VMCollection (STW) ⬜ todo
NoGC end-to-end ✅ C + OCaml test
MarkSweep / Immix

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors