|
Macaulay2 Engine
|
Engine-wide GC allocator surface (getmem / getmem_atomic) and debug-allocation trap. More...
#include <stdlib.h>#include <valgrind/memcheck.h>Go to the source code of this file.
Macros | |
| #define | TRAPCHK(p) |
| #define | TRAPCHK_SIZE(n) |
| #define | sizeofarray(s, len) |
| #define | sizeofarraytype(S, len) |
| #define | sizeofstruct(s) |
| #define | sizeofstructtype(S) |
| #define | getmemarraytype(S, len) |
| #define | getmemstructtype(S) |
| #define | getmematomicarraytype(S, len) |
| #define | getmematomicstructtype(S) |
| #define | getmemvectortype(S, len) |
| #define | getmematomicvectortype(S, len) |
Functions | |
| void | trap (void) |
| void | trapchk (void *) |
| void | trapchk_size (size_t) |
| int | badBlock () |
| static | __attribute__ ((unused)) void debug_version() |
| void | outofmem2 (size_t) |
| char * | getmem (size_t) |
| void | freemem (void *) |
| void | freememlen (void *, size_t) |
| char * | getmem_clear (size_t) |
| char * | getmem_atomic (size_t) |
| char * | getmem_atomic_clear (size_t) |
| void * | I_WRAP_SONAME_FNNAME_ZU (libgcZdsoZd1, GC_malloc)(size_t) |
| void * | I_WRAP_SONAME_FNNAME_ZU (libgcZdsoZd1, GC_malloc_atomic)(size_t) |
| void * | I_WRAP_SONAME_FNNAME_ZU (libgcZdsoZd1, GC_malloc_ignore_off_page)(size_t) |
| void * | I_WRAP_SONAME_FNNAME_ZU (libgcZdsoZd1, GC_malloc_atomic_ignore_off_page)(size_t) |
| void * | I_WRAP_SONAME_FNNAME_ZU (libgcZdsoZd1, GC_realloc)(void * |
Variables | |
| void * | trapaddr |
| int | trapcount |
| int | trapset |
| void | size_t |
Engine-wide GC allocator surface (getmem / getmem_atomic) and debug-allocation trap.
Declares the small extern "C" allocator family every engine translation unit and every generated-C .dd glue file calls to allocate memory: getmem for pointer-bearing GC blocks, getmem_atomic for pointer-free blocks the collector can skip scanning, the *_clear variants that zero-initialise, plus freemem / freememlen for explicit deletion when the caller knows the lifetime, and outofmem2(size_t) as the out-of-memory handler. Implementations sit on top of bdwgc (GC_malloc / GC_malloc_atomic / ...), so a future GC swap only has to retarget this layer.
In non-NDEBUG builds the trap* group (trapaddr, trapcount, trapset, trapchk, trapchk_size, badBlock) gives a lightweight allocation breakpoint: setting trapaddr to a pointer of interest, or arming trapset / trapcount to count down to the N-th allocation, makes the next matching getmem invoke the (empty) trap() function so a debugger can intercept it. The header also brings in Valgrind's function-wrap shims so GC allocations are visible to memcheck. The getmem*arraytype / getmem*structtype / getmem*vectortype macros at the bottom centralise the sizeof arithmetic for length-prefixed arrays, pointee-sized struct allocations, and plain T[len]-shaped vectors (with _atomic variants throughout for pointer-free payloads). An #ifdef MEMDEBUG block additionally exposes the M2_debug_malloc / _free / _realloc / _to_outer / _to_inner hooks for leak-tracking builds.
Definition in file m2-mem.h.