mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-06-17 01:00:20 +02:00
make symbol -> opcode lookup faster
* libguile/instructions.c (fetch_instruction_table) (scm_lookup_instruction_by_name): Rework so we lazily load instructions into an array keyed by opcode, and a hash table keyed by symbolic name. Much faster, in this hot spot of compilation. * libguile/vm-engine.c (vm_run): Use malloc instead of scm_gc_malloc, given that we aren't ever going to free this thing. * libguile/vm-expand.h (VM_DEFINE_FUNCTION, VM_DEFINE_LOADER): Rework to always be aliases to VM_DEFINE_INSTRUCTION. (VM_DEFINE_INSTRUCTION): In the table case, update to work with fetch_instruction_table().
This commit is contained in:
parent
ef7e18683c
commit
f775e51bce
3 changed files with 72 additions and 50 deletions
|
@ -80,8 +80,7 @@ vm_run (SCM vm, SCM program, SCM args)
|
|||
if (SCM_UNLIKELY (!jump_table))
|
||||
{
|
||||
int i;
|
||||
jump_table = scm_gc_malloc (SCM_VM_NUM_INSTRUCTIONS * sizeof(void*),
|
||||
"jump table");
|
||||
jump_table = malloc (SCM_VM_NUM_INSTRUCTIONS * sizeof(void*));
|
||||
for (i = 0; i < SCM_VM_NUM_INSTRUCTIONS; i++)
|
||||
jump_table[i] = &&vm_error_bad_instruction;
|
||||
#define VM_INSTRUCTION_TO_LABEL 1
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue