ssm  0.0.2
Runtime Library for the Sparse Synchronous Model
Blobs

Discussion

The SSM allocator allows programs to allocate contiguous chunks of reference-counted memory whose contents are of arbitrary layout. This object type provides users the flexibility to extend runtime with objects that the runtime does not natively support, so long as they commit to managing stored resources themselves, because the garbage collector will not scan the payload for other managed heap pointers.

Blobs use size-flavored ssm_mm headers, where the size field determines the size of blob payload. To support even larger blob sizes, the actual size is divided by SSM_BLOB_SIZE_SCALE while stored in size.

The heap memory layout for blobs are described by ssm_blob1.

Data Structures

struct  ssm_blob1
 The struct template of a heap-allocated blob. More...
 

Macros

#define SSM_BLOB_SIZE_SCALE   4
 The size resolution for heap-allocated blobs. More...
 
#define ssm_blob_size(size)    (sizeof(struct ssm_blob1) - SSM_BLOB_SIZE_SCALE + (size))
 Compute the size of a blob with its header. More...
 
#define ssm_blob_heap_size(v)    ssm_blob_size(((v).heap_ptr->info.size) * SSM_BLOB_SIZE_SCALE)
 Compute the size a blob in the heap. More...
 
#define ssm_blob_payload(v)    (&*(container_of((v).heap_ptr, struct ssm_blob1, mm)->payload))
 Obtain pointer to the payload of a blob from an ssm_value_t. More...
 
#define ssm_new_blob(s)
 

Functions

ssm_value_t ssm_new_blob_int (uint16_t size)
 Allocate a blob on the heap. More...
 

Macro Definition Documentation

◆ SSM_BLOB_SIZE_SCALE

#define SSM_BLOB_SIZE_SCALE   4

The size resolution for heap-allocated blobs.

Definition at line 1067 of file ssm.h.

◆ ssm_blob_size

#define ssm_blob_size (   size)     (sizeof(struct ssm_blob1) - SSM_BLOB_SIZE_SCALE + (size))

Compute the size of a blob with its header.

The size parameter should already be scaled, i.e., already multiplied by SSM_BLOB_SIZE_SCALE, before being passed into this macro.

Parameters
sizescaled size of the blob's payload.
Returns
size that a blob of size payload occupies in the heap.

Definition at line 1106 of file ssm.h.

◆ ssm_blob_heap_size

#define ssm_blob_heap_size (   v)     ssm_blob_size(((v).heap_ptr->info.size) * SSM_BLOB_SIZE_SCALE)

Compute the size a blob in the heap.

Parameters
vssm_value_t pointing to some blob in the heap.
Returns
size of the blob that v points to.

Definition at line 1114 of file ssm.h.

◆ ssm_blob_payload

#define ssm_blob_payload (   v)     (&*(container_of((v).heap_ptr, struct ssm_blob1, mm)->payload))

Obtain pointer to the payload of a blob from an ssm_value_t.

Definition at line 1118 of file ssm.h.

◆ ssm_new_blob

#define ssm_new_blob (   s)
Value:
(fprintf(stderr, "%s:%d:ssm_new_blob(%lu)\n", __FILE__, __LINE__, (size)), \
ssm_new_blob_int(size))

Definition at line 1128 of file ssm.h.

Function Documentation

◆ ssm_new_blob_int()

ssm_value_t ssm_new_blob_int ( uint16_t  size)

Allocate a blob on the heap.

Parameters
sizesize of the payload to the allocated.
Returns
ssm_value_t pointing to heap-allocated blob.

Definition at line 313 of file ssm-mem.c.