Module Stdlib.Obj

Operations on internal representations of values.

Not for the casual user.

type t;
type raw_data = nativeint;
let repr: 'a => t;
let obj: t => 'a;
let magic: 'a => 'b;
let is_block: t => bool;
let is_int: t => bool;
let tag: t => int;
let size: t => int;
let reachable_words: t => int;

Computes the total size (in words, including the headers) of all heap blocks accessible from the argument. Statically allocated blocks are included.

  • since 4.04
let field: t => int => t;
let set_field: t => int => t => unit;

When using flambda:

set_field MUST NOT be called on immutable blocks. (Blocks allocated in C stubs, or with new_block below, are always considered mutable.)

The same goes for set_double_field.

For experts only: set_field et al can be made safe by first wrapping the block in Sys.opaque_identity, so any information about its contents will not be propagated.

let double_field: t => int => float;
let set_double_field: t => int => float => unit;
let raw_field: t => int => raw_data;
let set_raw_field: t => int => raw_data => unit;
let new_block: int => int => t;
let dup: t => t;
let add_offset: t => Int32.t => t;
let with_tag: int => t => t;
let first_non_constant_constructor_tag: int;
let last_non_constant_constructor_tag: int;
let forcing_tag: int;
let cont_tag: int;
let lazy_tag: int;
let closure_tag: int;
let object_tag: int;
let infix_tag: int;
let forward_tag: int;
let no_scan_tag: int;
let abstract_tag: int;
let string_tag: int;
let double_tag: int;
let double_array_tag: int;
let custom_tag: int;
let int_tag: int;
let out_of_heap_tag: int;
let unaligned_tag: int;
module Extension_constructor: { ... };
module Ephemeron: { ... };

Ephemeron with arbitrary arity and untyped