Ticket #1427: retcon.diff

File retcon.diff, 15.9 KB (added by coke, 5 years ago)

Remove usage of RetCon in the src/

  • src/ops/core.ops

     
    746746    PMC * except = $1; 
    747747    opcode_t *dest; 
    748748    opcode_t * const ret    = expr NEXT(); 
    749     PMC      * const resume = new_ret_continuation_pmc(interp, ret); 
     749    PMC      * const resume = pmc_new(interp, enum_class_Continuation); 
    750750 
     751    VTABLE_set_pointer(interp, resume, ret); 
     752 
    751753    if (PMC_IS_NULL(except) || except->vtable->base_type != enum_class_Exception) 
    752754        except = Parrot_ex_build_exception(interp, EXCEPT_fatal, 
    753755                EXCEPTION_UNIMPLEMENTED, 
     
    792794inline op die(in STR) :flow { 
    793795    opcode_t        *dest; 
    794796    opcode_t * const ret       = expr NEXT(); 
    795     PMC      * const resume    = new_ret_continuation_pmc(interp, ret); 
     797    PMC      * const resume    = pmc_new(interp, enum_class_Continuation); 
    796798    PMC      * const exception = Parrot_ex_build_exception(interp, EXCEPT_error, 
    797799                                    CONTROL_ERROR, $1); 
    798800 
     801    VTABLE_set_pointer(interp, resume, ret); 
     802 
    799803    VTABLE_set_attr_str(interp, exception, 
    800804                        Parrot_str_new_constant(interp, "resume"), resume); 
    801805    dest = Parrot_ex_throw_from_op(interp, exception, ret); 
     
    805809inline op die(in PMC) :flow { 
    806810    opcode_t        *dest; 
    807811    opcode_t * const ret       = expr NEXT(); 
    808     PMC      * const resume    = new_ret_continuation_pmc(interp, ret); 
     812    PMC      * const resume    = pmc_new(interp, enum_class_Continuation); 
    809813    STRING   * const msg       = PMC_IS_NULL($1) ? NULL : VTABLE_get_string(interp, $1); 
    810814    PMC      * const exception = 
    811815        Parrot_ex_build_exception(interp, EXCEPT_error, CONTROL_ERROR, msg); 
    812816 
     817    VTABLE_set_pointer(interp, resume, ret); 
     818 
    813819    VTABLE_set_attr_str(interp, exception, 
    814820                        Parrot_str_new_constant(interp, "resume"), resume); 
    815821    dest = Parrot_ex_throw_from_op(interp, exception, ret); 
     
    831837inline op exit(in INT) :flow { 
    832838    opcode_t        *dest; 
    833839    opcode_t * const ret       = expr NEXT(); 
    834     PMC      * const resume    = new_ret_continuation_pmc(interp, ret); 
     840    PMC      * const resume    = pmc_new(interp, enum_class_Continuation); 
    835841    PMC      * const exception = Parrot_ex_build_exception(interp, EXCEPT_exit, $1, NULL); 
    836842 
     843    VTABLE_set_pointer(interp, resume, ret);  
     844 
    837845    VTABLE_set_attr_str(interp, exception, 
    838846                        Parrot_str_new_constant(interp, "resume"), resume); 
    839847    VTABLE_set_integer_keyed_str(interp, exception, 
  • src/pmc/retcontinuation.pmc

     
    1 /* 
    2 Copyright (C) 2001-2008, Parrot Foundation. 
    3 $Id$ 
    4  
    5 =head1 NAME 
    6  
    7 src/pmc/retcontinuation.pmc - Return Continuation 
    8  
    9 =head1 DESCRIPTION 
    10  
    11 C<RetContinuation> extends C<Continuation>. 
    12  
    13 A return continuation is a one shot Continuation.  It gets recycled immediately 
    14 after invocation. 
    15  
    16 =head2 Methods 
    17  
    18 =over 4 
    19  
    20 =cut 
    21  
    22 */ 
    23  
    24 #include "parrot/oplib/ops.h" 
    25  
    26 /* HEADERIZER HFILE: none */ 
    27 /* HEADERIZER BEGIN: static */ 
    28 /* HEADERIZER END: static */ 
    29  
    30 pmclass RetContinuation extends Continuation auto_attrs { 
    31  
    32 /* 
    33  
    34 =item C<void init()> 
    35  
    36 Initializes the continuation. 
    37  
    38 =cut 
    39  
    40 */ 
    41  
    42     VTABLE void init() { 
    43         Parrot_RetContinuation_attributes * const attrs = PARROT_RETCONTINUATION(SELF); 
    44  
    45         attrs->to_ctx          = CURRENT_CONTEXT(interp); 
    46         attrs->from_ctx        = PMCNULL;    /* filled in during a call */ 
    47         attrs->runloop_id      = 0; 
    48         attrs->seg             = interp->code; 
    49         attrs->address         = NULL; 
    50     } 
    51  
    52  
    53 /* 
    54  
    55 =item C<PMC *clone> 
    56  
    57 Return a new Continuation PMC with the context of SELF. Note: the returned 
    58 object is not a RetContinuation and creating a real Continuation invalidates 
    59 all RetContinuation all the way up the call chain.  That is, these can't be 
    60 recycled; they persist until the GC gets at them. 
    61  
    62 =cut 
    63  
    64 */ 
    65     VTABLE PMC *clone() { 
    66         invalidate_retc_context(INTERP, SELF); 
    67         return SUPER(); 
    68     } 
    69 /* 
    70  
    71 =item C<opcode_t *invoke(void *next)> 
    72  
    73 Transfers control to the calling context and frees the current context. 
    74  
    75 =cut 
    76  
    77 */ 
    78  
    79     VTABLE opcode_t *invoke(void *in_next) { 
    80         Parrot_Continuation_attributes *data = PARROT_CONTINUATION(SELF); 
    81         PMC               *from_ctx   = data->from_ctx; 
    82         PackFile_ByteCode * const seg = data->seg; 
    83         opcode_t          *next       = data->address; 
    84         UNUSED(in_next) 
    85  
    86         Parrot_continuation_check(interp, SELF); 
    87         Parrot_continuation_rewind_environment(interp, SELF); 
    88  
    89         /* recycle this PMC and make sure it doesn't get marked */ 
    90         if (!PMC_IS_NULL(from_ctx)) 
    91             Parrot_pcc_set_continuation(interp, from_ctx, NULL); 
    92  
    93         if (INTERP->code != seg) 
    94             Parrot_switch_to_cs(INTERP, seg, 1); 
    95  
    96         return next; 
    97     } 
    98 } 
    99  
    100  
    101 /* 
    102  
    103 =back 
    104  
    105 =head1 HISTORY 
    106  
    107 Initial revision by sean 2002/08/04. 
    108  
    109 =cut 
    110  
    111 */ 
    112  
    113 /* 
    114  * Local variables: 
    115  *   c-file-style: "parrot" 
    116  * End: 
    117  * vim: expandtab shiftwidth=4: 
    118  */ 
  • src/pmc/coroutine.pmc

     
    172172            PMC               *ctx        = Parrot_pcc_get_signature(INTERP, caller_ctx); 
    173173            PMC               *ccont      = INTERP->current_cont; 
    174174 
    175             if (ccont == NEED_CONTINUATION) 
    176                 ccont = (PMC *)new_ret_continuation_pmc(INTERP, next_op); 
     175            if (ccont == NEED_CONTINUATION) { 
     176                ccont = pmc_new(interp, enum_class_Continuation); 
     177                VTABLE_set_pointer(interp, ccont, next_op); 
     178            } 
    177179 
    178180            if (PObj_get_FLAGS(ccont) & SUB_FLAG_TAILCALL) 
    179181                Parrot_ex_throw_from_c_args(INTERP, NULL, CONTROL_ERROR, 
  • src/pmc/continuation.pmc

     
    7878        SET_ATTR_address(INTERP, SELF, NULL); 
    7979 
    8080        PObj_custom_mark_SET(SELF); 
    81  
    82         /* PANIC("don't do that"); */ 
    83         /* 
    84          * Whenever we create a continuation, all return continuations 
    85          * up the call chain may be reused due to invoking the 
    86          * continuation. To avoid that all return continuations are 
    87          * converted to true continuations. 
    88          */ 
    89         invalidate_retc_context(INTERP, SELF); 
    9081    } 
    9182 
    9283    /*if they pass in a PMC to initialize with*/ 
     
    109100        SET_ATTR_address(INTERP, SELF, address); 
    110101 
    111102        PObj_custom_mark_SET(SELF); 
    112  
    113         /* PANIC("don't do that"); */ 
    114         /* 
    115          * Whenever we create a continuation, all return continuations 
    116          * up the call chain may be reused due to invoking the 
    117          * continuation. To avoid that all return continuations are 
    118          * converted to true continuations. 
    119          */ 
    120         invalidate_retc_context(INTERP, SELF); 
    121103    } 
    122104 
    123105 
  • src/pmc/sub.pmc

     
    398398        pc                   = sub->seg->base.data + sub->start_offs; 
    399399        INTERP->current_cont = NULL; 
    400400 
    401         if (ccont == NEED_CONTINUATION) 
    402             ccont = new_ret_continuation_pmc(interp, (opcode_t *)next); 
     401        if (ccont == NEED_CONTINUATION) { 
     402            ccont = pmc_new(interp, enum_class_Continuation); 
     403            VTABLE_set_pointer(interp, ccont, next); 
     404        } 
    403405 
    404406        PARROT_ASSERT(!PMC_IS_NULL(ccont)); 
    405407 
     
    427429        PARROT_CONTINUATION(ccont)->from_ctx = context; 
    428430 
    429431        /* if this is an outer sub, then we need to set sub->ctx 
    430          * to the new context (refcounted) and convert the 
    431          * retcontinuation to a normal continuation.  */ 
     432         * to the new context (refcounted) */ 
    432433        if (PObj_get_FLAGS(SELF) & SUB_FLAG_IS_OUTER) { 
    433434            sub->ctx = context; 
    434             /* convert retcontinuation to a continuation */ 
    435             ccont->vtable = interp->vtables[enum_class_Continuation]; 
    436435        } 
    437436 
    438437        /* create pad if needed 
  • src/interp/inter_misc.c

     
    283283      case CURRENT_CONT: 
    284284        { 
    285285            PMC * const cont = Parrot_pcc_get_continuation(interp, CURRENT_CONTEXT(interp)); 
    286             if (!PMC_IS_NULL(cont) && cont->vtable->base_type == 
    287                     enum_class_RetContinuation) 
    288                 return VTABLE_clone(interp, cont); 
    289286            return cont; 
    290287        } 
    291288      case CURRENT_OBJECT: 
  • src/sub.c

     
    4949 
    5050/* 
    5151 
    52 =item C<PMC * new_ret_continuation_pmc(PARROT_INTERP, opcode_t *address)> 
    53  
    54 Returns a new C<RetContinuation> PMC, and sets address field to C<address> 
    55  
    56 =cut 
    57  
    58 */ 
    59  
    60 PARROT_EXPORT 
    61 PARROT_MALLOC 
    62 PARROT_CANNOT_RETURN_NULL 
    63 PMC * 
    64 new_ret_continuation_pmc(PARROT_INTERP, ARGIN_NULLOK(opcode_t *address)) 
    65 { 
    66     ASSERT_ARGS(new_ret_continuation_pmc) 
    67     PMC* const continuation = Parrot_pmc_new(interp, enum_class_RetContinuation); 
    68     VTABLE_set_pointer(interp, continuation, address); 
    69     return continuation; 
    70 } 
    71  
    72 /* 
    73  
    74 =item C<void invalidate_retc_context(PARROT_INTERP, PMC *cont)> 
    75  
    76 Make true Continuations from all RetContinuations up the call chain. 
    77  
    78 =cut 
    79  
    80 */ 
    81  
    82 void 
    83 invalidate_retc_context(PARROT_INTERP, ARGMOD(PMC *cont)) 
    84 { 
    85     ASSERT_ARGS(invalidate_retc_context) 
    86  
    87     PMC *ctx = PARROT_CONTINUATION(cont)->from_ctx; 
    88     cont = Parrot_pcc_get_continuation(interp, ctx); 
    89  
    90     while (1) { 
    91         /* 
    92          * We  stop if we encounter a true continuation, because 
    93          * if one were created, everything up the chain would have been 
    94          * invalidated earlier. 
    95          */ 
    96         if (!cont || cont->vtable != interp->vtables[enum_class_RetContinuation]) 
    97             break; 
    98         cont->vtable = interp->vtables[enum_class_Continuation]; 
    99         ctx  = Parrot_pcc_get_caller_ctx(interp, ctx); 
    100         cont = Parrot_pcc_get_continuation(interp, ctx); 
    101     } 
    102 } 
    103  
    104 /* 
    105  
    10652=item C<STRING* Parrot_full_sub_name(PARROT_INTERP, PMC* sub_pmc)> 
    10753 
    10854Return namespace, name, and location of subroutine. 
  • src/call/pcc.c

     
    340340    opcode_t    *dest; 
    341341    UINTVAL      n_regs_used[] = { 0, 0, 0, 0, 0, 0, 0, 0 }; 
    342342    PMC         *ctx  = Parrot_push_context(interp, n_regs_used); 
    343     PMC * const  ret_cont = new_ret_continuation_pmc(interp, NULL); 
     343    PMC * const  ret_cont = pmc_new(interp, enum_class_Continuation); 
    344344 
    345345    Parrot_pcc_set_signature(interp, ctx, call_object); 
    346346    Parrot_pcc_set_continuation(interp, ctx, ret_cont); 
  • MANIFEST

     
    11# ex: set ro: 
    22# $Id$ 
    33# 
    4 # generated by tools/dev/mk_manifest_and_skip.pl Tue Apr 20 20:11:26 2010 UT 
     4# generated by tools/dev/mk_manifest_and_skip.pl Tue Apr 20 23:21:11 2010 UT 
    55# 
    66# See below for documentation on the format of this file. 
    77# 
     
    14651465src/pmc/resizableintegerarray.pmc                           [] 
    14661466src/pmc/resizablepmcarray.pmc                               [] 
    14671467src/pmc/resizablestringarray.pmc                            [] 
    1468 src/pmc/retcontinuation.pmc                                 [] 
    14691468src/pmc/role.pmc                                            [] 
    14701469src/pmc/scalar.pmc                                          [] 
    14711470src/pmc/scheduler.pmc                                       [] 
     
    19481947t/pmc/resizableintegerarray.t                               [test] 
    19491948t/pmc/resizablepmcarray.t                                   [test] 
    19501949t/pmc/resizablestringarray.t                                [test] 
    1951 t/pmc/retcontinuation.t                                     [test] 
    19521950t/pmc/ro.t                                                  [test] 
    19531951t/pmc/role.t                                                [test] 
    19541952t/pmc/scalar.t                                              [test] 
  • include/parrot/sub.h

     
    172172/* Don't modify between HEADERIZER BEGIN / HEADERIZER END.  Your changes will be lost. */ 
    173173 
    174174PARROT_EXPORT 
    175 PARROT_MALLOC 
    176 PARROT_CANNOT_RETURN_NULL 
    177 PMC * new_ret_continuation_pmc(PARROT_INTERP, 
    178     ARGIN_NULLOK(opcode_t *address)) 
    179         __attribute__nonnull__(1); 
    180  
    181 PARROT_EXPORT 
    182175void Parrot_capture_lex(PARROT_INTERP, ARGMOD(PMC *sub_pmc)) 
    183176        __attribute__nonnull__(1) 
    184177        __attribute__nonnull__(2) 
     
    219212        __attribute__nonnull__(1) 
    220213        __attribute__nonnull__(2); 
    221214 
    222 void invalidate_retc_context(PARROT_INTERP, ARGMOD(PMC *cont)) 
    223         __attribute__nonnull__(1) 
    224         __attribute__nonnull__(2) 
    225         FUNC_MODIFIES(*cont); 
    226  
    227215void mark_context_start(void); 
    228216void Parrot_continuation_check(PARROT_INTERP, ARGIN(const PMC *pmc)) 
    229217        __attribute__nonnull__(1) 
     
    262250    ARGIN_NULLOK(opcode_t *pc)) 
    263251        __attribute__nonnull__(1); 
    264252 
    265 #define ASSERT_ARGS_new_ret_continuation_pmc __attribute__unused__ int _ASSERT_ARGS_CHECK = (\ 
    266        PARROT_ASSERT_ARG(interp)) 
    267253#define ASSERT_ARGS_Parrot_capture_lex __attribute__unused__ int _ASSERT_ARGS_CHECK = (\ 
    268254       PARROT_ASSERT_ARG(interp) \ 
    269255    , PARROT_ASSERT_ARG(sub_pmc)) 
     
    283269#define ASSERT_ARGS_parrot_new_closure __attribute__unused__ int _ASSERT_ARGS_CHECK = (\ 
    284270       PARROT_ASSERT_ARG(interp) \ 
    285271    , PARROT_ASSERT_ARG(sub_pmc)) 
    286 #define ASSERT_ARGS_invalidate_retc_context __attribute__unused__ int _ASSERT_ARGS_CHECK = (\ 
    287        PARROT_ASSERT_ARG(interp) \ 
    288     , PARROT_ASSERT_ARG(cont)) 
    289272#define ASSERT_ARGS_mark_context_start __attribute__unused__ int _ASSERT_ARGS_CHECK = (0) 
    290273#define ASSERT_ARGS_Parrot_continuation_check __attribute__unused__ int _ASSERT_ARGS_CHECK = (\ 
    291274       PARROT_ASSERT_ARG(interp) \ 
  • t/pmc/retcontinuation.t

     
    1 #! parrot 
    2 # Copyright (C) 2006-2008, Parrot Foundation. 
    3 # $Id$ 
    4  
    5 =head1 NAME 
    6  
    7 t/pmc/retcontinuation.t - test the RetContinuation PMC 
    8  
    9 =head1 SYNOPSIS 
    10  
    11     % prove t/pmc/retcontinuation.t 
    12  
    13 =head1 DESCRIPTION 
    14  
    15 Tests the RetContinuation PMC. 
    16  
    17 =cut 
    18  
    19 .sub main :main 
    20     .include 'test_more.pir' 
    21  
    22     plan(1) 
    23  
    24     new $P0, ['RetContinuation'] 
    25     ok(1, 'Instantiated a RetContinuation PMC') 
    26 .end 
    27  
    28 # Local Variables: 
    29 #   mode: pir 
    30 #   fill-column: 100 
    31 # End: 
    32 # vim: expandtab shiftwidth=4 ft=pir: 
  • t/op/gc.t

     
    508508 
    509509# coro context and invalid return continuations 
    510510# this is a stripped down version of imcc/t/syn/pcc_16 
    511 # s. also src/pmc/retcontinuation.pmc 
    512511 
    513512.sub coro_context_ret_continuation 
    514513    .const 'Sub' $P0 = "co1" 
  • PBC_COMPAT

     
    2727 
    2828# please insert tab separated entries at the top of the list 
    2929 
     306.6     2010.04.20      coke    remove retcontinuation PMC 
    30316.5     2010.03.09      cotto   remove cpu_ret op 
    31326.4     2010.03.02      cotto   remove prederef__ and reserved 
    32336.3     2010.02.16      whiteknight     Add OpLib and Opcode PMCs