[svn:parrot] r45867 - in trunk: . include/parrot src src/call src/interp src/ops src/pmc t/native_pbc t/op t/pmc

bacek at svn.parrot.org bacek at svn.parrot.org
Wed Apr 21 21:11:19 UTC 2010


Author: bacek
Date: Wed Apr 21 21:11:17 2010
New Revision: 45867
URL: https://trac.parrot.org/parrot/changeset/45867

Log:
Remove RetContinuation PMC. Closes TT#1427. Coke++ for all hard work.

Deleted:
   trunk/src/pmc/retcontinuation.pmc
   trunk/t/pmc/retcontinuation.t
Modified:
   trunk/MANIFEST
   trunk/PBC_COMPAT
   trunk/include/parrot/sub.h
   trunk/src/call/pcc.c
   trunk/src/interp/inter_misc.c
   trunk/src/ops/core.ops
   trunk/src/pmc/continuation.pmc
   trunk/src/pmc/coroutine.pmc
   trunk/src/pmc/sub.pmc
   trunk/src/sub.c
   trunk/t/native_pbc/annotations.pbc
   trunk/t/native_pbc/integer_1.pbc
   trunk/t/native_pbc/number_1.pbc
   trunk/t/native_pbc/string_1.pbc
   trunk/t/op/gc.t

Modified: trunk/MANIFEST
==============================================================================
--- trunk/MANIFEST	Wed Apr 21 20:44:35 2010	(r45866)
+++ trunk/MANIFEST	Wed Apr 21 21:11:17 2010	(r45867)
@@ -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                                       []
@@ -1949,7 +1948,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]

Modified: trunk/PBC_COMPAT
==============================================================================
--- trunk/PBC_COMPAT	Wed Apr 21 20:44:35 2010	(r45866)
+++ trunk/PBC_COMPAT	Wed Apr 21 21:11:17 2010	(r45867)
@@ -27,6 +27,7 @@
 
 # please insert tab separated entries at the top of the list
 
+6.7	2010.04.17	coke	remove RetContinuation PMC
 6.6	2010.04.17	bacek	add replace op
 6.5	2010.03.09	cotto	remove cpu_ret op
 6.4	2010.03.02	cotto	remove prederef__ and reserved

Modified: trunk/include/parrot/sub.h
==============================================================================
--- trunk/include/parrot/sub.h	Wed Apr 21 20:44:35 2010	(r45866)
+++ trunk/include/parrot/sub.h	Wed Apr 21 21:11:17 2010	(r45867)
@@ -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) \

Modified: trunk/src/call/pcc.c
==============================================================================
--- trunk/src/call/pcc.c	Wed Apr 21 20:44:35 2010	(r45866)
+++ trunk/src/call/pcc.c	Wed Apr 21 21:11:17 2010	(r45867)
@@ -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);

Modified: trunk/src/interp/inter_misc.c
==============================================================================
--- trunk/src/interp/inter_misc.c	Wed Apr 21 20:44:35 2010	(r45866)
+++ trunk/src/interp/inter_misc.c	Wed Apr 21 21:11:17 2010	(r45867)
@@ -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:

Modified: trunk/src/ops/core.ops
==============================================================================
--- trunk/src/ops/core.ops	Wed Apr 21 20:44:35 2010	(r45866)
+++ trunk/src/ops/core.ops	Wed Apr 21 21:11:17 2010	(r45867)
@@ -746,7 +746,9 @@
     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,
@@ -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,

Modified: trunk/src/pmc/continuation.pmc
==============================================================================
--- trunk/src/pmc/continuation.pmc	Wed Apr 21 20:44:35 2010	(r45866)
+++ trunk/src/pmc/continuation.pmc	Wed Apr 21 21:11:17 2010	(r45867)
@@ -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);
     }
 
 

Modified: trunk/src/pmc/coroutine.pmc
==============================================================================
--- trunk/src/pmc/coroutine.pmc	Wed Apr 21 20:44:35 2010	(r45866)
+++ trunk/src/pmc/coroutine.pmc	Wed Apr 21 21:11:17 2010	(r45867)
@@ -169,8 +169,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,

Deleted: trunk/src/pmc/retcontinuation.pmc
==============================================================================
--- trunk/src/pmc/retcontinuation.pmc	Wed Apr 21 21:11:17 2010	(r45866)
+++ /dev/null	00:00:00 1970	(deleted)
@@ -1,118 +0,0 @@
-/*
-Copyright (C) 2001-2008, Parrot Foundation.
-$Id$
-
-=head1 NAME
-
-src/pmc/retcontinuation.pmc - Return Continuation
-
-=head1 DESCRIPTION
-
-C<RetContinuation> extends C<Continuation>.
-
-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<void init()>
-
-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<PMC *clone>
-
-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<opcode_t *invoke(void *next)>
-
-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:
- */

Modified: trunk/src/pmc/sub.pmc
==============================================================================
--- trunk/src/pmc/sub.pmc	Wed Apr 21 20:44:35 2010	(r45866)
+++ trunk/src/pmc/sub.pmc	Wed Apr 21 21:11:17 2010	(r45867)
@@ -392,8 +392,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));
 
@@ -421,12 +423,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

Modified: trunk/src/sub.c
==============================================================================
--- trunk/src/sub.c	Wed Apr 21 20:44:35 2010	(r45866)
+++ trunk/src/sub.c	Wed Apr 21 21:11:17 2010	(r45867)
@@ -49,60 +49,6 @@
 
 /*
 
-=item C<PMC * new_ret_continuation_pmc(PARROT_INTERP, opcode_t *address)>
-
-Returns a new C<RetContinuation> PMC, and sets address field to C<address>
-
-=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<void invalidate_retc_context(PARROT_INTERP, PMC *cont)>
-
-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<STRING* Parrot_full_sub_name(PARROT_INTERP, PMC* sub_pmc)>
 
 Return namespace, name, and location of subroutine.

Modified: trunk/t/native_pbc/annotations.pbc
==============================================================================
Binary file (source and/or target). No diff available.

Modified: trunk/t/native_pbc/integer_1.pbc
==============================================================================
Binary file (source and/or target). No diff available.

Modified: trunk/t/native_pbc/number_1.pbc
==============================================================================
Binary file (source and/or target). No diff available.

Modified: trunk/t/native_pbc/string_1.pbc
==============================================================================
Binary file (source and/or target). No diff available.

Modified: trunk/t/op/gc.t
==============================================================================
--- trunk/t/op/gc.t	Wed Apr 21 20:44:35 2010	(r45866)
+++ trunk/t/op/gc.t	Wed Apr 21 21:11:17 2010	(r45867)
@@ -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"

Deleted: trunk/t/pmc/retcontinuation.t
==============================================================================
--- trunk/t/pmc/retcontinuation.t	Wed Apr 21 21:11:17 2010	(r45866)
+++ /dev/null	00:00:00 1970	(deleted)
@@ -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:


More information about the parrot-commits mailing list