diff --git a/include/parrot/interpreter.h b/include/parrot/interpreter.h index 961f2b7074..daff738b2f 100644 --- a/include/parrot/interpreter.h +++ b/include/parrot/interpreter.h @@ -1,5 +1,5 @@ /* interpreter.h - * Copyright (C) 2001-2010, Parrot Foundation. + * Copyright (C) 2001-2012, Parrot Foundation. * Overview: * The interpreter API handles running the operations */ @@ -90,6 +90,11 @@ typedef enum { } Parrot_clone_flags; /* &end_gen */ +/* Codes used by long jumps to runloop */ +#define PARROT_JMP_EXCEPTION_HANDLED 1 +#define PARROT_JMP_EXCEPTION_FROM_C 2 +#define PARROT_JMP_EXCEPTION_FINALIZED 3 + struct parrot_interp_t; /* One of the most common shim arguments is the interpreter itself, so it diff --git a/src/call/ops.c b/src/call/ops.c index a9fba07ec6..c7b9d6ad8f 100644 --- a/src/call/ops.c +++ b/src/call/ops.c @@ -91,7 +91,7 @@ runops(PARROT_INTERP, size_t offs) reenter: interp->current_runloop->handler_start = NULL; switch (setjmp(interp->current_runloop->resume)) { - case 1: + case PARROT_JMP_EXCEPTION_HANDLED: /* an exception was handled */ if (STACKED_EXCEPTIONS) free_runloop_jump_point(interp); @@ -104,7 +104,7 @@ runops(PARROT_INTERP, size_t offs) interp->current_runloop_id, interp->current_runloop_level); #endif return; - case 2: + case PARROT_JMP_EXCEPTION_FROM_C: /* Reenter the runloop from a exception thrown from C * with a pir handler */ free_runloops_until(interp, our_runloop_id); @@ -112,7 +112,7 @@ runops(PARROT_INTERP, size_t offs) offset = interp->current_runloop->handler_start - interp->code->base.data; /* Prevent incorrect reuse */ goto reenter; - case 3: + case PARROT_JMP_EXCEPTION_FINALIZED: /* Reenter the runloop when finished the handling of a * exception */ free_runloops_until(interp, our_runloop_id); diff --git a/src/exceptions.c b/src/exceptions.c index 930f99cfc2..6c7a06d89e 100644 --- a/src/exceptions.c +++ b/src/exceptions.c @@ -1,5 +1,5 @@ /* -Copyright (C) 2001-2010, Parrot Foundation. +Copyright (C) 2001-2012, Parrot Foundation. =head1 NAME @@ -236,7 +236,7 @@ Parrot_ex_throw_from_op(PARROT_INTERP, ARGIN(PMC *exception), ARGIN_NULLOK(void /* it's a C exception handler */ Parrot_runloop * const jump_point = (Parrot_runloop *)address; jump_point->exception = exception; - longjmp(jump_point->resume, 1); + longjmp(jump_point->resume, PARROT_JMP_EXCEPTION_HANDLED); } /* return the address of the handler */ @@ -360,7 +360,7 @@ Parrot_ex_throw_from_c(PARROT_INTERP, ARGIN(PMC *exception)) Parrot_runloop * const jump_point = (Parrot_runloop *)VTABLE_get_pointer(interp, handler); jump_point->exception = exception; - longjmp(jump_point->resume, 1); + longjmp(jump_point->resume, PARROT_JMP_EXCEPTION_HANDLED); } else { /* Run the handler. */ @@ -369,7 +369,7 @@ Parrot_ex_throw_from_c(PARROT_INTERP, ARGIN(PMC *exception)) setup_exception_args(interp, "P", exception); PARROT_ASSERT(return_point->handler_start == NULL); return_point->handler_start = address; - longjmp(return_point->resume, 2); + longjmp(return_point->resume, PARROT_JMP_EXCEPTION_FROM_C); } } diff --git a/src/ops/core.ops b/src/ops/core.ops index 0e58517ac2..a2802d6d1e 100644 --- a/src/ops/core.ops +++ b/src/ops/core.ops @@ -896,7 +896,7 @@ op finalize(in PMC) { if (rl) { if (rl != interp->current_runloop) { rl->handler_start = dest; - longjmp(rl->resume, 3); + longjmp(rl->resume, PARROT_JMP_EXCEPTION_FINALIZED); } } else diff --git a/src/ops/core_ops.c b/src/ops/core_ops.c index d73ea3d657..a37b82828d 100644 --- a/src/ops/core_ops.c +++ b/src/ops/core_ops.c @@ -14171,7 +14171,7 @@ Parrot_finalize_p(opcode_t *cur_opcode, PARROT_INTERP) { if (rl) { if ((rl != interp->current_runloop)) { rl->handler_start = dest; - longjmp(rl->resume, 3); + longjmp(rl->resume, PARROT_JMP_EXCEPTION_FINALIZED); } } @@ -14226,7 +14226,7 @@ Parrot_finalize_pc(opcode_t *cur_opcode, PARROT_INTERP) { if (rl) { if ((rl != interp->current_runloop)) { rl->handler_start = dest; - longjmp(rl->resume, 3); + longjmp(rl->resume, PARROT_JMP_EXCEPTION_FINALIZED); } }