|
LispBM
|


Go to the source code of this file.
Macros | |
Memory size macros | |
Convert number of memory blocks to number of memory words The block size is determined from the number of status bitpatterns that fit within one bitmap word. Status bit patterns are 2 bits, so in 32bits (one word on 32bit platform) you have 16 status patterns => block size is 16. On 64-bit platforms, LBM_MEMORY_BITMAP_SIZE divides by 2 because one 64-bit bitmap word can track 32 memory words (vs 16 on 32-bit). LBM_MEMORY is allocated as a number of whole WORDS (not bytes). So the thing that decides the possible sizes are really the bitmap sizes. Bitmaps have to be a multiple of words Memory sizes that make sense (32-bit): bitmap size words | memory size words | memory size bytes 1 | 1*16 = 16 | 64 2 | 2*16 = 32 | 128 10 | 10*16 = 160 | 640 64 | 64*16 = 1024 | 4096 100 | 100*16 1600 | 6400 There is a minimal viable size of lbm_memory but it depends on space used byt symbol representations and printing stack, gc stack. things like that. The minimal viable is likely about 4KB (to have approx 2KB lbm_mem avail at runtime) | |
| #define | LBM_MEMORY_SIZE_BLOCKS_TO_WORDS(X) (16*(X)) |
| #define | LBM_MEMORY_SIZE_64BYTES_TIMES_X(X) (16*(X)) |
| #define | LBM_MEMORY_BITMAP_SIZE(X) (X) |
Legacy Size Macros (deprecated) | |
| |
| #define | LBM_MEMORY_SIZE_512 LBM_MEMORY_SIZE_64BYTES_TIMES_X(8) |
| #define | LBM_MEMORY_SIZE_1K LBM_MEMORY_SIZE_64BYTES_TIMES_X(16) |
| #define | LBM_MEMORY_SIZE_2K LBM_MEMORY_SIZE_64BYTES_TIMES_X(32) |
| #define | LBM_MEMORY_SIZE_4K LBM_MEMORY_SIZE_64BYTES_TIMES_X(64) |
| #define | LBM_MEMORY_SIZE_8K LBM_MEMORY_SIZE_64BYTES_TIMES_X(128) |
| #define | LBM_MEMORY_SIZE_10K LBM_MEMORY_SIZE_64BYTES_TIMES_X(160) |
| #define | LBM_MEMORY_SIZE_12K LBM_MEMORY_SIZE_64BYTES_TIMES_X(192) |
| #define | LBM_MEMORY_SIZE_14K LBM_MEMORY_SIZE_64BYTES_TIMES_X(224) |
| #define | LBM_MEMORY_SIZE_16K LBM_MEMORY_SIZE_64BYTES_TIMES_X(256) |
| #define | LBM_MEMORY_SIZE_32K LBM_MEMORY_SIZE_64BYTES_TIMES_X(512) |
| #define | LBM_MEMORY_SIZE_1M LBM_MEMORY_SIZE_64BYTES_TIMES_X(16384) |
| #define | LBM_MEMORY_BITMAP_SIZE_512 LBM_MEMORY_BITMAP_SIZE(8) |
| #define | LBM_MEMORY_BITMAP_SIZE_1K LBM_MEMORY_BITMAP_SIZE(16) |
| #define | LBM_MEMORY_BITMAP_SIZE_2K LBM_MEMORY_BITMAP_SIZE(32) |
| #define | LBM_MEMORY_BITMAP_SIZE_4K LBM_MEMORY_BITMAP_SIZE(64) |
| #define | LBM_MEMORY_BITMAP_SIZE_8K LBM_MEMORY_BITMAP_SIZE(128) |
| #define | LBM_MEMORY_BITMAP_SIZE_10K LBM_MEMORY_BITMAP_SIZE(160) |
| #define | LBM_MEMORY_BITMAP_SIZE_12K LBM_MEMORY_BITMAP_SIZE(192) |
| #define | LBM_MEMORY_BITMAP_SIZE_14K LBM_MEMORY_BITMAP_SIZE(224) |
| #define | LBM_MEMORY_BITMAP_SIZE_16K LBM_MEMORY_BITMAP_SIZE(256) |
| #define | LBM_MEMORY_BITMAP_SIZE_32K LBM_MEMORY_BITMAP_SIZE(512) |
| #define | LBM_MEMORY_BITMAP_SIZE_1M LBM_MEMORY_BITMAP_SIZE(16384) |
Functions | |
| bool | lbm_memory_init (lbm_uint *data, lbm_uint data_size, lbm_uint *bitmap, lbm_uint bitmap_size) |
| void | lbm_memory_set_reserve (lbm_uint num_words) |
| lbm_uint | lbm_memory_get_reserve (void) |
| lbm_uint | lbm_memory_num_words (void) |
| lbm_uint | lbm_memory_num_free (void) |
| lbm_uint | lbm_memory_maximum_used (void) |
| void | lbm_memory_update_min_free (void) |
| lbm_uint | lbm_memory_longest_free (void) |
| lbm_uint * | lbm_memory_allocate (lbm_uint num_words) |
| int | lbm_memory_free (lbm_uint *ptr) |
| void * | lbm_malloc (size_t size) |
| void * | lbm_malloc_reserve (size_t size) |
| void | lbm_free (void *ptr) |
| int | lbm_memory_shrink (lbm_uint *ptr, lbm_uint n) |
| int | lbm_memory_ptr_inside (lbm_uint *ptr) |
| lbm_int | lbm_memory_address_to_ix (lbm_uint *ptr) |
| #define LBM_MEMORY_BITMAP_SIZE | ( | X | ) | (X) |
| #define LBM_MEMORY_BITMAP_SIZE_10K LBM_MEMORY_BITMAP_SIZE(160) |
| #define LBM_MEMORY_BITMAP_SIZE_12K LBM_MEMORY_BITMAP_SIZE(192) |
| #define LBM_MEMORY_BITMAP_SIZE_14K LBM_MEMORY_BITMAP_SIZE(224) |
| #define LBM_MEMORY_BITMAP_SIZE_16K LBM_MEMORY_BITMAP_SIZE(256) |
| #define LBM_MEMORY_BITMAP_SIZE_1K LBM_MEMORY_BITMAP_SIZE(16) |
| #define LBM_MEMORY_BITMAP_SIZE_1M LBM_MEMORY_BITMAP_SIZE(16384) |
| #define LBM_MEMORY_BITMAP_SIZE_2K LBM_MEMORY_BITMAP_SIZE(32) |
| #define LBM_MEMORY_BITMAP_SIZE_32K LBM_MEMORY_BITMAP_SIZE(512) |
| #define LBM_MEMORY_BITMAP_SIZE_4K LBM_MEMORY_BITMAP_SIZE(64) |
| #define LBM_MEMORY_BITMAP_SIZE_512 LBM_MEMORY_BITMAP_SIZE(8) |
| #define LBM_MEMORY_BITMAP_SIZE_8K LBM_MEMORY_BITMAP_SIZE(128) |
| #define LBM_MEMORY_SIZE_10K LBM_MEMORY_SIZE_64BYTES_TIMES_X(160) |
| #define LBM_MEMORY_SIZE_12K LBM_MEMORY_SIZE_64BYTES_TIMES_X(192) |
| #define LBM_MEMORY_SIZE_14K LBM_MEMORY_SIZE_64BYTES_TIMES_X(224) |
| #define LBM_MEMORY_SIZE_16K LBM_MEMORY_SIZE_64BYTES_TIMES_X(256) |
| #define LBM_MEMORY_SIZE_1K LBM_MEMORY_SIZE_64BYTES_TIMES_X(16) |
| #define LBM_MEMORY_SIZE_1M LBM_MEMORY_SIZE_64BYTES_TIMES_X(16384) |
| #define LBM_MEMORY_SIZE_2K LBM_MEMORY_SIZE_64BYTES_TIMES_X(32) |
| #define LBM_MEMORY_SIZE_32K LBM_MEMORY_SIZE_64BYTES_TIMES_X(512) |
| #define LBM_MEMORY_SIZE_4K LBM_MEMORY_SIZE_64BYTES_TIMES_X(64) |
| #define LBM_MEMORY_SIZE_512 LBM_MEMORY_SIZE_64BYTES_TIMES_X(8) |
| #define LBM_MEMORY_SIZE_64BYTES_TIMES_X | ( | X | ) | (16*(X)) |
| #define LBM_MEMORY_SIZE_8K LBM_MEMORY_SIZE_64BYTES_TIMES_X(128) |
| #define LBM_MEMORY_SIZE_BLOCKS_TO_WORDS | ( | X | ) | (16*(X)) |
| void lbm_free | ( | void * | ptr | ) |
Free memory allocated with lbm_malloc
| Pointer | to array to free |
| void * lbm_malloc | ( | size_t | size | ) |
Malloc like interface to lbm_memory
| size | Size in bytes of memory to allocate. |
| void * lbm_malloc_reserve | ( | size_t | size | ) |
Allocate memory potentially from the reserved memory.
| size | Size in bytes of memory to allocate. |
Allocate a number of words from the symbols and arrays memory.
| num_words | Number of words to allocate. |
| int lbm_memory_free | ( | lbm_uint * | ptr | ) |
Free an allocated array in the symbols and arrays memory.
| ptr | Pointer to array to free. |
| lbm_uint lbm_memory_get_reserve | ( | void | ) |
Get the number of words of memory that is treated as reserve.
| bool lbm_memory_init | ( | lbm_uint * | data, |
| lbm_uint | data_size, | ||
| lbm_uint * | bitmap, | ||
| lbm_uint | bitmap_size | ||
| ) |
Initialize the symbols and arrays memory
| data | Pointer to an array of uint32_t for data storage. |
| data_size | The size of the data storage array in number of uint32_t elements. |
| bitmap | Pointer to an array of uint32_t for memory allocator meta-data. |
| bitmap_size | The size of the meta-data in number of uint32_t elements. |
| lbm_uint lbm_memory_longest_free | ( | void | ) |
Find the length of the longest run of consecutire free indices in the LBM memory.
| lbm_uint lbm_memory_maximum_used | ( | void | ) |
Get the maximum of memory usage.
| lbm_uint lbm_memory_num_free | ( | void | ) |
| lbm_uint lbm_memory_num_words | ( | void | ) |
Size of of the symbols and arrays memory in uint32_t chunks.
| int lbm_memory_ptr_inside | ( | lbm_uint * | ptr | ) |
Check if a pointer points into the lbm_memory
| ptr |
| void lbm_memory_set_reserve | ( | lbm_uint | num_words | ) |
Set the size of the memory reserve in words.
| num_words | Number of words to treat as reserve. |
Shrink an allocated array.
| ptr | Pointer to array to shrink |
| n | New smaller size of array |
| void lbm_memory_update_min_free | ( | void | ) |
Update memory usage statistics. called by GC automatically