jon.recoil.org

Module Runtime_shape

module Sort = Jkind_types.Sort
module Or_void : sig ... end
module Runtime_layout : sig ... end
type t = private {
  1. desc : desc;
  2. runtime_layout : Runtime_layout.t;
  3. hash : int;
}

Runtime shapes describe the runtime representation of OxCaml values.

While a regular Shape.t can describe both types and module expressions, runtime shapes are specifically concerned with how values are represented at runtime. Every runtime shape has a Runtime_layout.t that describes its physical representation (e.g., boxed value, unboxed float, SIMD vector), but runtime shapes carry additional structural information beyond the layout:

  • For tuples and records: the types of each field
  • For variants: the constructors and their argument types
  • For recursive types: the recursive definition
  • For predefined types: specific information like array element types

This structural information is used during DWARF debug information generation to produce accurate type descriptions that debuggers can use to inspect values at runtime.

and desc = private
  1. | Unknown of Runtime_layout.t
  2. | Predef of predef
  3. | Tuple of {
    1. args : t list;
    2. kind : tuple_kind;
    }
  4. | Variant of {
    1. constructors : constructors;
    2. kind : variant_kind;
    }
  5. | Record of {
    1. fields : string mixed_block_field list;
    2. kind : record_kind;
    }
  6. | Func
  7. | Mu of t
  8. | Rec_var of Shape.DeBruijn_index.t * Runtime_layout.t
and tuple_kind = private
  1. | Tuple_boxed
    (*

    Same treatment as a mixed block; can contain anything in the near future.

    *)
and variant_kind = private
  1. | Variant_boxed
  2. | Variant_attribute_unboxed of Runtime_layout.t
  3. | Variant_polymorphic
and record_kind = private
  1. | Record_attribute_unboxed of Runtime_layout.t
  2. | Record_mixed
and 'label mixed_block_field = private {
  1. field_type : t;
  2. label : 'label;
}
and constructor = private
  1. | Constructor_with_tuple_arg of {
    1. name : string;
    2. args : unit mixed_block_field list;
    }
  2. | Constructor_with_record_arg of {
    1. name : string;
    2. args : string mixed_block_field list;
    }
and constructors = constructor list
and predef =
  1. | Array of array_kind
  2. | Bytes
  3. | Char
  4. | Extension_constructor
  5. | Float
  6. | Float32
  7. | Floatarray
  8. | Int
  9. | Int8
  10. | Int16
  11. | Int32
  12. | Int64
  13. | Lazy_t of t
  14. | Nativeint
  15. | String
  16. | Simd of simd_vec_split
  17. | Exception
  18. | Unboxed of unboxed
and array_kind =
  1. | Regular of t
  2. | Packed of t list
and unboxed =
  1. | Unboxed_float
  2. | Unboxed_float32
  3. | Unboxed_nativeint
  4. | Unboxed_int64
  5. | Unboxed_int32
  6. | Unboxed_int16
  7. | Unboxed_int8
  8. | Unboxed_simd of simd_vec_split
and simd_vec_split =
  1. | Int8x16
  2. | Int16x8
  3. | Int32x4
  4. | Int64x2
  5. | Float16x8
  6. | Float32x4
  7. | Float64x2
  8. | Int8x32
  9. | Int16x16
  10. | Int32x8
  11. | Int64x4
  12. | Float16x16
  13. | Float32x8
  14. | Float64x4
  15. | Int8x64
  16. | Int16x32
  17. | Int32x16
  18. | Int64x8
  19. | Float16x32
  20. | Float32x16
  21. | Float64x8
val runtime_layout_of_unboxed : unboxed -> Runtime_layout.t

Get the runtime layout of a built-in unboxed type.

val simd_vec_split_to_byte_size : simd_vec_split -> int

Get the byte size of a SIMD vector type.

val mixed_block_field : field_type:t -> label:'label -> 'label mixed_block_field

Create a mixed block field with the given type and label.

val map_mixed_block_field_label : ('a -> 'b) -> 'a mixed_block_field -> 'b mixed_block_field

Transform the label of a mixed block field.

val constructor_with_tuple_arg : name:string -> args:unit mixed_block_field list -> constructor

Create a constructor with tuple-style arguments for use in variants.

Note that in args, the order matters for the runtime memory layout. Ensure fields are in the correct order (i.e., values occur before non-values).

val constructor_with_record_arg : name:string -> args:string mixed_block_field list -> constructor

Create a constructor with record-style arguments for use in variants.

Note that in args, the order matters for the runtime memory layout. Ensure fields are in the correct order (i.e., values occur before non-values).

val constructor_name : constructor -> string

Get the name of a constructor.

val constructor_args : constructor -> string option mixed_block_field list

Get the arguments of a constructor as a list of fields with optional labels. Tuple-style constructors have None labels, record-style constructors have Some name labels.

val unknown : Runtime_layout.t -> t

Create an unknown shape with the given runtime layout. Used when more precise type information is unavailable.

val predef : predef -> t

Create a shape for a predefined type.

val tuple : t list -> t

Create a boxed tuple shape from a list of element shapes.

val variant : constructors -> t

Create a boxed variant shape from a list of constructors.

val polymorphic_variant : constructors -> t

Create a polymorphic variant shape from a list of constructors.

val variant_attribute_unboxed : constructor_name:string -> constructor_arg:string option mixed_block_field -> t

Attribute-unboxed variant. Argument must have been flattened beforehand. See type_shape_to_complex_shape.

val record_attribute_unboxed : contents:string mixed_block_field -> t

Attribute-unboxed record. Argument must have been flattened beforehand. See type_shape_to_complex_shape.

val record_mixed : string mixed_block_field list -> t

Mixed record with value layout. Fields must have been unarized beforehand.

val func : t

The shape of a function value (always has Value layout).

val mu : t -> t

Create a recursive type shape. The argument is the body of the recursive type, which may reference rec_var to refer back to the recursive binding.

Create a reference to a recursive binding using de Bruijn indexing.

val runtime_layout : t -> Runtime_layout.t

Project the runtime layout of a shape.

val print : Format.formatter -> t -> unit
val equal : t -> t -> bool
val hash : t -> int
module Cache : Hashtbl.S with type key = t