ssm  0.0.2
Runtime Library for the Sparse Synchronous Model
ssm_mm Struct Reference

The memory management metadata "header" for heap-allocated objects. More...

#include <ssm.h>

Data Fields

uint8_t ref_count
 The number of references to this object. More...
 
uint8_t kind
 The ssm_kind of object this is. More...
 
union {
   struct {
      uint8_t   count
 Number of ssm_value_t values in payload. More...
 
      uint8_t   tag
 Which variant is inhabited by this object. More...
 
   }   variant
 
   struct {
      uint8_t   count
 Number of ssm_value_t values in payload. More...
 
      uint8_t   cap
 Which variant is inhabited by this object. More...
 
   }   vector
 
   uint16_t   size
 16-bit size More...
 
info
 Three "flavors" of information embedded in the header. More...
 

Detailed Description

The memory management metadata "header" for heap-allocated objects.

This header should always be embedded in heap-allocated objects as the first field (at memory offset 0); values of type ssm_value_t will point to this header and use its kind and other fields to figure out the size and memory layout of the rest of the object.

The interpretation and usage of the latter 16 bits of this header, i.e., the info field, depends on the value of kind. For objects encoding variants (e.g., ssm_adt1), the count field counts the number of fields in the object payload, while the tag records which variant is inhabited by the object. Meanwhile, vector-style objects (e.g., ssm_closure1) also use the count field to record the number of values present, but use the cap field to determine the full capacity of the payload. Finally, objects like arrays and blobs do not need to record more than their size, and benefit from making use of all 16 bits to support up to 65536 sizes.

Definition at line 254 of file ssm.h.

Field Documentation

◆ ref_count

uint8_t ref_count

The number of references to this object.

Definition at line 255 of file ssm.h.

◆ kind

uint8_t kind

The ssm_kind of object this is.

Definition at line 256 of file ssm.h.

◆ count

uint8_t count

Number of ssm_value_t values in payload.

Definition at line 259 of file ssm.h.

◆ tag

uint8_t tag

Which variant is inhabited by this object.

Definition at line 260 of file ssm.h.

◆ 

struct { ... } variant

◆ cap

uint8_t cap

Which variant is inhabited by this object.

Definition at line 264 of file ssm.h.

◆ 

struct { ... } vector

◆ size

uint16_t size

16-bit size

Definition at line 266 of file ssm.h.

◆ 

union { ... } info

Three "flavors" of information embedded in the header.


The documentation for this struct was generated from the following file: