Ticket #926: cont-pmc.patch

File cont-pmc.patch, 35.1 KB (added by jrtayloriv, 12 years ago)

(buggy) patch to kill Parrot_cont struct

  • src/ops/core.ops

     
    578578    ctx = CONTEXT(interp); 
    579579    ccont = ctx->current_cont; 
    580580 
    581     if (PMC_cont(ccont)->address) { 
     581    if (PARROT_CONTINUATION(ccont)->address) { 
    582582        /* Call is from runops_fromc */ 
    583         Parrot_Context * const caller_ctx = PMC_cont(ccont)->to_ctx; 
     583        Parrot_Context * const caller_ctx = PARROT_CONTINUATION(ccont)->to_ctx; 
    584584        if (! caller_ctx) { 
    585585            /* there is no point calling Parrot_ex_throw_..., because 
    586586               PDB_backtrace can't deal with a missing to_ctx either. */ 
     
    617617    /* Get context of callee from return continuation. */ 
    618618    PMC * const cc = CONTEXT(interp)->current_cont; 
    619619    PMC *sig = NULL; 
    620     if (cc && PMC_cont(cc)->to_ctx) { 
     620    if (cc && PARROT_CONTINUATION(cc)->to_ctx) { 
    621621        /* caller context has results */ 
    622         opcode_t * const results = PMC_cont(cc)->to_ctx->current_results; 
     622        opcode_t * const results = PARROT_CONTINUATION(cc)->to_ctx->current_results; 
    623623        if (results) { 
    624624            /* get results PMC index and get PMC. */ 
    625             sig = PF_CONST(PMC_cont(cc)->seg, results[1])->u.key; 
     625            sig = PF_CONST(PARROT_CONTINUATION(cc)->seg, results[1])->u.key; 
    626626        } 
    627627    } 
    628628 
  • src/ops/pic.ops

     
    184184    opcode_t *dest_pc; 
    185185    void **dest_pred; 
    186186    Parrot_Context *caller_ctx, *ctx; 
    187     Parrot_cont *cc; 
     187    Parrot_Continuation_attributes *cc; 
    188188    int n; 
    189189 
    190190    ctx = CONTEXT(interp); 
    191191    mic = (Parrot_MIC *) cur_opcode[1]; 
    192192    ccont = ctx->current_cont; 
    193     cc = PMC_cont(ccont); 
     193    cc = PARROT_CONTINUATION(ccont); 
    194194    if (!cc->address) { 
    195195        interp->current_returns = CUR_OPCODE; 
    196196        n = VTABLE_get_integer(interp, mic->m.sig); 
  • src/debug.c

     
    35393539 
    35403540    /* backtrace: follow the continuation chain */ 
    35413541    while (1) { 
    3542         Parrot_cont *sub_cont; 
     3542        Parrot_Continuation_attributes *sub_cont; 
    35433543        sub = ctx->current_cont; 
    35443544 
    35453545        if (!sub) 
    35463546            break; 
    35473547 
    3548         sub_cont = PMC_cont(sub); 
     3548        sub_cont = PARROT_CONTINUATION(sub); 
    35493549 
    35503550        if (!sub_cont) 
    35513551            break; 
     
    35563556            break; 
    35573557 
    35583558        /* recursion detection */ 
    3559         if (!PMC_IS_NULL(old) && PMC_cont(old) && 
    3560             PMC_cont(old)->to_ctx->current_pc == 
    3561             PMC_cont(sub)->to_ctx->current_pc && 
    3562             PMC_cont(old)->to_ctx->current_sub == 
    3563             PMC_cont(sub)->to_ctx->current_sub) { 
     3559        if (!PMC_IS_NULL(old) && PARROT_CONTINUATION(old) && 
     3560            PARROT_CONTINUATION(old)->to_ctx->current_pc == 
     3561            PARROT_CONTINUATION(sub)->to_ctx->current_pc && 
     3562            PARROT_CONTINUATION(old)->to_ctx->current_sub == 
     3563            PARROT_CONTINUATION(sub)->to_ctx->current_sub) { 
    35643564                ++rec_level; 
    35653565        } 
    35663566        else if (rec_level != 0) { 
     
    35903590        } 
    35913591 
    35923592        /* get the next Continuation */ 
    3593         ctx = PMC_cont(sub)->to_ctx; 
     3593        ctx = PARROT_CONTINUATION(sub)->to_ctx; 
    35943594        old = sub; 
    35953595 
    35963596        if (!ctx) 
  • src/pic.c

     
    705705 
    706706    if (op == PARROT_OP_set_returns_pc) { 
    707707        PMC * const ccont = ctx->current_cont; 
    708         if (!PMC_cont(ccont)->address) 
     708        if (!PARROT_CONTINUATION(ccont)->address) 
    709709            return 0; 
    710         caller_ctx = PMC_cont(ccont)->to_ctx; 
     710        caller_ctx = PARROT_CONTINUATION(ccont)->to_ctx; 
    711711        args       = caller_ctx->current_results; 
    712712    } 
    713713    else { 
  • src/runcore/cores.c

     
    382382        PARROT_ASSERT(debugger); 
    383383 
    384384        /* set the top of the stack so GC can trace it for GC-able pointers 
    385          * see trace_system_areas() in src/cpu_dep.c */ 
     385         * see trace_system_areas() in src/gc/system.c */ 
    386386        debugger->lo_var_ptr = interp->lo_var_ptr; 
    387387 
    388388        pio = Parrot_io_STDERR(debugger); 
  • src/pmc/retcontinuation.pmc

     
    3636*/ 
    3737 
    3838    VTABLE void init() { 
    39         Parrot_RetContinuation_attributes * const attrs = 
    40             (Parrot_RetContinuation_attributes *) PMC_data(SELF); 
    41         PMC_cont(SELF) = new_ret_continuation(INTERP); 
     39        Parrot_RetContinuation_attributes * const attrs = PARROT_RETCONTINUATION(SELF); 
    4240 
    43         PObj_custom_mark_destroy_SETALL(SELF); 
     41        attrs->to_ctx          = CONTEXT(interp); 
     42        attrs->from_ctx        = CONTEXT(interp);    /* filled in during a call */ 
     43        attrs->runloop_id      = 0; 
     44        attrs->seg             = interp->code; 
     45        attrs->current_results = NULL; 
     46        attrs->address         = NULL; 
     47 
    4448    } 
    4549 
    46     /* 
    47      * XXX when reusing SUPER.destroy() RetContinuations 
    48      *     have to set ref_count initially to 1 
    49      */ 
    5050 
    51     VTABLE void destroy() { 
    52         Parrot_cont * const cc = PMC_cont(SELF); 
    53  
    54         if (cc) 
    55             mem_sys_free(cc); 
    56     } 
    5751/* 
    5852 
    5953=item C<PMC *clone> 
     
    8175*/ 
    8276 
    8377    VTABLE opcode_t *invoke(void *in_next) { 
    84         Parrot_cont       *cc         = PMC_cont(SELF); 
    85         Parrot_Context    *from_ctx   = cc->from_ctx; 
    86         PackFile_ByteCode * const seg = cc->seg; 
    87         opcode_t          *next       = cc->address; 
     78        Parrot_Context    *from_ctx        = PARROT_CONTINUATION(SELF)->from_ctx; 
     79        PackFile_ByteCode * const seg      = PARROT_CONTINUATION(SELF)->seg; 
     80        opcode_t          *next            = PARROT_CONTINUATION(SELF)->address; 
    8881        UNUSED(in_next) 
    8982 
    90         Parrot_continuation_check(interp, SELF, cc); 
    91         Parrot_continuation_rewind_environment(interp, SELF, cc); 
     83        Parrot_continuation_check(interp, SELF); 
     84        Parrot_continuation_rewind_environment(interp, SELF); 
    9285        Parrot_free_context(INTERP, from_ctx, 1); 
    9386 
    9487        /* the continuation is dead - delete and destroy it */ 
  • src/pmc/parrotinterpreter.pmc

     
    492492            for (; level; --level) { 
    493493                cont = ctx->current_cont; 
    494494 
    495                 if (PMC_IS_NULL(cont) || !PMC_cont(cont)->seg) 
     495                if (PMC_IS_NULL(cont) || !PARROT_CONTINUATION(cont)->seg) 
    496496                    Parrot_ex_throw_from_c_args(interp, NULL, 
    497497                        CONTROL_ERROR, "No such caller depth"); 
    498498 
    499                 ctx = PMC_cont(cont)->to_ctx; 
     499                ctx = PARROT_CONTINUATION(cont)->to_ctx; 
    500500 
    501501                if (!ctx->current_sub) 
    502502                    Parrot_ex_throw_from_c_args(interp, NULL, 
  • src/pmc/exception.pmc

     
    661661             * XXX TT#596 - when we have Context PMCs, just take and set that. */ 
    662662 
    663663            if (!PMC_IS_NULL(value) && VTABLE_isa(interp, value, CONST_STRING(interp, "Continuation"))) { 
    664                 Parrot_Context *ctx = PMC_cont(value)->from_ctx; 
     664                Parrot_Context *ctx = PARROT_CONTINUATION(value)->from_ctx; 
    665665                if (ctx) { 
    666666                    Parrot_context_ref(interp, ctx); 
    667667                    SET_ATTR_thrower(interp, SELF, ctx); 
     
    728728        /* Get resume continuation, to find location we failed at. */ 
    729729        GET_ATTR_resume(interp, SELF, resume); 
    730730        if (!PMC_IS_NULL(resume)) { 
    731             Parrot_cont *cont = PMC_cont(resume); 
     731            Parrot_Continuation_attributes *cont = PARROT_CONTINUATION(resume); 
    732732            if (cont->seg != NULL && cont->seg->annotations != NULL) 
    733733                result = PackFile_Annotations_lookup(interp, cont->seg->annotations, 
    734734                        cont->address - cont->seg->base.data, name); 
     
    762762        PMC *result = pmc_new(interp, enum_class_ResizablePMCArray); 
    763763        PMC *resume; 
    764764        Parrot_Context *cur_ctx; 
    765         Parrot_cont    *cont; 
     765        Parrot_Continuation_attributes    *cont; 
    766766 
    767767        /* Get starting context, then loop over them. */ 
    768768        GET_ATTR_resume(interp, SELF, resume); 
    769769        if (!PMC_IS_NULL(resume)) { 
    770770            /* We have a resume continuation, so we can get the address from 
    771771             * that. */ 
    772             cont    = PMC_cont(resume); 
     772            cont    = PARROT_CONTINUATION(resume); 
    773773            cur_ctx = cont->to_ctx; 
    774774        } 
    775775        else { 
  • src/pmc/coroutine.pmc

     
    149149            co->ctx                   = Parrot_context_ref(interp, ctx); 
    150150 
    151151            ctx->caller_ctx           = caller_ctx; 
    152             PMC_cont(ccont)->from_ctx = ctx; 
     152            PARROT_CONTINUATION(ccont)->from_ctx = ctx; 
    153153            ctx->current_sub          = SELF; 
    154154            ctx->current_HLL          = co->HLL_id; 
    155155            ctx->current_namespace    = co->namespace_stash; 
     
    186186 
    187187            /* and the recent call context */ 
    188188            ccont                 = ctx->current_cont; 
    189             ctx->caller_ctx       = PMC_cont(ccont)->to_ctx 
     189            ctx->caller_ctx       = PARROT_CONTINUATION(ccont)->to_ctx 
    190190                                  = CONTEXT(interp); 
    191191 
    192192            /* set context to coro context */ 
     
    203203 
    204204            wanted_seg            = co->caller_seg; 
    205205            ccont                 = co->ctx->current_cont; 
    206             ctx                   = PMC_cont(ccont)->to_ctx; 
     206            ctx                   = PARROT_CONTINUATION(ccont)->to_ctx; 
    207207 
    208208            if (! ctx) { 
    209209                /* This still isn't quite right, but it beats segfaulting.  See 
  • src/pmc/continuation.pmc

     
    4646 */ 
    4747 
    4848pmclass Continuation auto_attrs { 
    49     ATTR struct Parrot_cont *cont; /* the continuation struct */ 
    50  
     49    /* continuation destination */ 
     50    ATTR PackFile_ByteCode *seg;          /* bytecode segment */ 
     51    ATTR opcode_t *address;               /* start of bytecode, addr to continue */ 
     52    ATTR Parrot_Context *to_ctx;   /* pointer to dest context */ 
     53    /* a Continuation keeps the from_ctx alive */ 
     54    ATTR Parrot_Context *from_ctx; /* sub, this cont is returning from */ 
     55    ATTR opcode_t *current_results;       /* ptr into code with get_results opcode 
     56                                        full continuation only */ 
     57    ATTR int runloop_id;                  /* id of the creating runloop. */ 
     58    ATTR int invoked;                     /* flag when a handler has been invoked. */ 
    5159/* 
    5260 
    5361=item C<void init()> 
     
    5967*/ 
    6068 
    6169    VTABLE void init() { 
    62         Parrot_Continuation_attributes *attrs = 
    63             (Parrot_Continuation_attributes *) PMC_data(SELF); 
     70        Parrot_Continuation_attributes *attrs = PARROT_CONTINUATION(SELF); 
    6471 
    65         PMC_cont(SELF) = new_continuation(INTERP, NULL); 
     72        attrs->to_ctx = CONTEXT(interp); 
     73        attrs->from_ctx = Parrot_context_ref(interp, CONTEXT(interp)); 
     74        attrs->runloop_id    = 0; 
     75        attrs->seg       = interp->code; 
     76        attrs->address   = NULL; 
     77        attrs->current_results = attrs->to_ctx->current_results; 
     78 
     79        PObj_active_destroy_SET(SELF); 
    6680        PObj_custom_mark_destroy_SETALL(SELF); 
     81 
    6782        /* PANIC("don't do that"); */ 
    6883        /* 
    6984         * Whenever we create a continuation, all return continuations 
     
    7489        invalidate_retc_context(INTERP, SELF); 
    7590    } 
    7691 
     92    /*if they pass in a PMC to initialize with*/ 
     93    VTABLE void init_pmc(PMC *values) { 
     94        Parrot_Continuation_attributes *attrs = PARROT_CONTINUATION(SELF); 
     95         
     96        attrs->to_ctx = PARROT_CONTINUATION(values)->to_ctx; 
     97        attrs->from_ctx = Parrot_context_ref(interp, CONTEXT(interp)); 
     98        attrs->runloop_id    = 0; 
     99        attrs->seg       = PARROT_CONTINUATION(values)->seg; 
     100        attrs->address   = PARROT_CONTINUATION(values)->address; 
     101        attrs->current_results = attrs->to_ctx->current_results; 
     102 
     103        PObj_custom_mark_destroy_SETALL(SELF); 
     104 
     105        /* PANIC("don't do that"); */ 
     106        /* 
     107         * Whenever we create a continuation, all return continuations 
     108         * up the call chain may be reused due to invoking the 
     109         * continuation. To avoid that all return continuations are 
     110         * converted to true continuations. 
     111         */ 
     112        invalidate_retc_context(INTERP, SELF); 
     113    } 
     114 
     115     
     116 
    77117/* 
    78118 
    79119=item C<void mark()> 
     
    85125*/ 
    86126 
    87127    VTABLE void mark() { 
    88         Parrot_cont *cc = PMC_cont(SELF); 
     128        Parrot_Continuation_attributes *cc = PARROT_CONTINUATION(SELF); 
    89129 
     130        if(cc->seg) 
     131            Parrot_gc_mark_PObj_alive(interp, (PObj *)cc->seg);  
     132 
    90133        if (cc->to_ctx) 
    91134            mark_context(INTERP, cc->to_ctx); 
    92135        if (cc->from_ctx) 
     
    104147*/ 
    105148 
    106149    VTABLE void destroy() { 
    107         Parrot_cont * const cc = PMC_cont(SELF); 
     150        Parrot_Continuation_attributes * const cc = PARROT_CONTINUATION(SELF); 
    108151        if (cc) { 
    109152#if CTX_LEAK_DEBUG 
    110153            if (Interp_debug_TEST(interp, PARROT_CTX_DESTROY_DEBUG_FLAG)) { 
     
    117160            if (cc->from_ctx) 
    118161                Parrot_free_context(interp, cc->from_ctx, 1); 
    119162 
    120             mem_sys_free(cc); 
     163            if (cc->to_ctx) 
     164                Parrot_free_context(interp, cc->to_ctx, 1); 
    121165        } 
    122166    } 
    123167/* 
     
    131175*/ 
    132176 
    133177    VTABLE PMC *clone() { 
    134         Parrot_cont * const cc_self  = PMC_cont(SELF); 
    135         Parrot_cont * const cc       = new_continuation(INTERP, cc_self); 
    136         PMC         * const ret      = pmc_new(INTERP, enum_class_Continuation); 
    137         Parrot_cont * const ret_cont = PMC_cont(ret); 
    138178 
    139         PObj_custom_mark_destroy_SETALL(ret); 
     179        PMC         * ret      = pmc_new_init(interp, enum_class_Continuation, SELF); 
    140180 
    141181        /* free ret's PMC_cont */ 
    142         Parrot_free_context(interp, ret_cont->from_ctx, 1); 
    143         mem_sys_free(ret_cont); 
    144  
    145         cc->runloop_id = cc_self->runloop_id; 
    146         PMC_cont(ret)  = cc; 
    147  
     182        Parrot_free_context(interp, PARROT_CONTINUATION(ret)->from_ctx, 1); 
    148183        return ret; 
    149184    } 
    150185 
     
    158193 
    159194*/ 
    160195    VTABLE void set_pmc(PMC *src) { 
    161         Parrot_cont * const cc_self = PMC_cont(SELF); 
    162         Parrot_cont * const cc_src  = PMC_cont(src); 
     196        Parrot_Continuation_attributes * const cc_self = PARROT_CONTINUATION(SELF); 
     197        Parrot_Continuation_attributes * const cc_src  = PARROT_CONTINUATION(src); 
    163198 
    164199        STRUCT_COPY(cc_self, cc_src); 
    165200    } 
     
    176211 
    177212    VTABLE void set_pointer(void *value) { 
    178213        opcode_t    * const pos = (opcode_t *)value; 
    179         Parrot_cont * const cc  = PMC_cont(SELF); 
     214        Parrot_Continuation_attributes * const cc  = PARROT_CONTINUATION(SELF); 
    180215 
    181216        cc->address       = (opcode_t *)value; 
    182217        cc->runloop_id    = INTERP->current_runloop_id; 
     
    198233*/ 
    199234 
    200235    VTABLE void *get_pointer() { 
    201         return PMC_cont(SELF)->address; 
     236        return PARROT_CONTINUATION(SELF)->address; 
    202237    } 
    203238/* 
    204239 
     
    213248*/ 
    214249 
    215250    VTABLE INTVAL defined() { 
    216         return PMC_cont(SELF)->address != NULL; 
     251        return PARROT_CONTINUATION(SELF)->address != NULL; 
    217252    } 
    218253 
    219254    VTABLE INTVAL get_bool() { 
    220         return PMC_cont(SELF)->address != NULL; 
     255        return PARROT_CONTINUATION(SELF)->address != NULL; 
    221256    } 
    222257 
    223258/* 
     
    232267*/ 
    233268 
    234269    VTABLE opcode_t *invoke(void *next) { 
    235         Parrot_cont      *cc           = PMC_cont(SELF); 
    236         Parrot_Context   *from_ctx     = CONTEXT(interp); 
    237         Parrot_Context   *to_ctx       = cc->to_ctx; 
    238         opcode_t         *pc           = cc->address; 
     270        Parrot_Context   *from_ctx         = CONTEXT(interp); 
     271        Parrot_Context   *to_ctx           = PARROT_CONTINUATION(SELF)->to_ctx; 
     272        opcode_t         *pc               = PARROT_CONTINUATION(SELF)->address; 
    239273        UNUSED(next) 
    240274 
    241         Parrot_continuation_check(interp, SELF, cc); 
    242         Parrot_continuation_rewind_environment(interp, SELF, cc); 
     275        Parrot_continuation_check(interp, SELF); 
     276        Parrot_continuation_rewind_environment(interp, SELF); 
    243277 
    244278        /* pass args to where caller wants result */ 
    245         if (cc->current_results) 
    246             to_ctx->current_results = cc->current_results; 
     279        if (PARROT_CONTINUATION(SELF)->current_results) 
     280            to_ctx->current_results = PARROT_CONTINUATION(SELF)->current_results; 
    247281 
    248282        if (to_ctx->current_results && INTERP->current_args) { 
    249283            /* 
     
    266300        /* switch segment */ 
    267301        INTERP->current_args = NULL; 
    268302 
    269         if (INTERP->code != cc->seg) 
    270             Parrot_switch_to_cs(INTERP, cc->seg, 1); 
     303        if (INTERP->code != PARROT_CONTINUATION(SELF)->seg) 
     304            Parrot_switch_to_cs(INTERP, PARROT_CONTINUATION(SELF)->seg, 1); 
    271305 
    272306        return pc; 
    273307    } 
     
    283317*/ 
    284318 
    285319    VTABLE STRING *get_string() { 
    286         return Parrot_Context_infostr(INTERP, PMC_cont(SELF)->to_ctx); 
     320        return Parrot_Context_infostr(INTERP, PARROT_CONTINUATION(SELF)->to_ctx); 
    287321    } 
    288322 
    289323/* 
     
    297331*/ 
    298332 
    299333    METHOD caller() { 
    300         Parrot_cont *cc     = PMC_cont(SELF); 
     334        Parrot_Continuation_attributes *cc     = PARROT_CONTINUATION(SELF); 
    301335        PMC         *caller = cc->to_ctx->current_sub; 
    302336        Parrot_Sub_attributes  *sub; 
    303337 
     
    323357*/ 
    324358 
    325359    METHOD continuation() { 
    326         Parrot_cont *cc   = PMC_cont(SELF); 
     360        Parrot_Continuation_attributes *cc   = PARROT_CONTINUATION(SELF); 
    327361        PMC         *cont = cc->to_ctx->current_cont; 
    328362 
    329363        if (cont) 
  • src/pmc/exceptionhandler.pmc

     
    4040*/ 
    4141 
    4242    VTABLE void init() { 
    43         Parrot_ExceptionHandler_attributes * const core_struct = 
     43        Parrot_ExceptionHandler_attributes * const attrs = 
    4444            (Parrot_ExceptionHandler_attributes *)PMC_data(SELF); 
    45         Parrot_cont * const cc     = new_continuation(INTERP, NULL); 
     45        SUPER(); 
     46        attrs->invoked      = 0; 
     47        attrs->min_severity  = 0; 
     48        attrs->max_severity  = 0; 
     49        attrs->handled_types = PMCNULL; 
     50        attrs->handled_types_except = PMCNULL; 
    4651 
    47         cc->invoked                = 0; 
    48         PMC_cont(SELF)             = cc; 
    49         core_struct->min_severity  = 0; 
    50         core_struct->max_severity  = 0; 
    51         core_struct->handled_types = PMCNULL; 
    52         core_struct->handled_types_except = PMCNULL; 
    53  
    5452        /* an exception handler has no separate context; it's only a snapshot 
    5553         * of an "earlier" context, which is contained in the interpreter's 
    5654         * context - the stacks can only be deeper in the interpreter - so no 
    5755         * mark of context is needed */ 
    5856        PObj_custom_mark_SET(SELF); 
    59         PObj_active_destroy_SET(SELF); 
     57        PObj_custom_mark_destroy_SETALL(SELF); 
    6058    } 
    6159/* 
    6260 
     
    6967*/ 
    7068 
    7169    VTABLE void mark() { 
    72         Parrot_ExceptionHandler_attributes * const core_struct = 
     70        Parrot_ExceptionHandler_attributes * const attrs = 
    7371            PARROT_EXCEPTIONHANDLER(SELF); 
    74         if (core_struct->handled_types) 
    75             Parrot_gc_mark_PObj_alive(interp, (PObj *)core_struct->handled_types); 
    76         if (core_struct->handled_types_except) 
    77             Parrot_gc_mark_PObj_alive(interp, (PObj *)core_struct->handled_types_except); 
     72        if (attrs->handled_types) 
     73            Parrot_gc_mark_PObj_alive(interp, (PObj *)attrs->handled_types); 
     74        if (attrs->handled_types_except) 
     75            Parrot_gc_mark_PObj_alive(interp, (PObj *)attrs->handled_types_except); 
    7876        SUPER(); 
    7977    } 
    8078 
     79    VTABLE void destroy(){ 
     80 
     81        Parrot_ExceptionHandler_attributes *attrs = PARROT_EXCEPTIONHANDLER(SELF); 
     82 
     83        if (attrs->handled_types){ 
     84            PObj_on_free_list_SET((PObj *) attrs->handled_types); 
     85        } 
     86        if (attrs->handled_types_except){ 
     87            PObj_on_free_list_SET((PObj *) attrs->handled_types_except); 
     88        } 
     89        SUPER(); 
     90    } 
     91 
    8192    VTABLE PMC *clone() { 
    8293        PMC * const result = SUPER(); 
    8394        PObj_custom_mark_CLEAR(result); 
     
    95106*/ 
    96107 
    97108    VTABLE void set_integer_native(INTVAL value) { 
    98         Parrot_cont * const cc = (Parrot_cont *)PMC_cont(SELF); 
    99         cc->invoked = value; 
     109        PARROT_CONTINUATION(SELF)->invoked = value; 
    100110    } 
    101111 
    102112/* 
     
    110120*/ 
    111121 
    112122    VTABLE INTVAL get_integer() { 
    113         const Parrot_cont * const cc = (Parrot_cont *)PMC_cont(SELF); 
    114         return cc->invoked; 
     123        return PARROT_CONTINUATION(SELF)->invoked; 
    115124    } 
    116125 
    117126/* 
     
    125134*/ 
    126135 
    127136    VTABLE opcode_t *invoke(void *next) { 
    128         Parrot_cont * const cc = (Parrot_cont *)PMC_cont(SELF); 
    129         opcode_t    * const pc = cc->address; 
     137        opcode_t    * const pc = PARROT_CONTINUATION(SELF)->address; 
    130138 
    131         Parrot_continuation_check(interp, SELF, cc); 
    132         Parrot_continuation_rewind_environment(interp, SELF, cc); 
     139        Parrot_continuation_check(interp, SELF); 
     140        Parrot_continuation_rewind_environment(interp, SELF); 
    133141 
    134142        /* switch code segment if needed */ 
    135         if (INTERP->code != cc->seg) 
    136             Parrot_switch_to_cs(INTERP, cc->seg, 1); 
     143        if (INTERP->code != PARROT_CONTINUATION(SELF)->seg) 
     144            Parrot_switch_to_cs(INTERP, PARROT_CONTINUATION(SELF)->seg, 1); 
    137145 
    138146        return pc; 
    139147    } 
     
    232240*/ 
    233241 
    234242    METHOD min_severity(INTVAL severity :optional, INTVAL have_severity :opt_flag) { 
    235         Parrot_ExceptionHandler_attributes * const core_struct = 
     243        Parrot_ExceptionHandler_attributes * const attrs = 
    236244                    PARROT_EXCEPTIONHANDLER(SELF); 
    237245 
    238246        if (have_severity) 
    239             core_struct->min_severity = severity; 
     247            attrs->min_severity = severity; 
    240248        else 
    241             severity = core_struct->min_severity; 
     249            severity = attrs->min_severity; 
    242250 
    243251        RETURN(INTVAL severity); 
    244252    } 
     
    254262*/ 
    255263 
    256264    METHOD max_severity(INTVAL severity :optional, INTVAL have_severity :opt_flag) { 
    257         Parrot_ExceptionHandler_attributes * const core_struct = 
     265        Parrot_ExceptionHandler_attributes * const attrs = 
    258266                    PARROT_EXCEPTIONHANDLER(SELF); 
    259267 
    260268        if (have_severity) 
    261             core_struct->max_severity = severity; 
     269            attrs->max_severity = severity; 
    262270        else 
    263             severity = core_struct->max_severity; 
     271            severity = attrs->max_severity; 
    264272 
    265273        RETURN(INTVAL severity); 
    266274    } 
     
    276284*/ 
    277285 
    278286    METHOD handle_types(PMC *types :slurpy) { 
    279         Parrot_ExceptionHandler_attributes * const core_struct = 
     287        Parrot_ExceptionHandler_attributes * const attrs = 
    280288                    PARROT_EXCEPTIONHANDLER(SELF); 
    281         core_struct->handled_types = 
     289        attrs->handled_types = 
    282290            VTABLE_elements(interp, types) > 0 
    283291                ? types 
    284292                : PMCNULL; 
     
    295303*/ 
    296304 
    297305    METHOD handle_types_except(PMC *types :slurpy) { 
    298         Parrot_ExceptionHandler_attributes * const core_struct = 
     306        Parrot_ExceptionHandler_attributes * const attrs = 
    299307                    PARROT_EXCEPTIONHANDLER(SELF); 
    300         core_struct->handled_types_except = 
     308        attrs->handled_types_except = 
    301309            VTABLE_elements(interp, types) > 0 
    302310                ? types 
    303311                : PMCNULL; 
  • src/pmc/sub.pmc

     
    292292                    "maximum recursion depth exceeded"); 
    293293 
    294294        /* and copy set context variables */ 
    295         PMC_cont(ccont)->from_ctx = context; 
     295        PARROT_CONTINUATION(ccont)->from_ctx = context; 
    296296 
    297297        /* if this is an outer sub, then we need to set sub->ctx 
    298298         * to the new context (refcounted) and convert the 
  • src/exceptions.c

     
    251251           passed properly. */ 
    252252    } 
    253253    /* Set up the continuation context of the handler in the interpreter. */ 
    254     else if (PMC_cont(handler)->current_results) 
     254    else if (PARROT_CONTINUATION(handler)->current_results) 
    255255        address = pass_exception_args(interp, "P", address, 
    256256                CONTEXT(interp), exception); 
    257257 
     
    400400 
    401401    /* Run the handler. */ 
    402402    address = VTABLE_invoke(interp, handler, NULL); 
    403     if (PMC_cont(handler)->current_results) 
     403    if (PARROT_CONTINUATION(handler)->current_results) 
    404404        address = pass_exception_args(interp, "P", address, 
    405405                CONTEXT(interp), exception); 
    406406    PARROT_ASSERT(return_point->handler_start == NULL); 
  • src/sub.c

     
    127127 
    128128/* 
    129129 
    130 =item C<Parrot_cont * new_continuation(PARROT_INTERP, const Parrot_cont *to)> 
     130=item C<PMC * new_continuation(PARROT_INTERP, const PMC *to)> 
    131131 
    132 Returns a new C<Parrot_cont> to the context of C<to> with its own copy of the 
     132Returns a new C<PMC> to the context of C<to> with its own copy of the 
    133133current interpreter context.  If C<to> is C<NULL>, then the C<to_ctx> is set 
    134134to the current context. 
    135135 
     
    139139 
    140140PARROT_MALLOC 
    141141PARROT_CANNOT_RETURN_NULL 
    142 Parrot_cont * 
    143 new_continuation(PARROT_INTERP, ARGIN_NULLOK(const Parrot_cont *to)) 
     142PMC * 
     143new_continuation(PARROT_INTERP, ARGIN_NULLOK(PMC *to)) 
    144144{ 
    145145    ASSERT_ARGS(new_continuation) 
    146     Parrot_cont    * const cc     = mem_allocate_typed(Parrot_cont); 
    147     Parrot_Context * const to_ctx = to ? to->to_ctx : CONTEXT(interp); 
    148  
    149     cc->to_ctx        = to_ctx; 
    150     cc->from_ctx      = Parrot_context_ref(interp, CONTEXT(interp)); 
    151     cc->runloop_id    = 0; 
    152     if (to) { 
    153         cc->seg       = to->seg; 
    154         cc->address   = to->address; 
    155     } 
    156     else { 
    157         cc->seg       = interp->code; 
    158         cc->address   = NULL; 
    159     } 
    160  
    161     cc->current_results = to_ctx->current_results; 
     146     
     147    PMC * const cc = to ?  
     148        constant_pmc_new_init(interp, enum_class_Continuation, to) : 
     149        constant_pmc_new(interp, enum_class_Continuation); 
    162150    return cc; 
    163151} 
    164152 
    165153/* 
    166154 
    167 =item C<Parrot_cont * new_ret_continuation(PARROT_INTERP)> 
     155=item C<PMC * new_ret_continuation(PARROT_INTERP)> 
    168156 
    169 Returns a new C<Parrot_cont> pointing to the current context. 
     157Returns a new RetContinuation C<PMC> pointing to the current context. 
    170158 
    171159=cut 
    172160 
     
    174162 
    175163PARROT_MALLOC 
    176164PARROT_CANNOT_RETURN_NULL 
    177 Parrot_cont * 
     165PMC * 
    178166new_ret_continuation(PARROT_INTERP) 
    179167{ 
    180168    ASSERT_ARGS(new_ret_continuation) 
    181     Parrot_cont * const cc = mem_allocate_typed(Parrot_cont); 
    182  
    183     cc->to_ctx          = CONTEXT(interp); 
    184     cc->from_ctx        = CONTEXT(interp);    /* filled in during a call */ 
    185     cc->runloop_id      = 0; 
    186     cc->seg             = interp->code; 
    187     cc->current_results = NULL; 
    188     cc->address         = NULL; 
     169    PMC * const cc = pmc_new(interp, enum_class_RetContinuation); 
    189170    return cc; 
    190171} 
    191172 
     173 
    192174/* 
    193175 
    194176=item C<PMC * new_ret_continuation_pmc(PARROT_INTERP, opcode_t *address)> 
    195177 
    196 Returns a new C<RetContinuation> PMC. Uses one from the cache, 
    197 if possible; otherwise, creates a new one. 
     178Returns a new C<RetContinuation> PMC, and sets address field to C<address> 
    198179 
    199180=cut 
    200181 
     
    226207invalidate_retc_context(PARROT_INTERP, ARGMOD(PMC *cont)) 
    227208{ 
    228209    ASSERT_ARGS(invalidate_retc_context) 
    229     Parrot_Context *ctx = PMC_cont(cont)->from_ctx; 
     210 
     211    Parrot_Context *ctx = PARROT_CONTINUATION(cont)->from_ctx; 
    230212    cont = ctx->current_cont; 
    231213 
    232214    Parrot_set_context_threshold(interp, ctx); 
     
    589571 
    590572/* 
    591573 
    592 =item C<void Parrot_continuation_check(PARROT_INTERP, const PMC *pmc, const 
    593 Parrot_cont *cc)> 
     574=item C<void Parrot_continuation_check(PARROT_INTERP, const PMC *pmc> 
    594575 
    595576Verifies that the provided continuation is sane. 
    596577 
     
    599580*/ 
    600581 
    601582void 
    602 Parrot_continuation_check(PARROT_INTERP, ARGIN(const PMC *pmc), 
    603     ARGIN(const Parrot_cont *cc)) 
     583Parrot_continuation_check(PARROT_INTERP, ARGIN(const PMC *pmc)) 
    604584{ 
    605585    ASSERT_ARGS(Parrot_continuation_check) 
    606     Parrot_Context *to_ctx       = cc->to_ctx; 
     586    Parrot_Context *to_ctx       = PARROT_CONTINUATION(pmc)->to_ctx; 
    607587    Parrot_Context *from_ctx     = CONTEXT(interp); 
    608588 
    609589#if CTX_LEAK_DEBUG 
     
    620600 
    621601/* 
    622602 
    623 =item C<void Parrot_continuation_rewind_environment(PARROT_INTERP, PMC *pmc, 
    624 Parrot_cont *cc)> 
     603=item C<void Parrot_continuation_rewind_environment(PARROT_INTERP, PMC *pmc> 
    625604 
    626605Restores the appropriate context for the continuation. 
    627606 
     
    630609*/ 
    631610 
    632611void 
    633 Parrot_continuation_rewind_environment(PARROT_INTERP, SHIM(PMC *pmc), 
    634         ARGIN(Parrot_cont *cc)) 
     612Parrot_continuation_rewind_environment(PARROT_INTERP, ARGIN(PMC *pmc)) 
    635613{ 
    636614    ASSERT_ARGS(Parrot_continuation_rewind_environment) 
    637     Parrot_Context * const to_ctx = cc->to_ctx; 
    638615 
     616    Parrot_Context * const to_ctx = PARROT_CONTINUATION(pmc)->to_ctx; 
     617 
    639618    /* debug print before context is switched */ 
    640619    if (Interp_trace_TEST(interp, PARROT_TRACE_SUB_CALL_FLAG)) { 
    641620        PMC * const sub = to_ctx->current_sub; 
  • src/call/ops.c

     
    251251 
    252252    if (*sig_p && (dest[0]     == PARROT_OP_get_params_pc 
    253253    || (sub->vtable->base_type == enum_class_ExceptionHandler 
    254     &&  PMC_cont(sub)->current_results))) { 
     254    &&  PARROT_CONTINUATION(sub)->current_results))) { 
    255255        dest = parrot_pass_args_fromc(interp, sig_p, dest, old_ctx, ap); 
    256256    } 
    257257 
  • src/call/pcc.c

     
    517517    /* if this NCI call was a taicall, return results to caller's get_results 
    518518     * this also means that we pass the caller's register base pointer */ 
    519519    if (SUB_FLAG_TAILCALL_ISSET(current_cont)) 
    520         ctx = PMC_cont(current_cont)->to_ctx; 
     520        ctx = PARROT_CONTINUATION(current_cont)->to_ctx; 
    521521 
    522522    /* TODO simplify all */ 
    523523    Parrot_init_arg_sig(interp, CONTEXT(interp), sig, NULL, &st->src); 
     
    28642864    interp->current_object       = pmc; 
    28652865    interp->current_cont         = NEED_CONTINUATION; 
    28662866    ctx->current_cont            = ret_cont; 
    2867     PMC_cont(ret_cont)->from_ctx = Parrot_context_ref(interp, ctx); 
     2867    PARROT_CONTINUATION(ret_cont)->from_ctx = Parrot_context_ref(interp, ctx); 
    28682868    pccinvoke_meth               = VTABLE_find_method(interp, pmc, method_name); 
    28692869 
    28702870    if (PMC_IS_NULL(pccinvoke_meth)) 
     
    30073007    } 
    30083008    interp->current_cont         = NEED_CONTINUATION; 
    30093009    ctx->current_cont            = ret_cont; 
    3010     PMC_cont(ret_cont)->from_ctx = Parrot_context_ref(interp, ctx); 
     3010    PARROT_CONTINUATION(ret_cont)->from_ctx = Parrot_context_ref(interp, ctx); 
    30113011 
    30123012    /* Invoke the function */ 
    30133013    dest = VTABLE_invoke(interp, sub_obj, NULL); 
  • lib/Parrot/Pmc2c/PCCMETHOD.pm

     
    412412    } 
    413413 
    414414    _ctx->current_cont            = _ret_cont; 
    415     PMC_cont(_ret_cont)->from_ctx = _ctx; 
     415    PARROT_CONTINUATION(_ret_cont)->from_ctx = _ctx; 
    416416 
    417417    _current_args                 = interp->current_args; 
    418418    interp->current_args         = NULL; 
  • include/parrot/sub.h

     
    152152 
    153153typedef struct Parrot_Sub_attributes Parrot_sub; 
    154154typedef struct Parrot_Coroutine_attributes Parrot_coro; 
     155typedef struct Parrot_Continuation_attributes Parrot_cont; 
    155156 
    156 typedef struct Parrot_cont { 
    157     /* continuation destination */ 
    158     PackFile_ByteCode *seg;          /* bytecode segment */ 
    159     opcode_t *address;               /* start of bytecode, addr to continue */ 
    160     struct Parrot_Context *to_ctx;   /* pointer to dest context */ 
    161     /* a Continuation keeps the from_ctx alive */ 
    162     struct Parrot_Context *from_ctx; /* sub, this cont is returning from */ 
    163     opcode_t *current_results;       /* ptr into code with get_results opcode 
    164                                         full continuation only */ 
    165     int runloop_id;                  /* id of the creating runloop. */ 
    166     int invoked;                     /* flag when a handler has been invoked. */ 
    167 } Parrot_cont; 
     157#define PMC_cont(pmc) PARROT_CONTINUATION(pmc) 
    168158 
    169 #define PMC_cont(pmc) (PARROT_CONTINUATION(pmc)->cont) 
    170  
    171159typedef struct Parrot_Context_info { 
    172160    STRING   *subname; 
    173161    STRING   *nsname; 
     
    237225void mark_context_start(void); 
    238226PARROT_MALLOC 
    239227PARROT_CANNOT_RETURN_NULL 
    240 Parrot_cont * new_continuation(PARROT_INTERP, 
    241     ARGIN_NULLOK(const Parrot_cont *to)) 
     228PMC * new_continuation(PARROT_INTERP, 
     229    ARGIN_NULLOK(PMC *to)) 
    242230        __attribute__nonnull__(1); 
    243231 
    244232PARROT_MALLOC 
    245233PARROT_CANNOT_RETURN_NULL 
    246 Parrot_cont * new_ret_continuation(PARROT_INTERP) 
     234PMC * new_ret_continuation(PARROT_INTERP) 
    247235        __attribute__nonnull__(1); 
    248236 
    249237void Parrot_capture_lex(PARROT_INTERP, ARGMOD(PMC *sub_pmc)) 
     
    252240        FUNC_MODIFIES(*sub_pmc); 
    253241 
    254242void Parrot_continuation_check(PARROT_INTERP, 
    255     ARGIN(const PMC *pmc), 
    256     ARGIN(const Parrot_cont *cc)) 
     243    ARGIN(const PMC *pmc)) 
    257244        __attribute__nonnull__(1) 
    258         __attribute__nonnull__(2) 
    259         __attribute__nonnull__(3); 
     245        __attribute__nonnull__(2); 
    260246 
     247 
    261248void Parrot_continuation_rewind_environment(PARROT_INTERP, 
    262     SHIM(PMC *pmc), 
    263     ARGIN(Parrot_cont *cc)) 
     249    ARGIN(PMC *pmc)) 
    264250        __attribute__nonnull__(1) 
    265         __attribute__nonnull__(3); 
     251        __attribute__nonnull__(2); 
    266252 
    267253PARROT_CAN_RETURN_NULL 
    268254PARROT_WARN_UNUSED_RESULT 
     
    307293    || PARROT_ASSERT_ARG(sub_pmc) 
    308294#define ASSERT_ARGS_Parrot_continuation_check __attribute__unused__ int _ASSERT_ARGS_CHECK = \ 
    309295       PARROT_ASSERT_ARG(interp) \ 
    310     || PARROT_ASSERT_ARG(pmc) \ 
    311     || PARROT_ASSERT_ARG(cc) 
     296    || PARROT_ASSERT_ARG(pmc) 
    312297#define ASSERT_ARGS_Parrot_continuation_rewind_environment \ 
    313298     __attribute__unused__ int _ASSERT_ARGS_CHECK = \ 
    314299       PARROT_ASSERT_ARG(interp) \ 
    315     || PARROT_ASSERT_ARG(cc) 
     300    || PARROT_ASSERT_ARG(pmc) 
    316301#define ASSERT_ARGS_Parrot_find_pad __attribute__unused__ int _ASSERT_ARGS_CHECK = \ 
    317302       PARROT_ASSERT_ARG(interp) \ 
    318303    || PARROT_ASSERT_ARG(lex_name) \