diff options
author | Andy Wingo <wingo@pobox.com> | 2010-09-16 12:48:41 +0200 |
---|---|---|
committer | Andy Wingo <wingo@pobox.com> | 2010-09-16 12:48:41 +0200 |
commit | f312025167c5a93aacae69aef63be2fdc6bed7c6 (patch) | |
tree | 6290a69c0e5c2db70ca83281cea8b47175821adc /libguile/vm-i-system.c | |
parent | c45d4d775d47bd80650e9888bf47815a03b04332 (diff) | |
download | guile-f312025167c5a93aacae69aef63be2fdc6bed7c6.tar.gz |
add vm-abort-continuation-hook, vm-restore-continuation-hook
* libguile/vm-i-system.c (call_cc, tail_call_cc): Call the new
RESTORE_CONTINUATION_HOOK when a continuation is restored.
(prompt): Call the new ABORT_CONTINUATION_HOOK when entering the abort
handler's continuation.
* libguile/vm-engine.h (ABORT_CONTINUATION_HOOK)
(RESTORE_CONTINUATION_HOOK):
* libguile/vm.h (SCM_VM_ABORT_CONTINUATION_HOOK)
(SCM_VM_RESTORE_CONTINUATION_HOOK):
* libguile/vm.c: (scm_vm_abort_continuation_hook): New hook, called when
entering an abort handler.
(scm_vm_restore_continuation_hook): New hook, called after returning
to a continuation.
* module/system/vm/vm.scm: Add hooks to export list.
Diffstat (limited to 'libguile/vm-i-system.c')
-rw-r--r-- | libguile/vm-i-system.c | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/libguile/vm-i-system.c b/libguile/vm-i-system.c index 063270ffd..05c632c46 100644 --- a/libguile/vm-i-system.c +++ b/libguile/vm-i-system.c @@ -1142,12 +1142,17 @@ VM_DEFINE_INSTRUCTION (64, call_cc, "call/cc", 0, 1, 1) } else { - /* otherwise, the vm continuation was reinstated, and - scm_i_vm_return_to_continuation pushed on one value. So pull our regs - back down from the vp, and march on to the next instruction. */ + /* Otherwise, the vm continuation was reinstated, and + vm_return_to_continuation pushed on one value. We know only one + value was returned because we are in value context -- the + previous block jumped to vm_call, not vm_mv_call, after all. + + So, pull our regs back down from the vp, and march on to the + next instruction. */ CACHE_REGISTER (); program = SCM_FRAME_PROGRAM (fp); CACHE_PROGRAM (); + RESTORE_CONTINUATION_HOOK (); NEXT; } } @@ -1177,10 +1182,17 @@ VM_DEFINE_INSTRUCTION (65, tail_call_cc, "tail-call/cc", 0, 1, 1) else { /* Otherwise, cache regs and NEXT, as above. Invoking the continuation - does a return from the frame, either to the RA or MVRA. */ + does a return from the frame, either to the RA or + MVRA. */ CACHE_REGISTER (); program = SCM_FRAME_PROGRAM (fp); CACHE_PROGRAM (); + /* Unfortunately we don't know whether we are at the RA, and thus + have one value without an nvalues marker, or we are at the + MVRA and thus have multiple values and the nvalues + marker. Instead of adding heuristics here, we will let hook + client code do that. */ + RESTORE_CONTINUATION_HOOK (); NEXT; } } @@ -1505,6 +1517,9 @@ VM_DEFINE_INSTRUCTION (83, prompt, "prompt", 4, 2, 0) CACHE_REGISTER (); program = SCM_FRAME_PROGRAM (fp); CACHE_PROGRAM (); + /* The stack contains the values returned to this prompt, along + with a number-of-values marker -- like an MV return. */ + ABORT_CONTINUATION_HOOK (); NEXT; } |