Library
Module
Module type
Parameter
Class
Class type
Representation of ocaml values
This module aims at given a way to inspect the memory layout of ocaml values by providing some type to represent memory layouts, and some functions to convert arbitrary ocaml values into their explicit memory representation.
Contents of the closure info field, stored for each closure in a set of closures.
Represent OCaml blocks.
To have a high-level representation of a block's fields, we distinguish three cases:
and _ cell =
| Int : int -> [< `Inline | `Direct ] cell
Integers
*)| Pointer : addr -> [< `Inline | `Direct ] cell
Pointers to some block
*)| External : Nativeint.t -> [< `Inline ] cell
Out of heap pointer
*)| String : string -> [< `Block ] cell
String
*)| Double : float -> [< `Block | `Inline ] cell
A float
*)| Infix : [ `Inline ] cell
An infix header (used in closures)
*)| Closinfo : closinfo -> [< `Inline ] cell
Closure info field
*)The actual type of memory cells containing concrete values. There are actually three type of cells:
`Direct
cells are values that can be found in ocaml variables`Inline
cells are values that can be found in a block's field array`Block
cells are "big" values that take a whole blockObviously, some constructors can build more than one type of cells.
type pblock = private {
block : block;
The block being pointed at
*)offset : int;
The offset in the block (used in mutually rec closures)
*)}
This represents what is pointed at by a pointer. This is useful considering that an ocaml value can point at a closure within a set of closures, and thus point in the middle of an ocaml value (since there is an infix header, the value being pointed to is also an ocaml value, but things are easier to represent this way).
Apply the given function to a block, and all the blocks it points to (recursively). Each block is visited exactly once (the order is left unspecified though).
val repr : 'a -> [ `Direct ] cell
Get the representation of a direct ocaml value.
A type containing a function to create cells.
val context : (context -> 'a) -> 'a
Allow to use the same context for creating values, i.e. all values created with context.mk
will correctly identify shared values between translated values.