[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Guile-commits] 11/13: Minor optimizations to debug hook dispatch
From: |
Andy Wingo |
Subject: |
[Guile-commits] 11/13: Minor optimizations to debug hook dispatch |
Date: |
Wed, 27 Jun 2018 14:00:13 -0400 (EDT) |
wingo pushed a commit to branch master
in repository guile.
commit 19cff78bb5a0e4728f721ab9366898397b9c56e5
Author: Andy Wingo <address@hidden>
Date: Wed Jun 27 19:16:38 2018 +0200
Minor optimizations to debug hook dispatch
* libguile/vm.c (scm_call_n): Only call hooks if the engine supports
it.
(vm_dispatch_abort_hook, vm_dispatch_next_hook)
(vm_dispatch_pop_continuation_hook, vm_dispatch_push_continuation_hook)
(vm_dispatch_apply_hook, vm_dispatch_hook): Take a thread as arg
instead of VM, because that will probably already be in a register in
the VM. Given that all values are taken relative to the SP, no
need to pass that either.
* libguile/vm-engine.c (RUN_HOOK0, RUN_HOOK1): Update appropriately.
---
libguile/vm-engine.c | 4 ++--
libguile/vm.c | 47 ++++++++++++++++++++++++-----------------------
2 files changed, 26 insertions(+), 25 deletions(-)
diff --git a/libguile/vm-engine.c b/libguile/vm-engine.c
index 9e0e0ef..b0a5ca7 100644
--- a/libguile/vm-engine.c
+++ b/libguile/vm-engine.c
@@ -122,8 +122,8 @@
#else
#define RUN_HOOK(exp)
#endif
-#define RUN_HOOK0(h) RUN_HOOK (vm_dispatch_##h##_hook (VP))
-#define RUN_HOOK1(h, arg) RUN_HOOK (vm_dispatch_##h##_hook (VP, arg))
+#define RUN_HOOK0(h) RUN_HOOK (vm_dispatch_##h##_hook (thread))
+#define RUN_HOOK1(h, arg) RUN_HOOK (vm_dispatch_##h##_hook (thread, arg))
#define APPLY_HOOK() RUN_HOOK0 (apply)
#define PUSH_CONTINUATION_HOOK() RUN_HOOK0 (push_continuation)
diff --git a/libguile/vm.c b/libguile/vm.c
index e28f3f6..cb23535 100644
--- a/libguile/vm.c
+++ b/libguile/vm.c
@@ -194,12 +194,12 @@ scm_i_capture_current_stack (void)
0);
}
-static void vm_dispatch_apply_hook (struct scm_vm *vp) SCM_NOINLINE;
-static void vm_dispatch_push_continuation_hook (struct scm_vm *vp)
SCM_NOINLINE;
+static void vm_dispatch_apply_hook (scm_thread *thread) SCM_NOINLINE;
+static void vm_dispatch_push_continuation_hook (scm_thread *thread)
SCM_NOINLINE;
static void vm_dispatch_pop_continuation_hook
- (struct scm_vm *vp, union scm_vm_stack_element *old_fp) SCM_NOINLINE;
-static void vm_dispatch_next_hook (struct scm_vm *vp) SCM_NOINLINE;
-static void vm_dispatch_abort_hook (struct scm_vm *vp) SCM_NOINLINE;
+ (scm_thread *thread, union scm_vm_stack_element *old_fp) SCM_NOINLINE;
+static void vm_dispatch_next_hook (scm_thread *thread) SCM_NOINLINE;
+static void vm_dispatch_abort_hook (scm_thread *thread) SCM_NOINLINE;
/* Return the first integer greater than or equal to LEN such that
LEN % ALIGN == 0. Return LEN if ALIGN is zero. */
@@ -207,9 +207,9 @@ static void vm_dispatch_abort_hook (struct scm_vm *vp)
SCM_NOINLINE;
((align) ? (((len) - 1UL) | ((align) - 1UL)) + 1UL : (len))
static void
-vm_dispatch_hook (struct scm_vm *vp, int hook_num,
- union scm_vm_stack_element *argv, int n)
+vm_dispatch_hook (scm_thread *thread, int hook_num, int n)
{
+ struct scm_vm *vp = &thread->vm;
SCM hook;
struct scm_frame c_frame;
scm_t_cell *frame;
@@ -259,7 +259,7 @@ vm_dispatch_hook (struct scm_vm *vp, int hook_num,
SCM args[2];
args[0] = SCM_PACK_POINTER (frame);
- args[1] = argv[0].as_scm;
+ args[1] = vp->sp[0].as_scm;
scm_c_run_hookn (hook, args, 2);
}
else
@@ -268,7 +268,7 @@ vm_dispatch_hook (struct scm_vm *vp, int hook_num,
int i;
for (i = 0; i < n; i++)
- args = scm_cons (argv[i].as_scm, args);
+ args = scm_cons (vp->sp[i].as_scm, args);
scm_c_run_hook (hook, scm_cons (SCM_PACK_POINTER (frame), args));
}
@@ -277,28 +277,28 @@ vm_dispatch_hook (struct scm_vm *vp, int hook_num,
}
static void
-vm_dispatch_apply_hook (struct scm_vm *vp)
+vm_dispatch_apply_hook (scm_thread *thread)
{
- return vm_dispatch_hook (vp, SCM_VM_APPLY_HOOK, NULL, 0);
+ return vm_dispatch_hook (thread, SCM_VM_APPLY_HOOK, 0);
}
-static void vm_dispatch_push_continuation_hook (struct scm_vm *vp)
+static void vm_dispatch_push_continuation_hook (scm_thread *thread)
{
- return vm_dispatch_hook (vp, SCM_VM_PUSH_CONTINUATION_HOOK, NULL, 0);
+ return vm_dispatch_hook (thread, SCM_VM_PUSH_CONTINUATION_HOOK, 0);
}
-static void vm_dispatch_pop_continuation_hook (struct scm_vm *vp,
+static void vm_dispatch_pop_continuation_hook (scm_thread *thread,
union scm_vm_stack_element
*old_fp)
{
- return vm_dispatch_hook (vp, SCM_VM_POP_CONTINUATION_HOOK,
- vp->sp, SCM_FRAME_NUM_LOCALS (old_fp, vp->sp) - 1);
+ return vm_dispatch_hook (thread, SCM_VM_POP_CONTINUATION_HOOK,
+ SCM_FRAME_NUM_LOCALS (old_fp, thread->vm.sp) - 1);
}
-static void vm_dispatch_next_hook (struct scm_vm *vp)
+static void vm_dispatch_next_hook (scm_thread *thread)
{
- return vm_dispatch_hook (vp, SCM_VM_NEXT_HOOK, NULL, 0);
+ return vm_dispatch_hook (thread, SCM_VM_NEXT_HOOK, 0);
}
-static void vm_dispatch_abort_hook (struct scm_vm *vp)
+static void vm_dispatch_abort_hook (scm_thread *thread)
{
- return vm_dispatch_hook (vp, SCM_VM_ABORT_CONTINUATION_HOOK,
- vp->sp, SCM_FRAME_NUM_LOCALS (vp->fp, vp->sp) - 1);
+ return vm_dispatch_hook (thread, SCM_VM_ABORT_CONTINUATION_HOOK,
+ SCM_FRAME_NUM_LOCALS (thread->vm.fp, thread->vm.sp)
- 1);
}
@@ -1418,7 +1418,8 @@ scm_call_n (SCM proc, SCM *argv, size_t nargs)
{
scm_gc_after_nonlocal_exit ();
/* Non-local return. */
- vm_dispatch_abort_hook (vp);
+ if (vp->engine == SCM_VM_DEBUG_ENGINE && vp->trace_level > 0)
+ vm_dispatch_abort_hook (thread);
}
else
{
@@ -1429,7 +1430,7 @@ scm_call_n (SCM proc, SCM *argv, size_t nargs)
apply_non_program (thread);
if (vp->engine == SCM_VM_DEBUG_ENGINE && vp->trace_level > 0)
- vm_dispatch_apply_hook (vp);
+ vm_dispatch_apply_hook (thread);
}
thread->vm.registers = ®isters;
- [Guile-commits] branch master updated (7883290 -> 593e2db), Andy Wingo, 2018/06/27
- [Guile-commits] 01/13: allocate-words intrinsic, Andy Wingo, 2018/06/27
- [Guile-commits] 04/13: Intrinsic for "prompt", Andy Wingo, 2018/06/27
- [Guile-commits] 07/13: Refactor handling of active VM registers, Andy Wingo, 2018/06/27
- [Guile-commits] 05/13: bind-rest inst uses cons-rest intrinsic, Andy Wingo, 2018/06/27
- [Guile-commits] 11/13: Minor optimizations to debug hook dispatch,
Andy Wingo <=
- [Guile-commits] 02/13: Compile current-module as intrinsic call, Andy Wingo, 2018/06/27
- [Guile-commits] 12/13: Microoptimizations to hook dispatch, Andy Wingo, 2018/06/27
- [Guile-commits] 13/13: Refactor hook dispatch in VM, Andy Wingo, 2018/06/27
- [Guile-commits] 09/13: Intrinsics take registers from thread, Andy Wingo, 2018/06/27
- [Guile-commits] 06/13: Use CALL_INTRINSICS helper in VM, Andy Wingo, 2018/06/27
- [Guile-commits] 08/13: Minor scm_thread refactoring, Andy Wingo, 2018/06/27
- [Guile-commits] 03/13: Remove dedicated current-module instruction., Andy Wingo, 2018/06/27
- [Guile-commits] 10/13: Remove "resume" arg from vm engine, Andy Wingo, 2018/06/27