ICFP 2024
Mon 2 - Sat 7 September 2024 Milan, Italy
Sat 7 Sep 2024 10:07 - 10:30 at Orange 2 - OCaml compiler features and optimizations Chair(s): Stephen Dolan

This presentation concerns extending OCaml’s uniform value representation to allow some fields of a heap object to not themselves have the uniform value representation. We call such heap objects mixed blocks. The “mixed” suggests that some fields have the uniform value representation and some do not. The garbage collector must not scan those fields that do not, as it has no way to distinguish them from pointers that it must dereference. Mixed blocks are a departure from the current OCaml, which supports only uniform blocks: either all of the fields are scanned or none of the fields are scanned.

The main motivation for mixed blocks is performance. They allow you to store opaque data directly in a heap block alongside other data. This enjoys less indirection than the approach OCaml presently takes, which is to wrap opaque data in a dedicated heap block.

Jane Street also uses mixed blocks as a compilation strategy for structures containing unboxed types, like 64-bit floats.

An implementation of mixed blocks is available in Jane Street’s flambda-backend branch of the OCaml compiler. The approach we take sacrifices generic operations such as comparison.

Paper (ocaml2024-final12.pdf)330KiB

Sat 7 Sep

Displayed time zone: Amsterdam, Berlin, Bern, Rome, Stockholm, Vienna change