diff options
author | Andy Wingo <wingo@pobox.com> | 2013-05-23 15:07:37 +0200 |
---|---|---|
committer | Andy Wingo <wingo@pobox.com> | 2013-05-27 07:13:13 +0200 |
commit | c850a0ff4d0073364612ff5785bda8217ea9ae7f (patch) | |
tree | 82d3ce7de2f7eee2f0940eb72b502d2038ab1569 /libguile/vm-engine.c | |
parent | 27319ffaa90dc5789843d8b80842b9a6d36120e1 (diff) | |
download | guile-c850a0ff4d0073364612ff5785bda8217ea9ae7f.tar.gz |
pop-continuation abort-continuation hooks pass return vals directly
* doc/ref/api-debug.texi (VM Hooks): Update documentation.
* libguile/vm.c (vm_dispatch_hook):
* libguile/vm-engine.c: Rework the hook machinery so that they can
receive an arbitrary number of arguments. The return and abort
hooks will pass the values that they return to their continuations.
(vm_engine): Adapt to ABORT_CONTINUATION_HOOK change.
* libguile/vm-i-system.c (return, return/values): Adapt to
POP_CONTINUATION_HOOK change.
* module/system/vm/frame.scm (frame-return-values): Remove. The
pop-continuation-hook will pass the values directly.
* module/system/vm/trace.scm (print-return):
(trace-calls-to-procedure):
(trace-calls-in-procedure): Update to receive return values
directly.
* module/system/vm/traps.scm (trap-in-procedure)
(trap-in-dynamic-extent): Ignore return values.
(trap-frame-finish, trap-calls-in-dynamic-extent)
(trap-calls-to-procedure): Pass return values to the handlers.
Diffstat (limited to 'libguile/vm-engine.c')
-rw-r--r-- | libguile/vm-engine.c | 79 |
1 files changed, 33 insertions, 46 deletions
diff --git a/libguile/vm-engine.c b/libguile/vm-engine.c index 77c2e462a..1cd623d95 100644 --- a/libguile/vm-engine.c +++ b/libguile/vm-engine.c @@ -68,6 +68,38 @@ # define ASSERT(condition) #endif +#if VM_USE_HOOKS +#define RUN_HOOK(h, args, n) \ + do { \ + if (SCM_UNLIKELY (vp->trace_level > 0)) \ + { \ + SYNC_REGISTER (); \ + vm_dispatch_hook (vm, h, args, n); \ + } \ + } while (0) +#else +#define RUN_HOOK(h, args, n) +#endif +#define RUN_HOOK0(h) RUN_HOOK(h, NULL, 0) + +#define APPLY_HOOK() \ + RUN_HOOK0 (SCM_VM_APPLY_HOOK) +#define PUSH_CONTINUATION_HOOK() \ + RUN_HOOK0 (SCM_VM_PUSH_CONTINUATION_HOOK) +#define POP_CONTINUATION_HOOK(vals, n) \ + RUN_HOOK (SCM_VM_POP_CONTINUATION_HOOK, vals, n) +#define NEXT_HOOK() \ + RUN_HOOK0 (SCM_VM_NEXT_HOOK) +#define ABORT_CONTINUATION_HOOK(vals, n) \ + RUN_HOOK (SCM_VM_ABORT_CONTINUATION_HOOK, vals, n) +#define RESTORE_CONTINUATION_HOOK() \ + RUN_HOOK0 (SCM_VM_RESTORE_CONTINUATION_HOOK) + +#define VM_HANDLE_INTERRUPTS \ + SCM_ASYNC_TICK_WITH_CODE (current_thread, SYNC_REGISTER ()) + + + /* Cache the VM's instruction, stack, and frame pointer in local variables. */ #define CACHE_REGISTER() \ @@ -143,51 +175,6 @@ /* - * Hooks - */ - -#if VM_USE_HOOKS -#define RUN_HOOK(h) \ - { \ - if (SCM_UNLIKELY (vp->trace_level > 0)) \ - { \ - SYNC_REGISTER (); \ - vm_dispatch_hook (vm, h); \ - } \ - } -#define RUN_HOOK1(h, x) \ - { \ - if (SCM_UNLIKELY (vp->trace_level > 0)) \ - { \ - PUSH (x); \ - SYNC_REGISTER (); \ - vm_dispatch_hook (vm, h); \ - DROP(); \ - } \ - } -#else -#define RUN_HOOK(h) -#define RUN_HOOK1(h, x) -#endif - -#define APPLY_HOOK() \ - RUN_HOOK (SCM_VM_APPLY_HOOK) -#define PUSH_CONTINUATION_HOOK() \ - RUN_HOOK (SCM_VM_PUSH_CONTINUATION_HOOK) -#define POP_CONTINUATION_HOOK(n) \ - RUN_HOOK1 (SCM_VM_POP_CONTINUATION_HOOK, SCM_I_MAKINUM (n)) -#define NEXT_HOOK() \ - RUN_HOOK (SCM_VM_NEXT_HOOK) -#define ABORT_CONTINUATION_HOOK() \ - RUN_HOOK (SCM_VM_ABORT_CONTINUATION_HOOK) -#define RESTORE_CONTINUATION_HOOK() \ - RUN_HOOK (SCM_VM_RESTORE_CONTINUATION_HOOK) - -#define VM_HANDLE_INTERRUPTS \ - SCM_ASYNC_TICK_WITH_CODE (current_thread, SYNC_REGISTER ()) - - -/* * Stack operation */ @@ -352,7 +339,7 @@ VM_NAME (SCM vm, SCM program, SCM *argv, int nargs) CACHE_PROGRAM (); /* The stack contains the values returned to this continuation, along with a number-of-values marker -- like an MV return. */ - ABORT_CONTINUATION_HOOK (); + ABORT_CONTINUATION_HOOK (sp - SCM_I_INUM (*sp), SCM_I_INUM (*sp)); NEXT; } |