parrotcode: Allocate and deallocate tracked resources | |
Contents | C |
src/gc/resources.c - Allocate and deallocate tracked resources
static void alloc_new_block(PARROT_INTERP, size_t size, NOTNULL(Memory_Pool *pool), NOTNULL(const char *why))
PARROT_MALLOC PARROT_CANNOT_RETURN_NULL static void *mem_allocate(PARROT_INTERP, size_t size, NOTNULL(Memory_Pool *pool))
+-----------------+
| ref_count |f | # GC header
obj->bufstart -> +-----------------+
| data |
v v
* if PObj_is_COWable is set, then we have
- a ref_count, {inc, dec}remented by 2 always
- the lo bit 'f' means 'is being forwarded" - what TAIL_flag was
* if PObj_align_FLAG is set, obj->bufstart is aligned like discussed above
* obj->buflen is the usable length excluding the optional GC part.
PARROT_CANNOT_RETURN_NULL PARROT_WARN_UNUSED_RESULT static const char *buffer_location(PARROT_INTERP, NOTNULL(const PObj *b))
static void debug_print_buf(PARROT_INTERP, NOTNULL(const PObj *b))
static void compact_pool(PARROT_INTERP, NOTNULL(Memory_Pool *pool))
void Parrot_go_collect(PARROT_INTERP)
PARROT_PURE_FUNCTION PARROT_WARN_UNUSED_RESULT static size_t aligned_size(NOTNULL(const Buffer *buffer), size_t len)
PARROT_CANNOT_RETURN_NULL PARROT_WARN_UNUSED_RESULT static char *aligned_mem(NOTNULL(const Buffer *buffer), NOTNULL(char *mem))
PARROT_CONST_FUNCTION PARROT_WARN_UNUSED_RESULT static size_t aligned_string_size(size_t len)
PARROT_WARN_UNUSED_RESULT int Parrot_in_memory_pool(PARROT_INTERP, NOTNULL(void *bufstart))
void Parrot_reallocate(PARROT_INTERP, NOTNULL(Buffer *buffer), size_t tosize)
void Parrot_reallocate_string(PARROT_INTERP, NOTNULL(STRING *str), size_t tosize)
str->strstart
to the new buffer location, str->bufused
is not changed.void Parrot_allocate(PARROT_INTERP, NOTNULL(Buffer *buffer), size_t size)
size
has to be a multiple of the word size. PObj_buflen
will be set to exactly the given size
.void Parrot_allocate_aligned(PARROT_INTERP, NOTNULL(Buffer *buffer), size_t size)
size
will be rounded up and the address of the buffer will have the same alignment as a pointer returned by malloc(3) suitable to hold e.g. a FLOATVAL
array.void Parrot_allocate_string(PARROT_INTERP, NOTNULL(STRING *str), size_t size)
size
. This function sets also str->strstart
to the new buffer location, str->bufused
is not changed.PARROT_MALLOC PARROT_CANNOT_RETURN_NULL static Memory_Pool *new_memory_pool(size_t min_block, NULLOK(compact_f compact))
void Parrot_initialize_memory_pools(PARROT_INTERP)
void Parrot_destroy_memory_pools(PARROT_INTERP)
static void merge_pools(NOTNULL(Memory_Pool *dest), NOTNULL(Memory_Pool *source))
void Parrot_merge_memory_pools(NOTNULL(Interp *dest_interp), NOTNULL(Interp *source_interp))
source_interp
into dest_interp
.include/parrot/resources.h, src/gc/memory.c.
Initial version by Dan on 2001.10.2.
|