[svn:parrot] r47661 - in branches/gsoc_instrument: include/parrot src src/dynpmc
khairul at svn.parrot.org
khairul at svn.parrot.org
Wed Jun 16 17:50:09 UTC 2010
Author: khairul
Date: Wed Jun 16 17:50:08 2010
New Revision: 47661
URL: https://trac.parrot.org/parrot/changeset/47661
Log:
Handle exit opcodes and unhandled exceptions so that instruments can be finalized.
Modified:
branches/gsoc_instrument/include/parrot/call.h
branches/gsoc_instrument/src/dynpmc/instrument.pmc
branches/gsoc_instrument/src/exceptions.c
Modified: branches/gsoc_instrument/include/parrot/call.h
==============================================================================
--- branches/gsoc_instrument/include/parrot/call.h Wed Jun 16 17:47:01 2010 (r47660)
+++ branches/gsoc_instrument/include/parrot/call.h Wed Jun 16 17:50:08 2010 (r47661)
@@ -29,6 +29,7 @@
* jump buffer stack */
opcode_t *handler_start; /* Used in exception handling */
int id; /* runloop id */
+ PMC *exception; /* Reference to the exception object */
/* let the biggest element cross the cacheline boundary */
Parrot_jump_buff resume; /* jmp_buf */
Modified: branches/gsoc_instrument/src/dynpmc/instrument.pmc
==============================================================================
--- branches/gsoc_instrument/src/dynpmc/instrument.pmc Wed Jun 16 17:47:01 2010 (r47660)
+++ branches/gsoc_instrument/src/dynpmc/instrument.pmc Wed Jun 16 17:50:08 2010 (r47661)
@@ -613,10 +613,32 @@
Instrument_runcore_runops(PARROT_INTERP, Parrot_runcore_t *runcore, opcode_t *pc) {
Instrument_runcore_t *core = (Instrument_runcore_t *) runcore;
Parrot_Interp supervisor = core->supervisor_interp;
+ Parrot_runloop exc_handler;
/* Detect any dynlib loading, for example during load_bytecode. */
detect_loadlib(interp);
+ /* Setup an exception handler to handle exits and unhandled exceptions. */
+ if(setjmp(exc_handler.resume)) {
+ /* Check for exit or unhandled exception. */
+ if(*pc == enum_ops_exit_i || *pc == enum_ops_exit_ic) {
+ /* Exit called. Do nothing but return so we
+ can go on to finalize the instruments. */
+ }
+ else {
+ /* Unhandled exception found.
+ Print the exception type for now. */
+ Parrot_io_printf(supervisor,
+ "Unhandled exception of type %i found\n",
+ VTABLE_get_integer_keyed_str(interp, exc_handler.exception,
+ CONST_STRING(interp, "type")));
+ }
+
+ return pc;
+ }
+
+ Parrot_ex_add_c_handler(interp, &exc_handler);
+
while (pc) {
opcode_t *pc_copy = pc;
Parrot_pcc_set_pc(interp, CURRENT_CONTEXT(interp), pc);
Modified: branches/gsoc_instrument/src/exceptions.c
==============================================================================
--- branches/gsoc_instrument/src/exceptions.c Wed Jun 16 17:47:01 2010 (r47660)
+++ branches/gsoc_instrument/src/exceptions.c Wed Jun 16 17:50:08 2010 (r47661)
@@ -242,6 +242,7 @@
if (PObj_get_FLAGS(handler) & SUB_FLAG_C_HANDLER) {
/* it's a C exception handler */
Parrot_runloop * const jump_point = (Parrot_runloop *)address;
+ jump_point->exception = exception;
longjmp(jump_point->resume, 1);
}
@@ -367,6 +368,7 @@
if (PObj_get_FLAGS(handler) & SUB_FLAG_C_HANDLER) {
Parrot_runloop * const jump_point =
(Parrot_runloop * const)VTABLE_get_pointer(interp, handler);
+ jump_point->exception = exception;
longjmp(jump_point->resume, 1);
}
More information about the parrot-commits
mailing list