From 37a5970c19ca7ad2b5de2f667748c840c199f878 Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Mon, 4 Jul 2011 23:56:16 +0200 Subject: VM: Keep jump table address in a register. * libguile/vm-engine.c (VM_NAME)[HAVE_LABELS_AS_VALUES]: Rename `jump_table' to `jump_table_pointer'. Add `jump_table' as a local variable, initialize it. * libguile/vm-engine.h (JT_REG): New macro. --- libguile/vm-engine.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'libguile/vm-engine.c') diff --git a/libguile/vm-engine.c b/libguile/vm-engine.c index 22bd39c0e..c90458df6 100644 --- a/libguile/vm-engine.c +++ b/libguile/vm-engine.c @@ -61,23 +61,31 @@ VM_NAME (SCM vm, SCM program, SCM *argv, int nargs) SCM finish_args; /* used both for returns: both in error and normal situations */ #ifdef HAVE_LABELS_AS_VALUES - static void **jump_table = NULL; + static const void **jump_table_pointer = NULL; #endif - + #ifdef HAVE_LABELS_AS_VALUES - if (SCM_UNLIKELY (!jump_table)) + register const void **jump_table JT_REG; + + if (SCM_UNLIKELY (!jump_table_pointer)) { int i; - jump_table = malloc (SCM_VM_NUM_INSTRUCTIONS * sizeof(void*)); + jump_table_pointer = malloc (SCM_VM_NUM_INSTRUCTIONS * sizeof (void*)); for (i = 0; i < SCM_VM_NUM_INSTRUCTIONS; i++) - jump_table[i] = &&vm_error_bad_instruction; + jump_table_pointer[i] = &&vm_error_bad_instruction; #define VM_INSTRUCTION_TO_LABEL 1 +#define jump_table jump_table_pointer #include #include #include #include +#undef jump_table #undef VM_INSTRUCTION_TO_LABEL } + + /* Attempt to keep JUMP_TABLE_POINTER in a register. This saves one + load instruction at each instruction dispatch. */ + jump_table = jump_table_pointer; #endif /* Initialization */ -- cgit v1.2.3