Index: src/ops/core.ops =================================================================== --- src/ops/core.ops (revision 45835) +++ src/ops/core.ops (working copy) @@ -746,8 +746,10 @@ PMC * except = $1; opcode_t *dest; opcode_t * const ret = expr NEXT(); - PMC * const resume = new_ret_continuation_pmc(interp, ret); + PMC * const resume = pmc_new(interp, enum_class_Continuation); + VTABLE_set_pointer(interp, resume, ret); + if (PMC_IS_NULL(except) || except->vtable->base_type != enum_class_Exception) except = Parrot_ex_build_exception(interp, EXCEPT_fatal, EXCEPTION_UNIMPLEMENTED, @@ -792,10 +794,12 @@ inline op die(in STR) :flow { opcode_t *dest; opcode_t * const ret = expr NEXT(); - PMC * const resume = new_ret_continuation_pmc(interp, ret); + PMC * const resume = pmc_new(interp, enum_class_Continuation); PMC * const exception = Parrot_ex_build_exception(interp, EXCEPT_error, CONTROL_ERROR, $1); + VTABLE_set_pointer(interp, resume, ret); + VTABLE_set_attr_str(interp, exception, Parrot_str_new_constant(interp, "resume"), resume); dest = Parrot_ex_throw_from_op(interp, exception, ret); @@ -805,11 +809,13 @@ inline op die(in PMC) :flow { opcode_t *dest; opcode_t * const ret = expr NEXT(); - PMC * const resume = new_ret_continuation_pmc(interp, ret); + PMC * const resume = pmc_new(interp, enum_class_Continuation); STRING * const msg = PMC_IS_NULL($1) ? NULL : VTABLE_get_string(interp, $1); PMC * const exception = Parrot_ex_build_exception(interp, EXCEPT_error, CONTROL_ERROR, msg); + VTABLE_set_pointer(interp, resume, ret); + VTABLE_set_attr_str(interp, exception, Parrot_str_new_constant(interp, "resume"), resume); dest = Parrot_ex_throw_from_op(interp, exception, ret); @@ -831,9 +837,11 @@ inline op exit(in INT) :flow { opcode_t *dest; opcode_t * const ret = expr NEXT(); - PMC * const resume = new_ret_continuation_pmc(interp, ret); + PMC * const resume = pmc_new(interp, enum_class_Continuation); PMC * const exception = Parrot_ex_build_exception(interp, EXCEPT_exit, $1, NULL); + VTABLE_set_pointer(interp, resume, ret); + VTABLE_set_attr_str(interp, exception, Parrot_str_new_constant(interp, "resume"), resume); VTABLE_set_integer_keyed_str(interp, exception, Index: src/pmc/retcontinuation.pmc =================================================================== --- src/pmc/retcontinuation.pmc (revision 45835) +++ src/pmc/retcontinuation.pmc (working copy) @@ -1,118 +0,0 @@ -/* -Copyright (C) 2001-2008, Parrot Foundation. -$Id$ - -=head1 NAME - -src/pmc/retcontinuation.pmc - Return Continuation - -=head1 DESCRIPTION - -C extends C. - -A return continuation is a one shot Continuation. It gets recycled immediately -after invocation. - -=head2 Methods - -=over 4 - -=cut - -*/ - -#include "parrot/oplib/ops.h" - -/* HEADERIZER HFILE: none */ -/* HEADERIZER BEGIN: static */ -/* HEADERIZER END: static */ - -pmclass RetContinuation extends Continuation auto_attrs { - -/* - -=item C - -Initializes the continuation. - -=cut - -*/ - - VTABLE void init() { - Parrot_RetContinuation_attributes * const attrs = PARROT_RETCONTINUATION(SELF); - - attrs->to_ctx = CURRENT_CONTEXT(interp); - attrs->from_ctx = PMCNULL; /* filled in during a call */ - attrs->runloop_id = 0; - attrs->seg = interp->code; - attrs->address = NULL; - } - - -/* - -=item C - -Return a new Continuation PMC with the context of SELF. Note: the returned -object is not a RetContinuation and creating a real Continuation invalidates -all RetContinuation all the way up the call chain. That is, these can't be -recycled; they persist until the GC gets at them. - -=cut - -*/ - VTABLE PMC *clone() { - invalidate_retc_context(INTERP, SELF); - return SUPER(); - } -/* - -=item C - -Transfers control to the calling context and frees the current context. - -=cut - -*/ - - VTABLE opcode_t *invoke(void *in_next) { - Parrot_Continuation_attributes *data = PARROT_CONTINUATION(SELF); - PMC *from_ctx = data->from_ctx; - PackFile_ByteCode * const seg = data->seg; - opcode_t *next = data->address; - UNUSED(in_next) - - Parrot_continuation_check(interp, SELF); - Parrot_continuation_rewind_environment(interp, SELF); - - /* recycle this PMC and make sure it doesn't get marked */ - if (!PMC_IS_NULL(from_ctx)) - Parrot_pcc_set_continuation(interp, from_ctx, NULL); - - if (INTERP->code != seg) - Parrot_switch_to_cs(INTERP, seg, 1); - - return next; - } -} - - -/* - -=back - -=head1 HISTORY - -Initial revision by sean 2002/08/04. - -=cut - -*/ - -/* - * Local variables: - * c-file-style: "parrot" - * End: - * vim: expandtab shiftwidth=4: - */ Index: src/pmc/coroutine.pmc =================================================================== --- src/pmc/coroutine.pmc (revision 45835) +++ src/pmc/coroutine.pmc (working copy) @@ -172,8 +172,10 @@ PMC *ctx = Parrot_pcc_get_signature(INTERP, caller_ctx); PMC *ccont = INTERP->current_cont; - if (ccont == NEED_CONTINUATION) - ccont = (PMC *)new_ret_continuation_pmc(INTERP, next_op); + if (ccont == NEED_CONTINUATION) { + ccont = pmc_new(interp, enum_class_Continuation); + VTABLE_set_pointer(interp, ccont, next_op); + } if (PObj_get_FLAGS(ccont) & SUB_FLAG_TAILCALL) Parrot_ex_throw_from_c_args(INTERP, NULL, CONTROL_ERROR, Index: src/pmc/continuation.pmc =================================================================== --- src/pmc/continuation.pmc (revision 45835) +++ src/pmc/continuation.pmc (working copy) @@ -78,15 +78,6 @@ SET_ATTR_address(INTERP, SELF, NULL); PObj_custom_mark_SET(SELF); - - /* PANIC("don't do that"); */ - /* - * Whenever we create a continuation, all return continuations - * up the call chain may be reused due to invoking the - * continuation. To avoid that all return continuations are - * converted to true continuations. - */ - invalidate_retc_context(INTERP, SELF); } /*if they pass in a PMC to initialize with*/ @@ -109,15 +100,6 @@ SET_ATTR_address(INTERP, SELF, address); PObj_custom_mark_SET(SELF); - - /* PANIC("don't do that"); */ - /* - * Whenever we create a continuation, all return continuations - * up the call chain may be reused due to invoking the - * continuation. To avoid that all return continuations are - * converted to true continuations. - */ - invalidate_retc_context(INTERP, SELF); } Index: src/pmc/sub.pmc =================================================================== --- src/pmc/sub.pmc (revision 45835) +++ src/pmc/sub.pmc (working copy) @@ -398,8 +398,10 @@ pc = sub->seg->base.data + sub->start_offs; INTERP->current_cont = NULL; - if (ccont == NEED_CONTINUATION) - ccont = new_ret_continuation_pmc(interp, (opcode_t *)next); + if (ccont == NEED_CONTINUATION) { + ccont = pmc_new(interp, enum_class_Continuation); + VTABLE_set_pointer(interp, ccont, next); + } PARROT_ASSERT(!PMC_IS_NULL(ccont)); @@ -427,12 +429,9 @@ PARROT_CONTINUATION(ccont)->from_ctx = context; /* if this is an outer sub, then we need to set sub->ctx - * to the new context (refcounted) and convert the - * retcontinuation to a normal continuation. */ + * to the new context (refcounted) */ if (PObj_get_FLAGS(SELF) & SUB_FLAG_IS_OUTER) { sub->ctx = context; - /* convert retcontinuation to a continuation */ - ccont->vtable = interp->vtables[enum_class_Continuation]; } /* create pad if needed Index: src/interp/inter_misc.c =================================================================== --- src/interp/inter_misc.c (revision 45835) +++ src/interp/inter_misc.c (working copy) @@ -283,9 +283,6 @@ case CURRENT_CONT: { PMC * const cont = Parrot_pcc_get_continuation(interp, CURRENT_CONTEXT(interp)); - if (!PMC_IS_NULL(cont) && cont->vtable->base_type == - enum_class_RetContinuation) - return VTABLE_clone(interp, cont); return cont; } case CURRENT_OBJECT: Index: src/sub.c =================================================================== --- src/sub.c (revision 45835) +++ src/sub.c (working copy) @@ -49,60 +49,6 @@ /* -=item C - -Returns a new C PMC, and sets address field to C
- -=cut - -*/ - -PARROT_EXPORT -PARROT_MALLOC -PARROT_CANNOT_RETURN_NULL -PMC * -new_ret_continuation_pmc(PARROT_INTERP, ARGIN_NULLOK(opcode_t *address)) -{ - ASSERT_ARGS(new_ret_continuation_pmc) - PMC* const continuation = Parrot_pmc_new(interp, enum_class_RetContinuation); - VTABLE_set_pointer(interp, continuation, address); - return continuation; -} - -/* - -=item C - -Make true Continuations from all RetContinuations up the call chain. - -=cut - -*/ - -void -invalidate_retc_context(PARROT_INTERP, ARGMOD(PMC *cont)) -{ - ASSERT_ARGS(invalidate_retc_context) - - PMC *ctx = PARROT_CONTINUATION(cont)->from_ctx; - cont = Parrot_pcc_get_continuation(interp, ctx); - - while (1) { - /* - * We stop if we encounter a true continuation, because - * if one were created, everything up the chain would have been - * invalidated earlier. - */ - if (!cont || cont->vtable != interp->vtables[enum_class_RetContinuation]) - break; - cont->vtable = interp->vtables[enum_class_Continuation]; - ctx = Parrot_pcc_get_caller_ctx(interp, ctx); - cont = Parrot_pcc_get_continuation(interp, ctx); - } -} - -/* - =item C Return namespace, name, and location of subroutine. Index: src/call/pcc.c =================================================================== --- src/call/pcc.c (revision 45835) +++ src/call/pcc.c (working copy) @@ -340,7 +340,7 @@ opcode_t *dest; UINTVAL n_regs_used[] = { 0, 0, 0, 0, 0, 0, 0, 0 }; PMC *ctx = Parrot_push_context(interp, n_regs_used); - PMC * const ret_cont = new_ret_continuation_pmc(interp, NULL); + PMC * const ret_cont = pmc_new(interp, enum_class_Continuation); Parrot_pcc_set_signature(interp, ctx, call_object); Parrot_pcc_set_continuation(interp, ctx, ret_cont); Index: MANIFEST =================================================================== --- MANIFEST (revision 45835) +++ MANIFEST (working copy) @@ -1,7 +1,7 @@ # ex: set ro: # $Id$ # -# generated by tools/dev/mk_manifest_and_skip.pl Tue Apr 20 20:11:26 2010 UT +# generated by tools/dev/mk_manifest_and_skip.pl Tue Apr 20 23:21:11 2010 UT # # See below for documentation on the format of this file. # @@ -1465,7 +1465,6 @@ src/pmc/resizableintegerarray.pmc [] src/pmc/resizablepmcarray.pmc [] src/pmc/resizablestringarray.pmc [] -src/pmc/retcontinuation.pmc [] src/pmc/role.pmc [] src/pmc/scalar.pmc [] src/pmc/scheduler.pmc [] @@ -1948,7 +1947,6 @@ t/pmc/resizableintegerarray.t [test] t/pmc/resizablepmcarray.t [test] t/pmc/resizablestringarray.t [test] -t/pmc/retcontinuation.t [test] t/pmc/ro.t [test] t/pmc/role.t [test] t/pmc/scalar.t [test] Index: include/parrot/sub.h =================================================================== --- include/parrot/sub.h (revision 45835) +++ include/parrot/sub.h (working copy) @@ -172,13 +172,6 @@ /* Don't modify between HEADERIZER BEGIN / HEADERIZER END. Your changes will be lost. */ PARROT_EXPORT -PARROT_MALLOC -PARROT_CANNOT_RETURN_NULL -PMC * new_ret_continuation_pmc(PARROT_INTERP, - ARGIN_NULLOK(opcode_t *address)) - __attribute__nonnull__(1); - -PARROT_EXPORT void Parrot_capture_lex(PARROT_INTERP, ARGMOD(PMC *sub_pmc)) __attribute__nonnull__(1) __attribute__nonnull__(2) @@ -219,11 +212,6 @@ __attribute__nonnull__(1) __attribute__nonnull__(2); -void invalidate_retc_context(PARROT_INTERP, ARGMOD(PMC *cont)) - __attribute__nonnull__(1) - __attribute__nonnull__(2) - FUNC_MODIFIES(*cont); - void mark_context_start(void); void Parrot_continuation_check(PARROT_INTERP, ARGIN(const PMC *pmc)) __attribute__nonnull__(1) @@ -262,8 +250,6 @@ ARGIN_NULLOK(opcode_t *pc)) __attribute__nonnull__(1); -#define ASSERT_ARGS_new_ret_continuation_pmc __attribute__unused__ int _ASSERT_ARGS_CHECK = (\ - PARROT_ASSERT_ARG(interp)) #define ASSERT_ARGS_Parrot_capture_lex __attribute__unused__ int _ASSERT_ARGS_CHECK = (\ PARROT_ASSERT_ARG(interp) \ , PARROT_ASSERT_ARG(sub_pmc)) @@ -283,9 +269,6 @@ #define ASSERT_ARGS_parrot_new_closure __attribute__unused__ int _ASSERT_ARGS_CHECK = (\ PARROT_ASSERT_ARG(interp) \ , PARROT_ASSERT_ARG(sub_pmc)) -#define ASSERT_ARGS_invalidate_retc_context __attribute__unused__ int _ASSERT_ARGS_CHECK = (\ - PARROT_ASSERT_ARG(interp) \ - , PARROT_ASSERT_ARG(cont)) #define ASSERT_ARGS_mark_context_start __attribute__unused__ int _ASSERT_ARGS_CHECK = (0) #define ASSERT_ARGS_Parrot_continuation_check __attribute__unused__ int _ASSERT_ARGS_CHECK = (\ PARROT_ASSERT_ARG(interp) \ Index: t/pmc/retcontinuation.t =================================================================== --- t/pmc/retcontinuation.t (revision 45835) +++ t/pmc/retcontinuation.t (working copy) @@ -1,32 +0,0 @@ -#! parrot -# Copyright (C) 2006-2008, Parrot Foundation. -# $Id$ - -=head1 NAME - -t/pmc/retcontinuation.t - test the RetContinuation PMC - -=head1 SYNOPSIS - - % prove t/pmc/retcontinuation.t - -=head1 DESCRIPTION - -Tests the RetContinuation PMC. - -=cut - -.sub main :main - .include 'test_more.pir' - - plan(1) - - new $P0, ['RetContinuation'] - ok(1, 'Instantiated a RetContinuation PMC') -.end - -# Local Variables: -# mode: pir -# fill-column: 100 -# End: -# vim: expandtab shiftwidth=4 ft=pir: Index: t/op/gc.t =================================================================== --- t/op/gc.t (revision 45835) +++ t/op/gc.t (working copy) @@ -508,7 +508,6 @@ # coro context and invalid return continuations # this is a stripped down version of imcc/t/syn/pcc_16 -# s. also src/pmc/retcontinuation.pmc .sub coro_context_ret_continuation .const 'Sub' $P0 = "co1" Index: PBC_COMPAT =================================================================== --- PBC_COMPAT (revision 45835) +++ PBC_COMPAT (working copy) @@ -27,6 +27,7 @@ # please insert tab separated entries at the top of the list +6.6 2010.04.20 coke remove retcontinuation PMC 6.5 2010.03.09 cotto remove cpu_ret op 6.4 2010.03.02 cotto remove prederef__ and reserved 6.3 2010.02.16 whiteknight Add OpLib and Opcode PMCs