1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-06-11 06:20:23 +02:00

Microoptimizations to hook dispatch

* libguile/vm.c (vm_dispatch_hook): Add a check that we're in the debug
  engine and the trace level is positive.  Allows us to do cheaper
  checks for when to dispatch hooks.
  (scm_call_n): Just check if trace level is nonzero.
* libguile/vm-engine.c (RUN_HOOK): Likewise just check if trace level is
  nonzero.
This commit is contained in:
Andy Wingo 2018-06-27 19:26:03 +02:00
parent 19cff78bb5
commit 2a8d72f7e0
2 changed files with 6 additions and 3 deletions

View file

@ -112,7 +112,7 @@
#if VM_USE_HOOKS
#define RUN_HOOK(exp) \
do { \
if (SCM_UNLIKELY (VP->trace_level > 0)) \
if (SCM_UNLIKELY (VP->trace_level)) \
{ \
SYNC_IP (); \
exp; \

View file

@ -216,6 +216,9 @@ vm_dispatch_hook (scm_thread *thread, int hook_num, int n)
int saved_trace_level;
uint8_t saved_compare_result;
if (vp->trace_level <= 0 || vp->engine != SCM_VM_DEBUG_ENGINE)
return;
hook = vp->hooks[hook_num];
if (SCM_LIKELY (scm_is_false (hook))
@ -1418,7 +1421,7 @@ scm_call_n (SCM proc, SCM *argv, size_t nargs)
{
scm_gc_after_nonlocal_exit ();
/* Non-local return. */
if (vp->engine == SCM_VM_DEBUG_ENGINE && vp->trace_level > 0)
if (vp->trace_level)
vm_dispatch_abort_hook (thread);
}
else
@ -1429,7 +1432,7 @@ scm_call_n (SCM proc, SCM *argv, size_t nargs)
/* FIXME: Make this return an IP. */
apply_non_program (thread);
if (vp->engine == SCM_VM_DEBUG_ENGINE && vp->trace_level > 0)
if (vp->trace_level)
vm_dispatch_apply_hook (thread);
}