ssm
0.0.2
Runtime Library for the Sparse Synchronous Model
|
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... | |
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.
uint8_t count |
Number of ssm_value_t values in payload.
struct { ... } variant |
struct { ... } vector |
union { ... } info |
Three "flavors" of information embedded in the header.