src/register.c - Register handling routines


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 gargabe collector.

void Parrot_alloc_context(Interp *, INTVAL *n_regs_used)

Allocate a new context and set the context pointer.

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 destructur of a continuation.

Register Stack Functions ^

void setup_register_stacks(Interp *)

Sets 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 interpreter, Stack_Chunk_t *stack)

Marks the register stack and it's registers as live.


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