mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-05-20 11:40:18 +02:00
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.
This commit is contained in:
parent
c467c36374
commit
37a5970c19
2 changed files with 21 additions and 5 deletions
|
@ -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 <libguile/vm-expand.h>
|
||||
#include <libguile/vm-i-system.i>
|
||||
#include <libguile/vm-i-scheme.i>
|
||||
#include <libguile/vm-i-loader.i>
|
||||
#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 */
|
||||
|
|
|
@ -57,6 +57,11 @@
|
|||
/* too few registers! because of register allocation errors with various gcs,
|
||||
just punt on explicit assignments on i386, hoping that the "register"
|
||||
declaration will be sufficient. */
|
||||
#elif defined __x86_64__
|
||||
/* GCC 4.6 chooses %rbp for IP_REG and %rbx for SP_REG, which works
|
||||
well. Tell it to keep the jump table in a r12, which is
|
||||
callee-saved. */
|
||||
#define JT_REG asm ("r12")
|
||||
#endif
|
||||
#if defined(PPC) || defined(_POWER) || defined(_IBMR2)
|
||||
#define IP_REG asm("26")
|
||||
|
@ -89,6 +94,9 @@
|
|||
#ifndef FP_REG
|
||||
#define FP_REG
|
||||
#endif
|
||||
#ifndef JT_REG
|
||||
#define JT_REG
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue