diff --git a/include/parrot/sub.h b/include/parrot/sub.h index fca0de9496..68479ce8b5 100644 --- a/include/parrot/sub.h +++ b/include/parrot/sub.h @@ -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 */ diff --git a/src/gc/mark_sweep.c b/src/gc/mark_sweep.c index 155df17aff..18459693ef 100644 --- a/src/gc/mark_sweep.c +++ b/src/gc/mark_sweep.c @@ -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); diff --git a/src/pmc/coroutine.pmc b/src/pmc/coroutine.pmc index 49857c2e3d..876a8efa94 100644 --- a/src/pmc/coroutine.pmc +++ b/src/pmc/coroutine.pmc @@ -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, diff --git a/src/pmc/imccompiler.pmc b/src/pmc/imccompiler.pmc index a0a03450ad..7d78788029 100644 --- a/src/pmc/imccompiler.pmc +++ b/src/pmc/imccompiler.pmc @@ -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); diff --git a/src/pmc/nativepccmethod.pmc b/src/pmc/nativepccmethod.pmc index 7c89112f13..84289589da 100644 --- a/src/pmc/nativepccmethod.pmc +++ b/src/pmc/nativepccmethod.pmc @@ -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); diff --git a/src/pmc/nci.pmc b/src/pmc/nci.pmc index 1e9443c134..a52f0e7553 100644 --- a/src/pmc/nci.pmc +++ b/src/pmc/nci.pmc @@ -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); diff --git a/src/pmc/parrotinterpreter.pmc b/src/pmc/parrotinterpreter.pmc index 1bbf90d2af..5a243634c8 100644 --- a/src/pmc/parrotinterpreter.pmc +++ b/src/pmc/parrotinterpreter.pmc @@ -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 { diff --git a/src/pmc/sub.pmc b/src/pmc/sub.pmc index be111cd558..d6738830ee 100644 --- a/src/pmc/sub.pmc +++ b/src/pmc/sub.pmc @@ -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))