Operations on internal representations of values.
Not for the casual user.
external repr : 'a -> t = "%identity"
external obj : t -> 'a = "%identity"
val is_block : t -> bool
external is_int : t -> bool = "%obj_is_int"
external tag : t -> int = "caml_obj_tag"
external size : t -> int = "%obj_size"
external reachable_words : t -> int = "caml_obj_reachable_words"
Computes the total size (in words, including the headers) of all heap blocks accessible from the argument. Statically allocated blocks are excluded.
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
and set_tag
. However, for
set_tag
, in the case of immutable blocks where the middle-end optimizers
never see code that discriminates on their tag (for example records), the
operation should be safe. Such uses are nonetheless discouraged.
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.
external set_tag : t -> int -> unit = "caml_obj_set_tag"
val double_field : t -> int -> float
val set_double_field : t -> int -> float -> unit
external new_block : int -> int -> t = "caml_obj_block"
external truncate : t -> int -> unit = "caml_obj_truncate"
external add_offset : t -> Stdlib.Int32.t -> t = "caml_obj_add_offset"
The following two functions are deprecated. Use module Marshal instead.
val marshal : t -> bytes
val unmarshal : bytes -> int -> t * int
module Ephemeron : sig ... end