diff options
author | Andy Wingo <wingo@pobox.com> | 2013-11-19 22:14:20 +0100 |
---|---|---|
committer | Andy Wingo <wingo@pobox.com> | 2013-11-19 22:14:20 +0100 |
commit | ea0cd17d11fb73f79842c03b49df5c7aef4b36eb (patch) | |
tree | cf32222eaa7b831ae13be432a923a2b4091fb0f0 /libguile/vm-engine.c | |
parent | c4f7923fa9148204c7237e400c6e69056b69d4b2 (diff) | |
download | guile-ea0cd17d11fb73f79842c03b49df5c7aef4b36eb.tar.gz |
Rework hook dispatch mechanism
* libguile/vm-engine.c (RUN_HOOK, RUN_HOOK0, RUN_HOOK1): Rework to
dispatch through specific per-hook procedures. Might reduce register
pressure in the VM.
* libguile/vm.c (vm_dispatch_apply_hook):
(vm_dispatch_push_continuation_hook):
(vm_dispatch_pop_continuation_hook):
(vm_dispatch_next_hook):
(vm_dispatch_abort_hook):
(vm_dispatch_restore_continuation_hook): New internal helpers.
Diffstat (limited to 'libguile/vm-engine.c')
-rw-r--r-- | libguile/vm-engine.c | 28 |
1 files changed, 13 insertions, 15 deletions
diff --git a/libguile/vm-engine.c b/libguile/vm-engine.c index 85674c040..065b7fe7d 100644 --- a/libguile/vm-engine.c +++ b/libguile/vm-engine.c @@ -100,35 +100,32 @@ #endif #if VM_USE_HOOKS -#define RUN_HOOK(h, args, n) \ +#define RUN_HOOK(exp) \ do { \ if (SCM_UNLIKELY (vp->trace_level > 0)) \ { \ SYNC_REGISTER (); \ - vm_dispatch_hook (vm, h, args, n); \ + exp; \ } \ } while (0) #else -#define RUN_HOOK(h, args, n) +#define RUN_HOOK(exp) #endif -#define RUN_HOOK0(h) RUN_HOOK(h, NULL, 0) +#define RUN_HOOK0(h) RUN_HOOK (vm_dispatch_##h##_hook (vm)) +#define RUN_HOOK1(h, arg) RUN_HOOK (vm_dispatch_##h##_hook (vm, arg)) #define APPLY_HOOK() \ - RUN_HOOK0 (SCM_VM_APPLY_HOOK) + RUN_HOOK0 (apply) #define PUSH_CONTINUATION_HOOK() \ - RUN_HOOK0 (SCM_VM_PUSH_CONTINUATION_HOOK) + RUN_HOOK0 (push_continuation) #define POP_CONTINUATION_HOOK(old_fp) \ - RUN_HOOK (SCM_VM_POP_CONTINUATION_HOOK, \ - &SCM_FRAME_LOCAL (old_fp, 1), \ - SCM_FRAME_NUM_LOCALS (old_fp, vp->sp) - 1) + RUN_HOOK1 (pop_continuation, old_fp) #define NEXT_HOOK() \ - RUN_HOOK0 (SCM_VM_NEXT_HOOK) + RUN_HOOK0 (next) #define ABORT_CONTINUATION_HOOK() \ - RUN_HOOK (SCM_VM_ABORT_CONTINUATION_HOOK, \ - LOCAL_ADDRESS (1), \ - FRAME_LOCALS_COUNT () - 1) -#define RESTORE_CONTINUATION_HOOK() \ - RUN_HOOK0 (SCM_VM_RESTORE_CONTINUATION_HOOK) + RUN_HOOK0 (abort) +#define RESTORE_CONTINUATION_HOOK() \ + RUN_HOOK0 (restore_continuation) #define VM_HANDLE_INTERRUPTS \ SCM_ASYNC_TICK_WITH_CODE (current_thread, SYNC_REGISTER ()) @@ -3156,6 +3153,7 @@ VM_NAME (SCM vm, SCM program, SCM *argv, size_t nargs_) #undef RETURN_VALUE_LIST #undef RUN_HOOK #undef RUN_HOOK0 +#undef RUN_HOOK1 #undef SYNC_ALL #undef SYNC_BEFORE_GC #undef SYNC_IP |