mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-06-15 08:10:17 +02:00
Hook refactors
* libguile/vm.h (SCM_VM_NUM_HOOKS): Remove hook enumeration. (struct scm_vm): Re-arrange members to be more dense and to use common cache lines for commonly-used members. Declare hooks and their enabled flags by name. * libguile/vm-engine.c (RUN_HOOK): Refer to hooks by name. * libguile/vm.c (FOR_EACH_HOOK): New helper. (vm_hook_compute_enabled, vm_recompute_disable_mcode): New routines to recompute when hooks are enabled, and whether to disable mcode because hooks are active. (set_vm_trace_level): New helper. (invoke_hook): Take hook to invoke by value. (DEFINE_INVOKE_HOOK): Refactor to use named hooks. (scm_i_vm_prepare_stack): Init named hooks. (VM_ADD_HOOK, VM_REMOVE_HOOK): Refactor to use named hooks, and also recompute global disable_mcode flag. (scm_set_vm_trace_level_x, scm_c_set_vm_engine_x): Use internal helper.
This commit is contained in:
parent
8bb9ae3b51
commit
12b125f2ad
3 changed files with 116 additions and 87 deletions
|
@ -110,9 +110,9 @@
|
|||
#endif
|
||||
|
||||
#if VM_USE_HOOKS
|
||||
#define RUN_HOOK(H, h) \
|
||||
#define RUN_HOOK(h) \
|
||||
do { \
|
||||
if (SCM_UNLIKELY (VP->hooks_enabled[SCM_VM_##H##_HOOK])) \
|
||||
if (SCM_UNLIKELY (VP->h##_hook_enabled)) \
|
||||
{ \
|
||||
SYNC_IP (); \
|
||||
invoke_##h##_hook (thread); \
|
||||
|
@ -120,13 +120,13 @@
|
|||
} \
|
||||
} while (0)
|
||||
#else
|
||||
#define RUN_HOOK(H, h)
|
||||
#define RUN_HOOK(h)
|
||||
#endif
|
||||
|
||||
#define APPLY_HOOK() RUN_HOOK (APPLY, apply)
|
||||
#define RETURN_HOOK() RUN_HOOK (RETURN, return)
|
||||
#define NEXT_HOOK() RUN_HOOK (NEXT, next)
|
||||
#define ABORT_HOOK() RUN_HOOK (ABORT, abort)
|
||||
#define APPLY_HOOK() RUN_HOOK (apply)
|
||||
#define RETURN_HOOK() RUN_HOOK (return)
|
||||
#define NEXT_HOOK() RUN_HOOK (next)
|
||||
#define ABORT_HOOK() RUN_HOOK (abort)
|
||||
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue