Ticket #926: cont-pmc.patch
File cont-pmc.patch, 35.1 KB (added by jrtayloriv, 12 years ago) |
---|
-
src/ops/core.ops
578 578 ctx = CONTEXT(interp); 579 579 ccont = ctx->current_cont; 580 580 581 if (P MC_cont(ccont)->address) {581 if (PARROT_CONTINUATION(ccont)->address) { 582 582 /* Call is from runops_fromc */ 583 Parrot_Context * const caller_ctx = P MC_cont(ccont)->to_ctx;583 Parrot_Context * const caller_ctx = PARROT_CONTINUATION(ccont)->to_ctx; 584 584 if (! caller_ctx) { 585 585 /* there is no point calling Parrot_ex_throw_..., because 586 586 PDB_backtrace can't deal with a missing to_ctx either. */ … … 617 617 /* Get context of callee from return continuation. */ 618 618 PMC * const cc = CONTEXT(interp)->current_cont; 619 619 PMC *sig = NULL; 620 if (cc && P MC_cont(cc)->to_ctx) {620 if (cc && PARROT_CONTINUATION(cc)->to_ctx) { 621 621 /* caller context has results */ 622 opcode_t * const results = P MC_cont(cc)->to_ctx->current_results;622 opcode_t * const results = PARROT_CONTINUATION(cc)->to_ctx->current_results; 623 623 if (results) { 624 624 /* get results PMC index and get PMC. */ 625 sig = PF_CONST(P MC_cont(cc)->seg, results[1])->u.key;625 sig = PF_CONST(PARROT_CONTINUATION(cc)->seg, results[1])->u.key; 626 626 } 627 627 } 628 628 -
src/ops/pic.ops
184 184 opcode_t *dest_pc; 185 185 void **dest_pred; 186 186 Parrot_Context *caller_ctx, *ctx; 187 Parrot_ cont*cc;187 Parrot_Continuation_attributes *cc; 188 188 int n; 189 189 190 190 ctx = CONTEXT(interp); 191 191 mic = (Parrot_MIC *) cur_opcode[1]; 192 192 ccont = ctx->current_cont; 193 cc = P MC_cont(ccont);193 cc = PARROT_CONTINUATION(ccont); 194 194 if (!cc->address) { 195 195 interp->current_returns = CUR_OPCODE; 196 196 n = VTABLE_get_integer(interp, mic->m.sig); -
src/debug.c
3539 3539 3540 3540 /* backtrace: follow the continuation chain */ 3541 3541 while (1) { 3542 Parrot_ cont*sub_cont;3542 Parrot_Continuation_attributes *sub_cont; 3543 3543 sub = ctx->current_cont; 3544 3544 3545 3545 if (!sub) 3546 3546 break; 3547 3547 3548 sub_cont = P MC_cont(sub);3548 sub_cont = PARROT_CONTINUATION(sub); 3549 3549 3550 3550 if (!sub_cont) 3551 3551 break; … … 3556 3556 break; 3557 3557 3558 3558 /* recursion detection */ 3559 if (!PMC_IS_NULL(old) && P MC_cont(old) &&3560 P MC_cont(old)->to_ctx->current_pc ==3561 P MC_cont(sub)->to_ctx->current_pc &&3562 P MC_cont(old)->to_ctx->current_sub ==3563 P MC_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) { 3564 3564 ++rec_level; 3565 3565 } 3566 3566 else if (rec_level != 0) { … … 3590 3590 } 3591 3591 3592 3592 /* get the next Continuation */ 3593 ctx = P MC_cont(sub)->to_ctx;3593 ctx = PARROT_CONTINUATION(sub)->to_ctx; 3594 3594 old = sub; 3595 3595 3596 3596 if (!ctx) -
src/pic.c
705 705 706 706 if (op == PARROT_OP_set_returns_pc) { 707 707 PMC * const ccont = ctx->current_cont; 708 if (!P MC_cont(ccont)->address)708 if (!PARROT_CONTINUATION(ccont)->address) 709 709 return 0; 710 caller_ctx = P MC_cont(ccont)->to_ctx;710 caller_ctx = PARROT_CONTINUATION(ccont)->to_ctx; 711 711 args = caller_ctx->current_results; 712 712 } 713 713 else { -
src/runcore/cores.c
382 382 PARROT_ASSERT(debugger); 383 383 384 384 /* 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 */ 386 386 debugger->lo_var_ptr = interp->lo_var_ptr; 387 387 388 388 pio = Parrot_io_STDERR(debugger); -
src/pmc/retcontinuation.pmc
36 36 */ 37 37 38 38 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); 42 40 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 44 48 } 45 49 46 /*47 * XXX when reusing SUPER.destroy() RetContinuations48 * have to set ref_count initially to 149 */50 50 51 VTABLE void destroy() {52 Parrot_cont * const cc = PMC_cont(SELF);53 54 if (cc)55 mem_sys_free(cc);56 }57 51 /* 58 52 59 53 =item C<PMC *clone> … … 81 75 */ 82 76 83 77 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; 88 81 UNUSED(in_next) 89 82 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); 92 85 Parrot_free_context(INTERP, from_ctx, 1); 93 86 94 87 /* the continuation is dead - delete and destroy it */ -
src/pmc/parrotinterpreter.pmc
492 492 for (; level; --level) { 493 493 cont = ctx->current_cont; 494 494 495 if (PMC_IS_NULL(cont) || !P MC_cont(cont)->seg)495 if (PMC_IS_NULL(cont) || !PARROT_CONTINUATION(cont)->seg) 496 496 Parrot_ex_throw_from_c_args(interp, NULL, 497 497 CONTROL_ERROR, "No such caller depth"); 498 498 499 ctx = P MC_cont(cont)->to_ctx;499 ctx = PARROT_CONTINUATION(cont)->to_ctx; 500 500 501 501 if (!ctx->current_sub) 502 502 Parrot_ex_throw_from_c_args(interp, NULL, -
src/pmc/exception.pmc
661 661 * XXX TT#596 - when we have Context PMCs, just take and set that. */ 662 662 663 663 if (!PMC_IS_NULL(value) && VTABLE_isa(interp, value, CONST_STRING(interp, "Continuation"))) { 664 Parrot_Context *ctx = P MC_cont(value)->from_ctx;664 Parrot_Context *ctx = PARROT_CONTINUATION(value)->from_ctx; 665 665 if (ctx) { 666 666 Parrot_context_ref(interp, ctx); 667 667 SET_ATTR_thrower(interp, SELF, ctx); … … 728 728 /* Get resume continuation, to find location we failed at. */ 729 729 GET_ATTR_resume(interp, SELF, resume); 730 730 if (!PMC_IS_NULL(resume)) { 731 Parrot_ cont *cont = PMC_cont(resume);731 Parrot_Continuation_attributes *cont = PARROT_CONTINUATION(resume); 732 732 if (cont->seg != NULL && cont->seg->annotations != NULL) 733 733 result = PackFile_Annotations_lookup(interp, cont->seg->annotations, 734 734 cont->address - cont->seg->base.data, name); … … 762 762 PMC *result = pmc_new(interp, enum_class_ResizablePMCArray); 763 763 PMC *resume; 764 764 Parrot_Context *cur_ctx; 765 Parrot_ cont*cont;765 Parrot_Continuation_attributes *cont; 766 766 767 767 /* Get starting context, then loop over them. */ 768 768 GET_ATTR_resume(interp, SELF, resume); 769 769 if (!PMC_IS_NULL(resume)) { 770 770 /* We have a resume continuation, so we can get the address from 771 771 * that. */ 772 cont = P MC_cont(resume);772 cont = PARROT_CONTINUATION(resume); 773 773 cur_ctx = cont->to_ctx; 774 774 } 775 775 else { -
src/pmc/coroutine.pmc
149 149 co->ctx = Parrot_context_ref(interp, ctx); 150 150 151 151 ctx->caller_ctx = caller_ctx; 152 P MC_cont(ccont)->from_ctx = ctx;152 PARROT_CONTINUATION(ccont)->from_ctx = ctx; 153 153 ctx->current_sub = SELF; 154 154 ctx->current_HLL = co->HLL_id; 155 155 ctx->current_namespace = co->namespace_stash; … … 186 186 187 187 /* and the recent call context */ 188 188 ccont = ctx->current_cont; 189 ctx->caller_ctx = P MC_cont(ccont)->to_ctx189 ctx->caller_ctx = PARROT_CONTINUATION(ccont)->to_ctx 190 190 = CONTEXT(interp); 191 191 192 192 /* set context to coro context */ … … 203 203 204 204 wanted_seg = co->caller_seg; 205 205 ccont = co->ctx->current_cont; 206 ctx = P MC_cont(ccont)->to_ctx;206 ctx = PARROT_CONTINUATION(ccont)->to_ctx; 207 207 208 208 if (! ctx) { 209 209 /* This still isn't quite right, but it beats segfaulting. See -
src/pmc/continuation.pmc
46 46 */ 47 47 48 48 pmclass 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. */ 51 59 /* 52 60 53 61 =item C<void init()> … … 59 67 */ 60 68 61 69 VTABLE void init() { 62 Parrot_Continuation_attributes *attrs = 63 (Parrot_Continuation_attributes *) PMC_data(SELF); 70 Parrot_Continuation_attributes *attrs = PARROT_CONTINUATION(SELF); 64 71 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); 66 80 PObj_custom_mark_destroy_SETALL(SELF); 81 67 82 /* PANIC("don't do that"); */ 68 83 /* 69 84 * Whenever we create a continuation, all return continuations … … 74 89 invalidate_retc_context(INTERP, SELF); 75 90 } 76 91 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 77 117 /* 78 118 79 119 =item C<void mark()> … … 85 125 */ 86 126 87 127 VTABLE void mark() { 88 Parrot_ cont *cc = PMC_cont(SELF);128 Parrot_Continuation_attributes *cc = PARROT_CONTINUATION(SELF); 89 129 130 if(cc->seg) 131 Parrot_gc_mark_PObj_alive(interp, (PObj *)cc->seg); 132 90 133 if (cc->to_ctx) 91 134 mark_context(INTERP, cc->to_ctx); 92 135 if (cc->from_ctx) … … 104 147 */ 105 148 106 149 VTABLE void destroy() { 107 Parrot_ cont * const cc = PMC_cont(SELF);150 Parrot_Continuation_attributes * const cc = PARROT_CONTINUATION(SELF); 108 151 if (cc) { 109 152 #if CTX_LEAK_DEBUG 110 153 if (Interp_debug_TEST(interp, PARROT_CTX_DESTROY_DEBUG_FLAG)) { … … 117 160 if (cc->from_ctx) 118 161 Parrot_free_context(interp, cc->from_ctx, 1); 119 162 120 mem_sys_free(cc); 163 if (cc->to_ctx) 164 Parrot_free_context(interp, cc->to_ctx, 1); 121 165 } 122 166 } 123 167 /* … … 131 175 */ 132 176 133 177 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);138 178 139 P Obj_custom_mark_destroy_SETALL(ret);179 PMC * ret = pmc_new_init(interp, enum_class_Continuation, SELF); 140 180 141 181 /* 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); 148 183 return ret; 149 184 } 150 185 … … 158 193 159 194 */ 160 195 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); 163 198 164 199 STRUCT_COPY(cc_self, cc_src); 165 200 } … … 176 211 177 212 VTABLE void set_pointer(void *value) { 178 213 opcode_t * const pos = (opcode_t *)value; 179 Parrot_ cont * const cc = PMC_cont(SELF);214 Parrot_Continuation_attributes * const cc = PARROT_CONTINUATION(SELF); 180 215 181 216 cc->address = (opcode_t *)value; 182 217 cc->runloop_id = INTERP->current_runloop_id; … … 198 233 */ 199 234 200 235 VTABLE void *get_pointer() { 201 return P MC_cont(SELF)->address;236 return PARROT_CONTINUATION(SELF)->address; 202 237 } 203 238 /* 204 239 … … 213 248 */ 214 249 215 250 VTABLE INTVAL defined() { 216 return P MC_cont(SELF)->address != NULL;251 return PARROT_CONTINUATION(SELF)->address != NULL; 217 252 } 218 253 219 254 VTABLE INTVAL get_bool() { 220 return P MC_cont(SELF)->address != NULL;255 return PARROT_CONTINUATION(SELF)->address != NULL; 221 256 } 222 257 223 258 /* … … 232 267 */ 233 268 234 269 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; 239 273 UNUSED(next) 240 274 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); 243 277 244 278 /* 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; 247 281 248 282 if (to_ctx->current_results && INTERP->current_args) { 249 283 /* … … 266 300 /* switch segment */ 267 301 INTERP->current_args = NULL; 268 302 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); 271 305 272 306 return pc; 273 307 } … … 283 317 */ 284 318 285 319 VTABLE STRING *get_string() { 286 return Parrot_Context_infostr(INTERP, P MC_cont(SELF)->to_ctx);320 return Parrot_Context_infostr(INTERP, PARROT_CONTINUATION(SELF)->to_ctx); 287 321 } 288 322 289 323 /* … … 297 331 */ 298 332 299 333 METHOD caller() { 300 Parrot_ cont *cc = PMC_cont(SELF);334 Parrot_Continuation_attributes *cc = PARROT_CONTINUATION(SELF); 301 335 PMC *caller = cc->to_ctx->current_sub; 302 336 Parrot_Sub_attributes *sub; 303 337 … … 323 357 */ 324 358 325 359 METHOD continuation() { 326 Parrot_ cont *cc = PMC_cont(SELF);360 Parrot_Continuation_attributes *cc = PARROT_CONTINUATION(SELF); 327 361 PMC *cont = cc->to_ctx->current_cont; 328 362 329 363 if (cont) -
src/pmc/exceptionhandler.pmc
40 40 */ 41 41 42 42 VTABLE void init() { 43 Parrot_ExceptionHandler_attributes * const core_struct=43 Parrot_ExceptionHandler_attributes * const attrs = 44 44 (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; 46 51 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 54 52 /* an exception handler has no separate context; it's only a snapshot 55 53 * of an "earlier" context, which is contained in the interpreter's 56 54 * context - the stacks can only be deeper in the interpreter - so no 57 55 * mark of context is needed */ 58 56 PObj_custom_mark_SET(SELF); 59 PObj_ active_destroy_SET(SELF);57 PObj_custom_mark_destroy_SETALL(SELF); 60 58 } 61 59 /* 62 60 … … 69 67 */ 70 68 71 69 VTABLE void mark() { 72 Parrot_ExceptionHandler_attributes * const core_struct=70 Parrot_ExceptionHandler_attributes * const attrs = 73 71 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); 78 76 SUPER(); 79 77 } 80 78 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 81 92 VTABLE PMC *clone() { 82 93 PMC * const result = SUPER(); 83 94 PObj_custom_mark_CLEAR(result); … … 95 106 */ 96 107 97 108 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; 100 110 } 101 111 102 112 /* … … 110 120 */ 111 121 112 122 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; 115 124 } 116 125 117 126 /* … … 125 134 */ 126 135 127 136 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; 130 138 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); 133 141 134 142 /* 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); 137 145 138 146 return pc; 139 147 } … … 232 240 */ 233 241 234 242 METHOD min_severity(INTVAL severity :optional, INTVAL have_severity :opt_flag) { 235 Parrot_ExceptionHandler_attributes * const core_struct=243 Parrot_ExceptionHandler_attributes * const attrs = 236 244 PARROT_EXCEPTIONHANDLER(SELF); 237 245 238 246 if (have_severity) 239 core_struct->min_severity = severity;247 attrs->min_severity = severity; 240 248 else 241 severity = core_struct->min_severity;249 severity = attrs->min_severity; 242 250 243 251 RETURN(INTVAL severity); 244 252 } … … 254 262 */ 255 263 256 264 METHOD max_severity(INTVAL severity :optional, INTVAL have_severity :opt_flag) { 257 Parrot_ExceptionHandler_attributes * const core_struct=265 Parrot_ExceptionHandler_attributes * const attrs = 258 266 PARROT_EXCEPTIONHANDLER(SELF); 259 267 260 268 if (have_severity) 261 core_struct->max_severity = severity;269 attrs->max_severity = severity; 262 270 else 263 severity = core_struct->max_severity;271 severity = attrs->max_severity; 264 272 265 273 RETURN(INTVAL severity); 266 274 } … … 276 284 */ 277 285 278 286 METHOD handle_types(PMC *types :slurpy) { 279 Parrot_ExceptionHandler_attributes * const core_struct=287 Parrot_ExceptionHandler_attributes * const attrs = 280 288 PARROT_EXCEPTIONHANDLER(SELF); 281 core_struct->handled_types =289 attrs->handled_types = 282 290 VTABLE_elements(interp, types) > 0 283 291 ? types 284 292 : PMCNULL; … … 295 303 */ 296 304 297 305 METHOD handle_types_except(PMC *types :slurpy) { 298 Parrot_ExceptionHandler_attributes * const core_struct=306 Parrot_ExceptionHandler_attributes * const attrs = 299 307 PARROT_EXCEPTIONHANDLER(SELF); 300 core_struct->handled_types_except =308 attrs->handled_types_except = 301 309 VTABLE_elements(interp, types) > 0 302 310 ? types 303 311 : PMCNULL; -
src/pmc/sub.pmc
292 292 "maximum recursion depth exceeded"); 293 293 294 294 /* and copy set context variables */ 295 P MC_cont(ccont)->from_ctx = context;295 PARROT_CONTINUATION(ccont)->from_ctx = context; 296 296 297 297 /* if this is an outer sub, then we need to set sub->ctx 298 298 * to the new context (refcounted) and convert the -
src/exceptions.c
251 251 passed properly. */ 252 252 } 253 253 /* Set up the continuation context of the handler in the interpreter. */ 254 else if (P MC_cont(handler)->current_results)254 else if (PARROT_CONTINUATION(handler)->current_results) 255 255 address = pass_exception_args(interp, "P", address, 256 256 CONTEXT(interp), exception); 257 257 … … 400 400 401 401 /* Run the handler. */ 402 402 address = VTABLE_invoke(interp, handler, NULL); 403 if (P MC_cont(handler)->current_results)403 if (PARROT_CONTINUATION(handler)->current_results) 404 404 address = pass_exception_args(interp, "P", address, 405 405 CONTEXT(interp), exception); 406 406 PARROT_ASSERT(return_point->handler_start == NULL); -
src/sub.c
127 127 128 128 /* 129 129 130 =item C<P arrot_cont * new_continuation(PARROT_INTERP, const Parrot_cont*to)>130 =item C<PMC * new_continuation(PARROT_INTERP, const PMC *to)> 131 131 132 Returns a new C<P arrot_cont> to the context of C<to> with its own copy of the132 Returns a new C<PMC> to the context of C<to> with its own copy of the 133 133 current interpreter context. If C<to> is C<NULL>, then the C<to_ctx> is set 134 134 to the current context. 135 135 … … 139 139 140 140 PARROT_MALLOC 141 141 PARROT_CANNOT_RETURN_NULL 142 P arrot_cont*143 new_continuation(PARROT_INTERP, ARGIN_NULLOK( const Parrot_cont*to))142 PMC * 143 new_continuation(PARROT_INTERP, ARGIN_NULLOK(PMC *to)) 144 144 { 145 145 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); 162 150 return cc; 163 151 } 164 152 165 153 /* 166 154 167 =item C<P arrot_cont* new_ret_continuation(PARROT_INTERP)>155 =item C<PMC * new_ret_continuation(PARROT_INTERP)> 168 156 169 Returns a new C<Parrot_cont> pointing to the current context.157 Returns a new RetContinuation C<PMC> pointing to the current context. 170 158 171 159 =cut 172 160 … … 174 162 175 163 PARROT_MALLOC 176 164 PARROT_CANNOT_RETURN_NULL 177 P arrot_cont*165 PMC * 178 166 new_ret_continuation(PARROT_INTERP) 179 167 { 180 168 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); 189 170 return cc; 190 171 } 191 172 173 192 174 /* 193 175 194 176 =item C<PMC * new_ret_continuation_pmc(PARROT_INTERP, opcode_t *address)> 195 177 196 Returns a new C<RetContinuation> PMC. Uses one from the cache, 197 if possible; otherwise, creates a new one. 178 Returns a new C<RetContinuation> PMC, and sets address field to C<address> 198 179 199 180 =cut 200 181 … … 226 207 invalidate_retc_context(PARROT_INTERP, ARGMOD(PMC *cont)) 227 208 { 228 209 ASSERT_ARGS(invalidate_retc_context) 229 Parrot_Context *ctx = PMC_cont(cont)->from_ctx; 210 211 Parrot_Context *ctx = PARROT_CONTINUATION(cont)->from_ctx; 230 212 cont = ctx->current_cont; 231 213 232 214 Parrot_set_context_threshold(interp, ctx); … … 589 571 590 572 /* 591 573 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> 594 575 595 576 Verifies that the provided continuation is sane. 596 577 … … 599 580 */ 600 581 601 582 void 602 Parrot_continuation_check(PARROT_INTERP, ARGIN(const PMC *pmc), 603 ARGIN(const Parrot_cont *cc)) 583 Parrot_continuation_check(PARROT_INTERP, ARGIN(const PMC *pmc)) 604 584 { 605 585 ASSERT_ARGS(Parrot_continuation_check) 606 Parrot_Context *to_ctx = cc->to_ctx;586 Parrot_Context *to_ctx = PARROT_CONTINUATION(pmc)->to_ctx; 607 587 Parrot_Context *from_ctx = CONTEXT(interp); 608 588 609 589 #if CTX_LEAK_DEBUG … … 620 600 621 601 /* 622 602 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> 625 604 626 605 Restores the appropriate context for the continuation. 627 606 … … 630 609 */ 631 610 632 611 void 633 Parrot_continuation_rewind_environment(PARROT_INTERP, SHIM(PMC *pmc), 634 ARGIN(Parrot_cont *cc)) 612 Parrot_continuation_rewind_environment(PARROT_INTERP, ARGIN(PMC *pmc)) 635 613 { 636 614 ASSERT_ARGS(Parrot_continuation_rewind_environment) 637 Parrot_Context * const to_ctx = cc->to_ctx;638 615 616 Parrot_Context * const to_ctx = PARROT_CONTINUATION(pmc)->to_ctx; 617 639 618 /* debug print before context is switched */ 640 619 if (Interp_trace_TEST(interp, PARROT_TRACE_SUB_CALL_FLAG)) { 641 620 PMC * const sub = to_ctx->current_sub; -
src/call/ops.c
251 251 252 252 if (*sig_p && (dest[0] == PARROT_OP_get_params_pc 253 253 || (sub->vtable->base_type == enum_class_ExceptionHandler 254 && P MC_cont(sub)->current_results))) {254 && PARROT_CONTINUATION(sub)->current_results))) { 255 255 dest = parrot_pass_args_fromc(interp, sig_p, dest, old_ctx, ap); 256 256 } 257 257 -
src/call/pcc.c
517 517 /* if this NCI call was a taicall, return results to caller's get_results 518 518 * this also means that we pass the caller's register base pointer */ 519 519 if (SUB_FLAG_TAILCALL_ISSET(current_cont)) 520 ctx = P MC_cont(current_cont)->to_ctx;520 ctx = PARROT_CONTINUATION(current_cont)->to_ctx; 521 521 522 522 /* TODO simplify all */ 523 523 Parrot_init_arg_sig(interp, CONTEXT(interp), sig, NULL, &st->src); … … 2864 2864 interp->current_object = pmc; 2865 2865 interp->current_cont = NEED_CONTINUATION; 2866 2866 ctx->current_cont = ret_cont; 2867 P MC_cont(ret_cont)->from_ctx = Parrot_context_ref(interp, ctx);2867 PARROT_CONTINUATION(ret_cont)->from_ctx = Parrot_context_ref(interp, ctx); 2868 2868 pccinvoke_meth = VTABLE_find_method(interp, pmc, method_name); 2869 2869 2870 2870 if (PMC_IS_NULL(pccinvoke_meth)) … … 3007 3007 } 3008 3008 interp->current_cont = NEED_CONTINUATION; 3009 3009 ctx->current_cont = ret_cont; 3010 P MC_cont(ret_cont)->from_ctx = Parrot_context_ref(interp, ctx);3010 PARROT_CONTINUATION(ret_cont)->from_ctx = Parrot_context_ref(interp, ctx); 3011 3011 3012 3012 /* Invoke the function */ 3013 3013 dest = VTABLE_invoke(interp, sub_obj, NULL); -
lib/Parrot/Pmc2c/PCCMETHOD.pm
412 412 } 413 413 414 414 _ctx->current_cont = _ret_cont; 415 P MC_cont(_ret_cont)->from_ctx = _ctx;415 PARROT_CONTINUATION(_ret_cont)->from_ctx = _ctx; 416 416 417 417 _current_args = interp->current_args; 418 418 interp->current_args = NULL; -
include/parrot/sub.h
152 152 153 153 typedef struct Parrot_Sub_attributes Parrot_sub; 154 154 typedef struct Parrot_Coroutine_attributes Parrot_coro; 155 typedef struct Parrot_Continuation_attributes Parrot_cont; 155 156 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) 168 158 169 #define PMC_cont(pmc) (PARROT_CONTINUATION(pmc)->cont)170 171 159 typedef struct Parrot_Context_info { 172 160 STRING *subname; 173 161 STRING *nsname; … … 237 225 void mark_context_start(void); 238 226 PARROT_MALLOC 239 227 PARROT_CANNOT_RETURN_NULL 240 P arrot_cont* new_continuation(PARROT_INTERP,241 ARGIN_NULLOK( const Parrot_cont*to))228 PMC * new_continuation(PARROT_INTERP, 229 ARGIN_NULLOK(PMC *to)) 242 230 __attribute__nonnull__(1); 243 231 244 232 PARROT_MALLOC 245 233 PARROT_CANNOT_RETURN_NULL 246 P arrot_cont* new_ret_continuation(PARROT_INTERP)234 PMC * new_ret_continuation(PARROT_INTERP) 247 235 __attribute__nonnull__(1); 248 236 249 237 void Parrot_capture_lex(PARROT_INTERP, ARGMOD(PMC *sub_pmc)) … … 252 240 FUNC_MODIFIES(*sub_pmc); 253 241 254 242 void Parrot_continuation_check(PARROT_INTERP, 255 ARGIN(const PMC *pmc), 256 ARGIN(const Parrot_cont *cc)) 243 ARGIN(const PMC *pmc)) 257 244 __attribute__nonnull__(1) 258 __attribute__nonnull__(2) 259 __attribute__nonnull__(3); 245 __attribute__nonnull__(2); 260 246 247 261 248 void Parrot_continuation_rewind_environment(PARROT_INTERP, 262 SHIM(PMC *pmc), 263 ARGIN(Parrot_cont *cc)) 249 ARGIN(PMC *pmc)) 264 250 __attribute__nonnull__(1) 265 __attribute__nonnull__( 3);251 __attribute__nonnull__(2); 266 252 267 253 PARROT_CAN_RETURN_NULL 268 254 PARROT_WARN_UNUSED_RESULT … … 307 293 || PARROT_ASSERT_ARG(sub_pmc) 308 294 #define ASSERT_ARGS_Parrot_continuation_check __attribute__unused__ int _ASSERT_ARGS_CHECK = \ 309 295 PARROT_ASSERT_ARG(interp) \ 310 || PARROT_ASSERT_ARG(pmc) \ 311 || PARROT_ASSERT_ARG(cc) 296 || PARROT_ASSERT_ARG(pmc) 312 297 #define ASSERT_ARGS_Parrot_continuation_rewind_environment \ 313 298 __attribute__unused__ int _ASSERT_ARGS_CHECK = \ 314 299 PARROT_ASSERT_ARG(interp) \ 315 || PARROT_ASSERT_ARG( cc)300 || PARROT_ASSERT_ARG(pmc) 316 301 #define ASSERT_ARGS_Parrot_find_pad __attribute__unused__ int _ASSERT_ARGS_CHECK = \ 317 302 PARROT_ASSERT_ARG(interp) \ 318 303 || PARROT_ASSERT_ARG(lex_name) \