Skip to main content

Module object

Module object 

Source
Expand description

Object model of lean.h: object layouts, allocation, reference counting, boxing and constructor objects.

The layouts are the ones of lean.h on a 64-bit machine. Reference counting is single-threaded: m_rc > 0 is the count, m_rc == 0 marks a persistent object (inc/dec are no-ops), and negative counts are never created. With debug_assertions a freed object has its count set to FREED_RC and its memory is kept for a while, so that a later increment, decrement or field access of it panics.

Re-exports§

pub use crate::panic::lean_internal_panic;
pub use crate::panic::lean_internal_panic_out_of_memory;
pub use crate::panic::lean_internal_panic_rc_overflow;
pub use crate::panic::lean_internal_panic_unreachable;

Structs§

ArrayObject
ClosureObject
CtorObject
ExternalClass
lean_external_class.
ExternalObject
MpzObject
A big natural number or integer (mpz_object), holding a num-bigint value.
Object
Header of every heap object (lean_object).
RefObject
SArrayObject
StringObject
TaskObject
Tasks run synchronously when they are created, so m_imp is always null and m_value is set.
ThunkObject

Constants§

FREED_RC
Reference count written into a freed object when debug_assertions are enabled.
LEAN_ARRAY
LEAN_CLOSURE
LEAN_EXTERNAL
LEAN_LINEAR_MARK_MASK
Linearity marker bit in m_other of arrays, scalar arrays and strings.
LEAN_MAX_CTOR_TAG
LEAN_MPZ
LEAN_PROMISE
LEAN_REF
LEAN_RESERVED
LEAN_SCALAR_ARRAY
LEAN_STRING
LEAN_STRUCT_ARRAY
LEAN_TASK
LEAN_THUNK

Functions§

debug_check_live⚠
Panics (with debug_assertions) if o is a freed object.
lean_alloc_ctor⚠
Allocates a constructor object; the object fields are left for lean_ctor_set, the scalar area is zeroed.
lean_alloc_external⚠
lean_alloc_object⚠
Allocates sz bytes for an object (lean_alloc_object). The header is not initialized.
lean_alloc_ref⚠
lean_alloc_small_object⚠
lean_array_cptr⚠
lean_box
lean_box_float⚠
lean_box_float32⚠
lean_box_uint32⚠
lean_box_uint64⚠
lean_box_usize⚠
lean_closure_arg_cptr⚠
lean_ctor_get⚠
lean_ctor_get_float⚠
Reads a scalar field at offset bytes from the start of the object fields.
lean_ctor_get_float32⚠
Reads a scalar field at offset bytes from the start of the object fields.
lean_ctor_get_uint8⚠
Reads a scalar field at offset bytes from the start of the object fields.
lean_ctor_get_uint16⚠
Reads a scalar field at offset bytes from the start of the object fields.
lean_ctor_get_uint32⚠
Reads a scalar field at offset bytes from the start of the object fields.
lean_ctor_get_uint64⚠
Reads a scalar field at offset bytes from the start of the object fields.
lean_ctor_get_usize⚠
lean_ctor_num_objs⚠
lean_ctor_obj_cptr⚠
lean_ctor_release⚠
lean_ctor_scalar_cptr⚠
lean_ctor_set⚠
lean_ctor_set_float⚠
Writes a scalar field at offset bytes from the start of the object fields.
lean_ctor_set_float32⚠
Writes a scalar field at offset bytes from the start of the object fields.
lean_ctor_set_tag⚠
lean_ctor_set_uint8⚠
Writes a scalar field at offset bytes from the start of the object fields.
lean_ctor_set_uint16⚠
Writes a scalar field at offset bytes from the start of the object fields.
lean_ctor_set_uint32⚠
Writes a scalar field at offset bytes from the start of the object fields.
lean_ctor_set_uint64⚠
Writes a scalar field at offset bytes from the start of the object fields.
lean_ctor_set_usize⚠
lean_dealloc⚠
Returns the memory block of an object of sz bytes to the allocator.
lean_dec⚠
lean_dec_ref⚠
lean_dec_ref_cold⚠
Frees o (whose count dropped to zero) and every object only reachable from it, with an explicit work list instead of recursion (lean_del).
lean_del_object⚠
Frees the memory of o unless it is a scalar (del in the IR).
lean_free_object⚠
Frees the memory of an object without touching its fields (lean_free_object).
lean_free_small_object⚠
lean_get_external_class⚠
lean_get_external_data⚠
lean_has_rc⚠
lean_inc⚠
lean_inc_n⚠
lean_inc_ref⚠
lean_inc_ref_n⚠
lean_is_array⚠
lean_is_closure⚠
lean_is_ctor⚠
lean_is_exclusive⚠
lean_is_exclusive_obj⚠
lean_is_external⚠
lean_is_mpz⚠
lean_is_persistent⚠
lean_is_ref⚠
lean_is_sarray⚠
lean_is_scalar
lean_is_shared⚠
lean_is_st⚠
lean_is_string⚠
lean_is_task⚠
lean_is_thunk⚠
lean_mark_mt⚠
lean_mark_persistent⚠
Marks o and every object reachable from it as persistent (RC 0).
lean_nonzero_rc⚠
lean_obj_tag⚠
lean_object_byte_size⚠
Size in bytes of the memory block of an object (lean_object_byte_size).
lean_ptr_addr
lean_ptr_other⚠
lean_ptr_tag⚠
lean_sarray_elem_size⚠
lean_set_external_data⚠
lean_set_non_heap_header⚠
lean_set_non_heap_header: persistent header (RC 0).
lean_set_st_header⚠
lean_set_st_header: single-threaded header with RC 1.
lean_unbox
lean_unbox_float⚠
lean_unbox_float32⚠
lean_unbox_uint32⚠
lean_unbox_uint64⚠
lean_unbox_usize⚠

Type Aliases§

Obj
A Lean value: a pointer to a heap object, or a scalar (n << 1) | 1.