NAME ^

src/sub.c - Subroutines

DESCRIPTION ^

Subroutines, continuations, co-routines and other fun stuff...

Functions ^

void save_context(Interp *interp, struct Parrot_Context *ctx)

Save the current "context" of interpreter.

void restore_context(Interp *interp, struct Parrot_Context *ctx)

Set context of interpreter from a context buffer.

void mark_context(Interp *interpreter, struct Parrot_Context *ctx)

Marks the context *ctx.

static void prepend_stack( struct Stack_Chunk **interp_stack, struct Stack_Chunk **ctx_stack, struct Stack_Chunk *saved_stack, struct Stack_Chunk *saved_base)

The final ctx_stack = interp_stack + saved_stack. interp_stack and ctx_stack are already swapped here.

static void restore_stack( struct Stack_Chunk **interp_stack, struct Stack_Chunk **ctx_stack, struct Stack_Chunk **saved_stack, struct Stack_Chunk *saved_base)

Undo prepend_stack(). interp_stack and ctx_stack are already swapped here.

void swap_context(Interp *interp, struct PMC *sub)

Swaps the context.

struct Parrot_sub *new_sub(Interp *interp)

Returns a new Parrot_sub.

struct Parrot_sub *new_closure(Interp *interp)

Returns a new Parrot_sub with its own sctatchpad.

XXX: Need to document semantics in detail.

struct Parrot_cont *new_continuation(Interp *interp)

Returns a new Parrot_cont with its own copy of the current context.

struct Parrot_cont *new_ret_continuation(Interp *interp)

Returns a new Parrot_cont with its own copy of the current context.

struct Parrot_coro *new_coroutine(Interp *interp)

Returns a new Parrot_coro.

XXX: Need to document semantics in detail.

void mark_retc_cache(Interp *)

Mark the objects in the return continuation cache being alive.

void add_to_retc_cache(Interp *interpreter, PMC *pmc)

Add the return continuation pmc to the cache and turn off custom marking, so that its context isn't marked.

Note: the context structure in PMC_cont(pmc) remains allocated.

*/ void mark_retc_cache(Interp *interpreter) { PMC *pmc = interpreter->caches->retc_cache;

    while (pmc) {
        pobject_lives(interpreter, (PObj*)pmc);
        pmc = PREV_RETC(pmc);
    }
}
void add_to_retc_cache(Interp *interpreter, PMC *pmc) { Caches *mc = interpreter->caches;

    if (mc->retc_cache)
        PREV_RETC(mc->retc_cache) = mc->retc_cache;
    PREV_RETC(pmc) = NULL;
    mc->retc_cache = pmc;
    /* XXX expensive w. ARENA_DOD_FLAGS */
    PObj_custom_mark_CLEAR(pmc);
}
/*

PMC *new_ret_continuation_pmc(Interp *interp, opcode_t *address)

Returns a new RetContinuation PMC. Uses one from the cache, if possible; otherwise, creates a new one.

void copy_regs(Interp *, struct parrot_regs_t *caller_regs)

Copy function arguments or return values from caller_regs to interpreter.

void invalidate_retc_context(Interp *, struct Parrot_Context *ctx)

Make true Continuation from all RetContinuations up the call chain.

Parrot_full_sub_name

Print name and location of subroutine, This should finally use the label name of the frozen Sub PMC image for now locate the Sub name in the globals.

SEE ALSO ^

include/parrot/sub.h.

HISTORY ^

Initial version by Melvin on 2002/06/6.


parrot