Ticket #804: TT_804.patch
| File TT_804.patch, 4.2 KB (added by NotFound, 4 years ago) |
|---|
-
src/exceptions.c
1 1 /* 2 Copyright (C) 2001-200 8, Parrot Foundation.2 Copyright (C) 2001-2009, Parrot Foundation. 3 3 $Id$ 4 4 5 5 =head1 NAME … … 343 343 344 344 Parrot_runloop *return_point = interp->current_runloop; 345 345 RunProfile * const profile = interp->profile; 346 opcode_t *address; 346 347 PMC * const handler = 347 348 Parrot_cx_find_handler_local(interp, exception); 348 349 … … 384 385 } 385 386 386 387 /* Run the handler. */ 387 Parrot_runops_fromc_args(interp, handler, "vP", exception); 388 389 /* After handling a C exception, you don't want to resume at the point 390 * where the C exception was thrown. You want to resume the next outer 391 * runloop. */ 392 longjmp(return_point->resume, 1); 388 address = VTABLE_invoke(interp, handler, NULL); 389 if (PMC_cont(handler)->current_results) 390 address = pass_exception_args(interp, "P", address, 391 CONTEXT(interp), exception); 392 PARROT_ASSERT(return_point->handler_start == NULL); 393 return_point->handler_start = address; 394 longjmp(return_point->resume, 2); 393 395 } 394 396 395 397 /* -
src/call/ops.c
88 88 #endif 89 89 { 90 90 new_runloop_jump_point(interp); 91 if (setjmp(interp->current_runloop->resume)) { 92 /* an exception was handled */ 93 if (STACKED_EXCEPTIONS) 94 free_runloop_jump_point(interp); 91 reenter: 92 interp->current_runloop->handler_start = NULL; 93 switch (setjmp(interp->current_runloop->resume)) { 94 case 1: 95 /* an exception was handled */ 96 if (STACKED_EXCEPTIONS) 97 free_runloop_jump_point(interp); 95 98 96 interp->current_runloop_level = our_runloop_level - 1;97 interp->current_runloop_id = old_runloop_id;99 interp->current_runloop_level = our_runloop_level - 1; 100 interp->current_runloop_id = old_runloop_id; 98 101 99 102 #if RUNLOOP_TRACE 100 fprintf(stderr, "[handled exception; back to loop %d, level %d]\n",101 interp->current_runloop_id, interp->current_runloop_level);103 fprintf(stderr, "[handled exception; back to loop %d, level %d]\n", 104 interp->current_runloop_id, interp->current_runloop_level); 102 105 #endif 103 return; 106 return; 107 case 2: 108 /* Reenter the runloop from a exception thrown from C 109 * with a pir handler */ 110 PARROT_ASSERT(interp->current_runloop->handler_start); 111 offset = interp->current_runloop->handler_start - interp->code->base.data; 112 /* Prevent incorrect reuse */ 113 goto reenter; 114 default: 115 break; 104 116 } 105 117 } 106 118 107 119 runops_int(interp, offset); 108 120 121 interp->current_runloop->handler_start = NULL; 109 122 /* Remove the current runloop marker (put it on the free list). */ 110 123 if (STACKED_EXCEPTIONS || interp->current_runloop) 111 124 free_runloop_jump_point(interp); -
include/parrot/interpreter.h
1 1 /* interpreter.h 2 * Copyright (C) 2001-200 7, Parrot Foundation.2 * Copyright (C) 2001-2009, Parrot Foundation. 3 3 * SVN Info 4 4 * $Id$ 5 5 * Overview: … … 290 290 * runloop ID, so it still needs to be a separate stack for a while longer. */ 291 291 292 292 typedef struct parrot_runloop_t { 293 Parrot_jump_buff resume; /* jmp_buf */ 294 struct parrot_runloop_t *prev; /* interpreter's runloop jump buffer stack */ 293 Parrot_jump_buff resume; /* jmp_buf */ 294 struct parrot_runloop_t *prev; /* interpreter's runloop 295 * jump buffer stack */ 296 opcode_t *handler_start; /* Used in exception handling */ 295 297 } parrot_runloop_t; 296 298 297 299 typedef parrot_runloop_t Parrot_runloop;
