From d036239788b1825bfa05588d7f9ee379cd95fc54 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Fri, 22 May 2015 07:38:34 -0700 Subject: Ligher weight debug instrumentation. This speeds up the TXR Lisp interpreter, because do_eval sets up a debug frame and uses debug_return. * debug.c (debug_block_s): Symbol removed. (debug_init): Remove initialization of debug_block_s. * debug.h (debug_block_s): Declaration removed. (debug_enter): Do not establish a named block or a catch block; no time-wasting unwind stack manipulation at all. The debug_depth variable is managed by the extended setjmp context now. Provide a return value variable, and a well-defined name to branch to to exit from the debug block. (debug_return): Do not use heavy-weight uw_block_return; simply set the return variable and branch to debug_return_out label. * signal.h (EJ_DBG_MEMB, EJ_DBG_SAVE, EJ_DBG_REST, EJ_OPT_MEMB, EJ_OPT_SAVE, EJ_OPT_REST): New macros. (extended_jmp_buf): Define optional global state variables using EJ_OPT_MEMB. (extended_setjmp): Save and restore optional globals using EJ_OPT_SAVE and EJ_OPT_RESTORE. Now debug_depth is saved and restored if debugging support is compiled in. * match.c (open_data_source): Remove bogus debug_return invocations which were uncovered here by changes to the macro. * eval.c (do_eval, expand_macro): debug_return must now be after debug_end, because it won't dynamically clean up frames that it doesn't know about. The set_dyn_env is no longer unreachable in expand_macro; it is now necessary because debug_return isn't doing the longjmp that previously restored dyn_env. --- debug.h | 32 +++++++++++++++----------------- 1 file changed, 15 insertions(+), 17 deletions(-) (limited to 'debug.h') diff --git a/debug.h b/debug.h index 88695866..c14a304c 100644 --- a/debug.h +++ b/debug.h @@ -26,30 +26,28 @@ extern int opt_debugger; extern int debug_depth; -extern val debug_block_s; val debug(val form, val bindings, val data, val line, val pos, val base); #if CONFIG_DEBUG_SUPPORT -#define debug_enter \ - { \ - int debug_depth_save = debug_depth++; \ - uw_block_begin(debug_block_s, debug_result); \ - uw_simple_catch_begin { - -#define debug_leave \ - } \ - uw_unwind { \ - debug_depth = debug_depth_save; \ - } \ - uw_catch_end; \ - uw_block_end; \ - return debug_result; \ +#define debug_enter \ + { \ + int debug_depth_save = debug_depth++; \ + val debug_result = nil; \ + (void) 0 + +#define debug_leave \ + debug_return_out: \ + debug_depth = debug_depth_save; \ + return debug_result; \ } -#define debug_return(VAL) \ - uw_block_return(debug_block_s, VAL) +#define debug_return(VAL) \ + do { \ + debug_result = VAL; \ + goto debug_return_out; \ + } while (0) INLINE val debug_check(val form, val bindings, val data, val line, val pos, val base) -- cgit v1.2.3