guile-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Guile-commits] 12/13: Microoptimizations to hook dispatch


From: Andy Wingo
Subject: [Guile-commits] 12/13: Microoptimizations to hook dispatch
Date: Wed, 27 Jun 2018 14:00:13 -0400 (EDT)

wingo pushed a commit to branch master
in repository guile.

commit 2a8d72f7e0f54037f7d9200f48ee8c91d13e5b75
Author: Andy Wingo <address@hidden>
Date:   Wed Jun 27 19:26:03 2018 +0200

    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.
---
 libguile/vm-engine.c | 2 +-
 libguile/vm.c        | 7 +++++--
 2 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/libguile/vm-engine.c b/libguile/vm-engine.c
index b0a5ca7..d08ebbb 100644
--- a/libguile/vm-engine.c
+++ b/libguile/vm-engine.c
@@ -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;                                            \
diff --git a/libguile/vm.c b/libguile/vm.c
index cb23535..7720afa 100644
--- a/libguile/vm.c
+++ b/libguile/vm.c
@@ -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);
       }
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]