NAME ^

src/headers.c - Header management functions

DESCRIPTION ^

Handles getting of various headers, and pool creation.

Buffer Header Functions for small-object lookup table ^

static void *get_free_buffer

Gets a free Buffer from pool and returns it. Memory is cleared.

Header Pool Creation Functions ^

Small_Object_Pool *new_pmc_pool

Creates an new pool for PMCs and returns it.

Small_Object_Pool *new_bufferlike_pool

Creates a new pool for buffer-like structures. Usually you would need make_bufferlike_pool().

Small_Object_Pool *new_buffer_pool

Non-constant strings and plain Buffers are in the sized header pools.

Small_Object_Pool *new_string_pool

Creates a new pool for STRINGS and returns it.

Small_Object_Pool *make_bufferlike_pool

Make and return a bufferlike header pool.

Small_Object_Pool *get_bufferlike_pool

Return a bufferlike header pool, it must exist.

PMC *new_pmc_header

Get a header.

static PMC_EXT *new_pmc_ext

Creates a new PMC_EXT and returns it.

void add_pmc_ext

Adds a new PMC_EXT to pmc.

void add_pmc_sync

Adds a PMC_sync field to pmc.

STRING *new_string_header

Returns a new STRING header.

Buffer *new_buffer_header

Creates and returns a new Buffer.

void *new_bufferlike_header

Creates and returns a new buffer-like header.

size_t get_max_buffer_address

Calculates the maximum buffer address and returns it.

size_t get_min_buffer_address

Calculates the minimum buffer address and returns it.

size_t get_max_pmc_address

Calculates the maximum PMC address and returns it.

size_t get_min_pmc_address

Calculates the maximum PMC address and returns it.

int is_buffer_ptr

Checks that ptr is actually a Buffer.

int is_pmc_ptr

Checks that ptr is actually a PMC.

void Parrot_initialize_header_pools

Initialize the pools for the tracked resources.

int Parrot_forall_header_pools

Iterate through all header pools by calling the passed function. Returns zero if the iteration didn't stop or the returned value.

flag is one of

  POOL_PMC
  POOL_BUFFER
  POOL_CONST
  POOL_ALL
Only matching pools will be used.

arg

This argument is passed on to the iteration function.

pool_iter_fn

It is called with Interp*, Small_Object_Pool *, int flag, void *arg) If the function returns a non-zero value iteration will stop.

static void free_pool

Loops backwards through the provided pool, freeing all of its arenas.

static int sweep_cb_buf

Sweeps and frees the provided pool. Returns 0.

static int sweep_cb_pmc

Sweeps and frees a memory pool. Returns 0.

void Parrot_destroy_header_pools

Destroys the header pools.

static void fix_pmc_syncs

Walks through the given arena, looking for all live and shared PMCs, transferring their sync values to the destionation interpreter.

void Parrot_merge_header_pools

Merge the header pools of source_interp into those of dest_interp. (Used to deal with shared objects left after interpreter destruction.)

void Parrot_initialize_header_pool_names

If we want these names, they must be added in DOD.

SEE ALSO ^

include/parrot/headers.h.

HISTORY ^

Initial version by Mike Lambert on 2002.05.27.


parrot