Serene Runtime 1.0.0-dev
C runtime for the Serene programming language
Loading...
Searching...
No Matches
srn_mm_t Struct Reference

Main memory manager structure that will own all the allocated blocks and data. More...

#include <interface.h>

Collaboration diagram for srn_mm_t:
[legend]

Data Fields

srn_spinlock_t lock
 This spinlock is here to protect the srn_mm_t when allocating/deallocating new blocks.
srn_memory_provider_tprovider
 An abstraction over a memory provider like the malloc/free pair.
uint64_t block_bitmap [4]
 This is a 256bit bitmap we treat it as a whole.
size_t block_size
size_t block_count
 Number of live chains.
srn_block_tblocks [MAX_NUMBER_OF_BLOCKS]
srn_spinlock_t chain_locks [MAX_NUMBER_OF_BLOCKS]
 One lock per chain, keyed by block id.
srn_spinlock_t immortal_lock
 The immortal chain has no block id, so it gets its own chain lock.
srn_block_timmortal_block
 Immortal block is a chain of blocks which will never die.

Detailed Description

Main memory manager structure that will own all the allocated blocks and data.

In every instance of the compiler there should be only one instance of this. It should be created via srn_mm_init and destroyed via srn_shutdown_memory_manager.

Definition at line 107 of file interface.h.

Field Documentation

◆ block_bitmap

uint64_t srn_mm_t::block_bitmap[4]

This is a 256bit bitmap we treat it as a whole.

1 means that bit position in the blocks array is occupied for allocation. otherwise it is free.

Definition at line 121 of file interface.h.

◆ block_count

size_t srn_mm_t::block_count

Number of live chains.

Incremented on block allocation and decremented on release, both under lock.

Definition at line 125 of file interface.h.

◆ block_size

size_t srn_mm_t::block_size

Definition at line 122 of file interface.h.

◆ blocks

srn_block_t* srn_mm_t::blocks[MAX_NUMBER_OF_BLOCKS]

Definition at line 126 of file interface.h.

◆ chain_locks

srn_spinlock_t srn_mm_t::chain_locks[MAX_NUMBER_OF_BLOCKS]

One lock per chain, keyed by block id.

Held for the whole allocation walk and by release before freeing the chain. Living here rather than inside the blocks keeps the lock valid while the chain is being freed.

Definition at line 131 of file interface.h.

◆ immortal_block

srn_block_t* srn_mm_t::immortal_block

Immortal block is a chain of blocks which will never die.

We will free the chain at exit. it is there to allocate objects that will be around for the duration of the program.

Definition at line 139 of file interface.h.

◆ immortal_lock

srn_spinlock_t srn_mm_t::immortal_lock

The immortal chain has no block id, so it gets its own chain lock.

Definition at line 134 of file interface.h.

◆ lock

srn_spinlock_t srn_mm_t::lock

This spinlock is here to protect the srn_mm_t when allocating/deallocating new blocks.

It is NOT used to protect blocks themselves. For block level operations we use a block level spinlock

Definition at line 114 of file interface.h.

◆ provider

srn_memory_provider_t* srn_mm_t::provider

An abstraction over a memory provider like the malloc/free pair.

Definition at line 117 of file interface.h.


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