From: Matt Birkholz Date: Thu, 8 Mar 2012 04:06:24 +0000 (-0700) Subject: svm: Remove setjmp from execute_instruction. X-Git-Tag: release-9.2.0~270 X-Git-Url: https://birchwood-abbey.net/git?a=commitdiff_plain;h=ddd6395a50e33a34b42c39add3d6b621fdd08b72;p=mit-scheme.git svm: Remove setjmp from execute_instruction. Trade some debuggability for significantly better performance. --- diff --git a/src/microcode/svm1-interp.c b/src/microcode/svm1-interp.c index 72a236c8c..c20a174f2 100644 --- a/src/microcode/svm1-interp.c +++ b/src/microcode/svm1-interp.c @@ -30,8 +30,6 @@ USA. #include "fixnum.h" #include "svm1-defns.h" #include "cmpintmd/svm1.h" - -#define SVM1_REG_SP 0 typedef SCHEME_OBJECT word_t; /* convenience abbreviation */ @@ -145,14 +143,11 @@ static trap_3_t * traps_3 [256]; #define DECODE_TRAP_2(name) byte_t name = NEXT_BYTE #define DECODE_TRAP_3(name) byte_t name = NEXT_BYTE -static void signal_illegal_instruction (void); static void initialize_decoder_tables (void); static int initialized_p = 0; static int little_endian_p; -static bool execute_instruction (void); - static void compute_little_endian_p (void) { @@ -206,33 +201,16 @@ C_to_interface (void * address) { IMPORT_REGS (); PC = address; - while (execute_instruction ()); + while ((* (inst_defns[NEXT_BYTE])) ()); EXPORT_REGS (); return (svm1_result); } -static jmp_buf k_execute_instruction; - -static bool -execute_instruction (void) -{ - if ((setjmp (k_execute_instruction)) != 0) - return (0); - return ((* (inst_defns[NEXT_BYTE])) ()); -} - static bool illegal_instruction (void) -{ - signal_illegal_instruction (); - return (0); -} - -static void -signal_illegal_instruction (void) { svm1_result = ERR_COMPILED_CODE_ERROR; - longjmp (k_execute_instruction, 1); + return (0); } #define TO_SIGNED(n) ((long) (n)) @@ -279,8 +257,7 @@ static wreg_t decode_wreg (void) { byte_t b = NEXT_BYTE; - if (!WORD_REGISTER_P (b)) - signal_illegal_instruction (); + assert (WORD_REGISTER_P (b)); return (b); } @@ -288,8 +265,7 @@ static freg_t decode_freg (void) { byte_t b = NEXT_BYTE; - if (!FLOAT_REGISTER_P (b)) - signal_illegal_instruction (); + assert (FLOAT_REGISTER_P (b)); return (b); } @@ -297,8 +273,7 @@ static tc_t decode_type_word (void) { byte_t b = NEXT_BYTE; - if (b >= N_TYPE_CODES) - signal_illegal_instruction (); + assert (b < N_TYPE_CODES); return (b); } @@ -775,7 +750,7 @@ DEFINE_INST (trap_trap_0) static bool illegal_trap_0 (void) { - signal_illegal_instruction (); + svm1_result = ERR_COMPILED_CODE_ERROR; return (0); } @@ -788,7 +763,7 @@ DEFINE_INST (trap_trap_1_wr) static bool illegal_trap_1 (wreg_t r1) { - signal_illegal_instruction (); + svm1_result = ERR_COMPILED_CODE_ERROR; return (0); } @@ -801,7 +776,7 @@ DEFINE_INST (trap_trap_2_wr) static bool illegal_trap_2 (wreg_t r1, wreg_t r2) { - signal_illegal_instruction (); + svm1_result = ERR_COMPILED_CODE_ERROR; return (0); } @@ -814,7 +789,7 @@ DEFINE_INST (trap_trap_3_wr) static bool illegal_trap_3 (wreg_t r1, wreg_t r2, wreg_t r3) { - signal_illegal_instruction (); + svm1_result = ERR_COMPILED_CODE_ERROR; return (0); } @@ -1242,10 +1217,16 @@ decode_address (address_t * address) (* (address_decoders[NEXT_BYTE])) (address); } +static word_t +illegal_address_value (address_t * address) +{ + return (0); +} + static void illegal_address (address_t * address) { - signal_illegal_instruction (); + address->value = illegal_address_value; } static word_t