NAME ^

src/gc/resources.c - Handling Small Object Pools

DESCRIPTION ^

Handles the accessing of small object pools (header pools).

Functions ^

INTVAL contained_in_pool

Returns whether the given *ptr points to a location in pool.

int Parrot_is_const_pmc

Returns whether *pmc is a constant PMC. The given pointer is a constant PMC if it points into the constant PMC pool.

static void more_traceable_objects

We're out of traceable objects. First we try a DOD run to free some up. If that doesn't work, allocate a new arena.

static void gc_ms_add_free_pmc_ext

Add a freed PMC_EXT structure to the free list in the PMC_EXT pool. Objects on the free list can be reused later.

static void gc_ms_add_free_object

Add an unused object back to the pool's free list for later reuse. Set the PObj flags to indicate that the item is free.

static void *gc_ms_get_free_object

Free object allocator for the MS garbage collector system. If there are no free objects, call gc_ms_add_free_object to either free them up with a DOD run, or allocate new objects. If there are objects available on the free list, pop it off and return it.

static void *gc_ms_get_free_pmc_ext

Get a new PMC_EXT structure from the free pool and return it.

void Parrot_add_to_free_list

Adds the objects in the newly allocated arena to the free list.

void Parrot_append_arena_in_pool

Insert the new arena into the pool's structure. Arenas are stored in a linked list, so add the new arena to the list. Set information in the arenas structure, such as the number of objects allocated in it.

static void gc_ms_alloc_objects

New arena allocator function for the MS garbage collector system. Allocates and initializes a new memory arena in the given pool. Adds all the new objects to the pool's free list for later allocation.

Small_Object_Pool *new_small_object_pool

Creates a new Small_Object_Pool and returns a pointer to it. Initializes the pool structure based on the size of objects in the pool and the number of items to allocate in each arena.

void gc_pmc_ext_pool_init

Initialize the PMC_EXT pool functions. This is done separately from other pools.

static void gc_ms_pool_init

Initialize a memory pool for the MS garbage collector system. Sets the function pointers necessary to perform basic operations on a pool, such as object allocation.

void Parrot_gc_ms_init

Initialize the state structures of the gc system. Called immediately before creation of memory pools. This function must set the function pointers for add_free_object_fn, get_free_object_fn, alloc_object_fn, and more_object_fn.

void Parrot_small_object_pool_merge

Merge pool source into pool dest. Combines the free lists directly, moves all arenas to the new pool, and remove the old pool. To merge, the two pools must have the same object size, and the same name (if they have names).

SEE ALSO ^

include/parrot/smallobject.h, docs/memory_internals.pod.


parrot