Skip to content

Commit

Permalink
Kill NEED_CONTINUATION ugly hack.
Browse files Browse the repository at this point in the history
Continuation is always created on caller side now.
  • Loading branch information
bacek committed Feb 21, 2012
1 parent 0cb86fe commit 2caf6ce
Show file tree
Hide file tree
Showing 8 changed files with 5 additions and 25 deletions.
6 changes: 0 additions & 6 deletions include/parrot/sub.h
Expand Up @@ -102,12 +102,6 @@ typedef enum {
#define Sub_comp_INIT_SET(o) Sub_comp_flag_SET(PF_INIT, o)
#define Sub_comp_INIT_CLEAR(o) Sub_comp_flag_CLEAR(PF_INIT, o)

/*
* a flag to signal a Sub that a new Continuation should be created
*/

#define NEED_CONTINUATION ((PMC *)1)

/*
* maximum sub recursion depth
*/
Expand Down
5 changes: 1 addition & 4 deletions src/gc/mark_sweep.c
Expand Up @@ -214,14 +214,11 @@ static void
mark_interp(PARROT_INTERP)
{
ASSERT_ARGS(mark_interp)
PObj *obj;
/* mark the list of iglobals */
Parrot_gc_mark_PMC_alive(interp, interp->iglobals);

/* mark the current continuation */
obj = (PObj *)interp->current_cont;
if (obj && obj != (PObj *)NEED_CONTINUATION)
Parrot_gc_mark_PMC_alive(interp, (PMC *)obj);
Parrot_gc_mark_PMC_alive(interp, interp->current_cont);

/* mark the current context. */
Parrot_gc_mark_PMC_alive(interp, interp->cur_task);
Expand Down
5 changes: 1 addition & 4 deletions src/pmc/coroutine.pmc
Expand Up @@ -176,10 +176,7 @@ Swaps the "context".
PMC *ctx = Parrot_pcc_get_signature(INTERP, caller_ctx);
PMC *ccont = INTERP->current_cont;

if (ccont == NEED_CONTINUATION) {
ccont = Parrot_pmc_new(INTERP, enum_class_Continuation);
VTABLE_set_pointer(INTERP, ccont, next_op);
}
PARROT_ASSERT(!PMC_IS_NULL(ccont));

if (PObj_get_FLAGS(ccont) & SUB_FLAG_TAILCALL)
Parrot_ex_throw_from_c_args(INTERP, NULL, EXCEPTION_INVALID_OPERATION,
Expand Down
2 changes: 1 addition & 1 deletion src/pmc/imccompiler.pmc
Expand Up @@ -150,7 +150,7 @@ pmclass IMCCompiler auto_attrs provides HLLCompiler provide invokable {

/* Handle the case where we we've been tailcalled into. See NCI.invoke
for more details */
if (cont && cont != NEED_CONTINUATION
if (!PMC_IS_NULL(cont)
&& (PObj_get_FLAGS(cont) & SUB_FLAG_TAILCALL)) {
cont = Parrot_pcc_get_continuation(interp, CURRENT_CONTEXT(interp));
next = VTABLE_invoke(INTERP, cont, next);
Expand Down
2 changes: 1 addition & 1 deletion src/pmc/nativepccmethod.pmc
Expand Up @@ -125,7 +125,7 @@ Call the function pointer.
{
PMC *cont = INTERP->current_cont;

if (cont && cont != NEED_CONTINUATION
if (!PMC_IS_NULL(cont)
&& (PObj_get_FLAGS(cont) & SUB_FLAG_TAILCALL)) {
cont = Parrot_pcc_get_continuation(interp, CURRENT_CONTEXT(interp));
next = VTABLE_invoke(INTERP, cont, next);
Expand Down
2 changes: 1 addition & 1 deletion src/pmc/nci.pmc
Expand Up @@ -278,7 +278,7 @@ class, the PMC arguments are shifted down.
* return continuation here, which gets rid of this frame
* and returns the real return address
*/
if (cont && cont != NEED_CONTINUATION
if (!PMC_IS_NULL(cont)
&& (PObj_get_FLAGS(cont) & SUB_FLAG_TAILCALL)) {
cont = Parrot_pcc_get_continuation(interp, CURRENT_CONTEXT(interp));
next = VTABLE_invoke(INTERP, cont, next);
Expand Down
2 changes: 0 additions & 2 deletions src/pmc/parrotinterpreter.pmc
Expand Up @@ -173,8 +173,6 @@ create_interp(ARGIN(PMC *self), ARGIN_NULLOK(Parrot_Interp parent))

VTABLE_set_pmc_keyed_int(new_interp, new_interp->iglobals,
(INTVAL) IGLOBALS_INTERPRETER, self);

new_interp->current_cont = NEED_CONTINUATION;
}

pmclass ParrotInterpreter no_ro manual_attrs provides invokable {
Expand Down
6 changes: 0 additions & 6 deletions src/pmc/sub.pmc
Expand Up @@ -414,12 +414,6 @@ Invokes the subroutine.
pc = sub->seg->base.data + sub->start_offs;
INTERP->current_cont = NULL;

PARROT_ASSERT(ccont != NEED_CONTINUATION);
if (ccont == NEED_CONTINUATION) {
ccont = Parrot_pmc_new(INTERP, enum_class_Continuation);
VTABLE_set_pointer(INTERP, ccont, next);
}

PARROT_ASSERT(!PMC_IS_NULL(ccont));

if (PMC_IS_NULL(context))
Expand Down

0 comments on commit 2caf6ce

Please sign in to comment.