NAME ^

src/register.c - Register handling routines

DESCRIPTION ^

Parrot has 4 register sets, one for each of its basic types. The amount of registers in each set varies depending on the use counts of the respective subroutine and is determined by the PASM/PIR compiler in the register allocation pass (imcc/reg_alloc.c).

There is one register stack to support the saveall and restoreall opcodes. The former copies all registers to a newly allocated storage and points the register base pointers to this storage. In Parrot_pop_regs the register base pointers are restored to the previous values and the allocated register memory is discarded.

Context and Register Allocation Functions ^

static void new_context_mem(Interp *, context_mem *ctx_mem)

Allocate and initialize context memory chunk.

void destroy_context(Interp *)

Free allocated context memory

void create_initial_context(Interp *)

Create initial interpreter context.

void parrot_gc_context(Interp *)

Cleanup dead context memory. Called by the garbage collector.

parrot_context_t *Parrot_alloc_context(Interp *, INTVAL *n_regs_used)

Allocate a new context and set the context pointer. Please note that the register usage n_regs_used is not copied; just the pointer is stored. The function returns the new context.

parrot_context_t *Parrot_push_context(Interp *, INTVAL *n_regs_used)

Like above, remember old context in caller_ctx, suitable to use with Parrot_pop_context.

parrot_context_t *Parrot_dup_context(Interp *, parrot_context_t*)

Like above but duplicate the passed context.

void Parrot_set_context_threshold(Interp *, parrot_context_t *ctxp)

Mark the context as possible threshold.

void Parrot_free_context(Interp *, parrot_context_t *ctxp, int re_use)

Free the context. If re_use is true, this function is called by a return continuation invoke, else from the destructor of a continuation.

void Parrot_pop_context(Interp *)

Free the context created with Parrot_push_context and restore the previous context.

Register Stack Functions ^

void setup_register_stacks(Interp *)

Set up the register stacks.

void Parrot_push_regs(Interp *)

Save all registers onto the register stack.

void Parrot_pop_regs(Interp *)

Restore all registers from register stack.

void mark_register_stack(Parrot_Interp interp, Stack_Chunk_t *stack)

Marks the register stack and its registers as live.

SEE ALSO ^

include/parrot/register.h and src/stack_common.c


parrot